From 285d06499f4b045c1f0298fe93afdf9f6eb4d7cf Mon Sep 17 00:00:00 2001 From: Svilen Darvenyashki Date: Mon, 25 Aug 2025 16:54:16 +0300 Subject: [PATCH 1/3] chore: cypress-axe and access-continuum integration for e2e testing --- packages/cypress-internal/package.json | 14 ++-- .../src/acc_report/support.ts | 6 +- .../cypress-internal/src/acc_report/task.ts | 2 +- .../src/continuum/continuum.conf.js | 8 ++ .../cypress-internal/src/continuum/cypress.ts | 81 +++++++++++++++++++ .../cypress-internal/src/cypress.config.ts | 9 +++ packages/cypress-internal/src/helpers.ts | 31 ++++--- packages/main/cypress/e2e/a11y.cy.ts | 5 ++ packages/main/cypress/support/e2e.ts | 22 +++++ packages/main/package-scripts.cjs | 2 +- 10 files changed, 162 insertions(+), 18 deletions(-) create mode 100644 packages/cypress-internal/src/continuum/continuum.conf.js create mode 100644 packages/cypress-internal/src/continuum/cypress.ts create mode 100644 packages/main/cypress/e2e/a11y.cy.ts create mode 100644 packages/main/cypress/support/e2e.ts diff --git a/packages/cypress-internal/package.json b/packages/cypress-internal/package.json index 444c847bb3ae..b7561d7c8a1b 100644 --- a/packages/cypress-internal/package.json +++ b/packages/cypress-internal/package.json @@ -14,15 +14,17 @@ }, "type": "module", "dependencies": { - "eslint-plugin-cypress": "^3.4.0", + "@continuum/continuum-javascript-professional": "^7.3.0", + "@cypress/code-coverage": "^3.13.11", "@ui5/cypress-ct-ui5-webc": "0.0.4", + "axe-core": "^4.10.2", "cypress": "^13.11.0", - "typescript": "^5.6.2", - "rimraf": "^3.0.2", + "cypress-axe": "^1.6.0", "cypress-real-events": "^1.12.0", - "@cypress/code-coverage": "^3.13.11", - "axe-core": "^4.10.2", - "cypress-axe": "^1.6.0" + "eslint-plugin-cypress": "^3.4.0", + "rimraf": "^3.0.2", + "typescript": "^5.6.2", + "selenium-webdriver": "4.7.1" }, "peerDependencies": { "@ui5/webcomponents-base": "2.13.0-rc.2" diff --git a/packages/cypress-internal/src/acc_report/support.ts b/packages/cypress-internal/src/acc_report/support.ts index 097e110f306c..77fa6e3694e1 100644 --- a/packages/cypress-internal/src/acc_report/support.ts +++ b/packages/cypress-internal/src/acc_report/support.ts @@ -49,7 +49,11 @@ declare global { } Cypress.Commands.add("ui5CheckA11y", (context?: string | Node | undefined, options?: Options | undefined) => { - return cy.checkA11y(context || "[data-cy-root]", options, checkA11TerminalLog, false) + if (Cypress.env('ui5AccTasksRegistered') === "axe") { + return cy.checkA11y(context, options, checkA11TerminalLog, false) + } else if (Cypress.env('ui5AccTasksRegistered') === "continuum") { + return cy.runAllTestsForAssertions(); + } }) if (Cypress.env('ui5AccTasksRegistered') === true) { diff --git a/packages/cypress-internal/src/acc_report/task.ts b/packages/cypress-internal/src/acc_report/task.ts index 59c601dac675..44a3c0213e48 100644 --- a/packages/cypress-internal/src/acc_report/task.ts +++ b/packages/cypress-internal/src/acc_report/task.ts @@ -102,7 +102,7 @@ function accTask(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) } }) - config.env.ui5AccTasksRegistered = true + config.env.ui5AccTasksRegistered = "axe" } return config diff --git a/packages/cypress-internal/src/continuum/continuum.conf.js b/packages/cypress-internal/src/continuum/continuum.conf.js new file mode 100644 index 000000000000..68e754b94457 --- /dev/null +++ b/packages/cypress-internal/src/continuum/continuum.conf.js @@ -0,0 +1,8 @@ +window.LevelAccess_AccessContinuumConfiguration = { + "accessEngineType": "professional", + "ampInstanceUrl": "https://sap.levelaccess.net", + "defaultStandardIds": [ + 1001235, /* SAP Standards */ + ], + "includePotentialAccessibilityConcerns": false +} \ No newline at end of file diff --git a/packages/cypress-internal/src/continuum/cypress.ts b/packages/cypress-internal/src/continuum/cypress.ts new file mode 100644 index 000000000000..ea3e0c936d61 --- /dev/null +++ b/packages/cypress-internal/src/continuum/cypress.ts @@ -0,0 +1,81 @@ +// @ts-ignore +import {Continuum, ReportManagementStrategy, ModuleManagementStrategy} from '@continuum/continuum-javascript-professional'; + +// const accessEngineFilePath = `${__dirname}/../node_modules/@continuum/continuum-javascript-professional/AccessEngine.professional.js`.replace(/^\//, ''); // versions of Cypress prior to 5 include a leading forward slash in __dirname +const accessEngineFilePath = `../../node_modules/@continuum/continuum-javascript-professional/AccessEngine.professional.js`.replace(/^\//, ''); // versions of Cypress prior to 5 include a leading forward slash in __dirname + +const setUpContinuum = (configFilePath: string) => ( + // Using the Continuum JavaScript SDK requires to load the following files before invoking `Continuum.setUp`: + // * the Continuum configuration file (continuum.conf.js) specified by `configFilePath` + // * Access Engine (AccessEngine.professional.js), the underlying accessibility testing engine Continuum uses + + cy.readFile(configFilePath) + .then(configFileContents => window.eval(configFileContents)) + .window() + .then(windowUnderTest => ( + cy.readFile(accessEngineFilePath) + .then(accessEngineFileContents => { + Continuum.accessEngineCode = Continuum.createInjectableAccessEngineCode(accessEngineFileContents); + windowUnderTest.eval(Continuum.accessEngineCode); + }) + .then(() => Continuum.setUp(null, configFilePath, windowUnderTest)) + )) +); +const runAllTestsForAssertions = (includeiframe = false) => ( + // We verify Access Engine is loaded, loading it again only if necessary, before running accessibility tests using `Continuum.runAllTestsForAssertions` + cy.window() + .then(windowUnderTest => ( + cy.then(() => { + // @ts-ignore + if (!windowUnderTest.LevelAccess_Continuum_AccessEngine) { + return cy.readFile(accessEngineFilePath) + .then(accessEngineFileContents => windowUnderTest.eval(Continuum.createInjectableAccessEngineCode(accessEngineFileContents))); + } + }) + )) + .then(() => Continuum.runAllTests().then(function (accessibilityConcerns: any) { + + if (accessibilityConcerns?.length > 0) { + + cy.log(`Accessibility concerns found: ${accessibilityConcerns.length}`); + // print out some information about each accessibility concern, + // highlighting offending elements along the way + accessibilityConcerns.forEach((accessibilityConcern: any) => { + // if the element to highlight is in shadow DOM, highlight its shadow root nearest the light DOM; + // there's an outstanding defect preventing us from directly highlighting elements in shadow DOM: https://github.com/cypress-io/cypress/issues/8843 + const modifiedAccessibilityConcernPath = accessibilityConcern.path?.split("|:host>")[0]; // "|:host>" in the path indicates the element is in shadow DOM + + if (modifiedAccessibilityConcernPath) { + let originalNodeBorder: any; + cy.get(modifiedAccessibilityConcernPath).then(node => { + originalNodeBorder = node.css('border'); + node.css('border', '2px solid magenta'); + }) + .log(`Accessibility Concern: ${accessibilityConcern.attribute} ${accessibilityConcern.element}`) + .get(modifiedAccessibilityConcernPath, {log: false}).then(node => { + node.css('border', originalNodeBorder); + }); + } + }); + + } else { + cy.log("No accessibility concerns found"); + } + expect(accessibilityConcerns).to.have.lengthOf(0); + }).catch(function (oError: any) { + }) + ) +); + +Cypress.Commands.add("setUpContinuum", setUpContinuum); + +Cypress.Commands.add('runAllTestsForAssertions', runAllTestsForAssertions); + +declare global { + namespace Cypress { + interface Chainable { + setUpContinuum(configFilePath: string): Chainable; + runAllTestsForAssertions(includeiframe?: boolean): Chainable; + } + } +} \ No newline at end of file diff --git a/packages/cypress-internal/src/cypress.config.ts b/packages/cypress-internal/src/cypress.config.ts index 0e617c8c939d..93a56d418c27 100644 --- a/packages/cypress-internal/src/cypress.config.ts +++ b/packages/cypress-internal/src/cypress.config.ts @@ -7,6 +7,15 @@ import svgTask from "./svg_validation/task.js"; export default defineConfig({ + e2e: { + setupNodeEvents(on, config) { + coverageTask(on, config); + accTask(on, config); + svgTask(on, config); + + return config + }, + }, component: { setupNodeEvents(on, config) { coverageTask(on, config); diff --git a/packages/cypress-internal/src/helpers.ts b/packages/cypress-internal/src/helpers.ts index e27036469f0c..a086b70eeac8 100644 --- a/packages/cypress-internal/src/helpers.ts +++ b/packages/cypress-internal/src/helpers.ts @@ -1,16 +1,29 @@ declare global { - function ui5AccDescribe(title: string, fn: (this: Mocha.Suite) => void): Mocha.Suite | void; + function ui5AccDescribe(title: string, fn: (this: Mocha.Suite) => void, page?: string): Mocha.Suite | void; } -globalThis.ui5AccDescribe = (title: string, fn: (this: Mocha.Suite) => void): Mocha.Suite | void => { - if (Cypress.env('ui5AccTasksRegistered') === true) { - return describe.only(`${title}`, function (this: Mocha.Suite) { - before(() => { +globalThis.ui5AccDescribe = (title: string, fn: (this: Mocha.Suite) => void, page?: string): Mocha.Suite | void => { + if (Cypress.env('ui5AccTasksRegistered') === "axe") { + return describe.only(`${title}`, function (this: Mocha.Suite) { + before(() => { + if (page) { + cy.visit(page); + } cy.injectAxe({ axeCorePath: "../../node_modules/axe-core/axe.min.js" }); - }); - fn.call(this); - }); - } + }); + fn.call(this); + }); + } else if (Cypress.env('ui5AccTasksRegistered') === "continuum") { + return describe.only(`${title}`, function (this: Mocha.Suite) { + before(() => { + cy.setUpContinuum("../../packages/cypress-internal/src/continuum/continuum.conf.js"); + if (page) { + cy.visit(page); + } + }); + fn.call(this); + }); + }; }; export { } \ No newline at end of file diff --git a/packages/main/cypress/e2e/a11y.cy.ts b/packages/main/cypress/e2e/a11y.cy.ts new file mode 100644 index 000000000000..ad1c720c39dc --- /dev/null +++ b/packages/main/cypress/e2e/a11y.cy.ts @@ -0,0 +1,5 @@ +ui5AccDescribe("Automated accessibility tests", () => { + it("Icon only", () => { + cy.ui5CheckA11y(); + }) +}, "http://localhost:8080/packages/main/test/pages/Avatar.html"); \ No newline at end of file diff --git a/packages/main/cypress/support/e2e.ts b/packages/main/cypress/support/e2e.ts new file mode 100644 index 000000000000..59ead52c6b1a --- /dev/null +++ b/packages/main/cypress/support/e2e.ts @@ -0,0 +1,22 @@ +// *********************************************************** +// This example support/component.ts is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import '../../../cypress-internal/src/continuum/cypress'; +import "@ui5/cypress-internal/commands.js"; + + +// Example use: +// cy.mount(MyComponent) \ No newline at end of file diff --git a/packages/main/package-scripts.cjs b/packages/main/package-scripts.cjs index 455bdbea0698..4a3f66a7d2c8 100644 --- a/packages/main/package-scripts.cjs +++ b/packages/main/package-scripts.cjs @@ -7,7 +7,7 @@ const options = { dev: true, internal: { cypress_code_coverage: false, - cypress_acc_tests: false, + cypress_acc_tests: "axe", }, }; From e53caf5022ace9d6868fcc40f812cd93c3c6e4b6 Mon Sep 17 00:00:00 2001 From: Svilen Darvenyashki Date: Tue, 2 Sep 2025 14:00:41 +0300 Subject: [PATCH 2/3] chore: access continuum now can test nodes from pages --- .../src/acc_report/support.ts | 2 +- .../cypress-internal/src/continuum/cypress.ts | 76 +++++++++---------- packages/main/cypress/e2e/a11y.cy.ts | 2 +- 3 files changed, 36 insertions(+), 44 deletions(-) diff --git a/packages/cypress-internal/src/acc_report/support.ts b/packages/cypress-internal/src/acc_report/support.ts index 77fa6e3694e1..d9aefdd5c4dc 100644 --- a/packages/cypress-internal/src/acc_report/support.ts +++ b/packages/cypress-internal/src/acc_report/support.ts @@ -52,7 +52,7 @@ Cypress.Commands.add("ui5CheckA11y", (context?: string | Node | undefined, optio if (Cypress.env('ui5AccTasksRegistered') === "axe") { return cy.checkA11y(context, options, checkA11TerminalLog, false) } else if (Cypress.env('ui5AccTasksRegistered') === "continuum") { - return cy.runAllTestsForAssertions(); + return context ? cy.runAllTestsForAssertionsForNode(context) : cy.runAllTestsForAssertions() } }) diff --git a/packages/cypress-internal/src/continuum/cypress.ts b/packages/cypress-internal/src/continuum/cypress.ts index ea3e0c936d61..05dae484cb42 100644 --- a/packages/cypress-internal/src/continuum/cypress.ts +++ b/packages/cypress-internal/src/continuum/cypress.ts @@ -4,6 +4,26 @@ import {Continuum, ReportManagementStrategy, ModuleManagementStrategy} from '@co // const accessEngineFilePath = `${__dirname}/../node_modules/@continuum/continuum-javascript-professional/AccessEngine.professional.js`.replace(/^\//, ''); // versions of Cypress prior to 5 include a leading forward slash in __dirname const accessEngineFilePath = `../../node_modules/@continuum/continuum-javascript-professional/AccessEngine.professional.js`.replace(/^\//, ''); // versions of Cypress prior to 5 include a leading forward slash in __dirname +const _checkConcerns = (accessibilityConcerns: any[]) => { + if (accessibilityConcerns?.length > 0) { + accessibilityConcerns.forEach((concern) => { + cy.log(`Accessibility Concern: **${concern._bestPracticeDescription}**. \n **${concern.attribute}**. \n ${concern.element}`); + }); + } else { + cy.log("No accessibility concerns found"); + } + cy.then(() => expect(accessibilityConcerns).to.have.length(0)); +}; + +const _prepareAccessEngine = () => { + return cy.window().then(windowUnderTest => { + // @ts-ignore + if (!windowUnderTest.LevelAccess_Continuum_AccessEngine) { + return cy.readFile(accessEngineFilePath) + .then(accessEngineFileContents => windowUnderTest.eval(Continuum.createInjectableAccessEngineCode(accessEngineFileContents))); + } + }); +} const setUpContinuum = (configFilePath: string) => ( // Using the Continuum JavaScript SDK requires to load the following files before invoking `Continuum.setUp`: // * the Continuum configuration file (continuum.conf.js) specified by `configFilePath` @@ -22,60 +42,32 @@ const setUpContinuum = (configFilePath: string) => ( )) ); const runAllTestsForAssertions = (includeiframe = false) => ( - // We verify Access Engine is loaded, loading it again only if necessary, before running accessibility tests using `Continuum.runAllTestsForAssertions` - cy.window() - .then(windowUnderTest => ( - cy.then(() => { - // @ts-ignore - if (!windowUnderTest.LevelAccess_Continuum_AccessEngine) { - return cy.readFile(accessEngineFilePath) - .then(accessEngineFileContents => windowUnderTest.eval(Continuum.createInjectableAccessEngineCode(accessEngineFileContents))); - } - }) - )) + _prepareAccessEngine() .then(() => Continuum.runAllTests().then(function (accessibilityConcerns: any) { - - if (accessibilityConcerns?.length > 0) { - - cy.log(`Accessibility concerns found: ${accessibilityConcerns.length}`); - // print out some information about each accessibility concern, - // highlighting offending elements along the way - accessibilityConcerns.forEach((accessibilityConcern: any) => { - // if the element to highlight is in shadow DOM, highlight its shadow root nearest the light DOM; - // there's an outstanding defect preventing us from directly highlighting elements in shadow DOM: https://github.com/cypress-io/cypress/issues/8843 - const modifiedAccessibilityConcernPath = accessibilityConcern.path?.split("|:host>")[0]; // "|:host>" in the path indicates the element is in shadow DOM - - if (modifiedAccessibilityConcernPath) { - let originalNodeBorder: any; - cy.get(modifiedAccessibilityConcernPath).then(node => { - originalNodeBorder = node.css('border'); - node.css('border', '2px solid magenta'); - }) - .log(`Accessibility Concern: ${accessibilityConcern.attribute} ${accessibilityConcern.element}`) - .get(modifiedAccessibilityConcernPath, {log: false}).then(node => { - node.css('border', originalNodeBorder); - }); - } - }); - - } else { - cy.log("No accessibility concerns found"); - } - expect(accessibilityConcerns).to.have.lengthOf(0); - }).catch(function (oError: any) { + _checkConcerns(accessibilityConcerns); + }) + ) +); +const runAllTestsForAssertionsForNode = (node: string | Node) => ( + _prepareAccessEngine() + .then(() => Continuum.runAllTestsOnNode(node).then(function (accessibilityConcerns: any) { + _checkConcerns(accessibilityConcerns); }) ) ); Cypress.Commands.add("setUpContinuum", setUpContinuum); - +// @ts-ignore Cypress.Commands.add('runAllTestsForAssertions', runAllTestsForAssertions); +// @ts-ignore +Cypress.Commands.add('runAllTestsForAssertionsForNode', runAllTestsForAssertionsForNode); declare global { namespace Cypress { interface Chainable { setUpContinuum(configFilePath: string): Chainable; runAllTestsForAssertions(includeiframe?: boolean): Chainable; + runAllTestsForAssertionsForNode(node: string | Node): Chainable; } } -} \ No newline at end of file +} diff --git a/packages/main/cypress/e2e/a11y.cy.ts b/packages/main/cypress/e2e/a11y.cy.ts index ad1c720c39dc..9a760ebb3fe8 100644 --- a/packages/main/cypress/e2e/a11y.cy.ts +++ b/packages/main/cypress/e2e/a11y.cy.ts @@ -2,4 +2,4 @@ ui5AccDescribe("Automated accessibility tests", () => { it("Icon only", () => { cy.ui5CheckA11y(); }) -}, "http://localhost:8080/packages/main/test/pages/Avatar.html"); \ No newline at end of file +}, "http://localhost:8080/packages/main/test/pages/Button.html"); \ No newline at end of file From 548217314738146430e4fbbf5638ffeaf9216f8d Mon Sep 17 00:00:00 2001 From: Svilen Darvenyashki Date: Mon, 15 Sep 2025 12:58:16 +0300 Subject: [PATCH 3/3] fix: code cleanup --- packages/cypress-internal/package.json | 8 +++-- .../src/acc_report/support.ts | 29 +------------------ .../cypress-internal/src/continuum/cypress.ts | 4 ++- .../cypress-internal/src/cypress.config.ts | 12 +------- packages/cypress-internal/src/helpers.ts | 17 +++++------ packages/main/cypress/e2e/a11y.cy.ts | 2 +- packages/tools/components-package/nps.js | 2 +- 7 files changed, 19 insertions(+), 55 deletions(-) diff --git a/packages/cypress-internal/package.json b/packages/cypress-internal/package.json index b7561d7c8a1b..2adc4102ce65 100644 --- a/packages/cypress-internal/package.json +++ b/packages/cypress-internal/package.json @@ -14,7 +14,6 @@ }, "type": "module", "dependencies": { - "@continuum/continuum-javascript-professional": "^7.3.0", "@cypress/code-coverage": "^3.13.11", "@ui5/cypress-ct-ui5-webc": "0.0.4", "axe-core": "^4.10.2", @@ -23,10 +22,13 @@ "cypress-real-events": "^1.12.0", "eslint-plugin-cypress": "^3.4.0", "rimraf": "^3.0.2", - "typescript": "^5.6.2", - "selenium-webdriver": "4.7.1" + "typescript": "^5.6.2" }, "peerDependencies": { "@ui5/webcomponents-base": "2.13.0-rc.2" + }, + "optionalDependencies": { + "@continuum/continuum-javascript-professional": "^7.3.0", + "selenium-webdriver": "4.7.1" } } \ No newline at end of file diff --git a/packages/cypress-internal/src/acc_report/support.ts b/packages/cypress-internal/src/acc_report/support.ts index d9aefdd5c4dc..2a4ed92f3246 100644 --- a/packages/cypress-internal/src/acc_report/support.ts +++ b/packages/cypress-internal/src/acc_report/support.ts @@ -19,27 +19,6 @@ type TestReport = { errors: TestVialotation[] } -function checkA11TerminalLog(violations: typeof AxeResults.violations) { - const violationData = violations.map( - ({ id, impact, description, nodes }) => ({ - id, - impact, - description, - nodes: nodes.length - }) - ) - - const report: TestReport = { - testFile: Cypress.spec.relative, - errors: [{ - testTitlePath: Cypress.currentTest.titlePath, - violations: violationData, - }] - } - - cy.task('ui5ReportA11y', report) -} - declare global { namespace Cypress { interface Chainable { @@ -50,18 +29,12 @@ declare global { Cypress.Commands.add("ui5CheckA11y", (context?: string | Node | undefined, options?: Options | undefined) => { if (Cypress.env('ui5AccTasksRegistered') === "axe") { - return cy.checkA11y(context, options, checkA11TerminalLog, false) + return cy.checkA11y(context, options) } else if (Cypress.env('ui5AccTasksRegistered') === "continuum") { return context ? cy.runAllTestsForAssertionsForNode(context) : cy.runAllTestsForAssertions() } }) -if (Cypress.env('ui5AccTasksRegistered') === true) { - before(() => { - cy.task('ui5ReportA11yReset', Cypress.spec.relative); - }) -} - export type { TestReport, } \ No newline at end of file diff --git a/packages/cypress-internal/src/continuum/cypress.ts b/packages/cypress-internal/src/continuum/cypress.ts index 05dae484cb42..5ec3dd0ed0ec 100644 --- a/packages/cypress-internal/src/continuum/cypress.ts +++ b/packages/cypress-internal/src/continuum/cypress.ts @@ -12,7 +12,9 @@ const _checkConcerns = (accessibilityConcerns: any[]) => { } else { cy.log("No accessibility concerns found"); } - cy.then(() => expect(accessibilityConcerns).to.have.length(0)); + cy.wrap(accessibilityConcerns) + .should((concerns) => expect(concerns).to.have.length(0)); + }; const _prepareAccessEngine = () => { diff --git a/packages/cypress-internal/src/cypress.config.ts b/packages/cypress-internal/src/cypress.config.ts index 93a56d418c27..6ecc76445b74 100644 --- a/packages/cypress-internal/src/cypress.config.ts +++ b/packages/cypress-internal/src/cypress.config.ts @@ -2,24 +2,14 @@ import { defineConfig } from "cypress"; // @ts-ignore import viteConfig from "../../../vite.config.js"; import coverageTask from "@cypress/code-coverage/task.js"; -import accTask from "./acc_report/task.js"; import svgTask from "./svg_validation/task.js"; export default defineConfig({ - e2e: { - setupNodeEvents(on, config) { - coverageTask(on, config); - accTask(on, config); - svgTask(on, config); - - return config - }, - }, + e2e: {}, component: { setupNodeEvents(on, config) { coverageTask(on, config); - accTask(on, config); svgTask(on, config); return config diff --git a/packages/cypress-internal/src/helpers.ts b/packages/cypress-internal/src/helpers.ts index a086b70eeac8..b0eee05cef7a 100644 --- a/packages/cypress-internal/src/helpers.ts +++ b/packages/cypress-internal/src/helpers.ts @@ -1,25 +1,22 @@ declare global { - function ui5AccDescribe(title: string, fn: (this: Mocha.Suite) => void, page?: string): Mocha.Suite | void; + function ui5AccDescribe(title: string, fn: (this: Mocha.Suite) => void, page: string): Mocha.Suite | void; } -globalThis.ui5AccDescribe = (title: string, fn: (this: Mocha.Suite) => void, page?: string): Mocha.Suite | void => { - if (Cypress.env('ui5AccTasksRegistered') === "axe") { +globalThis.ui5AccDescribe = (title: string, fn: (this: Mocha.Suite) => void, page: string): Mocha.Suite | void => { + if (Cypress.env('UI5_ACC') === "axe") { return describe.only(`${title}`, function (this: Mocha.Suite) { before(() => { - if (page) { - cy.visit(page); - } + cy.visit(page); cy.injectAxe({ axeCorePath: "../../node_modules/axe-core/axe.min.js" }); }); fn.call(this); }); - } else if (Cypress.env('ui5AccTasksRegistered') === "continuum") { + } else if (Cypress.env('UI5_ACC') === "continuum") { return describe.only(`${title}`, function (this: Mocha.Suite) { before(() => { cy.setUpContinuum("../../packages/cypress-internal/src/continuum/continuum.conf.js"); - if (page) { - cy.visit(page); - } + cy.visit(page); + }); fn.call(this); }); diff --git a/packages/main/cypress/e2e/a11y.cy.ts b/packages/main/cypress/e2e/a11y.cy.ts index 9a760ebb3fe8..98885381e73f 100644 --- a/packages/main/cypress/e2e/a11y.cy.ts +++ b/packages/main/cypress/e2e/a11y.cy.ts @@ -1,5 +1,5 @@ ui5AccDescribe("Automated accessibility tests", () => { it("Icon only", () => { - cy.ui5CheckA11y(); + cy.ui5CheckA11y() }) }, "http://localhost:8080/packages/main/test/pages/Button.html"); \ No newline at end of file diff --git a/packages/tools/components-package/nps.js b/packages/tools/components-package/nps.js index 4b34a6e1ab7c..876faa60fa02 100644 --- a/packages/tools/components-package/nps.js +++ b/packages/tools/components-package/nps.js @@ -22,7 +22,7 @@ const cypressEnvVariables = (options, predefinedVars) => { variables.push(`CYPRESS_COVERAGE=${!!cypress_code_coverage}`); if (cypress_acc_tests) { - variables.push("CYPRESS_UI5_ACC=true"); + variables.push(`CYPRESS_UI5_ACC=${cypress_acc_tests}`); } return variables.length ? `cross-env ${variables.join(" ")}` : "";