import { App, router } from '@inertiajs/react';
import { renderToStaticMarkup } from 'react-dom/server';
import { afterEach, expect, test, vi } from 'vitest';
import Supply from '@/pages/supply/index';
afterEach(() => vi.restoreAllMocks());
const record = {
id: 9,
record_key: 'synthetic-agreement',
version: 2,
state: 'draft',
data: { reference: 'Original reference', currency: 'MZN' },
reason: 'Original synthetic preparation',
created_at: '2026-11-28T00:00:00Z',
snapshot: {},
canApprove: true,
canReturn: true,
canSuspend: false,
};
const props = {
kind: 'agreement',
view: 'agreements',
ready: true,
orderLimitsReady: false,
asOf: '2026-11-28',
canPrepare: true,
canReview: true,
canCustoms: false,
records: [record],
history: {},
projections: {},
items: [],
warehouses: [],
suppliers: [],
orders: [],
histories: [],
agreements: [],
contracts: [],
};
function identity(key = 'new', version = 0, state = 'new') {
return `supply:4:7:agreement:agreements:::true:true:true:false:false:${key}:${version}:${state}`;
}
function render(overrides = {}, actor = 7, tenant = 4) {
return renderToStaticMarkup(
,
);
}
test('contract workspace names its own preparation and document reference with separated navigation', () => {
const html = render({
kind: 'contract',
view: 'contracts',
orderLimitsReady: true,
records: [
{
...record,
kind: 'contract',
data: {
...record.data,
reference: '',
},
},
],
});
expect(html).toContain('Novo contrato com vários artigos');
expect(html).not.toContain('Novo acordo de fornecimento');
expect(html).toContain('Contrato <script>QA-CONTRACT</script>');
expect(html).not.toContain('');
const navigation = html.match(
/