mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-11 16:59:09 +00:00
Remove env option from a11y test to enable tests to run in docs env
Change-Id: Ieef80011996b8e7c5ff11239f2c9ae53da9b3e99
This commit is contained in:
parent
72e842e1f7
commit
18c65141f9
|
@ -4,8 +4,8 @@
|
|||
"start": "bash dev-scripts/setup-storybook.sh && start-storybook --quiet -p 6006 -s resources/skins.vector.styles",
|
||||
"test": "npm -s run lint && tsc && npm run test:unit && npm -s run doc",
|
||||
"test:unit": "jest --silent",
|
||||
"test:a11y": "node tests/a11y/runA11yTests.js --env development",
|
||||
"selenium-daily": "node tests/a11y/runA11yTests.js --env ci --logResults",
|
||||
"test:a11y": "node tests/a11y/runA11yTests.js",
|
||||
"selenium-daily": "node tests/a11y/runA11yTests.js --logResults",
|
||||
"lint": "npm -s run lint:js && npm -s run lint:styles && npm -s run lint:i18n",
|
||||
"lint:fix:js": "npm -s run lint:js -- --fix",
|
||||
"lint:fix:styles": "npm -s run lint:styles -- --fix",
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
// @ts-nocheck
|
||||
const config = {
|
||||
|
||||
const testData = {
|
||||
baseUrl: process.env.MW_SERVER,
|
||||
pageUrl: '/wiki/Polar_bear?useskin=vector-2022',
|
||||
loginUser: process.env.MEDIAWIKI_USER,
|
||||
loginPassword: process.env.MEDIAWIKI_PASSWORD
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
reportDir: 'docs/a11y',
|
||||
namespace: 'Vector',
|
||||
env: {
|
||||
development: {
|
||||
baseUrl: process.env.MW_SERVER,
|
||||
defaultPage: '/wiki/Polar_bear?useskin=vector-2022'
|
||||
},
|
||||
ci: {
|
||||
baseUrl: 'https://en.wikipedia.beta.wmflabs.org',
|
||||
defaultPage: '/wiki/Polar_bear'
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
viewport: {
|
||||
width: 1200,
|
||||
|
@ -31,40 +29,37 @@ const config = {
|
|||
'--disable-setuid-sandbox'
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
tests: [
|
||||
{
|
||||
name: 'default',
|
||||
url: testData.baseUrl + testData.defaultPage
|
||||
},
|
||||
{
|
||||
name: 'logged_in',
|
||||
url: testData.baseUrl + testData.defaultPage,
|
||||
wait: '500',
|
||||
actions: [
|
||||
'click #p-personal-checkbox',
|
||||
'wait for .vector-user-menu-login a to be visible',
|
||||
'click .vector-user-menu-login a',
|
||||
'wait for #wpName1 to be visible',
|
||||
'set field #wpName1 to ' + testData.loginUser,
|
||||
'set field #wpPassword1 to ' + testData.loginPassword,
|
||||
'click #wpLoginAttempt',
|
||||
'wait for #pt-userpage-2 to be visible' // Confirm login was successful
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'search',
|
||||
url: testData.baseUrl + testData.defaultPage,
|
||||
rootElement: '#p-search',
|
||||
wait: '500',
|
||||
actions: [
|
||||
'click #searchInput',
|
||||
'wait for .wvui-input__input to be added',
|
||||
'set field .wvui-input__input to Test'
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
config.tests = ( envName ) => ( [
|
||||
{
|
||||
name: 'default',
|
||||
url: config.env[ envName ].baseUrl + config.env[ envName ].defaultPage
|
||||
},
|
||||
{
|
||||
name: 'logged_in',
|
||||
url: config.env[ envName ].baseUrl + config.env[ envName ].defaultPage,
|
||||
wait: '500',
|
||||
actions: [
|
||||
'click #p-personal-checkbox',
|
||||
'wait for .vector-user-menu-login a to be visible',
|
||||
'click .vector-user-menu-login a',
|
||||
'wait for #wpName1 to be visible',
|
||||
'set field #wpName1 to ' + process.env.MEDIAWIKI_USER,
|
||||
'set field #wpPassword1 to ' + process.env.MEDIAWIKI_PASSWORD,
|
||||
'click #wpLoginAttempt',
|
||||
'wait for #pt-userpage-2 to be visible' // Confirm login was successful
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'search',
|
||||
url: config.env[ envName ].baseUrl + config.env[ envName ].defaultPage,
|
||||
rootElement: '#p-search',
|
||||
wait: '500',
|
||||
actions: [
|
||||
'click #searchInput',
|
||||
'wait for .wvui-input__input to be added',
|
||||
'set field .wvui-input__input to Test'
|
||||
]
|
||||
}
|
||||
] );
|
||||
|
||||
module.exports = config;
|
||||
|
|
|
@ -4,6 +4,7 @@ const fs = require( 'fs' );
|
|||
const fetch = require( 'node-fetch' );
|
||||
const path = require( 'path' );
|
||||
const pa11y = require( 'pa11y' );
|
||||
const { program } = require( 'commander' );
|
||||
|
||||
const htmlReporter = require( path.resolve( __dirname, './reporter/reporter.js' ) );
|
||||
const config = require( path.resolve( __dirname, 'a11y.config.js' ) );
|
||||
|
@ -38,20 +39,17 @@ function sendMetrics( namespace, name, count ) {
|
|||
*/
|
||||
async function runTests( opts ) {
|
||||
try {
|
||||
if ( !config.env[ opts.env ] ) {
|
||||
throw new Error( `Invalid env value: '${opts.env}'` );
|
||||
}
|
||||
|
||||
if ( opts.env !== 'ci' && opts.logResults ) {
|
||||
throw new Error( "Results can only be logged with '--env ci'" );
|
||||
}
|
||||
|
||||
const tests = config.tests( opts.env );
|
||||
const allTestsHaveNames = tests.filter( ( test ) => test.name ).length === tests.length;
|
||||
if ( !allTestsHaveNames ) {
|
||||
const tests = config.tests;
|
||||
const allValidTests = tests.filter( ( test ) => test.name ).length === tests.length;
|
||||
if ( !allValidTests ) {
|
||||
throw new Error( 'Config missing test name' );
|
||||
}
|
||||
|
||||
const canLogResults = process.env.BEACON_URL && config.namespace;
|
||||
if ( opts.logResults && !canLogResults ) {
|
||||
throw new Error( 'Unable to log results, missing config or env variables' );
|
||||
}
|
||||
|
||||
resetReportDir();
|
||||
|
||||
const testPromises = tests.map( ( test ) => {
|
||||
|
@ -81,10 +79,7 @@ async function runTests( opts ) {
|
|||
|
||||
// Send data to Graphite
|
||||
// BEACON_URL is only defined in CI env
|
||||
if ( opts.env === 'ci' && opts.logResults && process.env.BEACON_URL ) {
|
||||
if ( !config.namespace ) {
|
||||
throw new Error( 'Config missing namespace' );
|
||||
}
|
||||
if ( opts.logResults && canLogResults ) {
|
||||
await sendMetrics( config.namespace, testResult.name, errorNum )
|
||||
.then( ( response ) => {
|
||||
if ( response.ok ) {
|
||||
|
@ -109,10 +104,7 @@ async function runTests( opts ) {
|
|||
}
|
||||
|
||||
function setupCLI() {
|
||||
const { program } = require( 'commander' );
|
||||
|
||||
program
|
||||
.requiredOption( '-e, --env <env>', 'determine which urls tests are run on, development or ci' )
|
||||
.option( '-s, --silent', 'avoids logging results summary to console', false )
|
||||
.option( '-l, --logResults', 'log a11y results to Graphite, should only be used with --env ci', false )
|
||||
.action( ( opts ) => {
|
||||
|
|
Loading…
Reference in a new issue