angular-cn/aio/scripts/test-aio-a11y.js
George Kalpakas 7854c4ddbe test(docs-infra): run a11y tests against /tutorial and update a11y scores (#41103)
This commit adds `/tutorial` to the list of angular.io pages that we run
a11y tests against and updates the required scores to match the current
ones (to avoid a future regression going unnoticed).

PR Close #41103
2021-03-08 08:33:47 -08:00

40 lines
1000 B
JavaScript

#!/bin/env node
'use strict';
/**
* Usage:
* ```sh
* node scripts/test-aio-a11y <origin>
* ```
*
* Runs accessibility audits on several (pre-defined) pages on the specified origin. It fails, if
* the score for any page is below the minimum (see `MIN_SCORES_PER_PAGE` below).
*
* `<origin>` is the origin (scheme + hostname + port) of an angular.io deployment. It can be remote
* (e.g. `https://next.angular.io`) or local (e.g. `http://localhost:4200`).
*/
// Imports
const sh = require('shelljs');
sh.set('-e');
// Constants
const MIN_SCORES_PER_PAGE = {
'': 100,
'api': 100,
'api/core/Directive': 98,
'cli': 98,
'cli/add': 98,
'docs': 100,
'guide/docs-style-guide': 96,
'start': 98,
'tutorial': 98,
};
// Run
const auditWebAppCmd = `"${process.execPath}" "${__dirname}/audit-web-app"`;
const origin = process.argv[2];
for (const [page, minScore] of Object.entries(MIN_SCORES_PER_PAGE)) {
sh.exec(`${auditWebAppCmd} ${origin}/${page} accessibility:${minScore}`);
}