webship-js 2.0.6 → 2.0.8
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/.drone.yml +0 -0
- package/.harness/webship-js-pipeline.yml +0 -0
- package/.semaphore/semaphore.yml +0 -0
- package/.teamcity/pom.xml +0 -0
- package/.teamcity/settings.kts +0 -0
- package/.travis.yml +0 -0
- package/CLAUDE.md +1 -1
- package/Jenkinsfile +0 -0
- package/azure-pipelines.yml +0 -0
- package/bamboo-specs/bamboo.yml +0 -0
- package/bin/generate-reports.js +0 -0
- package/bin/init-webship.js +8 -9
- package/bin/postinstall.js +0 -0
- package/buildspec.yml +0 -0
- package/cloudbuild.yaml +0 -0
- package/codefresh.yml +0 -0
- package/docs/00-quick-start.md +0 -0
- package/docs/01-getting-started.md +0 -0
- package/docs/03-selector-registry.md +0 -0
- package/docs/05-web-first-assertions.md +2 -0
- package/docs/06-network-and-dialogs.md +0 -0
- package/docs/07-auth-state.md +0 -0
- package/docs/08-clock-mocking.md +0 -0
- package/docs/09-api-testing.md +0 -0
- package/docs/11-debugging.md +0 -0
- package/docs/12-ai-agent-guide.md +0 -0
- package/docs/13-faq.md +0 -0
- package/docs/14-recipes-cookbook.md +0 -0
- package/docs/15-tag-conventions.md +0 -0
- package/docs/16-ci-cd.md +0 -0
- package/docs/advanced-screenshots/then-i-save-fullscreen-screenshot.md +0 -0
- package/docs/advanced-screenshots/then-i-save-width-x-height-screenshot.md +0 -0
- package/docs/advanced-screenshots/when-i-save-screenshot-name-filename.md +0 -0
- package/docs/advanced-screenshots.md +0 -0
- package/docs/advanced-selectors.md +0 -0
- package/docs/api-step-definitions.md +0 -0
- package/docs/global-settings.md +5 -3
- package/docs/install-webship-js/ddev-webship-js.md +0 -0
- package/docs/step-definitions/given-i-am-anonymous-user.md +0 -0
- package/docs/step-definitions/given-i-am-homepage.md +0 -0
- package/docs/step-definitions/given-i-am-specific-page.md +4 -0
- package/docs/step-definitions/then-i-should-be.md +0 -0
- package/docs/step-definitions/then-i-should-see.md +6 -0
- package/docs/step-definitions/then-item-checkbox.md +0 -0
- package/docs/step-definitions/then-item-link-should-contain-url.md +0 -0
- package/docs/step-definitions/then-item-should-contain.md +0 -0
- package/docs/step-definitions/then-radio-button-value-should-be-selected.md +0 -0
- package/docs/step-definitions/then-response-status-code-should-be-number.md +0 -0
- package/docs/step-definitions/then-value-radio-button-selected.md +0 -0
- package/docs/step-definitions/when-i-attach-file-file-name-element.md +0 -0
- package/docs/step-definitions/when-i-check-checkbox.md +0 -0
- package/docs/step-definitions/when-i-click-link.md +0 -0
- package/docs/step-definitions/when-i-click-operation-text-row.md +0 -0
- package/docs/step-definitions/when-i-fill.md +0 -0
- package/docs/step-definitions/when-i-go-homepage.md +0 -0
- package/docs/step-definitions/when-i-go-specific-page.md +4 -0
- package/docs/step-definitions/when-i-move-backward-one-page.md +0 -0
- package/docs/step-definitions/when-i-move-forward-one-page.md +0 -0
- package/docs/step-definitions/when-i-press-button.md +0 -0
- package/docs/step-definitions/when-i-reload-page.md +0 -0
- package/docs/step-definitions/when-i-scroll.md +0 -0
- package/docs/step-definitions/when-i-select-option-select-list.md +0 -0
- package/docs/step-definitions/when-i-select-radio-button-value.md +0 -0
- package/docs/step-definitions/when-i-uncheck-checkbox.md +0 -0
- package/docs/step-definitions/when-i-wait-ajax-finish.md +0 -0
- package/docs/step-definitions/when-i-wait.md +0 -0
- package/docs/step-definitions.md +0 -0
- package/examples/account.html +0 -0
- package/examples/ajax-wait-examples.html +0 -0
- package/examples/cookies.html +0 -0
- package/examples/date.html +0 -0
- package/examples/dynamic-examples.html +0 -0
- package/examples/element-visibility.html +17 -0
- package/examples/element.html +0 -0
- package/examples/field.html +0 -0
- package/examples/keyboard.html +0 -0
- package/examples/links.html +0 -0
- package/examples/modal.html +0 -0
- package/examples/native-dialogs.html +22 -0
- package/examples/path.html +0 -0
- package/examples/table.html +0 -0
- package/examples/test--modal-dialogs.html +0 -0
- package/examples/test--when--i-additionally-select.html +0 -0
- package/examples/test--when--i-select-radio-button.html +0 -0
- package/examples/video-demo.html +0 -0
- package/examples/web-first-text.html +18 -0
- package/package.json +2 -2
- package/playwright.config.ts +0 -0
- package/tests/assets/test-document.pdf +0 -0
- package/tests/features/absolute-url.feature +51 -0
- package/tests/features/ajax-wait-examples.feature +0 -0
- package/tests/features/cookie.feature +0 -0
- package/tests/features/date.feature +0 -0
- package/tests/features/dynamic-content-examples.feature +0 -0
- package/tests/features/element.feature +0 -0
- package/tests/features/field.feature +0 -0
- package/tests/features/keyboard.feature +0 -0
- package/tests/features/link.feature +0 -0
- package/tests/features/modal-advanced-example.feature +0 -0
- package/tests/features/modal-basic-example.feature +0 -0
- package/tests/features/modal-error-handling-example.feature +0 -0
- package/tests/features/modal.feature +0 -0
- package/tests/features/path.feature +0 -0
- package/tests/features/pronoun-prefix-steps.feature +81 -0
- package/tests/features/response.feature +0 -0
- package/tests/features/responsive.feature +0 -0
- package/tests/features/table.feature +0 -0
- package/tests/features/test--given--i-am-an-anonymous-user.feature +0 -0
- package/tests/features/test--then--i-save-screenshot.feature +0 -0
- package/tests/features/test--then--i-see-locator.feature +0 -0
- package/tests/features/test--then--i-should-not-see-an-element.feature +11 -1
- package/tests/features/test--then--i-should-see-n-elements.feature +0 -0
- package/tests/features/test--then--print-current-url-and-response.feature +0 -0
- package/tests/features/test--when--i-additionally-select.feature +0 -0
- package/tests/features/test--when--i-follow.feature +0 -0
- package/tests/features/test--when--i-select-radio-button.feature +0 -0
- package/tests/features/video.feature +0 -0
- package/tests/features/wait.feature +0 -0
- package/tests/features/web-first-text.feature +21 -0
- package/tests/features/yaml.feature +0 -0
- package/tests/reports/README.md +0 -0
- package/tests/selectors/_canonical-keys.json +0 -0
- package/tests/selectors/back-end-selectors.json +0 -0
- package/tests/selectors/cms-contentful-admin.json +0 -0
- package/tests/selectors/cms-craft-admin.json +0 -0
- package/tests/selectors/cms-drupal-cms-gin.json +0 -0
- package/tests/selectors/cms-drupal-core-claro.json +0 -0
- package/tests/selectors/cms-generic-admin.json +0 -0
- package/tests/selectors/cms-ghost-admin.json +0 -0
- package/tests/selectors/cms-joomla-admin.json +0 -0
- package/tests/selectors/cms-magento2-admin.json +0 -0
- package/tests/selectors/cms-prestashop-admin.json +0 -0
- package/tests/selectors/cms-shopify-admin.json +0 -0
- package/tests/selectors/cms-strapi-admin.json +0 -0
- package/tests/selectors/cms-typo3-admin.json +0 -0
- package/tests/selectors/cms-woocommerce-front.json +0 -0
- package/tests/selectors/cms-wordpress-admin.json +0 -0
- package/tests/selectors/framework-ant-design.json +0 -0
- package/tests/selectors/framework-bootstrap.json +0 -0
- package/tests/selectors/framework-bulma.json +0 -0
- package/tests/selectors/framework-chakra.json +0 -0
- package/tests/selectors/framework-foundation.json +0 -0
- package/tests/selectors/framework-material-ui.json +0 -0
- package/tests/selectors/framework-shadcn.json +0 -0
- package/tests/selectors/framework-tailwind.json +0 -0
- package/tests/selectors/framework-vuetify.json +0 -0
- package/tests/selectors/front-end-selectors.json +0 -0
- package/tests/selectors/homepage-selectors.json +0 -0
- package/tests/step-definitions/a11y.steps.js +1 -1
- package/tests/step-definitions/action.steps.js +0 -0
- package/tests/step-definitions/api.steps.js +0 -0
- package/tests/step-definitions/assertion.steps.js +18 -3
- package/tests/step-definitions/auth.steps.js +1 -1
- package/tests/step-definitions/clock.steps.js +2 -2
- package/tests/step-definitions/cookie.steps.js +0 -0
- package/tests/step-definitions/debug.steps.js +0 -0
- package/tests/step-definitions/dialog.steps.js +4 -4
- package/tests/step-definitions/element.steps.js +0 -0
- package/tests/step-definitions/field.steps.js +0 -0
- package/tests/step-definitions/file-download.steps.js +2 -2
- package/tests/step-definitions/form.steps.js +0 -0
- package/tests/step-definitions/iframe.steps.js +1 -1
- package/tests/step-definitions/input.steps.js +0 -0
- package/tests/step-definitions/javascript.steps.js +0 -0
- package/tests/step-definitions/keyboard.steps.js +0 -0
- package/tests/step-definitions/link.steps.js +0 -0
- package/tests/step-definitions/metatag.steps.js +0 -0
- package/tests/step-definitions/modal.steps.js +0 -0
- package/tests/step-definitions/navigation.steps.js +8 -5
- package/tests/step-definitions/network.steps.js +1 -1
- package/tests/step-definitions/path.steps.js +0 -0
- package/tests/step-definitions/response.steps.js +0 -0
- package/tests/step-definitions/responsive.steps.js +0 -0
- package/tests/step-definitions/rest.steps.js +3 -2
- package/tests/step-definitions/screenshot.steps.js +0 -0
- package/tests/step-definitions/scroll.steps.js +0 -0
- package/tests/step-definitions/selectors.steps.js +0 -0
- package/tests/step-definitions/storage.steps.js +0 -0
- package/tests/step-definitions/table.steps.js +0 -0
- package/tests/step-definitions/video.steps.js +0 -0
- package/tests/step-definitions/wait.steps.js +3 -3
- package/tests/step-definitions/web-first.steps.js +14 -3
- package/tests/step-definitions/webship.js +16 -0
- package/tests/step-definitions/xml.steps.js +1 -1
- package/tests/step-definitions/yaml.steps.js +1 -1
- package/tsconfig.json +0 -0
- package/videos/README.md +0 -0
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Feature: Web-first text assertions read the text a visitor reads
|
|
2
|
+
As a tester,
|
|
3
|
+
I want "<selector>" should contain text "<text>" to ignore the whitespace the markup carries,
|
|
4
|
+
because a line the markup wraps reads as one line on the page.
|
|
5
|
+
|
|
6
|
+
Scenario: Text that the markup wraps onto a second line
|
|
7
|
+
Given I am on "/web-first-text.html"
|
|
8
|
+
Then ".site-footer" should contain text "Powered by Example"
|
|
9
|
+
And ".site-footer" should contain text "Powered by"
|
|
10
|
+
|
|
11
|
+
Scenario: Non-breaking spaces count as spaces
|
|
12
|
+
Given I am on "/web-first-text.html"
|
|
13
|
+
Then ".price" should contain text "Price: $99"
|
|
14
|
+
|
|
15
|
+
Scenario: The expected text is collapsed too
|
|
16
|
+
Given I am on "/web-first-text.html"
|
|
17
|
+
Then ".site-footer" should contain text "Powered by Example"
|
|
18
|
+
|
|
19
|
+
Scenario: Should have text stays the exact match
|
|
20
|
+
Given I am on "/web-first-text.html"
|
|
21
|
+
Then ".tagline" should have text "Built with care"
|
|
File without changes
|
package/tests/reports/README.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -889,7 +889,7 @@ Then(/^the page should not violate the accessibility rule "([^"]*)"$/, async fun
|
|
|
889
889
|
* Then I print accessibility violations
|
|
890
890
|
*
|
|
891
891
|
*/
|
|
892
|
-
Then(/^(I |we )*print accessibility violations$/, async function () {
|
|
892
|
+
Then(/^(I |we )*print accessibility violations$/, async function (pronounCase) {
|
|
893
893
|
const result = await runAxe(this);
|
|
894
894
|
if (result.violations.length === 0) {
|
|
895
895
|
console.log('\n--- Accessibility violations: none ---');
|
|
File without changes
|
|
File without changes
|
|
@@ -86,17 +86,32 @@ Then(/^(I |we )*should( not)* see "([^"]*)?" in( the)* "([^"]*)?" row$/, async f
|
|
|
86
86
|
// ---------------------------------------------------------------------------
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* Assert that an element
|
|
89
|
+
* Assert that an element is, or is not, visible on the page. The element is
|
|
90
|
+
* named by its exact visible text; a `<label for="...">` stands for the
|
|
91
|
+
* control it labels. The text is not a CSS selector: for a selector use
|
|
92
|
+
* `"<selector>" should be visible` or `"<selector>" should not be visible`.
|
|
93
|
+
*
|
|
94
|
+
* "should not see" is the opposite of "should see": it passes when no element
|
|
95
|
+
* named that way is visible, so an element that is hidden does not fail it.
|
|
90
96
|
*
|
|
91
97
|
* Example #1: Then I should see a "Username" element
|
|
92
98
|
* Example #2: Then I should not see a "Username" element
|
|
93
99
|
* Example #3: And we should see an "Email" element
|
|
100
|
+
* Example #4: Then I should not see an "Email" element
|
|
101
|
+
* Example #5: And we should not see a "Promo banner" element
|
|
94
102
|
*
|
|
95
103
|
*/
|
|
96
104
|
Then(/^(I |we )*should( not)* see (a|an) "([^"]*)?" element$/, async function (pronounCase, notCase, aAnCase, element) {
|
|
97
105
|
if (notCase) {
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
// Same lookup as the positive branch, over every match, without waiting.
|
|
107
|
+
const named = this.page.getByText(element, { exact: true });
|
|
108
|
+
const forIds = await named.evaluateAll((nodes) => nodes.map((node) => node.getAttribute('for')));
|
|
109
|
+
for (let i = 0; i < forIds.length; i++) {
|
|
110
|
+
const target = forIds[i]
|
|
111
|
+
? this.page.locator(`[id="${forIds[i].replace(/["\\]/g, '\\$&')}"]`).first()
|
|
112
|
+
: named.nth(i);
|
|
113
|
+
assert.ok(!(await target.isVisible()), `Element "${element}" should NOT be visible but it is.`);
|
|
114
|
+
}
|
|
100
115
|
} else {
|
|
101
116
|
const loc = this.page.getByText(element, { exact: true }).first();
|
|
102
117
|
const forAttr = await loc.getAttribute('for').catch(() => null);
|
|
@@ -115,7 +115,7 @@ Given(/^(I |we )*restore the auth state from "([^"]*)"$/, async function (pronou
|
|
|
115
115
|
* Then I should see "Login"
|
|
116
116
|
*
|
|
117
117
|
*/
|
|
118
|
-
Given(/^(I |we )*clear the auth state$/, async function () {
|
|
118
|
+
Given(/^(I |we )*clear the auth state$/, async function (pronoun) {
|
|
119
119
|
await this.context.clearCookies();
|
|
120
120
|
try {
|
|
121
121
|
await this.page.evaluate(() => {
|
|
@@ -85,7 +85,7 @@ When(/^(I |we )*advance the clock by (\d+) minutes?$/, async function (pronoun,
|
|
|
85
85
|
* Example #5: When I pause the clock
|
|
86
86
|
*
|
|
87
87
|
*/
|
|
88
|
-
When(/^(I |we )*pause the clock$/, async function () {
|
|
88
|
+
When(/^(I |we )*pause the clock$/, async function (pronoun) {
|
|
89
89
|
try { await this.page.clock.pauseAt(await this.page.evaluate(() => Date.now())); }
|
|
90
90
|
catch (e) { throw friendly({ action: 'pause the clock', cause: e, hint: ISO_HINT }); }
|
|
91
91
|
});
|
|
@@ -100,7 +100,7 @@ When(/^(I |we )*pause the clock$/, async function () {
|
|
|
100
100
|
* Example #5: When I resume the clock
|
|
101
101
|
*
|
|
102
102
|
*/
|
|
103
|
-
When(/^(I |we )*resume the clock$/, async function () {
|
|
103
|
+
When(/^(I |we )*resume the clock$/, async function (pronoun) {
|
|
104
104
|
try { await this.page.clock.resume(); }
|
|
105
105
|
catch (e) { throw friendly({ action: 'resume the clock', cause: e, hint: 'pause the clock first via "When I pause the clock".' }); }
|
|
106
106
|
});
|
|
File without changes
|
|
File without changes
|
|
@@ -59,7 +59,7 @@ function attach(world, action, promptInput, once) {
|
|
|
59
59
|
* Then the last dialog type should be "confirm"
|
|
60
60
|
*
|
|
61
61
|
*/
|
|
62
|
-
Given(/^(I |we )*will accept the next dialog$/, function () {
|
|
62
|
+
Given(/^(I |we )*will accept the next dialog$/, function (pronoun) {
|
|
63
63
|
attach(this, 'accept', undefined, true);
|
|
64
64
|
});
|
|
65
65
|
|
|
@@ -80,7 +80,7 @@ Given(/^(I |we )*will accept the next dialog$/, function () {
|
|
|
80
80
|
* When I close the tab
|
|
81
81
|
*
|
|
82
82
|
*/
|
|
83
|
-
Given(/^(I |we )*will dismiss the next dialog$/, function () {
|
|
83
|
+
Given(/^(I |we )*will dismiss the next dialog$/, function (pronoun) {
|
|
84
84
|
attach(this, 'dismiss', undefined, true);
|
|
85
85
|
});
|
|
86
86
|
|
|
@@ -171,7 +171,7 @@ Then(/^the last dialog type should be "([^"]*)"$/, function (type) {
|
|
|
171
171
|
* When I follow "Discard changes"
|
|
172
172
|
*
|
|
173
173
|
*/
|
|
174
|
-
Given(/^(I |we )*accept all confirmation dialogs$/, function () {
|
|
174
|
+
Given(/^(I |we )*accept all confirmation dialogs$/, function (pronoun) {
|
|
175
175
|
attach(this, 'accept', undefined, false);
|
|
176
176
|
});
|
|
177
177
|
|
|
@@ -188,6 +188,6 @@ Given(/^(I |we )*accept all confirmation dialogs$/, function () {
|
|
|
188
188
|
* When I follow "Leave page"
|
|
189
189
|
*
|
|
190
190
|
*/
|
|
191
|
-
Given(/^(I |we )*do not accept any confirmation dialogs$/, function () {
|
|
191
|
+
Given(/^(I |we )*do not accept any confirmation dialogs$/, function (pronoun) {
|
|
192
192
|
attach(this, 'dismiss', undefined, false);
|
|
193
193
|
});
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { friendly } = require('./webship');
|
|
3
|
+
const { friendly, resolveUrl } = require('./webship');
|
|
4
4
|
|
|
5
5
|
// Validate file downloads triggered via URL or link click.
|
|
6
6
|
|
|
@@ -31,7 +31,7 @@ function tmpDownloadDir() {
|
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
33
|
When(/^(I |we )*download the file from the URL "([^"]*)"$/, async function (pronoun, url) {
|
|
34
|
-
const target =
|
|
34
|
+
const target = resolveUrl(this.launchUrl, url);
|
|
35
35
|
try {
|
|
36
36
|
const resp = await this.page.request.get(target);
|
|
37
37
|
assert.strictEqual(resp.status(), 200, `Download failed with status ${resp.status()}.`);
|
|
File without changes
|
|
@@ -77,7 +77,7 @@ When(/^(I |we )*switch to iframe with locator "([^"]*)"$/, async function (prono
|
|
|
77
77
|
* And I press "Refresh"
|
|
78
78
|
*
|
|
79
79
|
*/
|
|
80
|
-
When(/^(I |we )*switch to the root document$/, async function () {
|
|
80
|
+
When(/^(I |we )*switch to the root document$/, async function (pronoun) {
|
|
81
81
|
this.frame = null;
|
|
82
82
|
});
|
|
83
83
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const { Given, When, Then } = require('@cucumber/cucumber');
|
|
8
8
|
const assert = require('assert');
|
|
9
|
-
const { gotoUrl, waitForPageLoad, smartSettle } = require('./webship');
|
|
9
|
+
const { gotoUrl, resolveUrl, waitForPageLoad, smartSettle } = require('./webship');
|
|
10
10
|
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
// Sessions / visits
|
|
@@ -49,7 +49,8 @@ Given(/^(I am |we are )?on( the)* (homepage|frontpage)$/, async function (pronou
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Open a specific page under the launch URL
|
|
52
|
+
* Open a specific page: a path is opened under the launch URL, an absolute
|
|
53
|
+
* `http://` or `https://` URL is opened as written.
|
|
53
54
|
*
|
|
54
55
|
* Example #1: Given I am on "/about-us.html"
|
|
55
56
|
* Example #2: Given I am on the "/about-us.html" page
|
|
@@ -61,7 +62,7 @@ Given(/^(I am |we are )?on( the)* (homepage|frontpage)$/, async function (pronou
|
|
|
61
62
|
*
|
|
62
63
|
*/
|
|
63
64
|
Given(/^(I am |we are )*on( the)* "([^"]*)?"( page)*$/, async function (pronounCase, theCase, url, pageCase) {
|
|
64
|
-
await gotoUrl(this.page, this.launchUrl
|
|
65
|
+
await gotoUrl(this.page, resolveUrl(this.launchUrl, url));
|
|
65
66
|
await this.page.waitForSelector('body', { state: 'attached', timeout: 10000 });
|
|
66
67
|
await waitForPageLoad(this.page);
|
|
67
68
|
});
|
|
@@ -87,7 +88,8 @@ When(/^(I go |I navigate |we go |we navigate |navigating )?to( the)* (homepage|f
|
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
|
-
* Navigate to a specific page
|
|
91
|
+
* Navigate to a specific page: a path is opened under the launch URL, an
|
|
92
|
+
* absolute `http://` or `https://` URL is opened as written.
|
|
91
93
|
*
|
|
92
94
|
* Example #1: When I go to "/contact-us.html"
|
|
93
95
|
* Example #2: When I go to "/user/login"
|
|
@@ -95,11 +97,12 @@ When(/^(I go |I navigate |we go |we navigate |navigating )?to( the)* (homepage|f
|
|
|
95
97
|
* Example #4: When navigating to "/products"
|
|
96
98
|
* Example #5: When we go to "/products"
|
|
97
99
|
* Example #6: When we navigate to "/terms"
|
|
100
|
+
* Example #7: When I go to "https://un.org"
|
|
98
101
|
*
|
|
99
102
|
*/
|
|
100
103
|
When(/^(I go |I navigate |we go |we navigate |navigating )?to "([^"]*)?"$/, async function (pronounCase, url) {
|
|
101
104
|
const defaultTime = this.minWaitTime.page || 3000;
|
|
102
|
-
await gotoUrl(this.page, this.launchUrl
|
|
105
|
+
await gotoUrl(this.page, resolveUrl(this.launchUrl, url));
|
|
103
106
|
await this.page.waitForSelector('body', { state: 'attached', timeout: defaultTime });
|
|
104
107
|
await waitForPageLoad(this.page, defaultTime);
|
|
105
108
|
});
|
|
@@ -216,7 +216,7 @@ Given(/^the network is online$/, async function () {
|
|
|
216
216
|
* Then a GET request to "**\/api/feed/page=2" should have been made
|
|
217
217
|
*
|
|
218
218
|
*/
|
|
219
|
-
Given(/^(I |we )*start recording network requests$/, function () {
|
|
219
|
+
Given(/^(I |we )*start recording network requests$/, function (pronounCase) {
|
|
220
220
|
ensureRequestLog(this);
|
|
221
221
|
});
|
|
222
222
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
const { Given, When, Then } = require('@cucumber/cucumber');
|
|
7
7
|
const assert = require('assert');
|
|
8
8
|
const axios = require('axios');
|
|
9
|
+
const { resolveUrl } = require('./webship');
|
|
9
10
|
|
|
10
11
|
function ensureState(world) {
|
|
11
12
|
if (!world._rest) world._rest = { headers: {}, response: null };
|
|
@@ -38,7 +39,7 @@ Given('a REST header {string} with value {string}', async function (name, value)
|
|
|
38
39
|
*/
|
|
39
40
|
When(/^(I |we )*send a REST "([^"]*)" request to "([^"]*)"$/, async function (pronoun, method, url) {
|
|
40
41
|
const s = ensureState(this);
|
|
41
|
-
const target =
|
|
42
|
+
const target = resolveUrl(this.launchUrl, url);
|
|
42
43
|
s.response = await axios.request({
|
|
43
44
|
method, url: target, headers: s.headers, validateStatus: () => true,
|
|
44
45
|
});
|
|
@@ -71,7 +72,7 @@ When(/^(I |we )*send a REST "([^"]*)" request to "([^"]*)"$/, async function (pr
|
|
|
71
72
|
*/
|
|
72
73
|
When(/^(I |we )*send a REST "([^"]*)" request to "([^"]*)" with body:$/, async function (pronoun, method, url, body) {
|
|
73
74
|
const s = ensureState(this);
|
|
74
|
-
const target =
|
|
75
|
+
const target = resolveUrl(this.launchUrl, url);
|
|
75
76
|
s.response = await axios.request({
|
|
76
77
|
method, url: target, headers: s.headers, data: body, validateStatus: () => true,
|
|
77
78
|
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -324,7 +324,7 @@ When(/^(I |we )*wait until at least (\d+) elements? match(?:es)? "([^"]*)"$/, as
|
|
|
324
324
|
* And I wait until requests are complete
|
|
325
325
|
*
|
|
326
326
|
*/
|
|
327
|
-
When(/^(I |we )*wait until (the network is idle|requests are complete|network goes quiet)$/, async function () {
|
|
327
|
+
When(/^(I |we )*wait until (the network is idle|requests are complete|network goes quiet)$/, async function (pronounCase, phrasing) {
|
|
328
328
|
await smartSettle(this.page, 10000);
|
|
329
329
|
});
|
|
330
330
|
|
|
@@ -344,7 +344,7 @@ When(/^(I |we )*wait until (the network is idle|requests are complete|network go
|
|
|
344
344
|
* Then "<#root>" should be attached
|
|
345
345
|
*
|
|
346
346
|
*/
|
|
347
|
-
When(/^(I |we )*wait until( the)* page is interactive$/, async function () {
|
|
347
|
+
When(/^(I |we )*wait until( the)* page is interactive$/, async function (pronounCase, theCase) {
|
|
348
348
|
await this.page.waitForSelector('body', { state: 'attached', timeout: 10000 });
|
|
349
349
|
await this.page.waitForLoadState('domcontentloaded', { timeout: 10000 });
|
|
350
350
|
});
|
|
@@ -368,7 +368,7 @@ When(/^(I |we )*wait until( the)* page is interactive$/, async function () {
|
|
|
368
368
|
* Then I should not see "Saved"
|
|
369
369
|
*
|
|
370
370
|
*/
|
|
371
|
-
When(/^(I |we )*wait until pending timers settle$/, async function () {
|
|
371
|
+
When(/^(I |we )*wait until pending timers settle$/, async function (pronounCase) {
|
|
372
372
|
await this.page.waitForFunction(
|
|
373
373
|
() => {
|
|
374
374
|
const t = window.__webshipPendingTimers;
|
|
@@ -17,6 +17,13 @@ function parseTimeout(secondsStr) {
|
|
|
17
17
|
return n > 0 ? n * 1000 : 5000;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// Collapse every run of whitespace (line breaks, tabs, non-breaking spaces) to
|
|
21
|
+
// one space and trim, so markup that wraps a line does not change the text a
|
|
22
|
+
// visitor reads.
|
|
23
|
+
function normalizeText(value) {
|
|
24
|
+
return String(value || '').replace(/\s+/g, ' ').trim();
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
// Poll fn() until it returns truthy, or timeout. fn() returns a value;
|
|
21
28
|
// `predicate` decides pass/fail. Returns the last value seen.
|
|
22
29
|
async function poll(fn, predicate, timeout, message) {
|
|
@@ -184,7 +191,10 @@ Then(/^"([^"]*)" should have text "([^"]*)"(?: within (\d+) seconds?)?$/, async
|
|
|
184
191
|
});
|
|
185
192
|
|
|
186
193
|
/**
|
|
187
|
-
* Assert an element's textContent contains an expected substring.
|
|
194
|
+
* Assert an element's textContent contains an expected substring. Runs of
|
|
195
|
+
* whitespace are collapsed to one space and trimmed on both sides first, so
|
|
196
|
+
* markup that wraps a line still matches. Use `should have text` for the
|
|
197
|
+
* exact match.
|
|
188
198
|
*
|
|
189
199
|
* Example #1: Then "h1" should contain text "Welcome"
|
|
190
200
|
* Example #2: Then ".badge" should contain text "unread" within 3 seconds
|
|
@@ -195,9 +205,10 @@ Then(/^"([^"]*)" should have text "([^"]*)"(?: within (\d+) seconds?)?$/, async
|
|
|
195
205
|
*/
|
|
196
206
|
Then(/^"([^"]*)" should contain text "([^"]*)"(?: within (\d+) seconds?)?$/, async function (selector, text, sec) {
|
|
197
207
|
const loc = this.page.locator(selector).first();
|
|
208
|
+
const expected = normalizeText(text);
|
|
198
209
|
await poll(
|
|
199
|
-
() => loc.textContent(),
|
|
200
|
-
(v) =>
|
|
210
|
+
async () => normalizeText(await loc.textContent()),
|
|
211
|
+
(v) => v.includes(expected),
|
|
201
212
|
parseTimeout(sec),
|
|
202
213
|
`Expected "${selector}" to contain text "${text}"`
|
|
203
214
|
);
|
|
@@ -293,6 +293,21 @@ function buildSelector(attrValue, attr) {
|
|
|
293
293
|
// empty-response edge cases so a redirect to about:blank or a 204 does
|
|
294
294
|
// not crash the suite. All other failures rethrow with extra context
|
|
295
295
|
// (URL + likely cause).
|
|
296
|
+
/**
|
|
297
|
+
* Resolve the value a step was given into the URL to request: an absolute
|
|
298
|
+
* `http://` or `https://` URL is returned as written, anything else is a
|
|
299
|
+
* path and is appended to the launch URL.
|
|
300
|
+
*
|
|
301
|
+
* @param {string} launchUrl
|
|
302
|
+
* @param {string} url
|
|
303
|
+
* @returns {string}
|
|
304
|
+
*/
|
|
305
|
+
function resolveUrl(launchUrl, url) {
|
|
306
|
+
const value = url === undefined || url === null ? '' : String(url);
|
|
307
|
+
if (/^https?:\/\//i.test(value)) return value;
|
|
308
|
+
return (launchUrl || '') + value;
|
|
309
|
+
}
|
|
310
|
+
|
|
296
311
|
/**
|
|
297
312
|
* Navigate to a URL with friendly error messages for common failures
|
|
298
313
|
* (server down, DNS, empty response). All other errors rethrow with
|
|
@@ -613,6 +628,7 @@ module.exports = {
|
|
|
613
628
|
isAnyModalVisible,
|
|
614
629
|
buildSelector,
|
|
615
630
|
gotoUrl,
|
|
631
|
+
resolveUrl,
|
|
616
632
|
fillField,
|
|
617
633
|
getLocatorText,
|
|
618
634
|
pad,
|
|
@@ -406,6 +406,6 @@ Then('the XML should not use the namespace {string}', async function (ns) {
|
|
|
406
406
|
* Example #5: When I print last XML response
|
|
407
407
|
*
|
|
408
408
|
*/
|
|
409
|
-
When(/^(I |we )*print last XML response$/, async function () {
|
|
409
|
+
When(/^(I |we )*print last XML response$/, async function (pronounCase) {
|
|
410
410
|
console.log(this._rawResponse || '(no response)');
|
|
411
411
|
});
|
|
@@ -908,6 +908,6 @@ Then('the YAML should not use the namespace {string}', function (ns) {
|
|
|
908
908
|
* And we print last YAML response
|
|
909
909
|
*
|
|
910
910
|
*/
|
|
911
|
-
When(/^(I |we )*print last YAML response$/, async function () {
|
|
911
|
+
When(/^(I |we )*print last YAML response$/, async function (pronounCase) {
|
|
912
912
|
console.log(this._rawYamlResponse || '(no response)');
|
|
913
913
|
});
|
package/tsconfig.json
CHANGED
|
File without changes
|
package/videos/README.md
CHANGED
|
File without changes
|