playwright-cucumber-ts-steps 1.3.0 → 1.3.2
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/dist/backend/actions/click.d.ts +84 -0
- package/dist/backend/actions/click.d.ts.map +1 -1
- package/dist/backend/actions/click.js +167 -17
- package/dist/backend/actions/form.d.ts +6 -0
- package/dist/backend/actions/form.d.ts.map +1 -1
- package/dist/backend/actions/form.js +17 -1
- package/dist/backend/actions/formTable.js +1 -1
- package/dist/backend/actions/frames.js +3 -3
- package/dist/backend/actions/index.d.ts +2 -0
- package/dist/backend/actions/index.d.ts.map +1 -1
- package/dist/backend/actions/index.js +2 -0
- package/dist/backend/actions/inputs.js +18 -18
- package/dist/backend/actions/interactions.d.ts +14 -5
- package/dist/backend/actions/interactions.d.ts.map +1 -1
- package/dist/backend/actions/interactions.js +69 -13
- package/dist/backend/actions/keyboard.js +6 -6
- package/dist/backend/actions/misc.d.ts +8 -2
- package/dist/backend/actions/misc.d.ts.map +1 -1
- package/dist/backend/actions/misc.js +64 -16
- package/dist/backend/actions/mobile.js +7 -7
- package/dist/backend/actions/mouse.js +9 -9
- package/dist/backend/actions/navigation.js +5 -5
- package/dist/backend/actions/visual.d.ts +47 -0
- package/dist/backend/actions/visual.d.ts.map +1 -0
- package/dist/backend/actions/visual.js +97 -0
- package/dist/backend/actions/waits.d.ts +6 -0
- package/dist/backend/actions/waits.d.ts.map +1 -1
- package/dist/backend/actions/waits.js +18 -5
- package/dist/backend/api/assertions.js +3 -3
- package/dist/backend/api/mock.js +3 -3
- package/dist/backend/api/network.js +6 -6
- package/dist/backend/api/requests.js +4 -4
- package/dist/backend/assertions/document.d.ts +61 -0
- package/dist/backend/assertions/document.d.ts.map +1 -0
- package/dist/backend/assertions/document.js +166 -0
- package/dist/backend/assertions/elements.d.ts +163 -0
- package/dist/backend/assertions/elements.d.ts.map +1 -0
- package/dist/backend/assertions/elements.js +441 -0
- package/dist/backend/assertions/expectVisible.js +1 -1
- package/dist/backend/assertions/forms.d.ts +43 -0
- package/dist/backend/assertions/forms.d.ts.map +1 -0
- package/dist/backend/assertions/forms.js +126 -0
- package/dist/backend/assertions/index.d.ts +10 -0
- package/dist/backend/assertions/index.d.ts.map +1 -1
- package/dist/backend/assertions/index.js +10 -0
- package/dist/backend/assertions/pageState.js +4 -4
- package/dist/backend/assertions/storage.d.ts +67 -0
- package/dist/backend/assertions/storage.d.ts.map +1 -0
- package/dist/backend/assertions/storage.js +220 -0
- package/dist/backend/assertions/text.d.ts +103 -12
- package/dist/backend/assertions/text.d.ts.map +1 -1
- package/dist/backend/assertions/text.js +207 -28
- package/dist/backend/assertions/visibility.d.ts +18 -0
- package/dist/backend/assertions/visibility.d.ts.map +1 -1
- package/dist/backend/assertions/visibility.js +58 -12
- package/dist/backend/auth/index.js +2 -2
- package/dist/backend/db/steps.d.ts +2 -2
- package/dist/backend/db/steps.d.ts.map +1 -1
- package/dist/backend/db/steps.js +11 -11
- package/dist/backend/elements/alerts.js +3 -3
- package/dist/backend/elements/find.js +26 -24
- package/dist/backend/elements/forms.js +4 -4
- package/dist/backend/elements/frames.js +3 -3
- package/dist/backend/utils/fixtures.js +1 -1
- package/dist/backend/utils/resolver.d.ts +6 -0
- package/dist/backend/utils/resolver.d.ts.map +1 -0
- package/dist/backend/utils/resolver.js +19 -0
- package/dist/component/index.d.ts +3 -0
- package/dist/component/index.d.ts.map +1 -0
- package/dist/component/index.js +6 -0
- package/dist/component/runner.d.ts +18 -0
- package/dist/component/runner.d.ts.map +1 -0
- package/dist/component/runner.js +91 -0
- package/dist/core/runner.d.ts +1 -0
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +179 -124
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/metadata.json +564 -172
- package/package.json +4 -3
package/dist/backend/api/mock.js
CHANGED
|
@@ -102,6 +102,6 @@ async function mockApiStatus(page, urlPatternKey, statusCode) {
|
|
|
102
102
|
// ==================================================
|
|
103
103
|
// GLUE STEPS
|
|
104
104
|
// ==================================================
|
|
105
|
-
(0, registry_1.Step)("I mock the API endpoint {string} with body {string}", mockApiWithInlineJson, "Given");
|
|
106
|
-
(0, registry_1.Step)("I mock the API endpoint {string} with response from {string}", mockApiWithFile, "Given");
|
|
107
|
-
(0, registry_1.Step)("I mock the API endpoint {string} with status {int}", mockApiStatus, "Given");
|
|
105
|
+
(0, registry_1.Step)("I pw mock the API endpoint {string} with body {string}", mockApiWithInlineJson, "Given");
|
|
106
|
+
(0, registry_1.Step)("I pw mock the API endpoint {string} with response from {string}", mockApiWithFile, "Given");
|
|
107
|
+
(0, registry_1.Step)("I pw mock the API endpoint {string} with status {int}", mockApiStatus, "Given");
|
|
@@ -165,9 +165,9 @@ async function browserFetchRequest(page, method, url, table) {
|
|
|
165
165
|
// ==================================================
|
|
166
166
|
// GLUE STEPS
|
|
167
167
|
// ==================================================
|
|
168
|
-
(0, registry_1.Step)("I intercept URL {string} and stub body:", interceptStubJson, "When"); // Handles DocString
|
|
169
|
-
(0, registry_1.Step)("I intercept URL {string} and stub body {string}", interceptStubRaw, "When");
|
|
170
|
-
(0, registry_1.Step)("I intercept URL {string}", interceptSpy, "When");
|
|
171
|
-
(0, registry_1.Step)("I make request to {string}", apiGetRequest, "When");
|
|
172
|
-
(0, registry_1.Step)("I make a POST request to {string} with JSON body:", apiPostRequest, "When"); // Handles DocString
|
|
173
|
-
(0, registry_1.Step)("I make a {word} request to {string}", browserFetchRequest, "When");
|
|
168
|
+
(0, registry_1.Step)("I pw intercept URL {string} and stub body:", interceptStubJson, "When"); // Handles DocString
|
|
169
|
+
(0, registry_1.Step)("I pw intercept URL {string} and stub body {string}", interceptStubRaw, "When");
|
|
170
|
+
(0, registry_1.Step)("I pw intercept URL {string}", interceptSpy, "When");
|
|
171
|
+
(0, registry_1.Step)("I pw make request to {string}", apiGetRequest, "When");
|
|
172
|
+
(0, registry_1.Step)("I pw make a POST request to {string} with JSON body:", apiPostRequest, "When"); // Handles DocString
|
|
173
|
+
(0, registry_1.Step)("I pw make a {word} request to {string}", browserFetchRequest, "When");
|
|
@@ -118,7 +118,7 @@ async function makePostRequestWithFile(page, urlKey, filePathKey) {
|
|
|
118
118
|
// ==================================================
|
|
119
119
|
// GLUE STEPS
|
|
120
120
|
// ==================================================
|
|
121
|
-
(0, registry_1.Step)("I make a GET request to {string}", makeGetRequest, "When");
|
|
122
|
-
(0, registry_1.Step)("I make a DELETE request to {string}", makeDeleteRequest, "When");
|
|
123
|
-
(0, registry_1.Step)("I make a POST request to {string} with data", makePostRequestWithTable, "When");
|
|
124
|
-
(0, registry_1.Step)("I make a POST request to {string} with payload from {string}", makePostRequestWithFile, "When");
|
|
121
|
+
(0, registry_1.Step)("I pw make a GET request to {string}", makeGetRequest, "When");
|
|
122
|
+
(0, registry_1.Step)("I pw make a DELETE request to {string}", makeDeleteRequest, "When");
|
|
123
|
+
(0, registry_1.Step)("I pw make a POST request to {string} with data", makePostRequestWithTable, "When");
|
|
124
|
+
(0, registry_1.Step)("I pw make a POST request to {string} with payload from {string}", makePostRequestWithFile, "When");
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asserts that the document title equals the expected value.
|
|
3
|
+
* Supports fixtures for reusable title values.
|
|
4
|
+
* @example Then I see document title "My Website - Home"
|
|
5
|
+
*/
|
|
6
|
+
export declare function expectDocumentTitle(page: any, titleKey: string): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Asserts that the document title contains the expected substring.
|
|
9
|
+
* Supports fixtures for reusable title values.
|
|
10
|
+
* @example Then I see document title contains "Website"
|
|
11
|
+
*/
|
|
12
|
+
export declare function expectDocumentTitleContains(page: any, titleKey: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Asserts that the current URL equals the expected value.
|
|
15
|
+
* Supports fixtures for reusable URL values.
|
|
16
|
+
* @example Then I see URL "https://example.com/dashboard"
|
|
17
|
+
*/
|
|
18
|
+
export declare function expectUrl(page: any, urlKey: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Asserts that the current URL contains the expected substring.
|
|
21
|
+
* Supports fixtures for reusable URL values.
|
|
22
|
+
* @example Then I see URL contains "dashboard"
|
|
23
|
+
*/
|
|
24
|
+
export declare function expectUrlContains(page: any, urlPartKey: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Asserts that the current pathname equals the expected value.
|
|
27
|
+
* Supports fixtures for reusable pathname values.
|
|
28
|
+
* @example Then I see pathname "/dashboard"
|
|
29
|
+
*/
|
|
30
|
+
export declare function expectPathname(page: any, pathnameKey: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Asserts that the current pathname contains the expected substring.
|
|
33
|
+
* Supports fixtures for reusable pathname values.
|
|
34
|
+
* @example Then I see pathname contains "dashboard"
|
|
35
|
+
*/
|
|
36
|
+
export declare function expectPathnameContains(page: any, pathnamePartKey: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Asserts that the current hash equals the expected value.
|
|
39
|
+
* Supports fixtures for reusable hash values.
|
|
40
|
+
* @example Then I see hash "#section1"
|
|
41
|
+
*/
|
|
42
|
+
export declare function expectHash(page: any, hashKey: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Asserts that the current hash contains the expected substring.
|
|
45
|
+
* Supports fixtures for reusable hash values.
|
|
46
|
+
* @example Then I see hash contains "section"
|
|
47
|
+
*/
|
|
48
|
+
export declare function expectHashContains(page: any, hashPartKey: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Asserts that the current search parameters contain the expected substring.
|
|
51
|
+
* Supports fixtures for reusable search values.
|
|
52
|
+
* @example Then I see search contains "query=test"
|
|
53
|
+
*/
|
|
54
|
+
export declare function expectSearchContains(page: any, searchPartKey: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Asserts that the current location equals the expected value.
|
|
57
|
+
* Supports fixtures for reusable location values.
|
|
58
|
+
* @example Then I see location "https://example.com/dashboard#top"
|
|
59
|
+
*/
|
|
60
|
+
export declare function expectLocation(page: any, locationKey: string): Promise<void>;
|
|
61
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/document.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAMf;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAMf;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,GAAG,EACT,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,GAAG,EACT,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,GAAG,EACT,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expectDocumentTitle = expectDocumentTitle;
|
|
4
|
+
exports.expectDocumentTitleContains = expectDocumentTitleContains;
|
|
5
|
+
exports.expectUrl = expectUrl;
|
|
6
|
+
exports.expectUrlContains = expectUrlContains;
|
|
7
|
+
exports.expectPathname = expectPathname;
|
|
8
|
+
exports.expectPathnameContains = expectPathnameContains;
|
|
9
|
+
exports.expectHash = expectHash;
|
|
10
|
+
exports.expectHashContains = expectHashContains;
|
|
11
|
+
exports.expectSearchContains = expectSearchContains;
|
|
12
|
+
exports.expectLocation = expectLocation;
|
|
13
|
+
//src/backend/assertions/document.ts
|
|
14
|
+
const test_1 = require("@playwright/test");
|
|
15
|
+
const registry_1 = require("../../core/registry");
|
|
16
|
+
const fixtures_1 = require("../utils/fixtures");
|
|
17
|
+
// ==================================================
|
|
18
|
+
// CORE FUNCTIONS
|
|
19
|
+
// ==================================================
|
|
20
|
+
/**
|
|
21
|
+
* Asserts that the document title equals the expected value.
|
|
22
|
+
* Supports fixtures for reusable title values.
|
|
23
|
+
* @example Then I see document title "My Website - Home"
|
|
24
|
+
*/
|
|
25
|
+
async function expectDocumentTitle(page, titleKey) {
|
|
26
|
+
const titles = (0, fixtures_1.loadFixture)("titles.json");
|
|
27
|
+
const expectedTitle = (0, fixtures_1.getFixtureValue)(titles, titleKey);
|
|
28
|
+
await (0, test_1.expect)(page).toHaveTitle(expectedTitle);
|
|
29
|
+
console.log(`✅ Document title is "${expectedTitle}"`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Asserts that the document title contains the expected substring.
|
|
33
|
+
* Supports fixtures for reusable title values.
|
|
34
|
+
* @example Then I see document title contains "Website"
|
|
35
|
+
*/
|
|
36
|
+
async function expectDocumentTitleContains(page, titleKey) {
|
|
37
|
+
const titles = (0, fixtures_1.loadFixture)("titles.json");
|
|
38
|
+
const expectedTitle = (0, fixtures_1.getFixtureValue)(titles, titleKey);
|
|
39
|
+
const actualTitle = await page.title();
|
|
40
|
+
if (!actualTitle.includes(expectedTitle)) {
|
|
41
|
+
throw new Error(`Document title "${actualTitle}" does not contain "${expectedTitle}"`);
|
|
42
|
+
}
|
|
43
|
+
console.log(`✅ Document title contains "${expectedTitle}"`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Asserts that the current URL equals the expected value.
|
|
47
|
+
* Supports fixtures for reusable URL values.
|
|
48
|
+
* @example Then I see URL "https://example.com/dashboard"
|
|
49
|
+
*/
|
|
50
|
+
async function expectUrl(page, urlKey) {
|
|
51
|
+
const urls = (0, fixtures_1.loadFixture)("urls.json");
|
|
52
|
+
const expectedUrl = (0, fixtures_1.getFixtureValue)(urls, urlKey);
|
|
53
|
+
await (0, test_1.expect)(page).toHaveURL(expectedUrl);
|
|
54
|
+
console.log(`✅ Current URL is "${expectedUrl}"`);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Asserts that the current URL contains the expected substring.
|
|
58
|
+
* Supports fixtures for reusable URL values.
|
|
59
|
+
* @example Then I see URL contains "dashboard"
|
|
60
|
+
*/
|
|
61
|
+
async function expectUrlContains(page, urlPartKey) {
|
|
62
|
+
const urls = (0, fixtures_1.loadFixture)("urls.json");
|
|
63
|
+
const urlPart = (0, fixtures_1.getFixtureValue)(urls, urlPartKey);
|
|
64
|
+
const currentUrl = page.url();
|
|
65
|
+
if (!currentUrl.includes(urlPart)) {
|
|
66
|
+
throw new Error(`Current URL "${currentUrl}" does not contain "${urlPart}"`);
|
|
67
|
+
}
|
|
68
|
+
console.log(`✅ Current URL contains "${urlPart}"`);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Asserts that the current pathname equals the expected value.
|
|
72
|
+
* Supports fixtures for reusable pathname values.
|
|
73
|
+
* @example Then I see pathname "/dashboard"
|
|
74
|
+
*/
|
|
75
|
+
async function expectPathname(page, pathnameKey) {
|
|
76
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
77
|
+
const expectedPath = (0, fixtures_1.getFixtureValue)(paths, pathnameKey);
|
|
78
|
+
const currentPath = new URL(page.url()).pathname;
|
|
79
|
+
if (currentPath !== expectedPath) {
|
|
80
|
+
throw new Error(`Current pathname "${currentPath}" does not equal "${expectedPath}"`);
|
|
81
|
+
}
|
|
82
|
+
console.log(`✅ Current pathname is "${expectedPath}"`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Asserts that the current pathname contains the expected substring.
|
|
86
|
+
* Supports fixtures for reusable pathname values.
|
|
87
|
+
* @example Then I see pathname contains "dashboard"
|
|
88
|
+
*/
|
|
89
|
+
async function expectPathnameContains(page, pathnamePartKey) {
|
|
90
|
+
const paths = (0, fixtures_1.loadFixture)("paths.json");
|
|
91
|
+
const pathnamePart = (0, fixtures_1.getFixtureValue)(paths, pathnamePartKey);
|
|
92
|
+
const currentPath = new URL(page.url()).pathname;
|
|
93
|
+
if (!currentPath.includes(pathnamePart)) {
|
|
94
|
+
throw new Error(`Current pathname "${currentPath}" does not contain "${pathnamePart}"`);
|
|
95
|
+
}
|
|
96
|
+
console.log(`✅ Current pathname contains "${pathnamePart}"`);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Asserts that the current hash equals the expected value.
|
|
100
|
+
* Supports fixtures for reusable hash values.
|
|
101
|
+
* @example Then I see hash "#section1"
|
|
102
|
+
*/
|
|
103
|
+
async function expectHash(page, hashKey) {
|
|
104
|
+
const hashes = (0, fixtures_1.loadFixture)("hashes.json");
|
|
105
|
+
const expectedHash = (0, fixtures_1.getFixtureValue)(hashes, hashKey);
|
|
106
|
+
const currentHash = new URL(page.url()).hash;
|
|
107
|
+
if (currentHash !== expectedHash) {
|
|
108
|
+
throw new Error(`Current hash "${currentHash}" does not equal "${expectedHash}"`);
|
|
109
|
+
}
|
|
110
|
+
console.log(`✅ Current hash is "${expectedHash}"`);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Asserts that the current hash contains the expected substring.
|
|
114
|
+
* Supports fixtures for reusable hash values.
|
|
115
|
+
* @example Then I see hash contains "section"
|
|
116
|
+
*/
|
|
117
|
+
async function expectHashContains(page, hashPartKey) {
|
|
118
|
+
const hashes = (0, fixtures_1.loadFixture)("hashes.json");
|
|
119
|
+
const hashPart = (0, fixtures_1.getFixtureValue)(hashes, hashPartKey);
|
|
120
|
+
const currentHash = new URL(page.url()).hash;
|
|
121
|
+
if (!currentHash.includes(hashPart)) {
|
|
122
|
+
throw new Error(`Current hash "${currentHash}" does not contain "${hashPart}"`);
|
|
123
|
+
}
|
|
124
|
+
console.log(`✅ Current hash contains "${hashPart}"`);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Asserts that the current search parameters contain the expected substring.
|
|
128
|
+
* Supports fixtures for reusable search values.
|
|
129
|
+
* @example Then I see search contains "query=test"
|
|
130
|
+
*/
|
|
131
|
+
async function expectSearchContains(page, searchPartKey) {
|
|
132
|
+
const searches = (0, fixtures_1.loadFixture)("searches.json");
|
|
133
|
+
const searchPart = (0, fixtures_1.getFixtureValue)(searches, searchPartKey);
|
|
134
|
+
const currentSearch = new URL(page.url()).search;
|
|
135
|
+
if (!currentSearch.includes(searchPart)) {
|
|
136
|
+
throw new Error(`Current search "${currentSearch}" does not contain "${searchPart}"`);
|
|
137
|
+
}
|
|
138
|
+
console.log(`✅ Current search contains "${searchPart}"`);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Asserts that the current location equals the expected value.
|
|
142
|
+
* Supports fixtures for reusable location values.
|
|
143
|
+
* @example Then I see location "https://example.com/dashboard#top"
|
|
144
|
+
*/
|
|
145
|
+
async function expectLocation(page, locationKey) {
|
|
146
|
+
const locations = (0, fixtures_1.loadFixture)("locations.json");
|
|
147
|
+
const expectedLocation = (0, fixtures_1.getFixtureValue)(locations, locationKey);
|
|
148
|
+
const currentLocation = page.url();
|
|
149
|
+
if (currentLocation !== expectedLocation) {
|
|
150
|
+
throw new Error(`Current location "${currentLocation}" does not equal "${expectedLocation}"`);
|
|
151
|
+
}
|
|
152
|
+
console.log(`✅ Current location is "${expectedLocation}"`);
|
|
153
|
+
}
|
|
154
|
+
// ==================================================
|
|
155
|
+
// GLUE STEPS
|
|
156
|
+
// ==================================================
|
|
157
|
+
(0, registry_1.Step)("I pw see document title {string}", expectDocumentTitle, "Then");
|
|
158
|
+
(0, registry_1.Step)("I pw see document title contains {string}", expectDocumentTitleContains, "Then");
|
|
159
|
+
(0, registry_1.Step)("I pw see URL {string}", expectUrl, "Then");
|
|
160
|
+
(0, registry_1.Step)("I pw see URL contains {string}", expectUrlContains, "Then");
|
|
161
|
+
(0, registry_1.Step)("I pw see pathname {string}", expectPathname, "Then");
|
|
162
|
+
(0, registry_1.Step)("I pw see pathname contains {string}", expectPathnameContains, "Then");
|
|
163
|
+
(0, registry_1.Step)("I pw see hash {string}", expectHash, "Then");
|
|
164
|
+
(0, registry_1.Step)("I pw see hash contains {string}", expectHashContains, "Then");
|
|
165
|
+
(0, registry_1.Step)("I pw see search contains {string}", expectSearchContains, "Then");
|
|
166
|
+
(0, registry_1.Step)("I pw see location {string}", expectLocation, "Then");
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts the number of elements matching the selector.
|
|
3
|
+
* Supports fixtures for reusable selectors.
|
|
4
|
+
* @example Then I count elements "li.item"
|
|
5
|
+
*/
|
|
6
|
+
export declare function countElements(page: any, selectorKey: string): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Asserts that a button element does not exist or is not visible.
|
|
9
|
+
* Supports fixtures for reusable selectors.
|
|
10
|
+
* @example Then I do not see button element "nav.logoutBtn"
|
|
11
|
+
*/
|
|
12
|
+
export declare function expectButtonNotVisible(page: any, selectorKey: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Asserts that a heading element does not exist or is not visible.
|
|
15
|
+
* Supports fixtures for reusable selectors.
|
|
16
|
+
* @example Then I do not see heading element "h1.main-title"
|
|
17
|
+
*/
|
|
18
|
+
export declare function expectHeadingNotVisible(page: any, selectorKey: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Asserts that a label element does not exist or is not visible.
|
|
21
|
+
* Supports fixtures for reusable selectors.
|
|
22
|
+
* @example Then I do not see label element "label.username-label"
|
|
23
|
+
*/
|
|
24
|
+
export declare function expectLabelNotVisible(page: any, selectorKey: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Asserts that a link element does not exist or is not visible.
|
|
27
|
+
* Supports fixtures for reusable selectors.
|
|
28
|
+
* @example Then I do not see link element "a.privacy-link"
|
|
29
|
+
*/
|
|
30
|
+
export declare function expectLinkNotVisible(page: any, selectorKey: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Asserts that an element with a specific test ID does not exist or is not visible.
|
|
33
|
+
* Supports fixtures for reusable test IDs.
|
|
34
|
+
* @example Then I do not see testid element "data-testid=my-component"
|
|
35
|
+
*/
|
|
36
|
+
export declare function expectTestIdNotVisible(page: any, selectorKey: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Asserts that an element with a specific role does not exist or is not visible.
|
|
39
|
+
* Supports fixtures for reusable roles.
|
|
40
|
+
* @example Then I do not see role element "button"
|
|
41
|
+
*/
|
|
42
|
+
export declare function expectRoleNotVisible(page: any, roleKey: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Asserts that an option element does not exist or is not visible.
|
|
45
|
+
* Supports fixtures for reusable selectors.
|
|
46
|
+
* @example Then I do not see option element "option[value='disabled']"
|
|
47
|
+
*/
|
|
48
|
+
export declare function expectOptionNotVisible(page: any, selectorKey: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Asserts that an element with a specific attribute does not exist or is not visible.
|
|
51
|
+
* Supports fixtures for reusable selectors and attribute values.
|
|
52
|
+
* @example Then I do not see element with attribute "aria-hidden" having value "false"
|
|
53
|
+
*/
|
|
54
|
+
export declare function expectElementWithAttributeNotVisible(page: any, attrKey: string, valueKey: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Asserts that an element has an attribute containing the specified value.
|
|
57
|
+
* Supports fixtures for reusable selectors, attributes and values.
|
|
58
|
+
* @example Then I see element attribute "class" contains "active"
|
|
59
|
+
*/
|
|
60
|
+
export declare function expectElementAttributeContains(page: any, selectorKey: string, attrKey: string, valueKey: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Asserts that an element has an attribute equal to the specified value.
|
|
63
|
+
* Supports fixtures for reusable selectors, attributes and values.
|
|
64
|
+
* @example Then I see element attribute "class" equals "btn-primary"
|
|
65
|
+
*/
|
|
66
|
+
export declare function expectElementAttributeEquals(page: any, selectorKey: string, attrKey: string, valueKey: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Asserts that an element has a specific attribute.
|
|
69
|
+
* Supports fixtures for reusable selectors and attributes.
|
|
70
|
+
* @example Then I see element has attribute "aria-label"
|
|
71
|
+
*/
|
|
72
|
+
export declare function expectElementHasAttribute(page: any, selectorKey: string, attrKey: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Asserts that a button element exists and is visible.
|
|
75
|
+
* Supports fixtures for reusable selectors.
|
|
76
|
+
* @example Then I see button element "nav.loginBtn"
|
|
77
|
+
*/
|
|
78
|
+
export declare function expectButtonVisible(page: any, selectorKey: string): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Gets an element by selector and asserts it has a class containing the specified text.
|
|
81
|
+
* @example Then I get element by selector "button.primary" to have class containing "active"
|
|
82
|
+
*/
|
|
83
|
+
export declare function expectElementToHaveClassContaining(page: any, selectorKey: string, classKey: string): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Asserts that an element does NOT contain the specified text.
|
|
86
|
+
* Supports fixtures for reusable selectors and text values.
|
|
87
|
+
* @example Then I get element by selector "error.message" to not contain text "success"
|
|
88
|
+
*/
|
|
89
|
+
export declare function expectElementToNotContainText(page: any, selectorKey: string, textKey: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Gets an element by selector and asserts it has the exact text specified.
|
|
92
|
+
* @example Then I get element by selector "header.title" to have text "Welcome Home"
|
|
93
|
+
*/
|
|
94
|
+
export declare function expectElementToHaveText(page: any, selectorKey: string, textKey: string): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Gets an element by selector and asserts it contains the specified text.
|
|
97
|
+
* @example Then I get element by selector "error.message" to contain text "invalid credentials"
|
|
98
|
+
*/
|
|
99
|
+
export declare function expectElementToContainText(page: any, selectorKey: string, textKey: string): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Gets an element by selector and asserts it has the specified value.
|
|
102
|
+
* @example Then I get element by selector "login.usernameField" to have value "john_doe"
|
|
103
|
+
*/
|
|
104
|
+
export declare function expectElementToHaveValue(page: any, selectorKey: string, valueKey: string): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Gets an element by selector and asserts it has the specified attribute with value.
|
|
107
|
+
* @example Then I get element by selector "terms.link" to have attribute "href" with value "/terms-and-conditions"
|
|
108
|
+
*/
|
|
109
|
+
export declare function expectElementAttributeValue(page: any, selectorKey: string, attrKey: string, valueKey: string): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Gets an element by selector and asserts it is visible.
|
|
112
|
+
* @example When I get element by selector "div.modal" to be visible
|
|
113
|
+
*/
|
|
114
|
+
export declare function getElementBySelectorToBeVisible(page: any, selectorKey: string): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Asserts that a heading element exists and is visible.
|
|
117
|
+
* Supports fixtures for reusable selectors.
|
|
118
|
+
* @example Then I see heading element "h1.main-title"
|
|
119
|
+
*/
|
|
120
|
+
export declare function expectHeadingVisible(page: any, selectorKey: string): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Asserts that a label element exists and is visible.
|
|
123
|
+
* Supports fixtures for reusable selectors.
|
|
124
|
+
* @example Then I see label element "label.username-label"
|
|
125
|
+
*/
|
|
126
|
+
export declare function expectLabelVisible(page: any, selectorKey: string): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Asserts that a link element exists and is visible.
|
|
129
|
+
* Supports fixtures for reusable selectors.
|
|
130
|
+
* @example Then I see link element "a.privacy-link"
|
|
131
|
+
*/
|
|
132
|
+
export declare function expectLinkVisible(page: any, selectorKey: string): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Asserts that an element with a specific test ID exists and is visible.
|
|
135
|
+
* Supports fixtures for reusable test IDs.
|
|
136
|
+
* @example Then I see testid element "data-testid=my-component"
|
|
137
|
+
*/
|
|
138
|
+
export declare function expectTestIdVisible(page: any, selectorKey: string): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Asserts that an element with a specific role exists and is visible.
|
|
141
|
+
* Supports fixtures for reusable roles.
|
|
142
|
+
* @example Then I see role element "button"
|
|
143
|
+
*/
|
|
144
|
+
export declare function expectRoleVisible(page: any, roleKey: string): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Asserts that an option element exists and is visible.
|
|
147
|
+
* Supports fixtures for reusable selectors.
|
|
148
|
+
* @example Then I see option element "option[value='enabled']"
|
|
149
|
+
*/
|
|
150
|
+
export declare function expectOptionVisible(page: any, selectorKey: string): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Asserts that an element has a specific count of occurrences.
|
|
153
|
+
* Supports fixtures for reusable selectors.
|
|
154
|
+
* @example Then I expect "li.item" to have count 5
|
|
155
|
+
*/
|
|
156
|
+
export declare function expectElementToHaveCount(page: any, selectorKey: string, count: number): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Asserts that an element is hidden (not visible).
|
|
159
|
+
* Supports fixtures for reusable selectors.
|
|
160
|
+
* @example Then I expect "modal.overlay" to be hidden
|
|
161
|
+
*/
|
|
162
|
+
export declare function expectElementToBeHidden(page: any, selectorKey: string): Promise<void>;
|
|
163
|
+
//# sourceMappingURL=elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/elements.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,iBAI/B;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,GAAG,EACT,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAaf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