test: protect CSRF fix, simplified shell and PDF projection
This commit is contained in:
@@ -0,0 +1,51 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
import { resolve } from 'node:path';
|
||||||
|
import test from 'node:test';
|
||||||
|
|
||||||
|
function source(path: string): string {
|
||||||
|
return readFileSync(resolve(process.cwd(), path), 'utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
test('F6.2 planning uses the shared CSRF-aware API requester', () => {
|
||||||
|
const page = source('../web-v2/src/pages/InspectionVisitCreateF61Page.tsx');
|
||||||
|
const api = source('../web-v2/src/lib/api.ts');
|
||||||
|
|
||||||
|
assert.match(page, /import \{ apiRequest \} from '\.\.\/lib\/api';/);
|
||||||
|
assert.doesNotMatch(page, /async function requestJson/);
|
||||||
|
assert.doesNotMatch(page, /fetch\(`\/api\/v3/);
|
||||||
|
assert.match(page, /apiRequest<CreatedInspection>\('\/inspection-visits'/);
|
||||||
|
assert.match(api, /headers\.set\('x-csrf-token', token\)/);
|
||||||
|
assert.match(api, /readCsrfCookie\(\)/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('F6.2 removes the duplicated global operational bar and hidden persisted filters', () => {
|
||||||
|
const layout = source('../web-v2/src/layout/AppLayout.tsx');
|
||||||
|
const context = source('../web-v2/src/context/OperationalContext.tsx');
|
||||||
|
|
||||||
|
assert.doesNotMatch(layout, /OperationalContextBar/);
|
||||||
|
assert.match(context, /localStorage\.removeItem\(LEGACY_STORAGE_KEY\)/);
|
||||||
|
assert.doesNotMatch(context, /localStorage\.setItem/);
|
||||||
|
assert.match(context, /useState\(''\)/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('F6.2 exposes provisional PDF data contracts for Actas and Informes', () => {
|
||||||
|
const projection = source('../web-v2/src/components/DocumentPdfProjection.tsx');
|
||||||
|
const actPage = source('../web-v2/src/pages/InspectionActEditorPage.tsx');
|
||||||
|
const reportPage = source('../web-v2/src/pages/ReportDetailPage.tsx');
|
||||||
|
const model = source('../docs/INSPECTION_DOCUMENT_MODEL.md');
|
||||||
|
const spec = source('../docs/PDF_PROVISIONAL_STRUCTURE.md');
|
||||||
|
|
||||||
|
assert.match(projection, /PDF PRELIMINAR · ESTRUCTURA PROYECTADA/);
|
||||||
|
assert.match(projection, /Contrato de datos estable, renderer reemplazable/);
|
||||||
|
assert.match(projection, /Identificación y contexto/);
|
||||||
|
assert.match(projection, /Firmas y manifestaciones/);
|
||||||
|
assert.match(projection, /GEDO e integridad/);
|
||||||
|
assert.match(projection, /Anexo final/);
|
||||||
|
assert.match(actPage, /<DocumentPdfProjection kind="act" \/>/);
|
||||||
|
assert.match(reportPage, /<DocumentPdfProjection kind="report" \/>/);
|
||||||
|
assert.match(model, /Inspección o visita \| 1 a muchos \| Actas de inspección/);
|
||||||
|
assert.match(model, /Informe técnico \| 1 a 1 \| Acta fuente/);
|
||||||
|
assert.match(spec, /Cada INF tiene \*\*una sola Acta fuente\*\*/);
|
||||||
|
assert.match(spec, /Acta fuente completa como anexo final/);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user