59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
import { ROUTE_REGISTRY } from "../../src/features/installed-feature-contracts.js";
|
|
|
|
export const MANUAL_A11Y_ROUTE_IDS = Object.freeze(
|
|
Object.values(ROUTE_REGISTRY).map((route) => route.routeId),
|
|
);
|
|
|
|
const REVIEW_FIELDS = Object.freeze([
|
|
"M1 Keyboard",
|
|
"M2 Visible focus",
|
|
"M3 Route focus",
|
|
"M4 Modal focus",
|
|
"M5 Error association",
|
|
"M6 Color signal",
|
|
"M7 Reduced motion",
|
|
"Screen reader",
|
|
]);
|
|
|
|
/** @param {string} content */
|
|
export function validateManualA11yEvidence(content) {
|
|
const fields = Object.fromEntries(
|
|
content
|
|
.split(/\r?\n/)
|
|
.map((line) => /^([^:]+):\s*(.*)$/.exec(line))
|
|
.filter(Boolean)
|
|
.map((match) => [
|
|
/** @type {RegExpExecArray} */ (match)[1].trim(),
|
|
/** @type {RegExpExecArray} */ (match)[2].trim(),
|
|
]),
|
|
);
|
|
const failures = [];
|
|
if (fields.Status !== "reviewed") failures.push("Status");
|
|
if (!fields["Route ID"]) failures.push("Route ID");
|
|
if (!fields["Release ID"]) failures.push("Release ID");
|
|
if (!fields.Reviewer) failures.push("Reviewer");
|
|
if (!fields.Signature) failures.push("Signature");
|
|
if (fields.Attestation !== "accepted") failures.push("Attestation");
|
|
if (
|
|
!fields["Reviewed at"] ||
|
|
!Number.isFinite(Date.parse(fields["Reviewed at"]))
|
|
) {
|
|
failures.push("Reviewed at");
|
|
}
|
|
|
|
for (const field of REVIEW_FIELDS) {
|
|
const result = fields[field];
|
|
if (
|
|
result !== "pass" &&
|
|
!/^not-applicable \(.+\)$/.test(result ?? "")
|
|
) {
|
|
failures.push(field);
|
|
}
|
|
}
|
|
return Object.freeze({
|
|
fields: Object.freeze(fields),
|
|
failures: Object.freeze(failures),
|
|
passed: failures.length === 0,
|
|
});
|
|
}
|