webship-js 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/AGENTS.md +109 -0
  2. package/CLAUDE.md +317 -0
  3. package/bin/generate-reports.js +181 -9
  4. package/cucumber.js +10 -4
  5. package/docs/00-quick-start.md +102 -0
  6. package/docs/01-getting-started.md +102 -0
  7. package/docs/02-bbr-smart-waits.md +77 -0
  8. package/docs/03-selector-registry.md +95 -0
  9. package/docs/04-step-reference.md +728 -0
  10. package/docs/05-web-first-assertions.md +91 -0
  11. package/docs/06-network-and-dialogs.md +83 -0
  12. package/docs/07-auth-state.md +75 -0
  13. package/docs/08-clock-mocking.md +59 -0
  14. package/docs/09-api-testing.md +114 -0
  15. package/docs/10-accessibility.md +167 -0
  16. package/docs/11-debugging.md +129 -0
  17. package/docs/12-ai-agent-guide.md +338 -0
  18. package/docs/13-faq.md +236 -0
  19. package/docs/14-recipes-cookbook.md +255 -0
  20. package/docs/15-tag-conventions.md +76 -0
  21. package/docs/advanced-screenshots/then-i-save-fullscreen-screenshot.md +36 -0
  22. package/docs/advanced-screenshots/then-i-save-width-x-height-screenshot.md +34 -0
  23. package/docs/advanced-screenshots/when-i-save-screenshot-name-filename.md +45 -0
  24. package/docs/advanced-screenshots.md +52 -0
  25. package/docs/advanced-selectors.md +18 -0
  26. package/docs/api-step-definitions.md +45 -0
  27. package/docs/diffy-step-definitions/then-compare-diffy-env1-env2.md +30 -0
  28. package/docs/diffy-step-definitions/then-create-diffy-comparison-name-value.md +21 -0
  29. package/docs/diffy-step-definitions/then-create-diffy-comparison.md +25 -0
  30. package/docs/diffy-step-definitions/then-create-diffy-screenshot-environment-name.md +35 -0
  31. package/docs/diffy-step-definitions/then-i-take-screenshot.md +21 -0
  32. package/docs/diffy-step-definitions/then-i-take-screenshots-all-breakpoints.md +27 -0
  33. package/docs/diffy-step-definitions/then-send-screenshots-diffy-name-value.md +27 -0
  34. package/docs/diffy-step-definitions/then-upload-folder-url-diffy-snapshotname.md +28 -0
  35. package/docs/diffy-step-definitions/then-wait-diffy-comparison-complete.md +21 -0
  36. package/docs/diffy-step-definitions/when-i-resize-window-number.md +29 -0
  37. package/docs/diffy-step-definitions.md +21 -0
  38. package/docs/global-settings.md +244 -0
  39. package/docs/index.md +104 -0
  40. package/docs/install-webship-js/ddev-webship-js.md +52 -0
  41. package/docs/install-webship-js.md +35 -0
  42. package/docs/overview.md +41 -0
  43. package/docs/step-definitions/given-i-am-anonymous-user.md +67 -0
  44. package/docs/step-definitions/given-i-am-homepage.md +68 -0
  45. package/docs/step-definitions/given-i-am-specific-page.md +72 -0
  46. package/docs/step-definitions/then-i-should-be.md +56 -0
  47. package/docs/step-definitions/then-i-should-see.md +62 -0
  48. package/docs/step-definitions/then-item-checkbox.md +54 -0
  49. package/docs/step-definitions/then-item-link-should-contain-url.md +84 -0
  50. package/docs/step-definitions/then-item-should-contain.md +67 -0
  51. package/docs/step-definitions/then-radio-button-value-should-be-selected.md +68 -0
  52. package/docs/step-definitions/then-response-status-code-should-be-number.md +69 -0
  53. package/docs/step-definitions/then-value-radio-button-selected.md +62 -0
  54. package/docs/step-definitions/when-i-attach-file-file-name-element.md +71 -0
  55. package/docs/step-definitions/when-i-check-checkbox.md +60 -0
  56. package/docs/step-definitions/when-i-click-link.md +51 -0
  57. package/docs/step-definitions/when-i-click-operation-text-row.md +71 -0
  58. package/docs/step-definitions/when-i-fill.md +59 -0
  59. package/docs/step-definitions/when-i-go-homepage.md +60 -0
  60. package/docs/step-definitions/when-i-go-specific-page.md +67 -0
  61. package/docs/step-definitions/when-i-move-backward-one-page.md +49 -0
  62. package/docs/step-definitions/when-i-move-forward-one-page.md +58 -0
  63. package/docs/step-definitions/when-i-press-button.md +58 -0
  64. package/docs/step-definitions/when-i-reload-page.md +51 -0
  65. package/docs/step-definitions/when-i-scroll.md +73 -0
  66. package/docs/step-definitions/when-i-select-option-select-list.md +53 -0
  67. package/docs/step-definitions/when-i-select-radio-button-value.md +62 -0
  68. package/docs/step-definitions/when-i-uncheck-checkbox.md +57 -0
  69. package/docs/step-definitions/when-i-wait-ajax-finish.md +64 -0
  70. package/docs/step-definitions/when-i-wait.md +62 -0
  71. package/docs/step-definitions.md +50 -0
  72. package/examples/a11y.html +31 -0
  73. package/examples/cookies.html +10 -0
  74. package/examples/date.html +12 -0
  75. package/examples/element.html +11 -0
  76. package/examples/field.html +24 -0
  77. package/examples/keyboard.html +11 -0
  78. package/examples/links.html +9 -0
  79. package/examples/modal.html +14 -0
  80. package/examples/path.html +3 -0
  81. package/examples/table.html +13 -0
  82. package/package.json +10 -3
  83. package/playwright.config.ts +3 -2
  84. package/tests/features/a11y.feature +39 -0
  85. package/tests/features/cookie.feature +13 -0
  86. package/tests/features/date.feature +11 -0
  87. package/tests/features/element.feature +16 -0
  88. package/tests/features/field.feature +25 -0
  89. package/tests/features/keyboard.feature +10 -0
  90. package/tests/features/link.feature +11 -0
  91. package/tests/features/modal-advanced-example.feature +1 -1
  92. package/tests/features/modal.feature +11 -0
  93. package/tests/features/path.feature +16 -0
  94. package/tests/features/response.feature +8 -0
  95. package/tests/features/responsive.feature +10 -0
  96. package/tests/features/table.feature +18 -0
  97. package/tests/features/wait.feature +7 -0
  98. package/tests/features/yaml.feature +102 -0
  99. package/tests/reports/README.md +55 -0
  100. package/tests/selectors/_canonical-keys.json +113 -0
  101. package/tests/selectors/back-end-selectors.json +7 -1
  102. package/tests/selectors/cms-contentful-admin.json +35 -0
  103. package/tests/selectors/cms-craft-admin.json +39 -0
  104. package/tests/selectors/cms-drupal-cms-gin.json +56 -0
  105. package/tests/selectors/cms-drupal-core-claro.json +50 -0
  106. package/tests/selectors/cms-generic-admin.json +34 -0
  107. package/tests/selectors/cms-ghost-admin.json +34 -0
  108. package/tests/selectors/cms-joomla-admin.json +41 -0
  109. package/tests/selectors/cms-magento2-admin.json +32 -0
  110. package/tests/selectors/cms-prestashop-admin.json +38 -0
  111. package/tests/selectors/cms-shopify-admin.json +25 -0
  112. package/tests/selectors/cms-strapi-admin.json +42 -0
  113. package/tests/selectors/cms-typo3-admin.json +41 -0
  114. package/tests/selectors/cms-woocommerce-front.json +50 -0
  115. package/tests/selectors/cms-wordpress-admin.json +31 -0
  116. package/tests/selectors/framework-ant-design.json +80 -0
  117. package/tests/selectors/framework-bootstrap.json +86 -0
  118. package/tests/selectors/framework-bulma.json +74 -0
  119. package/tests/selectors/framework-chakra.json +58 -0
  120. package/tests/selectors/framework-foundation.json +51 -0
  121. package/tests/selectors/framework-material-ui.json +72 -0
  122. package/tests/selectors/framework-shadcn.json +51 -0
  123. package/tests/selectors/framework-tailwind.json +40 -0
  124. package/tests/selectors/framework-vuetify.json +61 -0
  125. package/tests/step-definitions/a11y.steps.js +798 -0
  126. package/tests/step-definitions/action.steps.js +167 -0
  127. package/tests/step-definitions/{webship-api.js → api.steps.js} +24 -7
  128. package/tests/step-definitions/assertion.steps.js +352 -0
  129. package/tests/step-definitions/auth.steps.js +124 -0
  130. package/tests/step-definitions/clock.steps.js +128 -0
  131. package/tests/step-definitions/cookie.steps.js +216 -0
  132. package/tests/step-definitions/debug.steps.js +31 -0
  133. package/tests/step-definitions/dialog.steps.js +193 -0
  134. package/tests/step-definitions/element.steps.js +314 -0
  135. package/tests/step-definitions/field.steps.js +653 -0
  136. package/tests/step-definitions/file-download.steps.js +193 -0
  137. package/tests/step-definitions/form.steps.js +333 -0
  138. package/tests/step-definitions/iframe.steps.js +178 -0
  139. package/tests/step-definitions/input.steps.js +163 -0
  140. package/tests/step-definitions/javascript.steps.js +71 -0
  141. package/tests/step-definitions/keyboard.steps.js +78 -0
  142. package/tests/step-definitions/link.steps.js +142 -0
  143. package/tests/step-definitions/metatag.steps.js +91 -0
  144. package/tests/step-definitions/modal.steps.js +219 -0
  145. package/tests/step-definitions/navigation.steps.js +218 -0
  146. package/tests/step-definitions/network.steps.js +238 -0
  147. package/tests/step-definitions/path.steps.js +141 -0
  148. package/tests/step-definitions/response.steps.js +98 -0
  149. package/tests/step-definitions/responsive.steps.js +123 -0
  150. package/tests/step-definitions/rest.steps.js +111 -0
  151. package/tests/step-definitions/{webship-screenshot.js → screenshot.steps.js} +1 -5
  152. package/tests/step-definitions/scroll.steps.js +189 -0
  153. package/tests/step-definitions/{webship-selectors.js → selectors.steps.js} +46 -11
  154. package/tests/step-definitions/storage.steps.js +194 -0
  155. package/tests/step-definitions/table.steps.js +181 -0
  156. package/tests/step-definitions/wait.steps.js +400 -0
  157. package/tests/step-definitions/web-first.steps.js +296 -0
  158. package/tests/step-definitions/webship.js +552 -1507
  159. package/tests/step-definitions/xml.steps.js +409 -0
  160. package/tests/step-definitions/yaml.steps.js +911 -0
  161. package/tests/step-definitions-diffy/webship-diffy.js +0 -13
  162. package/tsconfig.json +19 -3
@@ -0,0 +1,798 @@
1
+ 'use strict';
2
+
3
+ // Accessibility (a11y) step definitions.
4
+ //
5
+ // Two layers:
6
+ //
7
+ // 1. Custom JS probes — fast, dependency-free assertions for POUR
8
+ // fundamentals (alt text, label association, landmarks, focus,
9
+ // headings, skip link, ARIA validity, tabindex, title, zoom).
10
+ // Each probe maps to a specific WCAG 2.1 / 2.2 success criterion.
11
+ //
12
+ // 2. axe-core integration — full WCAG audit via the official Deque
13
+ // engine (https://github.com/dequelabs/axe-core). axe ships ~100
14
+ // rules covering WCAG 2.0 / 2.1 / 2.2 levels A, AA, AAA plus best-
15
+ // practice and experimental rules. Each violation has an `impact`
16
+ // field (`minor` / `moderate` / `serious` / `critical`) for triage.
17
+ //
18
+ // Standards & references:
19
+ // - WCAG 2.1 https://www.w3.org/TR/WCAG21/
20
+ // - WCAG 2.2 https://www.w3.org/TR/WCAG22/
21
+ // - WAI overview https://www.w3.org/WAI/
22
+ // - Evaluation tools https://www.w3.org/WAI/test-evaluate/tools/list/
23
+ // - MDN Accessibility https://developer.mozilla.org/en-US/docs/Web/Accessibility
24
+ // - axe-core rules https://github.com/dequelabs/axe-core/tree/develop/doc/rule-descriptions.md
25
+ // - Deque Labs https://github.com/dequelabs/
26
+ //
27
+ // Defaults: the audit-level steps target WCAG 2.1 / 2.2 AA — the level
28
+ // required by the EU Web Accessibility Directive, US Section 508, and UK
29
+ // PSBAR. Use `at level "AAA"` for stricter scenarios.
30
+
31
+ const { When, Then } = require('@cucumber/cucumber');
32
+ const assert = require('assert');
33
+
34
+ // axe-core is loaded lazily so the file works even before deps install.
35
+ let AxeBuilder; try { AxeBuilder = require('@axe-core/playwright').default; } catch { /* lazy */ }
36
+
37
+ const WCAG_TAGS = {
38
+ 'A': ['wcag2a', 'wcag21a'],
39
+ 'AA': ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa'],
40
+ 'AAA': ['wcag2a', 'wcag2aa', 'wcag2aaa', 'wcag21a', 'wcag21aa', 'wcag21aaa', 'wcag22aaa'],
41
+ };
42
+
43
+ function summariseViolations(violations) {
44
+ if (violations.length === 0) return 'no violations';
45
+ const head = violations.slice(0, 5).map((v) =>
46
+ ` [${v.impact}] ${v.id} — ${v.help} (${v.nodes.length} node${v.nodes.length === 1 ? '' : 's'})`
47
+ ).join('\n');
48
+ const more = violations.length > 5 ? `\n ... and ${violations.length - 5} more` : '';
49
+ return head + more;
50
+ }
51
+
52
+ async function runAxe(world, opts = {}) {
53
+ if (!AxeBuilder) {
54
+ throw new Error('axe-core a11y steps require @axe-core/playwright. Install: npm i @axe-core/playwright axe-core');
55
+ }
56
+ let builder = new AxeBuilder({ page: world.page });
57
+ if (opts.tags) builder = builder.withTags(opts.tags);
58
+ if (opts.include) builder = builder.include(opts.include);
59
+ if (opts.exclude) builder = builder.exclude(opts.exclude);
60
+ return builder.analyze();
61
+ }
62
+
63
+ // ---------------------------------------------------------------------------
64
+ // Image alt text
65
+ // ---------------------------------------------------------------------------
66
+
67
+ /**
68
+ * Assert every <img> on the page has an `alt` attribute.
69
+ *
70
+ * Empty `alt=""` is allowed (decorative images per WCAG); `role="presentation"`
71
+ * is also allowed. Only a missing `alt` attribute fails. Iterates every <img>
72
+ * in the document, including those nested in shadow-light DOM that the page
73
+ * has rendered, so it works on infinite-scroll lists and image galleries too.
74
+ *
75
+ * Example #1: Then every image should have an alt attribute
76
+ * Example #2: And every image should have an alt attribute
77
+ * Example #3: Given I am on "/photos"
78
+ * Then every image should have an alt attribute
79
+ * Example #4: When I scroll to the bottom
80
+ * Then every image should have an alt attribute
81
+ * Example #5: When I follow "Gallery"
82
+ * Then every image should have an alt attribute
83
+ *
84
+ */
85
+ Then(/^every image should have an alt attribute$/, async function () {
86
+ const missing = await this.page.evaluate(() =>
87
+ Array.from(document.querySelectorAll('img'))
88
+ .filter((img) => !img.hasAttribute('alt') && img.getAttribute('role') !== 'presentation')
89
+ .map((img) => img.outerHTML.slice(0, 120))
90
+ );
91
+ assert.strictEqual(missing.length, 0,
92
+ `Found ${missing.length} <img> without alt:\n ${missing.join('\n ')}`);
93
+ });
94
+
95
+ // ---------------------------------------------------------------------------
96
+ // Form label association
97
+ // ---------------------------------------------------------------------------
98
+
99
+ /**
100
+ * Assert every form input/select/textarea has an accessible name.
101
+ *
102
+ * Pass condition: each field has at least ONE of —
103
+ * - `aria-label` attribute
104
+ * - `aria-labelledby` attribute pointing at a real element
105
+ * - matching `<label for="...">`
106
+ * - wrapping `<label>` element
107
+ *
108
+ * Submit/reset/button/image inputs and `type="hidden"` are exempt because
109
+ * they get their accessible name from `value` or `alt`.
110
+ *
111
+ * Example #1: Then every form field should have an accessible label
112
+ * Example #2: Given I am on "/register"
113
+ * Then every form field should have an accessible label
114
+ * Example #3: When I open the settings modal
115
+ * Then every form field should have an accessible label
116
+ * Example #4: And every form field should have an accessible label
117
+ * Example #5: Then the page should have a main landmark
118
+ * And every form field should have an accessible label
119
+ *
120
+ */
121
+ Then(/^every form field should have an accessible label$/, async function () {
122
+ const missing = await this.page.evaluate(() => {
123
+ const fields = Array.from(document.querySelectorAll('input:not([type="hidden"]), select, textarea'));
124
+ return fields.filter((el) => {
125
+ if (el.hasAttribute('aria-label') || el.hasAttribute('aria-labelledby')) return false;
126
+ if (el.id && document.querySelector(`label[for="${el.id}"]`)) return false;
127
+ if (el.closest('label')) return false;
128
+ const t = el.getAttribute('type');
129
+ if (t === 'submit' || t === 'button' || t === 'reset' || t === 'image') return false;
130
+ return true;
131
+ }).map((el) => el.outerHTML.slice(0, 120));
132
+ });
133
+ assert.strictEqual(missing.length, 0,
134
+ `Found ${missing.length} unlabeled form field(s):\n ${missing.join('\n ')}`);
135
+ });
136
+
137
+ // ---------------------------------------------------------------------------
138
+ // Landmarks / page structure
139
+ // ---------------------------------------------------------------------------
140
+
141
+ /**
142
+ * Assert the page has a primary `<main>` (or `[role="main"]`) landmark.
143
+ *
144
+ * Screen readers announce landmarks; missing the main landmark forces users
145
+ * to navigate the page linearly. WCAG 2.4.1 (Bypass Blocks) requires it.
146
+ *
147
+ * Example #1: Then the page should have a main landmark
148
+ * Example #2: Given I am on "/about"
149
+ * Then the page should have a main landmark
150
+ * Example #3: When I follow "Pricing"
151
+ * Then the page should have a main landmark
152
+ * Example #4: And the page should have a main landmark
153
+ * Example #5: Then the page should have a navigation landmark
154
+ * And the page should have a main landmark
155
+ *
156
+ */
157
+ Then(/^the page should have a main landmark$/, async function () {
158
+ const count = await this.page.locator('main, [role="main"]').count();
159
+ assert.ok(count >= 1, 'Page is missing a <main> or [role="main"] landmark.');
160
+ });
161
+
162
+ /**
163
+ * Assert the page has at least one navigation landmark.
164
+ *
165
+ * Counts both `<nav>` and `[role="navigation"]`.
166
+ *
167
+ * Example #1: Then the page should have a navigation landmark
168
+ * Example #2: Given I am on the homepage
169
+ * Then the page should have a navigation landmark
170
+ * Example #3: Given I am on "/admin"
171
+ * Then the page should have a navigation landmark
172
+ * Example #4: And the page should have a navigation landmark
173
+ * Example #5: Then the page should have exactly one h1
174
+ * And the page should have a navigation landmark
175
+ *
176
+ */
177
+ Then(/^the page should have a navigation landmark$/, async function () {
178
+ const count = await this.page.locator('nav, [role="navigation"]').count();
179
+ assert.ok(count >= 1, 'Page is missing a <nav> or [role="navigation"] landmark.');
180
+ });
181
+
182
+ /**
183
+ * Assert the page has exactly one `<h1>`.
184
+ *
185
+ * Multiple h1s are valid HTML5 with sectioning roots, but most assistive tech
186
+ * still treats the document outline as flat. One h1 per page is the safe
187
+ * default.
188
+ *
189
+ * Example #1: Then the page should have exactly one h1
190
+ * Example #2: Given I am on the homepage
191
+ * Then the page should have exactly one h1
192
+ * Example #3: When I follow "About"
193
+ * Then the page should have exactly one h1
194
+ * Example #4: And the page should have exactly one h1
195
+ * Example #5: Then the page should have a main landmark
196
+ * And the page should have exactly one h1
197
+ *
198
+ */
199
+ Then(/^the page should have exactly one h1$/, async function () {
200
+ const count = await this.page.locator('h1').count();
201
+ assert.strictEqual(count, 1, `Expected 1 <h1>, found ${count}.`);
202
+ });
203
+
204
+ // ---------------------------------------------------------------------------
205
+ // Focus assertions
206
+ // ---------------------------------------------------------------------------
207
+
208
+ /**
209
+ * Assert the currently focused element matches a CSS selector.
210
+ *
211
+ * Useful for tab-order and skip-link tests.
212
+ *
213
+ * Example #1: Then the focused element should match "#email"
214
+ * Example #2: When I press the "Tab" key
215
+ * Then the focused element should match "#email"
216
+ * Example #3: When I press the "Tab" key 2 times
217
+ * Then the focused element should match "#password"
218
+ * Example #4: When I focus on the element "#search"
219
+ * Then the focused element should match "input[type=search]"
220
+ * Example #5: When I follow "Skip to main content"
221
+ * Then the focused element should match "main h1"
222
+ *
223
+ */
224
+ Then(/^the focused element should match "([^"]*)"$/, async function (selector) {
225
+ const matches = await this.page.evaluate((sel) => {
226
+ const el = document.activeElement;
227
+ return !!(el && el.matches && el.matches(sel));
228
+ }, selector);
229
+ assert.ok(matches, `Focused element does not match "${selector}".`);
230
+ });
231
+
232
+ /**
233
+ * Assert the currently focused element's accessible name contains text.
234
+ *
235
+ * Resolution order: aria-label → aria-labelledby → label[for] → wrapping
236
+ * <label> → value/placeholder/title/textContent.
237
+ *
238
+ * Example #1: Then the focused element should be labeled "Email"
239
+ * Example #2: When I press the "Tab" key
240
+ * Then the focused element should be labeled "Email"
241
+ * Example #3: When I press the "Tab" key 2 times
242
+ * Then the focused element should be labeled "Password"
243
+ * Example #4: When I press the "Tab" key 3 times
244
+ * Then the focused element should be labeled "Sign in"
245
+ * Example #5: When I focus on the element "#agree"
246
+ * Then the focused element should be labeled "I agree"
247
+ *
248
+ */
249
+ Then(/^the focused element should be labeled "([^"]*)"$/, async function (text) {
250
+ const name = await this.page.evaluate(() => {
251
+ const el = document.activeElement;
252
+ if (!el) return '';
253
+ const ariaLabel = el.getAttribute('aria-label');
254
+ if (ariaLabel) return ariaLabel.trim();
255
+ const labelledby = el.getAttribute('aria-labelledby');
256
+ if (labelledby) {
257
+ const ref = document.getElementById(labelledby);
258
+ if (ref) return (ref.textContent || '').trim();
259
+ }
260
+ if (el.id) {
261
+ const lbl = document.querySelector(`label[for="${el.id}"]`);
262
+ if (lbl) return (lbl.textContent || '').trim();
263
+ }
264
+ const wrapping = el.closest && el.closest('label');
265
+ if (wrapping) return (wrapping.textContent || '').trim();
266
+ return ((el.value || el.placeholder || el.getAttribute('title') || el.textContent || '')).trim();
267
+ });
268
+ assert.ok(name.includes(text),
269
+ `Expected focused element to be labeled including "${text}", got "${name}".`);
270
+ });
271
+
272
+ // ---------------------------------------------------------------------------
273
+ // Page language
274
+ // ---------------------------------------------------------------------------
275
+
276
+ /**
277
+ * Assert the document has a `lang` attribute on `<html>`.
278
+ *
279
+ * Required by WCAG 3.1.1 — screen readers use `lang` to pick the right
280
+ * pronunciation engine. Missing or empty `lang` fails.
281
+ *
282
+ * Example #1: Then the page should declare a language
283
+ * Example #2: Given I am on the homepage
284
+ * Then the page should declare a language
285
+ * Example #3: When I follow "About"
286
+ * Then the page should declare a language
287
+ * Example #4: And the page should declare a language
288
+ * Example #5: Then the page should have a main landmark
289
+ * And the page should declare a language
290
+ *
291
+ */
292
+ Then(/^the page should declare a language$/, async function () {
293
+ const lang = await this.page.evaluate(() => document.documentElement.getAttribute('lang') || '');
294
+ assert.ok(lang.length > 0, 'Page <html> is missing a "lang" attribute.');
295
+ });
296
+
297
+ /**
298
+ * Assert the document `lang` equals an expected value.
299
+ *
300
+ * Example #1: Then the page language should be "en"
301
+ * Example #2: Given I am on the homepage
302
+ * Then the page language should be "en"
303
+ * Example #3: When I switch to the French version
304
+ * Then the page language should be "fr"
305
+ * Example #4: When I switch to the Arabic version
306
+ * Then the page language should be "ar"
307
+ * Example #5: And the page language should be "en-US"
308
+ *
309
+ */
310
+ Then(/^the page language should be "([^"]*)"$/, async function (expected) {
311
+ const lang = await this.page.evaluate(() => document.documentElement.getAttribute('lang') || '');
312
+ assert.strictEqual(lang, expected, `Expected page lang="${expected}", got "${lang}".`);
313
+ });
314
+
315
+ // ---------------------------------------------------------------------------
316
+ // Heading hierarchy (WCAG 1.3.1 — Info and Relationships)
317
+ // ---------------------------------------------------------------------------
318
+
319
+ /**
320
+ * Assert headings appear in non-skipping order (h1 → h2 → h3 — never
321
+ * h1 → h3). Required by WCAG 1.3.1 / 2.4.6 for screen-reader navigation.
322
+ *
323
+ * Example #1: Then the heading hierarchy should be valid
324
+ * Example #2: Given I am on the homepage
325
+ * Then the heading hierarchy should be valid
326
+ * Example #3: When I follow "About"
327
+ * Then the heading hierarchy should be valid
328
+ * Example #4: And the heading hierarchy should be valid
329
+ * Example #5: Then the page should have exactly one h1
330
+ * And the heading hierarchy should be valid
331
+ *
332
+ */
333
+ Then(/^the heading hierarchy should be valid$/, async function () {
334
+ const skips = await this.page.evaluate(() => {
335
+ const out = [];
336
+ const headings = Array.from(document.querySelectorAll('h1, h2, h3, h4, h5, h6'));
337
+ let prev = 0;
338
+ for (const h of headings) {
339
+ const level = parseInt(h.tagName.slice(1), 10);
340
+ if (prev > 0 && level - prev > 1) {
341
+ out.push(`<${h.tagName.toLowerCase()}>${(h.textContent || '').slice(0, 60).trim()}</${h.tagName.toLowerCase()}> (skipped from h${prev})`);
342
+ }
343
+ prev = level;
344
+ }
345
+ return out;
346
+ });
347
+ assert.strictEqual(skips.length, 0,
348
+ `Heading hierarchy skips levels:\n ${skips.join('\n ')}`);
349
+ });
350
+
351
+ // ---------------------------------------------------------------------------
352
+ // Skip link (WCAG 2.4.1 — Bypass Blocks)
353
+ // ---------------------------------------------------------------------------
354
+
355
+ /**
356
+ * Assert the page exposes a skip-link as the first focusable element. WCAG
357
+ * 2.4.1 requires a mechanism to bypass repeated content blocks.
358
+ *
359
+ * Detection: anchor with href="#..." that resolves to an existing target
360
+ * AND text matching "skip" / "main content" / "to content".
361
+ *
362
+ * Example #1: Then the page should have a skip link
363
+ * Example #2: Given I am on the homepage
364
+ * Then the page should have a skip link
365
+ * Example #3: When I press the key "Tab"
366
+ * Then the focused element should match "a[href^='#']"
367
+ * And the page should have a skip link
368
+ * Example #4: Then the page should have a skip link
369
+ * And the page should have a main landmark
370
+ * Example #5: When I follow "About"
371
+ * Then the page should have a skip link
372
+ *
373
+ */
374
+ Then(/^the page should have a skip link$/, async function () {
375
+ const ok = await this.page.evaluate(() => {
376
+ const links = Array.from(document.querySelectorAll('a[href^="#"]'));
377
+ return links.some((a) => {
378
+ const href = a.getAttribute('href') || '';
379
+ const id = href.slice(1);
380
+ const target = id ? document.getElementById(id) : null;
381
+ const txt = (a.textContent || '').toLowerCase();
382
+ return target && (txt.includes('skip') || txt.includes('main content') || txt.includes('to content'));
383
+ });
384
+ });
385
+ assert.ok(ok, 'Page is missing a skip link.');
386
+ });
387
+
388
+ // ---------------------------------------------------------------------------
389
+ // Accessible name on buttons / links (WCAG 4.1.2 — Name, Role, Value)
390
+ // ---------------------------------------------------------------------------
391
+
392
+ /**
393
+ * Assert every <button> / role="button" has an accessible name (visible
394
+ * text, aria-label, or aria-labelledby).
395
+ *
396
+ * Example #1: Then every button should have an accessible name
397
+ * Example #2: Given I am on the homepage
398
+ * Then every button should have an accessible name
399
+ * Example #3: When I am on "/checkout"
400
+ * Then every button should have an accessible name
401
+ * Example #4: And every button should have an accessible name
402
+ * Example #5: Then every button should have an accessible name
403
+ * And every link should have an accessible name
404
+ *
405
+ */
406
+ Then(/^every button should have an accessible name$/, async function () {
407
+ const missing = await this.page.evaluate(() => {
408
+ const els = Array.from(document.querySelectorAll('button, [role="button"], input[type="submit"], input[type="button"]'));
409
+ return els.filter((el) => {
410
+ if (el.hasAttribute('aria-label') && el.getAttribute('aria-label').trim()) return false;
411
+ if (el.hasAttribute('aria-labelledby')) return false;
412
+ if (el.tagName === 'INPUT') {
413
+ return !((el.value || '').trim());
414
+ }
415
+ return !(el.textContent || '').trim();
416
+ }).map((el) => el.outerHTML.slice(0, 120));
417
+ });
418
+ assert.strictEqual(missing.length, 0,
419
+ `Found ${missing.length} button(s) without accessible name:\n ${missing.join('\n ')}`);
420
+ });
421
+
422
+ /**
423
+ * Assert every <a> has an accessible name.
424
+ *
425
+ * Example #1: Then every link should have an accessible name
426
+ * Example #2: Given I am on the homepage
427
+ * Then every link should have an accessible name
428
+ * Example #3: When I am on "/blog"
429
+ * Then every link should have an accessible name
430
+ * Example #4: And every link should have an accessible name
431
+ * Example #5: Then every button should have an accessible name
432
+ * And every link should have an accessible name
433
+ *
434
+ */
435
+ Then(/^every link should have an accessible name$/, async function () {
436
+ const missing = await this.page.evaluate(() => {
437
+ const links = Array.from(document.querySelectorAll('a[href]'));
438
+ return links.filter((a) => {
439
+ if (a.hasAttribute('aria-label') && a.getAttribute('aria-label').trim()) return false;
440
+ if (a.hasAttribute('aria-labelledby')) return false;
441
+ if ((a.textContent || '').trim()) return false;
442
+ // Allow image-link if alt has text.
443
+ const img = a.querySelector('img[alt]');
444
+ if (img && (img.getAttribute('alt') || '').trim()) return false;
445
+ return true;
446
+ }).map((a) => a.outerHTML.slice(0, 120));
447
+ });
448
+ assert.strictEqual(missing.length, 0,
449
+ `Found ${missing.length} link(s) without accessible name:\n ${missing.join('\n ')}`);
450
+ });
451
+
452
+ // ---------------------------------------------------------------------------
453
+ // tabindex hygiene (WCAG 2.4.3 — Focus Order)
454
+ // ---------------------------------------------------------------------------
455
+
456
+ /**
457
+ * Assert NO interactive element uses a positive `tabindex`. Positive values
458
+ * break natural focus order — WCAG 2.4.3 violation in practice.
459
+ *
460
+ * Example #1: Then no element should have a positive tabindex
461
+ * Example #2: Given I am on the homepage
462
+ * Then no element should have a positive tabindex
463
+ * Example #3: When I am on "/form"
464
+ * Then no element should have a positive tabindex
465
+ * Example #4: And no element should have a positive tabindex
466
+ * Example #5: Then no element should have a positive tabindex
467
+ * And the heading hierarchy should be valid
468
+ *
469
+ */
470
+ Then(/^no element should have a positive tabindex$/, async function () {
471
+ const offenders = await this.page.evaluate(() =>
472
+ Array.from(document.querySelectorAll('[tabindex]'))
473
+ .filter((el) => parseInt(el.getAttribute('tabindex'), 10) > 0)
474
+ .map((el) => el.outerHTML.slice(0, 120))
475
+ );
476
+ assert.strictEqual(offenders.length, 0,
477
+ `Found ${offenders.length} element(s) with positive tabindex:\n ${offenders.join('\n ')}`);
478
+ });
479
+
480
+ // ---------------------------------------------------------------------------
481
+ // ARIA validity (WCAG 4.1.2)
482
+ // ---------------------------------------------------------------------------
483
+
484
+ /**
485
+ * Assert every `aria-labelledby` / `aria-describedby` / `aria-controls`
486
+ * / `aria-owns` references an existing element id.
487
+ *
488
+ * Example #1: Then every ARIA reference should resolve
489
+ * Example #2: Given I am on the homepage
490
+ * Then every ARIA reference should resolve
491
+ * Example #3: When I am on "/dashboard"
492
+ * Then every ARIA reference should resolve
493
+ * Example #4: And every ARIA reference should resolve
494
+ * Example #5: Then every ARIA reference should resolve
495
+ * And every button should have an accessible name
496
+ *
497
+ */
498
+ Then(/^every ARIA reference should resolve$/, async function () {
499
+ const broken = await this.page.evaluate(() => {
500
+ const attrs = ['aria-labelledby', 'aria-describedby', 'aria-controls', 'aria-owns', 'aria-flowto'];
501
+ const out = [];
502
+ for (const attr of attrs) {
503
+ const els = Array.from(document.querySelectorAll(`[${attr}]`));
504
+ for (const el of els) {
505
+ const ids = (el.getAttribute(attr) || '').split(/\s+/).filter(Boolean);
506
+ for (const id of ids) {
507
+ if (!document.getElementById(id)) {
508
+ out.push(`<${el.tagName.toLowerCase()} ${attr}="${el.getAttribute(attr)}"> — missing id "${id}"`);
509
+ }
510
+ }
511
+ }
512
+ }
513
+ return out;
514
+ });
515
+ assert.strictEqual(broken.length, 0,
516
+ `Found ${broken.length} broken ARIA reference(s):\n ${broken.join('\n ')}`);
517
+ });
518
+
519
+ /**
520
+ * Assert no element uses an invalid ARIA role. Reference: WAI-ARIA 1.2.
521
+ *
522
+ * Example #1: Then every ARIA role should be valid
523
+ * Example #2: Given I am on the homepage
524
+ * Then every ARIA role should be valid
525
+ * Example #3: When I am on "/dashboard"
526
+ * Then every ARIA role should be valid
527
+ * Example #4: And every ARIA role should be valid
528
+ * Example #5: Then every ARIA role should be valid
529
+ * And every ARIA reference should resolve
530
+ *
531
+ */
532
+ Then(/^every ARIA role should be valid$/, async function () {
533
+ const VALID = new Set([
534
+ 'alert', 'alertdialog', 'application', 'article', 'banner', 'blockquote',
535
+ 'button', 'caption', 'cell', 'checkbox', 'code', 'columnheader', 'combobox',
536
+ 'complementary', 'contentinfo', 'definition', 'deletion', 'dialog',
537
+ 'directory', 'document', 'emphasis', 'feed', 'figure', 'form', 'generic',
538
+ 'graphics-document', 'graphics-object', 'graphics-symbol', 'grid',
539
+ 'gridcell', 'group', 'heading', 'img', 'insertion', 'link', 'list',
540
+ 'listbox', 'listitem', 'log', 'main', 'marquee', 'math', 'menu', 'menubar',
541
+ 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'meter', 'navigation',
542
+ 'none', 'note', 'option', 'paragraph', 'presentation', 'progressbar',
543
+ 'radio', 'radiogroup', 'region', 'row', 'rowgroup', 'rowheader',
544
+ 'scrollbar', 'search', 'searchbox', 'separator', 'slider', 'spinbutton',
545
+ 'status', 'strong', 'subscript', 'superscript', 'switch', 'tab', 'table',
546
+ 'tablist', 'tabpanel', 'term', 'textbox', 'time', 'timer', 'toolbar',
547
+ 'tooltip', 'tree', 'treegrid', 'treeitem',
548
+ ]);
549
+ const invalid = await this.page.evaluate((valid) => {
550
+ return Array.from(document.querySelectorAll('[role]'))
551
+ .filter((el) => {
552
+ const roles = (el.getAttribute('role') || '').split(/\s+/).filter(Boolean);
553
+ return roles.some((r) => !valid.includes(r));
554
+ })
555
+ .map((el) => `${el.tagName.toLowerCase()} role="${el.getAttribute('role')}"`);
556
+ }, [...VALID]);
557
+ assert.strictEqual(invalid.length, 0,
558
+ `Found ${invalid.length} invalid ARIA role(s):\n ${invalid.join('\n ')}`);
559
+ });
560
+
561
+ // ---------------------------------------------------------------------------
562
+ // Forms — autocomplete, required (WCAG 1.3.5 — Identify Input Purpose)
563
+ // ---------------------------------------------------------------------------
564
+
565
+ /**
566
+ * Assert every form field exposing `aria-required="true"` is also marked
567
+ * with the native `required` attribute (or vice versa). Mismatch confuses
568
+ * assistive tech.
569
+ *
570
+ * Example #1: Then required fields should be consistently marked
571
+ * Example #2: Given I am on "/signup"
572
+ * Then required fields should be consistently marked
573
+ * Example #3: When I am on "/checkout"
574
+ * Then required fields should be consistently marked
575
+ * Example #4: And required fields should be consistently marked
576
+ * Example #5: Then every form field should have an accessible label
577
+ * And required fields should be consistently marked
578
+ *
579
+ */
580
+ Then(/^required fields should be consistently marked$/, async function () {
581
+ const mismatches = await this.page.evaluate(() => {
582
+ const out = [];
583
+ const fields = Array.from(document.querySelectorAll('input, select, textarea'));
584
+ for (const el of fields) {
585
+ const native = el.hasAttribute('required');
586
+ const aria = el.getAttribute('aria-required') === 'true';
587
+ if (native !== aria && (native || aria)) {
588
+ out.push(el.outerHTML.slice(0, 120));
589
+ }
590
+ }
591
+ return out;
592
+ });
593
+ // Strict mismatch — any field with one but not the other is a finding.
594
+ assert.strictEqual(mismatches.length, 0,
595
+ `Found ${mismatches.length} field(s) with inconsistent required marking:\n ${mismatches.join('\n ')}`);
596
+ });
597
+
598
+ // ---------------------------------------------------------------------------
599
+ // Page <title> (WCAG 2.4.2 — Page Titled)
600
+ // ---------------------------------------------------------------------------
601
+
602
+ /**
603
+ * Assert the document has a non-empty `<title>`. WCAG 2.4.2.
604
+ *
605
+ * Example #1: Then the page should have a title
606
+ * Example #2: Given I am on the homepage
607
+ * Then the page should have a title
608
+ * Example #3: When I am on "/about"
609
+ * Then the page should have a title
610
+ * Example #4: And the page should have a title
611
+ * Example #5: Then the page should have a title
612
+ * And the page should declare a language
613
+ *
614
+ */
615
+ Then(/^the page should have a title$/, async function () {
616
+ const title = await this.page.title();
617
+ assert.ok(title && title.trim().length > 0, 'Page is missing a non-empty <title>.');
618
+ });
619
+
620
+ // ---------------------------------------------------------------------------
621
+ // Viewport meta (WCAG 1.4.4 — Resize Text without horizontal scroll)
622
+ // ---------------------------------------------------------------------------
623
+
624
+ /**
625
+ * Assert the viewport meta tag does not disable user-scaling
626
+ * (`user-scalable=no` or `maximum-scale=1`). WCAG 1.4.4 / 1.4.10.
627
+ *
628
+ * Example #1: Then user zoom should be allowed
629
+ * Example #2: Given I am on the homepage
630
+ * Then user zoom should be allowed
631
+ * Example #3: When I am on "/article"
632
+ * Then user zoom should be allowed
633
+ * Example #4: And user zoom should be allowed
634
+ * Example #5: Then user zoom should be allowed
635
+ * And the page should declare a language
636
+ *
637
+ */
638
+ Then(/^user zoom should be allowed$/, async function () {
639
+ const blocked = await this.page.evaluate(() => {
640
+ const m = document.querySelector('meta[name="viewport"]');
641
+ if (!m) return false;
642
+ const c = (m.getAttribute('content') || '').toLowerCase();
643
+ return /user-scalable\s*=\s*(no|0)/.test(c) || /maximum-scale\s*=\s*1(\.0)?(\b|$)/.test(c);
644
+ });
645
+ assert.ok(!blocked, 'Viewport meta tag disables user-scaling — fails WCAG 1.4.4 / 1.4.10.');
646
+ });
647
+
648
+ // ===========================================================================
649
+ // axe-core full WCAG audit (https://github.com/dequelabs/axe-core)
650
+ // ===========================================================================
651
+
652
+ /**
653
+ * Run an axe-core audit and assert ZERO violations across the supplied WCAG
654
+ * level. Defaults to AA — the level mandated by most accessibility laws.
655
+ *
656
+ * Example #1: Then the page should pass an accessibility audit
657
+ * Example #2: Then the page should pass an accessibility audit at level "A"
658
+ * Example #3: Then the page should pass an accessibility audit at level "AA"
659
+ * Example #4: And the page should pass an accessibility audit at level "AAA"
660
+ * Example #5: When I am on "/dashboard"
661
+ * Then the page should pass an accessibility audit at level "AA"
662
+ *
663
+ */
664
+ Then(/^the page should pass an accessibility audit(?: at level "(A|AA|AAA)")?$/, async function (level) {
665
+ const tags = WCAG_TAGS[level || 'AA'];
666
+ const result = await runAxe(this, { tags });
667
+ assert.strictEqual(result.violations.length, 0,
668
+ `Expected no WCAG ${level || 'AA'} violations, got ${result.violations.length}:\n${summariseViolations(result.violations)}`);
669
+ });
670
+
671
+ /**
672
+ * Assert NO axe violations of the given impact severity.
673
+ * Levels: `minor`, `moderate`, `serious`, `critical`.
674
+ *
675
+ * Use to gate merges on critical/serious issues while triaging minor regressions.
676
+ *
677
+ * Example #1: Then the page should have no critical accessibility violations
678
+ * Example #2: Then the page should have no serious accessibility violations
679
+ * Example #3: And the page should have no moderate accessibility violations
680
+ * Example #4: When I am on "/checkout"
681
+ * Then the page should have no critical accessibility violations
682
+ * Example #5: Then the page should have no critical accessibility violations
683
+ * And the page should have no serious accessibility violations
684
+ *
685
+ */
686
+ Then(/^the page should have no (critical|serious|moderate|minor) accessibility violations$/, async function (impact) {
687
+ const result = await runAxe(this);
688
+ const filtered = result.violations.filter((v) => v.impact === impact);
689
+ assert.strictEqual(filtered.length, 0,
690
+ `Expected no ${impact} violations, got ${filtered.length}:\n${summariseViolations(filtered)}`);
691
+ });
692
+
693
+ /**
694
+ * Audit ONLY the subtree under a CSS selector. Use when third-party widgets
695
+ * are known-bad and you only want to gate your own components.
696
+ *
697
+ * Example #1: Then the element "main" should pass an accessibility audit
698
+ * Example #2: Then the element "#checkout-form" should pass an accessibility audit
699
+ * Example #3: And the element ".product-card" should pass an accessibility audit
700
+ * Example #4: Then the element "#dashboard-widget" should pass an accessibility audit
701
+ * Example #5: Then the element "[data-testid=signup]" should pass an accessibility audit
702
+ *
703
+ */
704
+ Then(/^the element "([^"]*)" should pass an accessibility audit$/, async function (selector) {
705
+ const result = await runAxe(this, { include: selector, tags: WCAG_TAGS.AA });
706
+ assert.strictEqual(result.violations.length, 0,
707
+ `Expected no violations within "${selector}", got ${result.violations.length}:\n${summariseViolations(result.violations)}`);
708
+ });
709
+
710
+ /**
711
+ * Audit the page but EXCLUDE the subtree under a CSS selector. Skip
712
+ * known-bad embedded content (third-party iframes, legacy widgets, ads).
713
+ *
714
+ * Example #1: Then the page should pass an accessibility audit excluding "iframe.payment"
715
+ * Example #2: Then the page should pass an accessibility audit excluding "#chat-widget"
716
+ * Example #3: And the page should pass an accessibility audit excluding ".legacy-banner"
717
+ * Example #4: Then the page should pass an accessibility audit excluding "[data-third-party]"
718
+ * Example #5: Then the page should pass an accessibility audit excluding ".ads"
719
+ *
720
+ */
721
+ Then(/^the page should pass an accessibility audit excluding "([^"]*)"$/, async function (selector) {
722
+ const result = await runAxe(this, { exclude: selector, tags: WCAG_TAGS.AA });
723
+ assert.strictEqual(result.violations.length, 0,
724
+ `Expected no violations excluding "${selector}", got ${result.violations.length}:\n${summariseViolations(result.violations)}`);
725
+ });
726
+
727
+ /**
728
+ * Assert a specific axe rule does not fire. Use for fine-grained gates —
729
+ * e.g. ensure color-contrast is fixed even if other rules still red.
730
+ *
731
+ * Common rule ids: `color-contrast`, `image-alt`, `label`, `link-name`,
732
+ * `button-name`, `heading-order`, `landmark-one-main`, `region`,
733
+ * `aria-valid-attr`, `tabindex`, `bypass`, `frame-title`, `meta-viewport`,
734
+ * `valid-lang`, `duplicate-id-aria`, `list`, `listitem`.
735
+ *
736
+ * Example #1: Then the page should not violate the accessibility rule "color-contrast"
737
+ * Example #2: Then the page should not violate the accessibility rule "image-alt"
738
+ * Example #3: And the page should not violate the accessibility rule "label"
739
+ * Example #4: Then the page should not violate the accessibility rule "link-name"
740
+ * Example #5: Then the page should not violate the accessibility rule "heading-order"
741
+ *
742
+ */
743
+ Then(/^the page should not violate the accessibility rule "([^"]*)"$/, async function (ruleId) {
744
+ const result = await runAxe(this);
745
+ const hit = result.violations.find((v) => v.id === ruleId);
746
+ assert.ok(!hit, hit ? `Rule "${ruleId}" violated by ${hit.nodes.length} node(s):\n ${hit.nodes.slice(0, 5).map((n) => n.target.join(' ')).join('\n ')}` : '');
747
+ });
748
+
749
+ /**
750
+ * Print every axe violation to stdout (debug aid). Strip from CI runs.
751
+ *
752
+ * Example #1: Then I print accessibility violations
753
+ * Example #2: When I am on "/checkout"
754
+ * Then I print accessibility violations
755
+ * Example #3: And we print accessibility violations
756
+ * Example #4: Then I print accessibility violations
757
+ * And the page should have no critical accessibility violations
758
+ * Example #5: When I follow "Pricing"
759
+ * Then I print accessibility violations
760
+ *
761
+ */
762
+ Then(/^(I |we )*print accessibility violations$/, async function () {
763
+ const result = await runAxe(this);
764
+ if (result.violations.length === 0) {
765
+ console.log('\n--- Accessibility violations: none ---');
766
+ return;
767
+ }
768
+ console.log('\n--- Accessibility violations ---');
769
+ for (const v of result.violations) {
770
+ console.log(`[${v.impact}] ${v.id} — ${v.help}`);
771
+ console.log(` ${v.helpUrl}`);
772
+ for (const n of v.nodes.slice(0, 3)) {
773
+ console.log(` ${n.target.join(' ')}`);
774
+ if (n.failureSummary) console.log(` ${n.failureSummary.split('\n')[0]}`);
775
+ }
776
+ if (v.nodes.length > 3) console.log(` ... and ${v.nodes.length - 3} more node(s)`);
777
+ }
778
+ });
779
+
780
+ /**
781
+ * Assert axe finds zero violations of an exact list of rules. Use for
782
+ * smoke-test gating: pin the small list of rules you absolutely require to
783
+ * pass, run them on every page.
784
+ *
785
+ * Example #1: Then the page should pass the accessibility rules "image-alt, label"
786
+ * Example #2: Then the page should pass the accessibility rules "color-contrast"
787
+ * Example #3: And the page should pass the accessibility rules "button-name, link-name"
788
+ * Example #4: Then the page should pass the accessibility rules "landmark-one-main, region"
789
+ * Example #5: Then the page should pass the accessibility rules "aria-valid-attr, aria-valid-attr-value"
790
+ *
791
+ */
792
+ Then(/^the page should pass the accessibility rules "([^"]*)"$/, async function (csv) {
793
+ const ids = csv.split(',').map((s) => s.trim()).filter(Boolean);
794
+ const result = await runAxe(this);
795
+ const hits = result.violations.filter((v) => ids.includes(v.id));
796
+ assert.strictEqual(hits.length, 0,
797
+ `Required rule(s) violated:\n${summariseViolations(hits)}`);
798
+ });