import { mkdir } from "node:fs/promises"; import { ROUTE_REGISTRY } from "../src/features/installed-feature-contracts.ts"; import { COMPOSED_CONTRACT_CONTRIBUTIONS } from "../src/features/loaded-feature-runtimes.ts"; import { automatedA11yArtifactSchema } from "./contracts/release-artifacts.ts"; import { automatedA11yReport, oneResourceReadRoutes, oneResourceRoutesCountedAsChecked, readA11yNotCheckedRoutes, } from "./lib/a11y-data-state.ts"; import { MANUAL_A11Y_ROUTE_IDS } from "./lib/manual-a11y-evidence.ts"; import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts"; await mkdir("artifacts/tests", { recursive: true }); // 1103/11-01. Routes the spec scanned only on their failure state are not // reported as passed. const notChecked = await readA11yNotCheckedRoutes(MANUAL_A11Y_ROUTE_IDS); // 1106/11-01. The records come from the spec alone. The descriptors say which // routes need one, so a record call the spec lost fails here instead of // counting a detail page as passed. const countedAsChecked = oneResourceRoutesCountedAsChecked( oneResourceReadRoutes( Object.values(ROUTE_REGISTRY), COMPOSED_CONTRACT_CONTRIBUTIONS.httpByOperationId.values(), ), notChecked, ); if (countedAsChecked.length > 0) { process.stderr.write( `a11y.json not written:\n${countedAsChecked.map((line) => `a11y: ${line}`).join("\n")}\n`, ); process.exit(1); } await writeValidatedJsonArtifact({ path: "artifacts/tests/a11y.json", schema: automatedA11yArtifactSchema, value: automatedA11yReport({ routeIds: MANUAL_A11Y_ROUTE_IDS, notChecked, generatedAt: new Date().toISOString(), }), }); for (const { routeId, reason } of notChecked) { process.stdout.write(`a11y: ${routeId} not checked in its own state (${reason})\n`); }