Skip to content

Commit

Permalink
WEBUI-1266: update package.js files
Browse files Browse the repository at this point in the history
  • Loading branch information
poonamyadav252 committed Sep 20, 2023
1 parent dc1c590 commit 284cbc5
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 115 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/a11y.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ jobs:
- uses: actions/setup-node@v3
with:
registry-url: ${{ env.NPM_REPOSITORY }}
node-version: 14
node-version: 18
scope: '@nuxeo'

- name: Install Web UI
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PACKAGES_TOKEN }}
run: |
npm install
pushd packages/nuxeo-web-ui-ftest
npm install
popd
pushd packages/nuxeo-designer-catalog
npm install
popd
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand All @@ -63,9 +75,5 @@ jobs:
- name: Web UI build
run: mvn -B -ntp install

#==================================================================================================================
# this line of code has been commented on due to some driver issues, we will resume it once WEBUI-1266 is resolved.
#==================================================================================================================
# - name: A11y checks
# run: mvn -B -ntp -f plugin/a11y install
#==================================================================================================================
- name: A11y checks
run: mvn -B -ntp -f plugin/a11y install
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"license": "Apache-2.0",
"vendor": "Nuxeo",
"engines": {
"node": ">=14.0.0"
"node": ">=18.0.0"
},
"config": {
"workboxCli": "3.6.3"
},
"devDependencies": {
"@cucumber/cucumber": "^7.0.0",
Expand Down Expand Up @@ -55,9 +58,9 @@
"style-loader": "^2.0.0",
"url-loader": "^4.1.1",
"vm-browserify": "^1.1.2",
"wdio-chromedriver-service": "^8.0.0",
"wdio-chromedriver-service": "^8.1.1",
"wdio-cucumber-reporter": "0.0.2",
"wdio-json-reporter": "^2.0.0",
"wdio-json-reporter": "^3.0.0",
"webpack": "^5.3.0",
"webpack-bundle-analyzer": "^3.9.0",
"webpack-cli": "^4.1.0",
Expand All @@ -74,7 +77,7 @@
"prebuild": "npm-run-all prepare:*",
"prepare:tmp": "rm -rf .tmp",
"prepare:i18n": "node scripts/merge-messages.js",
"prepare:workbox": "workbox copyLibraries .tmp && mv .tmp/workbox-v$npm_package_devDependencies_workbox_cli .tmp/workbox",
"prepare:workbox": "workbox copyLibraries .tmp && mv .tmp/workbox-v${npm_package_config_workboxCli} .tmp/workbox",
"build": "webpack --env production",
"postbuild": "npm-run-all fix:*",
"fix:preview": "replace 'elements/' '${window.location.pathname}/' dist/index.html",
Expand Down Expand Up @@ -174,7 +177,7 @@
"@polymer/paper-toolbar": "^3.0.0",
"@polymer/paper-tooltip": "^3.0.0",
"@polymer/polymer": "^3.0.0",
"@wdio/allure-reporter": "^7.2.0",
"@wdio/allure-reporter": "^7.32.0",
"@webcomponents/html-imports": "^1.2.0",
"aws-sdk": "^2.420.0",
"dotenv": "^8.0.0",
Expand Down
19 changes: 9 additions & 10 deletions packages/nuxeo-web-ui-ftest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@
},
"license": "Apache-2.0",
"engines": {
"node": ">=10.23.0 <15.0.0"
"node": ">=18.0.0"
},
"dependencies": {
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/register": "^7.14.5",
"@cucumber/cucumber": "^7.0.0",
"@cucumber/tag-expressions": "^2.0.4",
"@wdio/cli": "7.20.5",
"@wdio/cucumber-framework": "^7.20.3",
"@wdio/local-runner": "^7.2.0",
"@wdio/selenium-standalone-service": "7.2.0",
"@wdio/spec-reporter": "^7.2.0",
"@wdio/sync": "^7.2.0",
"@wdio/cli": "^8.16.11",
"@wdio/cucumber-framework": "^8.16.11",
"@wdio/local-runner": "^8.16.11",
"@wdio/selenium-standalone-service": "^8.15.0",
"@wdio/spec-reporter": "^8.16.9",
"babel-plugin-transform-rename-import": "^2.3.0",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0",
Expand All @@ -40,8 +39,8 @@
"multiple-cucumber-html-reporter": "^1.18.0",
"node-fetch": "^2.6.1",
"nuxeo": "^4.0.3",
"wdio-chromedriver-service": "^7.0.0",
"wdio-cucumberjs-json-reporter": "^2.0.3",
"webdriverio": "^7.2.0"
"wdio-chromedriver-service": "^8.1.1",
"wdio-cucumberjs-json-reporter": "^5.1.7",
"webdriverio": "^8.16.11"
}
}
32 changes: 17 additions & 15 deletions packages/nuxeo-web-ui-ftest/scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,23 @@ if (process.env.DRIVER_VERSION == null) {
if (match) {
const checkVersion = match[1];
try {
done = fetch(`https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${checkVersion}`).then((response) => {
if (response.ok) {
return response
.text()
.then((newDriverVersion) => {
// eslint-disable-next-line no-console
console.log(`ChromeDriver ${newDriverVersion} needed.`);
process.env.DRIVER_VERSION = newDriverVersion;
})
.catch((e) => {
console.error('unable to parse ChromeDriver version: ', e);
});
}
console.error('unable to fetch ChromeDriver version: ', response);
});
done = fetch(`https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_${checkVersion}`).then(
(response) => {
if (response.ok) {
return response
.text()
.then((newDriverVersion) => {
// eslint-disable-next-line no-console
console.log(`ChromeDriver ${newDriverVersion} needed.`);
process.env.DRIVER_VERSION = newDriverVersion;
})
.catch((e) => {
console.error('unable to parse ChromeDriver version: ', e);
});
}
console.error('unable to fetch ChromeDriver version: ', response);
},
);
} catch (e) {
console.error('unable to fetch ChromeDriver version: ', e);
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/a11y/getDriverVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const match = version && version.match(/([0-9]+)\./);
if (match) {
const checkVersion = match[1];
try {
fetch(`https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${checkVersion}`).then((response) => {
fetch(`https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_${checkVersion}`).then((response) => {
if (response.ok) {
return response
.text()
Expand Down
15 changes: 7 additions & 8 deletions plugin/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@nuxeo/nuxeo-web-ui-a11y",
"version": "1.0.0",
"engines": {
"node": ">=10.23.0"
"node": ">=18.0.0"
},
"scripts": {
"start": "npm run test",
Expand All @@ -15,15 +15,14 @@
"@babel/preset-env": "^7.15.0",
"@babel/register": "^7.14.5",
"@nuxeo/nuxeo-web-ui-ftest": "file:../../packages/nuxeo-web-ui-ftest",
"@wdio/cli": "^8.15.5",
"@wdio/local-runner": "^8.15.4",
"@wdio/mocha-framework": "8.15.4",
"@wdio/selenium-standalone-service": "^8.14.0",
"@wdio/spec-reporter": "^8.14.0",
"@wdio/sync": "^7.27.0",
"@wdio/cli": "^8.16.11",
"@wdio/local-runner": "^8.16.11",
"@wdio/mocha-framework": "8.16.11",
"@wdio/selenium-standalone-service": "^8.15.0",
"@wdio/spec-reporter": "^8.16.9",
"axe-core": "^4.1.2",
"chrome-launcher": "^0.14.0",
"node-fetch": "^2.6.1",
"wdio-chromedriver-service": "^7.0.0"
"wdio-chromedriver-service": "^8.1.1"
}
}
30 changes: 13 additions & 17 deletions plugin/a11y/test/a11y-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@ import { runAxeCore } from './axe-reporter.js';

export function reportA11y(expectedViolations, expectedIncompleteViolations, setup) {
let _report;

const getReport = () => {
const getReport = async () => {
if (_report) {
return _report;
}
browser.setTimeout({ script: 240000 });

setup();

browser.pause(3000);
_report = runAxeCore();

await setup();
await browser.setTimeout({ script: 240000 });
await browser.pause(3000);
_report = await runAxeCore();
return _report;
};

context('Violations', () => {
let report;

before(() => {
report = getReport();
before(async () => {
report = await getReport();
});

Object.entries(expectedViolations).forEach(([violation, issues]) => {
it(`${violation}: ${issues} issue(s)`, () => {
expect(report.violations).toEqual(
it(`${violation}: ${issues} issue(s)`, async () => {
await expect(report.violations).toEqual(
expect.arrayContaining([
{
id: violation,
Expand All @@ -41,13 +37,13 @@ export function reportA11y(expectedViolations, expectedIncompleteViolations, set
context('Incomplete violations', () => {
let report;

before(() => {
report = getReport();
before(async () => {
report = await getReport();
});

Object.entries(expectedIncompleteViolations).forEach(([violation, issues]) => {
it(`${violation}: ${issues} issue(s)`, () => {
expect(report.incomplete).toEqual(
it(`${violation}: ${issues} issue(s)`, async () => {
await expect(report.incomplete).toEqual(
expect.arrayContaining([
{
id: violation,
Expand Down
65 changes: 35 additions & 30 deletions plugin/a11y/test/axe-reporter.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
// eslint-disable-next-line import/no-unresolved
import { source } from 'axe-core';

export function runAxeCore() {
// inject the axe-core lib
browser.execute(source);
class AxeCore {
async run() {
await browser.execute(source);
const options = {
runOnly: {
type: 'tag',
values: ['ACT', 'best-practice', 'wcag2a', 'wcag2aa'],
},
};
// run inside browser and get results
const results = await browser.executeAsync((opts, done) => {
// eslint-disable-next-line no-undef
axe
.run(opts)
.then((res) => done(res))
.catch((err) => {
throw err;
});
}, options);
return this.process(await results);
}

// https://github.com/dequelabs/axe-core/blob/develop/doc/API.md
const options = {
runOnly: {
type: 'tag',
values: ['ACT', 'best-practice', 'wcag2a', 'wcag2aa'],
},
};
// run inside browser and get results
const results = browser.executeAsync((opts, done) => {
// eslint-disable-next-line no-undef
axe
.run(opts)
.then((res) => done(res))
.catch((err) => {
throw err;
});
}, options);

return {
results,
incomplete: results.incomplete.map((a) => {
return { id: a.id, issues: a.nodes.length };
}),
violations: results.violations.map((a) => {
return { id: a.id, issues: a.nodes.length };
}),
};
process(results) {
return {
results,
incomplete: results.incomplete.map((a) => {
return { id: a.id, issues: a.nodes.length };
}),
violations: results.violations.map((a) => {
return { id: a.id, issues: a.nodes.length };
}),
};
}
}
export async function runAxeCore() {
return new AxeCore().run();
}
19 changes: 12 additions & 7 deletions plugin/a11y/test/helpers/login.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import Login from '@nuxeo/nuxeo-web-ui-ftest/pages/login';
import UI from '@nuxeo/nuxeo-web-ui-ftest/pages/ui';

const login = (username = 'Administrator', password = 'Administrator') => {
const login = async (username = 'Administrator', password = 'Administrator') => {
const logIn = Login.get();
logIn.username = username;
logIn.password = password;
logIn.submit();
const ui = UI.get();
ui.waitForVisible('nuxeo-page');
await logIn.setUsername(username);
await logIn.setPassword(password);
await logIn.submit();
};

export const authRedirect = async (browser, path) => {
await login();
await browser.url(path);
await browser.execute(() => {
document.dispatchEvent(new CustomEvent('automation-ready'));
});
};

export default login;
14 changes: 7 additions & 7 deletions plugin/a11y/test/specs/browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import '../imports';
import UI from '@nuxeo/nuxeo-web-ui-ftest/pages/ui';
import documentService from '@nuxeo/nuxeo-web-ui-ftest/features/step_definitions/support/services/documentService';
import login from '../helpers/login';
import { authRedirect } from '../helpers/login';
import { reportA11y } from '../a11y-reporter.js';

const EXPECTED_VIOLATIONS = {
Expand Down Expand Up @@ -36,10 +35,11 @@ describe('Nuxeo Browser', () => {

after(async () => documentService.reset());

reportA11y(EXPECTED_VIOLATIONS, EXPECTED_INCOMPLETE_VIOLATIONS, () => {
login();
const ui = UI.get();
ui.browser.browseTo(doc.path);
ui.browser.currentPage.waitForDisplayed();
reportA11y(EXPECTED_VIOLATIONS, EXPECTED_INCOMPLETE_VIOLATIONS, async () => {
await authRedirect(browser, `#!/browse${doc.path}`);
await browser.$('#documentViewsItems nuxeo-page-item.iron-selected').waitForExist({ timeout: 15000 });
const elementName = await browser.getAttribute('#documentViewsItems nuxeo-page-item.iron-selected', 'name');
const context = await browser.$(`#nxContent [name='${elementName}']`);
return context;
});
});
Loading

0 comments on commit 284cbc5

Please sign in to comment.