Skip to content

Commit e776393

Browse files
committed
chore: Configure a11y test suite for CI pipelines
- Add a11y test suite definition and scripts - Configure CI to run a11y tests on PR and develop branch
1 parent b499d06 commit e776393

File tree

5 files changed

+123
-10
lines changed

5 files changed

+123
-10
lines changed

.github/workflows/ci-merge-checks.yml

+40-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
GH_TOKEN: ${{ github.token }}
1414
NODE_VERSION: '20'
1515
CONTINUUM_REGISTRY_TOKEN: ${{ secrets.CONTINUUM_REGISTRY_TOKEN }}
16+
COMMON_SAP_ARTIFACTORY_TOKEN: ${{ secrets.COMMON_SAP_ARTIFACTORY_TOKEN }}
1617

1718
concurrency:
1819
group: ci-merge-checks-${{ github.head_ref || github.run_id }}
@@ -151,8 +152,44 @@ jobs:
151152
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
152153
run: |
153154
ci-scripts/e2e-cypress.sh -s b2b
155+
a11y_e2e_tests:
156+
needs: [no_retries, validate_e2e_execution]
157+
name: MC - E2E A11Y
158+
runs-on: ubuntu-latest
159+
strategy:
160+
matrix:
161+
containers: [1, 2]
162+
if: ${{ needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
163+
steps:
164+
- name: Forcefully fail build if e2e job is retried
165+
uses: actions/github-script@v7
166+
with:
167+
script: |
168+
core.setFailed('Please push a commit to trigger the build. To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`')
169+
if: ${{ github.run_attempt > 1 }}
170+
- uses: actions/checkout@v4
171+
- name: Setup node
172+
uses: actions/setup-node@v4
173+
with:
174+
node-version: ${{ env.NODE_VERSION }}
175+
- name: Cache node_modules
176+
id: cache-node-modules
177+
uses: actions/cache@v4
178+
with:
179+
path: |
180+
node_modules
181+
projects/storefrontapp-e2e-cypress/node_modules
182+
~/.cache/Cypress
183+
key: nodemodules-${{ github.event.pull_request.base.sha }}
184+
restore-keys: nodemodules-${{ github.event.pull_request.base.sha }}
185+
- name: Run e2es
186+
env:
187+
SPA_ENV: ci
188+
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
189+
run: |
190+
ci-scripts/e2e-cypress.sh -s a11y
154191
merge_checks_result:
155-
needs: [b2c_e2e_tests, b2c_ssr_e2e_tests, b2b_e2e_tests]
192+
needs: [b2c_e2e_tests, b2c_ssr_e2e_tests, b2b_e2e_tests, a11y_e2e_tests]
156193
name: MC - Result
157194
runs-on: ubuntu-latest
158195
if: ${{ always() }}
@@ -173,4 +210,5 @@ jobs:
173210
if: |
174211
needs.b2c_e2e_tests.result == 'failure' || needs.b2c_e2e_tests.result == 'cancelled' ||
175212
needs.b2c_ssr_e2e_tests.result == 'failure' || needs.b2c_ssr_e2e_tests.result == 'cancelled' ||
176-
needs.b2b_e2e_tests.result == 'failure' || needs.b2b_e2e_tests.result == 'cancelled'
213+
needs.b2b_e2e_tests.result == 'failure' || needs.b2b_e2e_tests.result == 'cancelled' ||
214+
needs.a11y_e2e_tests.result == 'failure' || needs.a11y_e2e_tests.result == 'cancelled'

.github/workflows/ci.yml

+37
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
CYPRESS_KEY: ${{ secrets.CYPRESS_KEY }}
1212
NODE_VERSION: '20'
1313
CONTINUUM_REGISTRY_TOKEN: ${{ secrets.CONTINUUM_REGISTRY_TOKEN }}
14+
COMMON_SAP_ARTIFACTORY_TOKEN: ${{ secrets.COMMON_SAP_ARTIFACTORY_TOKEN }}
1415

1516
concurrency:
1617
group: ci-${{ github.head_ref || github.run_id }}
@@ -217,6 +218,42 @@ jobs:
217218
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
218219
run: |
219220
ci-scripts/e2e-cypress.sh -s b2b
221+
a11y_e2e_tests:
222+
needs: [no_retries, validate_e2e_execution]
223+
name: E2E tests for A11Y
224+
runs-on: ubuntu-latest
225+
strategy:
226+
matrix:
227+
containers: [1, 2]
228+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || needs.validate_e2e_execution.outputs.SHOULD_RUN_E2E == 'true' }}
229+
steps:
230+
- name: Forcefully fail build if e2e job is retried
231+
uses: actions/github-script@v7
232+
with:
233+
script: |
234+
core.setFailed('Please push a commit to trigger the build. To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`')
235+
if: ${{ github.run_attempt > 1 }}
236+
- uses: actions/checkout@v4
237+
- name: Setup node
238+
uses: actions/setup-node@v4
239+
with:
240+
node-version: ${{ env.NODE_VERSION }}
241+
- name: Cache node_modules
242+
id: cache-node-modules
243+
uses: actions/cache@v4
244+
with:
245+
path: |
246+
node_modules
247+
projects/storefrontapp-e2e-cypress/node_modules
248+
~/.cache/Cypress
249+
key: nodemodules-${{ github.event.pull_request.base.sha }}
250+
restore-keys: nodemodules-${{ github.event.pull_request.base.sha }}
251+
- name: Run e2es
252+
env:
253+
SPA_ENV: ci
254+
BUILD_NUMBER: ci-build-number-${{ github.event.pull_request.head.sha || github.run_id }}
255+
run: |
256+
ci-scripts/e2e-cypress.sh -s a11y
220257
ssr_tests:
221258
needs: [no_retries, validate_e2e_execution]
222259
name: SSR Tests

ci-scripts/e2e-cypress.sh

+38-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,32 @@ POSITIONAL=()
77
readonly help_display="Usage: $0 [ command_options ] [ param ]
88
99
command options:
10-
--suite, -s e2e suite to run (b2c, b2b, cds, flaky). Default: b2c
10+
--suite, -s e2e suite to run (b2c, b2b, cds, flaky, a11y). Default: b2c
1111
--environment, --env [ 2005 | 2011 | ccv2]. Default: 2005
1212
--help, -h show help
1313
--ssr Run ssr smoke test
1414
"
1515

16+
display_a11y_docs_link() {
17+
echo ""
18+
echo -e "\033[31m⚠️ Accessibility tests failed\033[0m"
19+
echo -e "\033[33mℹ️ For guidance on resolving issues, see:\033[0m"
20+
echo -e "\033[36m🔗 https://wiki.one.int.sap/wiki/display/spar/Spartacus+Accessibility+Feature+Compliance\033[0m"
21+
echo ""
22+
}
23+
24+
25+
# Function to run a11y tests and print documentation link if they fail
26+
run_a11y_tests_with_docs_on_failure() {
27+
if npm run e2e:run:ci:a11y; then
28+
return 0
29+
else
30+
display_a11y_docs_link
31+
return 1
32+
fi
33+
}
34+
35+
1636
while [ "${1:0:1}" == "-" ]; do
1737
case "$1" in
1838
'--suite' | '-s')
@@ -139,8 +159,13 @@ else
139159
echo "Running full Cypress end-to-end tests for epic branch"
140160
npm run e2e:run:ci"${SUITE}"
141161
else
142-
echo "Running core Cypress end-to-end tests for pull requests"
143-
npm run e2e:run:ci:core"${SUITE}"
162+
if [[ "${SUITE}" == ":a11y" ]]; then
163+
echo "Running a11y Cypress end-to-end tests for pull requests"
164+
run_a11y_tests_with_docs_on_failure
165+
else
166+
echo "Running core Cypress end-to-end tests for pull requests"
167+
npm run e2e:run:ci:core"${SUITE}"
168+
fi
144169
fi
145170

146171
elif [ "${GITHUB_EVENT_NAME}" == "push" ]; then
@@ -151,10 +176,18 @@ else
151176
npm run e2e:run:ci:core"${SUITE}"
152177
else
153178
echo "Running full Cypress end-to-end tests"
154-
npm run e2e:run:ci"${SUITE}"
179+
if [[ "${SUITE}" == ":a11y" ]]; then
180+
run_a11y_tests_with_docs_on_failure
181+
else
182+
npm run e2e:run:ci"${SUITE}"
183+
fi
155184
fi
156185
else
157186
echo "Running full Cypress end-to-end tests"
158-
npm run e2e:run:ci"${SUITE}"
187+
if [[ "${SUITE}" == ":a11y" ]]; then
188+
run_a11y_tests_with_docs_on_failure
189+
else
190+
npm run e2e:run:ci"${SUITE}"
191+
fi
159192
fi
160193
fi

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
"e2e:run:ci:release": "npm --prefix ./projects/storefrontapp-e2e-cypress run cy:run:ci:release",
8787
"e2e:run:ci:b2b:release": "npm --prefix ./projects/storefrontapp-e2e-cypress run cy:run:ci:b2b:release",
8888
"e2e:run:ci:ssr:release": "npm --prefix ./projects/storefrontapp-e2e-cypress run cy:run:ci:ssr:release",
89+
"e2e:run:ci:a11y": "npm --prefix ./projects/storefrontapp-e2e-cypress run cy:run:ci:a11y",
90+
"e2e:run:ci:a11y:release": "npm --prefix ./projects/storefrontapp-e2e-cypress run cy:run:ci:a11y:release",
8991
"generate:docs": "npx @compodoc/[email protected] -p tsconfig.compodoc.json",
9092
"generate:publish:docs": "npm run generate:docs && npm run publish:docs",
9193
"graph": "nx graph",

projects/storefrontapp-e2e-cypress/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
"cy:run": "cypress run",
1616
"cy:run:b2b": "cypress run --env BASE_SITE=powertools-spa,OCC_PREFIX_USER_ENDPOINT=orgUsers",
1717
"cy:run:core": "cypress run --spec \"cypress/e2e/**/*.core-e2e.cy.ts\"",
18+
"cy:run:a11y": "cypress run --spec \"cypress/e2e/**/*.a11y-e2e.cy.ts\"",
1819
"cy:run:product-configurator-vc": "cypress run --spec \"cypress/e2e/**/*-configurator*.*e2e.cy.ts\"",
1920
"cy:run:cpq": "cypress run --config-file cypress.config.ci.ts --config baseUrl=https://jsapps.cpce-teamtiger1-d2-public.model-t.cc.commerce.ondemand.com,defaultCommandTimeout=100000,requestTimeout=1000000,responseTimeout=1000000,pageLoadTimeout=1000000 --reporter junit --reporter-options mochaFile=results/test-results-[hash].xml --env API_URL=https://api.cpce-teamtiger1-d2-public.model-t.cc.commerce.ondemand.com --spec \"cypress/e2e/**/cpq-configuration.core-e2e.cy.ts\"",
20-
"cy:run:ci": "cypress run --config-file cypress.config.ci.ts --record --key $CYPRESS_KEY --tag \"b2c,all\" --parallel --ci-build-id $BUILD_NUMBER --group B2C --spec \"cypress/e2e/!(vendor|b2b|ssr|cx_ccv2)/**/(!(my-account-v2))*e2e.cy.ts\" --reporter junit --reporter-options mochaFile=results/e2e-test-b2c-[hash].xml",
21-
"cy:run:ci:core": "cypress run --config-file cypress.config.ci.ts --record --key $CYPRESS_KEY --tag \"b2c,core\" --parallel --ci-build-id $BUILD_NUMBER --group B2C --spec \"cypress/e2e/!(vendor|b2b|ssr|cx_ccv2)/**/*.core-e2e.cy.ts\"",
21+
"cy:run:ci": "cypress run --config-file cypress.config.ci.ts --record --key $CYPRESS_KEY --tag \"b2c,all\" --parallel --ci-build-id $BUILD_NUMBER --group B2C --spec \"cypress/e2e/!(vendor|b2b|ssr|cx_ccv2|cx_mcs)/**/(!(my-account-v2))*e2e.cy.ts\" --reporter junit --reporter-options mochaFile=results/e2e-test-b2c-[hash].xml",
22+
"cy:run:ci:core": "cypress run --config-file cypress.config.ci.ts --record --key $CYPRESS_KEY --tag \"b2c,core\" --parallel --ci-build-id $BUILD_NUMBER --group B2C --spec \"cypress/e2e/!(vendor|b2b|ssr|cx_ccv2|cx_mcs)/**/*.core-e2e.cy.ts\"",
23+
"cy:run:ci:a11y": "cypress run --config-file cypress.config.ci.ts --record --key $CYPRESS_KEY --tag \"a11y,all\" --parallel --ci-build-id $BUILD_NUMBER --group A11Y --spec \"cypress/e2e/**/*.a11y-e2e.cy.ts\" --reporter junit --reporter-options mochaFile=results/e2e-test-a11y-[hash].xml",
2224
"cy:run:ci:b2b": "cypress run --config-file cypress.config.ci.ts --env BASE_SITE=powertools-spa,OCC_PREFIX_USER_ENDPOINT=orgUsers --record --key $CYPRESS_KEY --tag \"b2b,all\" --parallel --ci-build-id $BUILD_NUMBER --group B2B --spec \"cypress/e2e/b2b/regression/**/*e2e.cy.ts\" --reporter junit --reporter-options mochaFile=results/e2e-test-b2b-[hash].xml",
2325
"cy:run:ci:core:b2b": "cypress run --config-file cypress.config.ci.ts --env BASE_SITE=powertools-spa,OCC_PREFIX_USER_ENDPOINT=orgUsers --record --key $CYPRESS_KEY --tag \"b2b,core\" --parallel --ci-build-id $BUILD_NUMBER --group B2B --spec \"cypress/e2e/b2b/regression/**/*.core-e2e.cy.ts\"",
2426
"cy:run:ci:ccv2": "cypress run --config-file cypress.config.ci.ts --config baseUrl=$ENDPOINT_URL_PUBLIC_SPARTACUS --reporter junit --reporter-options mochaFile=results/spartacus-test-results-[hash].xml --env API_URL=$ENDPOINT_URL_PUBLIC_API --spec $E2ES_TO_RUN",
@@ -39,7 +41,8 @@
3941
"cy:run:ci:my-account-v2": "cypress run --config-file cypress.config.ci.ts --env API_URL=https://api.cg79x9wuu9-eccommerc1-s5-public.model-t.myhybris.cloud/ --tag \"my-account-v2\" --group MY-ACCOUNT-V2 --spec \"cypress/e2e/regression/my-account/my-account-v2-*.e2e.cy.ts\"",
4042
"cy:run:ci:release": "cypress run --config-file cypress.config.ci.ts --spec \"$(cat tests_to_run.txt)\" --reporter junit --reporter-options mochaFile=results/e2e-test-b2c-[hash].xml",
4143
"cy:run:ci:b2b:release": "cypress run --config-file cypress.config.ci.ts --env BASE_SITE=powertools-spa,OCC_PREFIX_USER_ENDPOINT=orgUsers --spec \"cypress/e2e/b2b/regression/**/*e2e.cy.ts\" --reporter junit --reporter-options mochaFile=results/e2e-test-b2b-[hash].xml",
42-
"cy:run:ci:ssr:release": "cypress run --config-file cypress.config.ci.ts --config baseUrl=http://localhost:4000 --spec \"cypress/e2e/ssr/*.e2e.cy.ts\" --reporter junit --reporter-options mochaFile=results/e2e-test-ssr-[hash].xml"
44+
"cy:run:ci:ssr:release": "cypress run --config-file cypress.config.ci.ts --config baseUrl=http://localhost:4000 --spec \"cypress/e2e/ssr/*.e2e.cy.ts\" --reporter junit --reporter-options mochaFile=results/e2e-test-ssr-[hash].xml",
45+
"cy:run:ci:a11y:release": "cypress run --config-file cypress.config.ci.ts --spec \"cypress/e2e/**/*.a11y-e2e.cy.ts\" --reporter junit --reporter-options mochaFile=results/e2e-test-a11y-[hash].xml"
4346
},
4447
"devDependencies": {
4548
"@babel/core": "^7.14.3",

0 commit comments

Comments
 (0)