fix: require signed accessibility evidence per route
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
export const MANUAL_A11Y_ROUTE_IDS = Object.freeze([
|
||||
"APP_HOME",
|
||||
"SAMPLE_RESOURCE_LIST",
|
||||
"NOT_FOUND",
|
||||
]);
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user