@@ -62,6 +62,96 @@ function render(overrides = {}, actor = 7, tenant = 4) {
|
||||
);
|
||||
}
|
||||
|
||||
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: '<script>QA-CONTRACT</script>',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
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('<script>QA-CONTRACT</script>');
|
||||
const navigation = html.match(
|
||||
/<nav aria-label="Consultas e cadastros de fornecimento"[\s\S]*?<\/nav>/,
|
||||
)?.[0];
|
||||
expect(navigation).toContain('flex flex-wrap gap-x-4 gap-y-2');
|
||||
expect(navigation).toContain('/compras/acordos/vigencia?kind=contract');
|
||||
expect(navigation).toContain('/compras/fornecimento?view=agreements');
|
||||
});
|
||||
|
||||
test('contract without a documentary reference stays explicit and read-only users get no preparation', () => {
|
||||
const html = render({
|
||||
kind: 'contract',
|
||||
view: 'contracts',
|
||||
canPrepare: false,
|
||||
records: [
|
||||
{
|
||||
...record,
|
||||
data: { reference: '' },
|
||||
canApprove: false,
|
||||
canReturn: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(html).toContain('Contrato sem referência indicada');
|
||||
expect(html).not.toContain('Novo contrato com vários artigos');
|
||||
expect(html).not.toContain('Abrir preparação');
|
||||
expect(render()).toContain('Novo acordo de fornecimento');
|
||||
});
|
||||
|
||||
test('supply guidance follows the current area and keeps customs responsibilities in imports', () => {
|
||||
const areas = [
|
||||
[
|
||||
'contracts',
|
||||
'contract',
|
||||
'limites globais',
|
||||
'Compras prepara os contratos',
|
||||
],
|
||||
[
|
||||
'agreements',
|
||||
'agreement',
|
||||
'condições de fornecimento',
|
||||
'Compras prepara os acordos',
|
||||
],
|
||||
[
|
||||
'calendar',
|
||||
'policy',
|
||||
'parâmetros de stock',
|
||||
'Compras prepara as políticas',
|
||||
],
|
||||
];
|
||||
for (const [view, kind, description, responsibility] of areas) {
|
||||
const html = render({ view, kind, records: [], canPrepare: false });
|
||||
expect(html).toContain(description);
|
||||
expect(html).toContain(responsibility);
|
||||
expect(html).not.toContain('responsável aduaneiro');
|
||||
expect(html).not.toContain('Logística acompanha');
|
||||
}
|
||||
const imports = render({
|
||||
view: 'imports',
|
||||
kind: 'import',
|
||||
records: [],
|
||||
canPrepare: false,
|
||||
orderLimitsReady: true,
|
||||
});
|
||||
expect(imports).toContain('Acompanhe as ordens importadas');
|
||||
expect(imports).toContain('Logística acompanha embarque e chegada');
|
||||
expect(imports).toContain('responsável aduaneiro');
|
||||
expect(imports).not.toContain('Compras prepara os contratos');
|
||||
expect(imports).not.toContain('Consultas e cadastros de fornecimento');
|
||||
});
|
||||
|
||||
test('new supply preparation restores without saving and is isolated by identity, source and capabilities', () => {
|
||||
vi.spyOn(router, 'restore').mockImplementation((key) =>
|
||||
key === `${identity()}:prepare:data`
|
||||
|
||||
Reference in New Issue
Block a user