67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { expect, test } from 'vitest';
|
|
import {
|
|
SubmissionPreviewDetails,
|
|
RequisitionSubmissionConfirmation,
|
|
type SubmissionPreview,
|
|
} from '@/components/requisition-submission-confirmation';
|
|
|
|
const preview: SubmissionPreview = {
|
|
state: 'planned',
|
|
process_version: 3,
|
|
subtotal_minor: '10000',
|
|
total_minor: '11600',
|
|
approval_amount_minor: '13000',
|
|
includes_tax: true,
|
|
provisional_rules: true,
|
|
import_basis: true,
|
|
steps: [
|
|
{ role: 'department_head', label: null },
|
|
{ role: 'configured_1', label: 'Direcção <QA>' },
|
|
],
|
|
};
|
|
|
|
test('confirmation names the exact document and approval bases and ordered routing without treating preview as submission', () => {
|
|
const html = renderToStaticMarkup(
|
|
<SubmissionPreviewDetails number="REQ-QA-1" preview={preview} />,
|
|
);
|
|
expect(html).toContain('116,00 MZN');
|
|
expect(html).toContain('130,00 MZN');
|
|
expect(html).toContain('estimativa de importação');
|
|
expect(html).toContain('provisórias');
|
|
expect(html).toContain('Chefe de departamento');
|
|
expect(html).toContain('Direcção <QA>');
|
|
expect(html).toContain('não cria reservas nem aprovações');
|
|
expect(html).not.toContain('configured_1');
|
|
});
|
|
|
|
test('unknown routing does not display a zero or invent approval stages', () => {
|
|
const html = renderToStaticMarkup(
|
|
<SubmissionPreviewDetails
|
|
number="REQ-QA-2"
|
|
preview={{ state: 'unavailable', message: 'Reveja a estimativa' }}
|
|
/>,
|
|
);
|
|
expect(html).toContain('Reveja a estimativa');
|
|
expect(html).not.toContain('0,00 MZN');
|
|
expect(html).not.toContain('<ol');
|
|
});
|
|
|
|
test('opening confirmation does not invoke the submission callback during rendering', () => {
|
|
let submitted = false;
|
|
const html = renderToStaticMarkup(
|
|
<RequisitionSubmissionConfirmation
|
|
number="REQ-QA-1"
|
|
preview={preview}
|
|
processing={false}
|
|
errors={[]}
|
|
onConfirm={() => {
|
|
submitted = true;
|
|
}}
|
|
/>,
|
|
);
|
|
expect(submitted).toBe(false);
|
|
expect(html).toContain('Submeter para aprovação');
|
|
expect(html).not.toContain('Confirmar e submeter');
|
|
});
|