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.
- package/.circleci/config.yml +10 -1
- package/.drone.yml +7 -7
- package/.github/ISSUE_TEMPLATE/issue.md +37 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +24 -0
- package/.github/workflows/github-actions.yml +101 -4
- package/.gitlab-ci.yml +9 -4
- package/.harness/webship-js-pipeline.yml +5 -6
- package/.semaphore/semaphore.yml +6 -9
- package/.teamcity/settings.kts +7 -6
- package/.travis.yml +6 -1
- package/AGENTS.md +1 -1
- package/CLAUDE.md +69 -24
- package/Jenkinsfile +5 -3
- package/README.md +13 -1
- package/azure-pipelines.yml +17 -8
- package/bamboo-specs/bamboo.yml +9 -15
- package/bin/generate-reports.js +51 -7
- package/bin/init-webship.js +127 -23
- package/bitbucket-pipelines.yml +5 -1
- package/buildspec.yml +6 -7
- package/cloudbuild.yaml +28 -12
- package/codefresh.yml +6 -6
- package/cucumber.js +46 -11
- package/docs/00-quick-start.md +38 -7
- package/docs/02-bbr-smart-waits.md +21 -10
- package/docs/03-selector-registry.md +24 -0
- package/docs/04-step-reference.md +53 -27
- package/docs/05-web-first-assertions.md +6 -0
- package/docs/07-auth-state.md +1 -1
- package/docs/08-clock-mocking.md +21 -2
- package/docs/09-api-testing.md +40 -2
- package/docs/10-accessibility.md +2 -0
- package/docs/11-debugging.md +24 -1
- package/docs/12-ai-agent-guide.md +8 -1
- package/docs/13-faq.md +75 -1
- package/docs/14-recipes-cookbook.md +2 -0
- package/docs/15-tag-conventions.md +5 -1
- package/docs/16-ci-cd.md +161 -124
- package/docs/README.md +5 -5
- package/docs/advanced-screenshots.md +3 -1
- package/docs/api-step-definitions.md +16 -2
- package/docs/global-settings.md +70 -18
- package/docs/install-webship-js/ddev-webship-js.md +3 -0
- package/docs/install-webship-js.md +16 -2
- package/docs/step-definitions/then-i-should-see.md +14 -1
- package/docs/step-definitions/then-item-checkbox.md +2 -0
- package/docs/step-definitions/when-i-fill.md +4 -0
- package/docs/step-definitions/when-i-select-option-select-list.md +2 -0
- package/examples/a11y-legacy-widget.html +34 -0
- package/examples/auth-state.html +42 -0
- package/examples/choice-controls.html +29 -0
- package/examples/clock.html +33 -0
- package/examples/datetime-fields.html +52 -0
- package/examples/downloads/webship-archive.zip +0 -0
- package/examples/downloads/webship-notes.txt +4 -0
- package/examples/downloads/webship-report.csv +4 -0
- package/examples/downloads.html +16 -0
- package/examples/element-selector-hint.html +16 -0
- package/examples/element-viewport.html +42 -0
- package/examples/field-states.html +27 -0
- package/examples/field-types.html +98 -0
- package/examples/fill-in-empty.html +26 -0
- package/examples/fill-unreachable.html +27 -0
- package/examples/iframe-inner.html +20 -0
- package/examples/iframe-nested.html +16 -0
- package/examples/iframe-newsletter.html +29 -0
- package/examples/iframe-order.html +26 -0
- package/examples/iframe-outer.html +15 -0
- package/examples/iframe.html +21 -0
- package/examples/javascript-errors.html +35 -0
- package/examples/links.html +1 -0
- package/examples/metatags.html +18 -0
- package/examples/mouse-and-pointer.html +83 -0
- package/examples/multi-value-fields.html +54 -0
- package/examples/native-dialogs.html +8 -0
- package/examples/network.html +83 -0
- package/examples/registered-names.html +15 -0
- package/examples/scroll-horizontal.html +50 -0
- package/examples/select-by-label.html +33 -0
- package/examples/selectors-position.html +29 -0
- package/examples/settle-budget.html +21 -0
- package/examples/sorted-tables.html +38 -0
- package/examples/storage.html +57 -0
- package/examples/text-matching.html +48 -0
- package/examples/text-order.html +25 -0
- package/examples/touch.html +22 -0
- package/examples/viewport-size.html +24 -0
- package/examples/viewport-top.html +36 -0
- package/examples/wait-conditions.html +69 -0
- package/examples/web-first.html +99 -0
- package/package.json +24 -2
- package/playwright.config.ts +3 -1
- package/tests/assets/catalog.xml +19 -0
- package/tests/assets/feed-namespaced.xml +13 -0
- package/tests/assets/sitemap.xml +14 -0
- package/tests/assets/webship-site-expected.yaml +21 -0
- package/tests/assets/webship-site.schema.json +46 -0
- package/tests/assets/webship-site.yaml +21 -0
- package/tests/check-api-launch-url.js +106 -0
- package/tests/check-assets.js +103 -0
- package/tests/check-attachments.js +105 -0
- package/tests/check-breakpoints.js +117 -0
- package/tests/check-clock.js +143 -0
- package/tests/check-config.js +90 -0
- package/tests/check-context.js +215 -0
- package/tests/check-dry-run.js +104 -0
- package/tests/check-examples.js +241 -0
- package/tests/check-exit-report.js +141 -0
- package/tests/check-javascript-errors.js +105 -0
- package/tests/check-must-fail.js +85 -0
- package/tests/check-paths.js +82 -0
- package/tests/check-report.js +119 -0
- package/tests/check-scaffold.js +246 -0
- package/tests/check-screenshots.js +117 -0
- package/tests/check-settle-verbs.js +137 -0
- package/tests/check-time-limit.js +104 -0
- package/tests/check-video.js +156 -0
- package/tests/check-world.js +167 -0
- package/tests/features/a11y.feature +18 -0
- package/tests/features/api-base-url.feature +25 -0
- package/tests/features/api-form-data.feature +18 -0
- package/tests/features/api-json-paths.feature +24 -0
- package/tests/features/api-response-contains.feature +21 -0
- package/tests/features/api-response-header-presence.feature +17 -0
- package/tests/features/api-response-header.feature +17 -0
- package/tests/features/api-saved-placeholders.feature +37 -0
- package/tests/features/api-step-definitions-individual.feature +1 -1
- package/tests/features/api-tables.feature +40 -0
- package/tests/features/auth-state.feature +32 -0
- package/tests/features/breakpoints.feature +25 -0
- package/tests/features/choice-controls.feature +35 -0
- package/tests/features/clock.feature +27 -0
- package/tests/features/complete-api-testing-examples.feature +1 -1
- package/tests/features/cookie.feature +9 -0
- package/tests/features/datetime-field-lookup.feature +29 -0
- package/tests/features/dialog.feature +27 -0
- package/tests/features/element-selector-hint.feature +14 -0
- package/tests/features/element.feature +47 -0
- package/tests/features/field-state.feature +21 -0
- package/tests/features/field.feature +104 -0
- package/tests/features/file-download.feature +64 -0
- package/tests/features/fill-in-empty-value.feature +41 -0
- package/tests/features/fill-reachable.feature +13 -0
- package/tests/features/iframe-nested.feature +43 -0
- package/tests/features/iframe.feature +83 -0
- package/tests/features/javascript-tolerated-errors.feature +20 -0
- package/tests/features/javascript.feature +47 -0
- package/tests/features/link.feature +11 -0
- package/tests/features/metatag.feature +38 -0
- package/tests/features/modal-open.feature +13 -0
- package/tests/features/mouse-and-pointer.feature +86 -0
- package/tests/features/multi-value-field-lookup.feature +30 -0
- package/tests/features/network-mocking.feature +80 -0
- package/tests/features/registered-names.feature +14 -0
- package/tests/features/responsive.feature +27 -0
- package/tests/features/scroll-horizontal.feature +55 -0
- package/tests/features/select-by-label.feature +31 -0
- package/tests/features/selector-files.feature +14 -0
- package/tests/features/selectors-position.feature +41 -0
- package/tests/features/selectors-table-header.feature +35 -0
- package/tests/features/settle-budget.feature +11 -0
- package/tests/features/sorted-tables.feature +19 -0
- package/tests/features/storage-quoted-values.feature +26 -0
- package/tests/features/storage.feature +98 -0
- package/tests/features/test--then--i-see-locator.feature +13 -0
- package/tests/features/test--then--i-should--see-text-in-element.feature +9 -1
- package/tests/features/test--then--the-field-should-contain-value.feature +8 -0
- package/tests/features/text-matching.feature +38 -0
- package/tests/features/text-order.feature +14 -0
- package/tests/features/touch.feature +21 -0
- package/tests/features/video.feature +1 -0
- package/tests/features/viewport-top.feature +13 -0
- package/tests/features/wait.feature +89 -0
- package/tests/features/web-first.feature +100 -0
- package/tests/features/xml-namespaces.feature +34 -0
- package/tests/features/xml.feature +96 -0
- package/tests/features/yaml.feature +75 -0
- package/tests/must-fail/api-json-paths.feature +21 -0
- package/tests/must-fail/api-response-contains.feature +23 -0
- package/tests/must-fail/api-response-header-presence.feature +17 -0
- package/tests/must-fail/api-response-header.feature +21 -0
- package/tests/must-fail/api-without-base-url.feature +11 -0
- package/tests/must-fail/assertions.feature +96 -0
- package/tests/must-fail/breakpoints.feature +15 -0
- package/tests/must-fail/choice-controls.feature +25 -0
- package/tests/must-fail/clock.feature +11 -0
- package/tests/must-fail/datetime-field.feature +10 -0
- package/tests/must-fail/element-selector-hint.feature +17 -0
- package/tests/must-fail/field-state.feature +20 -0
- package/tests/must-fail/fill-field.feature +30 -0
- package/tests/must-fail/iframe-text.feature +17 -0
- package/tests/must-fail/modal-open.feature +26 -0
- package/tests/must-fail/multi-value-field.feature +18 -0
- package/tests/must-fail/registered-names.feature +25 -0
- package/tests/must-fail/select-list.feature +15 -0
- package/tests/must-fail/selector-files.feature +10 -0
- package/tests/must-fail/sorted-tables.feature +20 -0
- package/tests/must-fail/storage-before-a-page.feature +13 -0
- package/tests/must-fail/text-matching.feature +16 -0
- package/tests/must-fail/text-order.feature +15 -0
- package/tests/must-fail/viewport-top.feature +20 -0
- package/tests/must-fail/waits.feature +51 -0
- package/tests/must-fail/yaml-numbers.feature +48 -0
- package/tests/reports/README.md +2 -2
- package/tests/step-definitions/a11y.steps.js +36 -23
- package/tests/step-definitions/action.steps.js +22 -8
- package/tests/step-definitions/api.steps.js +349 -67
- package/tests/step-definitions/assertion.steps.js +327 -63
- package/tests/step-definitions/auth.steps.js +15 -18
- package/tests/step-definitions/clock.steps.js +22 -0
- package/tests/step-definitions/debug.steps.js +8 -0
- package/tests/step-definitions/dialog.steps.js +9 -2
- package/tests/step-definitions/element.steps.js +135 -18
- package/tests/step-definitions/field.steps.js +523 -80
- package/tests/step-definitions/file-download.steps.js +74 -10
- package/tests/step-definitions/form.steps.js +76 -29
- package/tests/step-definitions/iframe.steps.js +89 -29
- package/tests/step-definitions/input.steps.js +26 -7
- package/tests/step-definitions/javascript.steps.js +64 -22
- package/tests/step-definitions/modal.steps.js +79 -13
- package/tests/step-definitions/navigation.steps.js +14 -0
- package/tests/step-definitions/network.steps.js +15 -5
- package/tests/step-definitions/response.steps.js +6 -4
- package/tests/step-definitions/responsive.steps.js +26 -33
- package/tests/step-definitions/screenshot.steps.js +26 -9
- package/tests/step-definitions/scroll.steps.js +20 -0
- package/tests/step-definitions/selectors.steps.js +104 -51
- package/tests/step-definitions/storage.steps.js +41 -16
- package/tests/step-definitions/table.steps.js +81 -6
- package/tests/step-definitions/video.steps.js +52 -55
- package/tests/step-definitions/wait.steps.js +209 -54
- package/tests/step-definitions/web-first.steps.js +69 -35
- package/tests/step-definitions/webship.js +807 -128
- package/tests/step-definitions/xml.steps.js +124 -28
- package/tests/step-definitions/yaml.steps.js +90 -46
- package/.scratch/commit.txt +0 -14
- package/.scratch/docs.py +0 -42
- package/.scratch/echo-server.js +0 -8
- package/.scratch/echo.js +0 -35
- package/.scratch/echo.pid +0 -1
- package/.scratch/features/cookies.feature +0 -22
- package/.scratch/http.pid +0 -1
- package/.scratch/https.pid +0 -1
- package/.scratch/issue.md +0 -49
- package/.scratch/one.js +0 -2
- package/.scratch/one.json +0 -280
- package/.scratch/patch.py +0 -163
- 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
|
package/tests/reports/README.md
CHANGED
|
@@ -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` | `
|
|
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
|
|
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"
|
|
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"
|
|
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"
|
|
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"
|
|
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"
|
|
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
|
|
458
|
+
* Example #3: When I follow "Français"
|
|
455
459
|
* Then the page language should be "fr"
|
|
456
|
-
* Example #4: When I
|
|
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)
|
|
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
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
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
|
-
|
|
1025
|
-
|
|
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
|
|
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
|
-
*
|
|
153
|
-
* `
|
|
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(
|
|
180
|
+
await this.page.locator(element).setInputFiles(resolveAssetFile(this, fileName));
|
|
167
181
|
});
|