@@ -1,5 +1,6 @@
|
||||
import { App } from '@inertiajs/react';
|
||||
import type { Page } from '@inertiajs/core';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import { QuotationCommercialTerms } from '@/components/quotation-commercial-terms';
|
||||
@@ -23,7 +24,7 @@ const policy = {
|
||||
weights: { price: 40, quality: 20, delivery: 15, history: 15, payment: 10 },
|
||||
};
|
||||
function render(
|
||||
Component: typeof Comparison | typeof QuotationExchangePanel,
|
||||
Component: ComponentProps<typeof App>['initialComponent'],
|
||||
props: Record<string, unknown>,
|
||||
) {
|
||||
const page = {
|
||||
@@ -39,6 +40,54 @@ function render(
|
||||
);
|
||||
}
|
||||
|
||||
test.each([true, false])(
|
||||
'related quotation stages remain grouped and preserve conditional urgency access (%s)',
|
||||
(urgent) => {
|
||||
const html = render(Comparison, {
|
||||
requisition: {
|
||||
id: 42,
|
||||
number: 'REQ-42',
|
||||
justification: 'Synthetic navigation QA',
|
||||
items: [],
|
||||
},
|
||||
suppliers: [],
|
||||
quotations: [],
|
||||
canCreate: false,
|
||||
canEvaluate: false,
|
||||
ready: false,
|
||||
topIds: [],
|
||||
comparisonPolicy: {
|
||||
...policy,
|
||||
...(urgent ? { urgent_minimum_proposals: 1 } : {}),
|
||||
},
|
||||
urgentQuotationReady: urgent,
|
||||
});
|
||||
const group = html.match(
|
||||
/<details[^>]*>[\s\S]*?Outras etapas e documentos do processo[\s\S]*?<\/details>/,
|
||||
)?.[0];
|
||||
expect(group).toBeDefined();
|
||||
expect(group).not.toMatch(/<details[^>]*\bopen\b/);
|
||||
expect(group).toContain(
|
||||
'aria-label="Etapas e documentos relacionados"',
|
||||
);
|
||||
expect(group).toContain('grid gap-3 sm:grid-cols-2');
|
||||
for (const path of [
|
||||
'abertura',
|
||||
'qualificacao',
|
||||
'admissao',
|
||||
'recomendacao',
|
||||
'relatorio',
|
||||
]) {
|
||||
expect(group).toContain(`/requisicoes/42/${path}`);
|
||||
}
|
||||
expect(group).toContain('href="/requisicoes/42"');
|
||||
expect(group).toContain('href="/conflitos"');
|
||||
expect(group?.includes('/requisicoes/42/urgencia-stock')).toBe(urgent);
|
||||
expect(html).toContain('href="/requisicoes/42/adjudicacao"');
|
||||
expect(html).toContain('Comparação ainda incompleta.');
|
||||
},
|
||||
);
|
||||
|
||||
test.each([true, false])(
|
||||
'process rates retain provenance and restrict the finance form (%s)',
|
||||
(canRecord) => {
|
||||
|
||||
Reference in New Issue
Block a user