webship-js 2.0.10 → 2.0.12

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 (248) hide show
  1. package/.circleci/config.yml +10 -1
  2. package/.drone.yml +7 -7
  3. package/.github/ISSUE_TEMPLATE/issue.md +37 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +24 -0
  5. package/.github/workflows/github-actions.yml +101 -4
  6. package/.gitlab-ci.yml +9 -4
  7. package/.harness/webship-js-pipeline.yml +5 -6
  8. package/.semaphore/semaphore.yml +6 -9
  9. package/.teamcity/settings.kts +7 -6
  10. package/.travis.yml +6 -1
  11. package/AGENTS.md +1 -1
  12. package/CLAUDE.md +69 -24
  13. package/Jenkinsfile +5 -3
  14. package/README.md +13 -1
  15. package/azure-pipelines.yml +17 -8
  16. package/bamboo-specs/bamboo.yml +9 -15
  17. package/bin/generate-reports.js +51 -7
  18. package/bin/init-webship.js +127 -23
  19. package/bitbucket-pipelines.yml +5 -1
  20. package/buildspec.yml +6 -7
  21. package/cloudbuild.yaml +28 -12
  22. package/codefresh.yml +6 -6
  23. package/cucumber.js +46 -11
  24. package/docs/00-quick-start.md +38 -7
  25. package/docs/02-bbr-smart-waits.md +21 -10
  26. package/docs/03-selector-registry.md +24 -0
  27. package/docs/04-step-reference.md +53 -27
  28. package/docs/05-web-first-assertions.md +6 -0
  29. package/docs/07-auth-state.md +1 -1
  30. package/docs/08-clock-mocking.md +21 -2
  31. package/docs/09-api-testing.md +40 -2
  32. package/docs/10-accessibility.md +2 -0
  33. package/docs/11-debugging.md +24 -1
  34. package/docs/12-ai-agent-guide.md +8 -1
  35. package/docs/13-faq.md +75 -1
  36. package/docs/14-recipes-cookbook.md +2 -0
  37. package/docs/15-tag-conventions.md +5 -1
  38. package/docs/16-ci-cd.md +161 -124
  39. package/docs/README.md +5 -5
  40. package/docs/advanced-screenshots.md +3 -1
  41. package/docs/api-step-definitions.md +16 -2
  42. package/docs/global-settings.md +70 -18
  43. package/docs/install-webship-js/ddev-webship-js.md +3 -0
  44. package/docs/install-webship-js.md +16 -2
  45. package/docs/step-definitions/then-i-should-see.md +14 -1
  46. package/docs/step-definitions/then-item-checkbox.md +2 -0
  47. package/docs/step-definitions/when-i-fill.md +4 -0
  48. package/docs/step-definitions/when-i-select-option-select-list.md +2 -0
  49. package/examples/a11y-legacy-widget.html +34 -0
  50. package/examples/auth-state.html +42 -0
  51. package/examples/choice-controls.html +29 -0
  52. package/examples/clock.html +33 -0
  53. package/examples/datetime-fields.html +52 -0
  54. package/examples/downloads/webship-archive.zip +0 -0
  55. package/examples/downloads/webship-notes.txt +4 -0
  56. package/examples/downloads/webship-report.csv +4 -0
  57. package/examples/downloads.html +16 -0
  58. package/examples/element-selector-hint.html +16 -0
  59. package/examples/element-viewport.html +42 -0
  60. package/examples/field-states.html +27 -0
  61. package/examples/field-types.html +98 -0
  62. package/examples/fill-in-empty.html +26 -0
  63. package/examples/fill-unreachable.html +27 -0
  64. package/examples/iframe-inner.html +20 -0
  65. package/examples/iframe-nested.html +16 -0
  66. package/examples/iframe-newsletter.html +29 -0
  67. package/examples/iframe-order.html +26 -0
  68. package/examples/iframe-outer.html +15 -0
  69. package/examples/iframe.html +21 -0
  70. package/examples/javascript-errors.html +35 -0
  71. package/examples/links.html +1 -0
  72. package/examples/metatags.html +18 -0
  73. package/examples/mouse-and-pointer.html +83 -0
  74. package/examples/multi-value-fields.html +54 -0
  75. package/examples/native-dialogs.html +8 -0
  76. package/examples/network.html +83 -0
  77. package/examples/registered-names.html +15 -0
  78. package/examples/scroll-horizontal.html +50 -0
  79. package/examples/select-by-label.html +33 -0
  80. package/examples/selectors-position.html +29 -0
  81. package/examples/settle-budget.html +21 -0
  82. package/examples/sorted-tables.html +38 -0
  83. package/examples/storage.html +57 -0
  84. package/examples/text-matching.html +48 -0
  85. package/examples/text-order.html +25 -0
  86. package/examples/touch.html +22 -0
  87. package/examples/viewport-size.html +24 -0
  88. package/examples/viewport-top.html +36 -0
  89. package/examples/wait-conditions.html +69 -0
  90. package/examples/web-first.html +99 -0
  91. package/package.json +24 -2
  92. package/playwright.config.ts +3 -1
  93. package/tests/assets/catalog.xml +19 -0
  94. package/tests/assets/feed-namespaced.xml +13 -0
  95. package/tests/assets/sitemap.xml +14 -0
  96. package/tests/assets/webship-site-expected.yaml +21 -0
  97. package/tests/assets/webship-site.schema.json +46 -0
  98. package/tests/assets/webship-site.yaml +21 -0
  99. package/tests/check-api-launch-url.js +106 -0
  100. package/tests/check-assets.js +103 -0
  101. package/tests/check-attachments.js +105 -0
  102. package/tests/check-breakpoints.js +117 -0
  103. package/tests/check-clock.js +143 -0
  104. package/tests/check-config.js +90 -0
  105. package/tests/check-context.js +215 -0
  106. package/tests/check-dry-run.js +104 -0
  107. package/tests/check-examples.js +241 -0
  108. package/tests/check-exit-report.js +141 -0
  109. package/tests/check-javascript-errors.js +105 -0
  110. package/tests/check-must-fail.js +85 -0
  111. package/tests/check-paths.js +82 -0
  112. package/tests/check-report.js +119 -0
  113. package/tests/check-scaffold.js +246 -0
  114. package/tests/check-screenshots.js +117 -0
  115. package/tests/check-settle-verbs.js +137 -0
  116. package/tests/check-time-limit.js +104 -0
  117. package/tests/check-video.js +156 -0
  118. package/tests/check-world.js +167 -0
  119. package/tests/features/a11y.feature +18 -0
  120. package/tests/features/api-base-url.feature +25 -0
  121. package/tests/features/api-form-data.feature +18 -0
  122. package/tests/features/api-json-paths.feature +24 -0
  123. package/tests/features/api-response-contains.feature +21 -0
  124. package/tests/features/api-response-header-presence.feature +17 -0
  125. package/tests/features/api-response-header.feature +17 -0
  126. package/tests/features/api-saved-placeholders.feature +37 -0
  127. package/tests/features/api-step-definitions-individual.feature +1 -1
  128. package/tests/features/api-tables.feature +40 -0
  129. package/tests/features/auth-state.feature +32 -0
  130. package/tests/features/breakpoints.feature +25 -0
  131. package/tests/features/choice-controls.feature +35 -0
  132. package/tests/features/clock.feature +27 -0
  133. package/tests/features/complete-api-testing-examples.feature +1 -1
  134. package/tests/features/cookie.feature +9 -0
  135. package/tests/features/datetime-field-lookup.feature +29 -0
  136. package/tests/features/dialog.feature +27 -0
  137. package/tests/features/element-selector-hint.feature +14 -0
  138. package/tests/features/element.feature +47 -0
  139. package/tests/features/field-state.feature +21 -0
  140. package/tests/features/field.feature +104 -0
  141. package/tests/features/file-download.feature +64 -0
  142. package/tests/features/fill-in-empty-value.feature +41 -0
  143. package/tests/features/fill-reachable.feature +13 -0
  144. package/tests/features/iframe-nested.feature +43 -0
  145. package/tests/features/iframe.feature +83 -0
  146. package/tests/features/javascript-tolerated-errors.feature +20 -0
  147. package/tests/features/javascript.feature +47 -0
  148. package/tests/features/link.feature +11 -0
  149. package/tests/features/metatag.feature +38 -0
  150. package/tests/features/modal-open.feature +13 -0
  151. package/tests/features/mouse-and-pointer.feature +86 -0
  152. package/tests/features/multi-value-field-lookup.feature +30 -0
  153. package/tests/features/network-mocking.feature +80 -0
  154. package/tests/features/registered-names.feature +14 -0
  155. package/tests/features/responsive.feature +27 -0
  156. package/tests/features/scroll-horizontal.feature +55 -0
  157. package/tests/features/select-by-label.feature +31 -0
  158. package/tests/features/selector-files.feature +14 -0
  159. package/tests/features/selectors-position.feature +41 -0
  160. package/tests/features/selectors-table-header.feature +35 -0
  161. package/tests/features/settle-budget.feature +11 -0
  162. package/tests/features/sorted-tables.feature +19 -0
  163. package/tests/features/storage-quoted-values.feature +26 -0
  164. package/tests/features/storage.feature +98 -0
  165. package/tests/features/test--then--i-see-locator.feature +13 -0
  166. package/tests/features/test--then--i-should--see-text-in-element.feature +9 -1
  167. package/tests/features/test--then--the-field-should-contain-value.feature +8 -0
  168. package/tests/features/text-matching.feature +38 -0
  169. package/tests/features/text-order.feature +14 -0
  170. package/tests/features/touch.feature +21 -0
  171. package/tests/features/video.feature +1 -0
  172. package/tests/features/viewport-top.feature +13 -0
  173. package/tests/features/wait.feature +89 -0
  174. package/tests/features/web-first.feature +100 -0
  175. package/tests/features/xml-namespaces.feature +34 -0
  176. package/tests/features/xml.feature +96 -0
  177. package/tests/features/yaml.feature +75 -0
  178. package/tests/must-fail/api-json-paths.feature +21 -0
  179. package/tests/must-fail/api-response-contains.feature +23 -0
  180. package/tests/must-fail/api-response-header-presence.feature +17 -0
  181. package/tests/must-fail/api-response-header.feature +21 -0
  182. package/tests/must-fail/api-without-base-url.feature +11 -0
  183. package/tests/must-fail/assertions.feature +96 -0
  184. package/tests/must-fail/breakpoints.feature +15 -0
  185. package/tests/must-fail/choice-controls.feature +25 -0
  186. package/tests/must-fail/clock.feature +11 -0
  187. package/tests/must-fail/datetime-field.feature +10 -0
  188. package/tests/must-fail/element-selector-hint.feature +17 -0
  189. package/tests/must-fail/field-state.feature +20 -0
  190. package/tests/must-fail/fill-field.feature +30 -0
  191. package/tests/must-fail/iframe-text.feature +17 -0
  192. package/tests/must-fail/modal-open.feature +26 -0
  193. package/tests/must-fail/multi-value-field.feature +18 -0
  194. package/tests/must-fail/registered-names.feature +25 -0
  195. package/tests/must-fail/select-list.feature +15 -0
  196. package/tests/must-fail/selector-files.feature +10 -0
  197. package/tests/must-fail/sorted-tables.feature +20 -0
  198. package/tests/must-fail/storage-before-a-page.feature +13 -0
  199. package/tests/must-fail/text-matching.feature +16 -0
  200. package/tests/must-fail/text-order.feature +15 -0
  201. package/tests/must-fail/viewport-top.feature +20 -0
  202. package/tests/must-fail/waits.feature +51 -0
  203. package/tests/must-fail/yaml-numbers.feature +48 -0
  204. package/tests/reports/README.md +2 -2
  205. package/tests/step-definitions/a11y.steps.js +36 -23
  206. package/tests/step-definitions/action.steps.js +22 -8
  207. package/tests/step-definitions/api.steps.js +349 -67
  208. package/tests/step-definitions/assertion.steps.js +327 -63
  209. package/tests/step-definitions/auth.steps.js +15 -18
  210. package/tests/step-definitions/clock.steps.js +22 -0
  211. package/tests/step-definitions/debug.steps.js +8 -0
  212. package/tests/step-definitions/dialog.steps.js +9 -2
  213. package/tests/step-definitions/element.steps.js +135 -18
  214. package/tests/step-definitions/field.steps.js +523 -80
  215. package/tests/step-definitions/file-download.steps.js +74 -10
  216. package/tests/step-definitions/form.steps.js +76 -29
  217. package/tests/step-definitions/iframe.steps.js +89 -29
  218. package/tests/step-definitions/input.steps.js +26 -7
  219. package/tests/step-definitions/javascript.steps.js +64 -22
  220. package/tests/step-definitions/modal.steps.js +79 -13
  221. package/tests/step-definitions/navigation.steps.js +14 -0
  222. package/tests/step-definitions/network.steps.js +15 -5
  223. package/tests/step-definitions/response.steps.js +6 -4
  224. package/tests/step-definitions/responsive.steps.js +26 -33
  225. package/tests/step-definitions/screenshot.steps.js +26 -9
  226. package/tests/step-definitions/scroll.steps.js +20 -0
  227. package/tests/step-definitions/selectors.steps.js +104 -51
  228. package/tests/step-definitions/storage.steps.js +41 -16
  229. package/tests/step-definitions/table.steps.js +81 -6
  230. package/tests/step-definitions/video.steps.js +52 -55
  231. package/tests/step-definitions/wait.steps.js +209 -54
  232. package/tests/step-definitions/web-first.steps.js +69 -35
  233. package/tests/step-definitions/webship.js +807 -128
  234. package/tests/step-definitions/xml.steps.js +124 -28
  235. package/tests/step-definitions/yaml.steps.js +90 -46
  236. package/.scratch/commit.txt +0 -14
  237. package/.scratch/docs.py +0 -42
  238. package/.scratch/echo-server.js +0 -8
  239. package/.scratch/echo.js +0 -35
  240. package/.scratch/echo.pid +0 -1
  241. package/.scratch/features/cookies.feature +0 -22
  242. package/.scratch/http.pid +0 -1
  243. package/.scratch/https.pid +0 -1
  244. package/.scratch/issue.md +0 -49
  245. package/.scratch/one.js +0 -2
  246. package/.scratch/one.json +0 -280
  247. package/.scratch/patch.py +0 -163
  248. package/.scratch/pr.md +0 -30
@@ -0,0 +1,51 @@
1
+ @must-fail
2
+ Feature: Waits that must fail, and what they say
3
+ Every scenario waits for something that never happens on the example pages.
4
+ tests/check-must-fail.js runs them and checks that each one fails at its
5
+ last step with the message its description announces, the address of the
6
+ page and a hint.
7
+
8
+ Scenario: A text that never arrives
9
+ Fails with: The text "Never arrives" did not appear within 10 seconds.
10
+ Given I am on "/about-us.html"
11
+ When I wait for the text "Never arrives" to appear
12
+
13
+ Scenario: A text that never leaves
14
+ Fails with: The text "Paragraph example" is still on the page after 10 seconds.
15
+ Given I am on "/about-us.html"
16
+ When I wait for the text "Paragraph example" to disappear
17
+
18
+ Scenario: An element that never appears
19
+ Fails with: The element "#no-such-element-here" did not appear within 10 seconds.
20
+ Given I am on "/about-us.html"
21
+ When I wait for "#no-such-element-here" to appear
22
+
23
+ Scenario: An element that never disappears
24
+ Fails with: The element "#paragraphid" is still visible after 10 seconds.
25
+ Given I am on "/about-us.html"
26
+ When I wait for "#paragraphid" to disappear
27
+
28
+ Scenario: A URL that never comes
29
+ Fails with: The URL does not contain "/dashboard" after 10 seconds.
30
+ Given I am on "/about-us.html"
31
+ When I wait until the URL contains "/dashboard"
32
+
33
+ Scenario: A page title that never comes
34
+ Fails with: The page title is not "Dashboard" after 10 seconds.
35
+ Given I am on "/about-us.html"
36
+ When I wait until the page title is "Dashboard"
37
+
38
+ Scenario: A number of elements that is never reached
39
+ Fails with: Expected 7 element(s) matching "#users tbody tr" within 10 seconds.
40
+ Given I am on "/table.html"
41
+ When I wait until 7 elements match "#users tbody tr"
42
+
43
+ Scenario: A minimum number of elements that is never reached
44
+ Fails with: Expected at least 7 element(s) matching "#users tbody tr" within 10 seconds.
45
+ Given I am on "/table.html"
46
+ When I wait until at least 7 elements match "#users tbody tr"
47
+
48
+ Scenario: A text that does not show up in time
49
+ Fails with: The text "Never arrives" did not appear within 2 seconds.
50
+ Given I am on "/about-us.html"
51
+ Then eventually I should see "Never arrives" within 2 seconds
@@ -0,0 +1,48 @@
1
+ @must-fail
2
+ Feature: YAML numbers that must fail, and what they say
3
+ tests/check-must-fail.js runs these scenarios and checks that each one fails
4
+ at its last step with the message its description announces, the address of
5
+ the page and a hint.
6
+
7
+ Scenario: A quoted number is a string, not a number
8
+ Fails with: The YAML value at "/spec/replicas" is the string "3", not a number.
9
+ Given the YAML response content is the following:
10
+ """
11
+ spec:
12
+ replicas: "3"
13
+ """
14
+ Then the YAML value at "/spec/replicas" should be between 1 and 5
15
+
16
+ Scenario: A null is not zero
17
+ Fails with: The YAML value at "/timeout" is null, not a number.
18
+ Given the YAML response content is the following:
19
+ """
20
+ timeout: ~
21
+ """
22
+ Then the YAML value at "/timeout" should be greater than or equal to 0
23
+
24
+ Scenario: A boolean is not one
25
+ Fails with: The YAML value at "/retries" is the boolean true, not a number.
26
+ Given the YAML response content is the following:
27
+ """
28
+ retries: true
29
+ """
30
+ Then the YAML value at "/retries" should be less than or equal to 3
31
+
32
+ Scenario: A number that is not greater
33
+ Fails with: The YAML value at "/spec/replicas" is 3, not greater than 5.
34
+ Given the YAML response content is the following:
35
+ """
36
+ spec:
37
+ replicas: 3
38
+ """
39
+ Then the YAML value at "/spec/replicas" should be greater than 5
40
+
41
+ Scenario: A number out of the range
42
+ Fails with: The YAML value at "/spec/replicas" is 7, not between 1 and 5.
43
+ Given the YAML response content is the following:
44
+ """
45
+ spec:
46
+ replicas: 7
47
+ """
48
+ Then the YAML value at "/spec/replicas" should be between 1 and 5
@@ -20,9 +20,9 @@ Override paths with env vars:
20
20
  | `WEBSHIP_REPORT_DISABLE` | _unset_ | `1` to skip HTML generation |
21
21
  | `WEBSHIP_REPORT_THEME` | `bootstrap` | `bootstrap` / `hierarchy` / `foundation` / `simple` |
22
22
  | `WEBSHIP_REPORT_TITLE` | `Test Report` | Brand title in the HTML header |
23
- | `WEBSHIP_REPORT_APP_VERSION` | `2.0.0` | Metadata field |
23
+ | `WEBSHIP_REPORT_APP_VERSION` | the `version` of the project's `package.json` | Metadata field |
24
24
  | `WEBSHIP_REPORT_ENV` | `development` | Test-environment metadata |
25
- | `WEBSHIP_REPORT_EXECUTED` | `Remote` | Execution location metadata |
25
+ | `WEBSHIP_REPORT_EXECUTED` | `Remote` when `CI` is set, else `Local` | Execution location metadata |
26
26
 
27
27
  ## Regenerate manually
28
28
 
@@ -273,7 +273,7 @@ Then(/^every image should have an alt attribute$/, async function () {
273
273
  * Example #1: Then every form field should have an accessible label
274
274
  * Example #2: Given I am on "/register"
275
275
  * Then every form field should have an accessible label
276
- * Example #3: When I open the settings modal
276
+ * Example #3: When I press "Open settings"
277
277
  * Then every form field should have an accessible label
278
278
  * Example #4: And every form field should have an accessible label
279
279
  * Example #5: Then the page should have a main landmark
@@ -362,9 +362,10 @@ Then(/^the page should have exactly one h1$/, async function () {
362
362
  * Useful for tab-order and skip-link tests.
363
363
  *
364
364
  * Example #1: Then the focused element should match "#email"
365
- * Example #2: When I press the "Tab" key
365
+ * Example #2: When I press the key "Tab"
366
366
  * Then the focused element should match "#email"
367
- * Example #3: When I press the "Tab" key 2 times
367
+ * Example #3: When I press the key "Tab"
368
+ * And I press the key "Tab"
368
369
  * Then the focused element should match "#password"
369
370
  * Example #4: When I focus on the element "#search"
370
371
  * Then the focused element should match "input[type=search]"
@@ -387,11 +388,14 @@ Then(/^the focused element should match "([^"]*)"$/, async function (selector) {
387
388
  * <label> → value/placeholder/title/textContent.
388
389
  *
389
390
  * Example #1: Then the focused element should be labeled "Email"
390
- * Example #2: When I press the "Tab" key
391
+ * Example #2: When I press the key "Tab"
391
392
  * Then the focused element should be labeled "Email"
392
- * Example #3: When I press the "Tab" key 2 times
393
+ * Example #3: When I press the key "Tab"
394
+ * And I press the key "Tab"
393
395
  * Then the focused element should be labeled "Password"
394
- * Example #4: When I press the "Tab" key 3 times
396
+ * Example #4: When I press the key "Tab"
397
+ * And I press the key "Tab"
398
+ * And I press the key "Tab"
395
399
  * Then the focused element should be labeled "Sign in"
396
400
  * Example #5: When I focus on the element "#agree"
397
401
  * Then the focused element should be labeled "I agree"
@@ -451,9 +455,9 @@ Then(/^the page should declare a language$/, async function () {
451
455
  * Example #1: Then the page language should be "en"
452
456
  * Example #2: Given I am on the homepage
453
457
  * Then the page language should be "en"
454
- * Example #3: When I switch to the French version
458
+ * Example #3: When I follow "Français"
455
459
  * Then the page language should be "fr"
456
- * Example #4: When I switch to the Arabic version
460
+ * Example #4: When I follow "العربية"
457
461
  * Then the page language should be "ar"
458
462
  * Example #5: And the page language should be "en-US"
459
463
  *
@@ -877,7 +881,8 @@ Then(/^the page should not violate the accessibility rule "([^"]*)"$/, async fun
877
881
  });
878
882
 
879
883
  /**
880
- * Print every axe violation to stdout (debug aid). Strip from CI runs.
884
+ * Print every axe violation to stdout (debug aid), and attach the same text
885
+ * to the step, so the JSON report and the HTML report show it too.
881
886
  *
882
887
  * Example #1: Then I print accessibility violations
883
888
  * Example #2: When I am on "/checkout"
@@ -891,20 +896,24 @@ Then(/^the page should not violate the accessibility rule "([^"]*)"$/, async fun
891
896
  */
892
897
  Then(/^(I |we )*print accessibility violations$/, async function (pronounCase) {
893
898
  const result = await runAxe(this);
899
+ const lines = [];
894
900
  if (result.violations.length === 0) {
895
- console.log('\n--- Accessibility violations: none ---');
896
- return;
897
- }
898
- console.log('\n--- Accessibility violations ---');
899
- for (const v of result.violations) {
900
- console.log(`[${v.impact}] ${v.id} — ${v.help}`);
901
- console.log(` ${v.helpUrl}`);
902
- for (const n of v.nodes.slice(0, 3)) {
903
- console.log(` ${n.target.join(' ')}`);
904
- if (n.failureSummary) console.log(` ${n.failureSummary.split('\n')[0]}`);
901
+ lines.push('--- Accessibility violations: none ---');
902
+ } else {
903
+ lines.push('--- Accessibility violations ---');
904
+ for (const v of result.violations) {
905
+ lines.push(`[${v.impact}] ${v.id} — ${v.help}`);
906
+ lines.push(` ${v.helpUrl}`);
907
+ for (const n of v.nodes.slice(0, 3)) {
908
+ lines.push(` ${n.target.join(' ')}`);
909
+ if (n.failureSummary) lines.push(` ${n.failureSummary.split('\n')[0]}`);
910
+ }
911
+ if (v.nodes.length > 3) lines.push(` ... and ${v.nodes.length - 3} more node(s)`);
905
912
  }
906
- if (v.nodes.length > 3) console.log(` ... and ${v.nodes.length - 3} more node(s)`);
907
913
  }
914
+ const text = lines.join('\n');
915
+ console.log('\n' + text);
916
+ await this.attach(text, 'text/plain');
908
917
  });
909
918
 
910
919
  /**
@@ -1005,7 +1014,9 @@ Then(/^the page should pass the full accessibility check(?: at level "(A|AA|AAA)
1005
1014
 
1006
1015
  /**
1007
1016
  * The same whole-page check, reported rather than asserted. Use it to see
1008
- * where a page stands before deciding what to gate on.
1017
+ * where a page stands before deciding what to gate on. The report goes to
1018
+ * stdout and is attached to the step, so the JSON report and the HTML report
1019
+ * show it too.
1009
1020
  *
1010
1021
  * Example #1: Then I print the full accessibility check
1011
1022
  * Example #2: When I go to "/about-us"
@@ -1021,6 +1032,8 @@ Then(/^(?:I |we )*print the full accessibility check$/, async function () {
1021
1032
  const result = await runAxe(this, { tags: WCAG_TAGS.AA });
1022
1033
  const found = await structuralAudit(this.page);
1023
1034
  const lines = fullCheckReport(result.violations, found);
1024
- console.log(`\n--- Full accessibility check: ${this.page.url()} ---`);
1025
- console.log(lines.length ? lines.join('\n\n') : ' nothing to report');
1035
+ const text = `--- Full accessibility check: ${this.page.url()} ---\n` +
1036
+ (lines.length ? lines.join('\n\n') : ' nothing to report');
1037
+ console.log('\n' + text);
1038
+ await this.attach(text, 'text/plain');
1026
1039
  });
@@ -4,13 +4,12 @@
4
4
  // press, click (text / attr / row / link follow), and file attach.
5
5
 
6
6
  const { When } = require('@cucumber/cucumber');
7
- const path = require('path');
8
- const { buildSelector, friendly } = require('./webship');
7
+ const { buildSelector, friendly, resolveAssetFile, registeredNameHint } = require('./webship');
9
8
 
10
9
  // Wrap a Playwright action with a friendlier error pointing at the
11
10
  // failing locator + Gherkin step. Pass `label` describing the step
12
11
  // ("press button", "click link", ...) and the user-supplied target.
13
- async function actOrExplain(label, target, fn) {
12
+ async function actOrExplain(label, target, fn, registryHint) {
14
13
  try {
15
14
  await fn();
16
15
  } catch (e) {
@@ -19,6 +18,7 @@ async function actOrExplain(label, target, fn) {
19
18
  `Failed to ${label} "${target}".\n` +
20
19
  ` ${msg}\n` +
21
20
  ` Hints:\n` +
21
+ (registryHint ? ` - ${registryHint}\n` : '') +
22
22
  ` - Check the visible text matches exactly (case-sensitive).\n` +
23
23
  ` - Use the "by attr" variant if the element has no readable text.\n` +
24
24
  ` - Use "wait for ... to appear" if the element renders late.`
@@ -26,6 +26,15 @@ async function actOrExplain(label, target, fn) {
26
26
  }
27
27
  }
28
28
 
29
+ // What a press or a click step says when it was given a name of the selector
30
+ // registry: the bare-name click and the element click read a selector.
31
+ function clickRegistryHint(world, name) {
32
+ return registeredNameHint(world, name, {
33
+ bare: 'I click {name}',
34
+ withSelector: (selector) => `I click on the element "${selector}"`,
35
+ });
36
+ }
37
+
29
38
  // ---------------------------------------------------------------------------
30
39
  // Press / click — by visible text
31
40
  // ---------------------------------------------------------------------------
@@ -48,7 +57,7 @@ When(/^(I |we )*press( the)* "([^"]*)?"( button)*$/, async function (pronounCase
48
57
  .filter({ hasText: new RegExp('^' + esc + '$') })
49
58
  .first()
50
59
  .click();
51
- });
60
+ }, clickRegistryHint(this, element));
52
61
  });
53
62
 
54
63
  /**
@@ -72,6 +81,7 @@ When(/^(I |we )*press "([^"]*)?" by( its)*(?: "([^"]*)?")* (attribute|attr)$/, a
72
81
  * Example #2: And I click "aboutUs"
73
82
  * Example #3: When we click "Read more"
74
83
  * Example #4: And click "Home"
84
+ * Example #5: When we click "Sign up"
75
85
  *
76
86
  */
77
87
  When(/^(I |we )*click "([^"]*)?"$/, async function (pronounCase, item) {
@@ -82,7 +92,7 @@ When(/^(I |we )*click "([^"]*)?"$/, async function (pronounCase, item) {
82
92
  .filter({ hasText: new RegExp('^' + esc + '$') })
83
93
  .first()
84
94
  .click();
85
- });
95
+ }, clickRegistryHint(this, item));
86
96
  });
87
97
 
88
98
  /**
@@ -92,6 +102,7 @@ When(/^(I |we )*click "([^"]*)?"$/, async function (pronounCase, item) {
92
102
  * Example #2: When I click "data-selector-about" by attribute
93
103
  * Example #3: And I click "about-us-css" by "class" attr
94
104
  * Example #4: And I click "about-us-id" by its "id" attribute
105
+ * Example #5: When we click "submit-button" by its "data-testid" attribute
95
106
  *
96
107
  */
97
108
  When(/^(I |we )*click "([^"]*)?" by( its)*(?: "([^"]*)?")* (attribute|attr)$/, async function (pronounCase, attrValue, itsCase, attr, attrWord) {
@@ -105,6 +116,7 @@ When(/^(I |we )*click "([^"]*)?" by( its)*(?: "([^"]*)?")* (attribute|attr)$/, a
105
116
  * Example #2: When I click "Delete" in the "Product A" row
106
117
  * Example #3: When we click "View Details" in the "Order #12345" row
107
118
  * Example #4: And I click "Download" in the "Report 2024" row
119
+ * Example #5: When we click "Archive" in the "Invoice 1042" row
108
120
  *
109
121
  */
110
122
  When(/^(I |we )*click "([^"]*)?" in( the)* "([^"]*)?" row$/, async function (pronounCase, clickText, theCase, rowIdentifier) {
@@ -149,8 +161,10 @@ When(/^(I |we )*follow "([^"]*)"$/, async function (pronounCase, link) {
149
161
  /**
150
162
  * Attach a file from tests/assets/ to a file input.
151
163
  *
152
- * The file path is resolved against `this.assetsFolder` (default
153
- * `tests/assets/`). The target selector must address an `<input type="file">`.
164
+ * A file name is looked for in the project's `tests/assets/`
165
+ * (`this.assetsFolder`), then as written from the project root; a file that
166
+ * is in neither fails with the paths tried. The target selector must address
167
+ * an `<input type="file">`.
154
168
  *
155
169
  * Example #1: When I attach the file "profile-icon.jpg" to "#profile-icon-upload"
156
170
  * Example #2: When we attach file "resume.pdf" to "#resume"
@@ -163,5 +177,5 @@ When(/^(I |we )*follow "([^"]*)"$/, async function (pronounCase, link) {
163
177
  *
164
178
  */
165
179
  When(/^(I |we )*attach( the)* file "([^"]*)?" to "([^"]*)?"$/, async function (pronounCase, theCase, fileName, element) {
166
- await this.page.locator(element).setInputFiles(path.resolve(this.assetsFolder, fileName));
180
+ await this.page.locator(element).setInputFiles(resolveAssetFile(this, fileName));
167
181
  });