| 
									
										
										
										
											2019-07-04 02:34:32 +03:00
										 |  |  | #!/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, | 
					
						
							| 
									
										
										
										
											2019-06-25 15:27:47 -07:00
										 |  |  |   'api': 100, | 
					
						
							| 
									
										
										
										
											2020-07-09 19:22:30 +03:00
										 |  |  |   'api/core/Directive': 98, | 
					
						
							| 
									
										
										
										
											2021-06-03 16:43:03 +03:00
										 |  |  |   'cli': 100, | 
					
						
							|  |  |  |   'cli/add': 100, | 
					
						
							| 
									
										
										
										
											2019-07-04 02:34:32 +03:00
										 |  |  |   'docs': 100, | 
					
						
							| 
									
										
										
										
											2021-03-06 12:47:21 +02:00
										 |  |  |   'guide/docs-style-guide': 96, | 
					
						
							| 
									
										
										
										
											2021-06-03 16:43:03 +03:00
										 |  |  |   'start/start-routing': 98, | 
					
						
							| 
									
										
										
										
											2021-03-06 12:47:21 +02:00
										 |  |  |   'tutorial': 98, | 
					
						
							| 
									
										
										
										
											2019-07-04 02:34:32 +03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 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}`); | 
					
						
							|  |  |  | } |