ci(docs-infra): run a11y audits on certain pages on CI (#31414)
PR Close #31414
This commit is contained in:

committed by
Matias Niemelä

parent
5c738417db
commit
0e86551a63
38
aio/scripts/test-aio-a11y.js
Normal file
38
aio/scripts/test-aio-a11y.js
Normal file
@ -0,0 +1,38 @@
|
||||
#!/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': 90,
|
||||
'api/core/Directive': 90,
|
||||
'cli': 91,
|
||||
'cli/add': 91,
|
||||
'docs': 100,
|
||||
'guide/docs-style-guide': 88,
|
||||
'start': 90,
|
||||
};
|
||||
|
||||
// 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}`);
|
||||
}
|
Reference in New Issue
Block a user