playwright-cucumber-ts-steps 1.0.1 → 1.0.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/README.md +195 -256
- package/dist/backend/actions/index.js +4 -0
- package/dist/backend/actions/interactions.js +23 -0
- package/dist/backend/actions/navigation.js +19 -0
- package/dist/backend/api/assertions.js +26 -0
- package/dist/backend/api/index.js +4 -0
- package/dist/backend/api/requests.js +24 -0
- package/dist/backend/api/state.js +15 -0
- package/dist/backend/assertions/expectVisible.js +8 -0
- package/dist/backend/assertions/index.js +5 -0
- package/dist/backend/assertions/pageState.js +25 -0
- package/dist/backend/assertions/text.js +20 -0
- package/dist/backend/assertions/visibility.js +20 -0
- package/dist/backend/auth/index.js +71 -0
- package/dist/backend/elements/alerts.js +21 -0
- package/dist/backend/elements/forms.js +59 -0
- package/dist/backend/elements/frames.js +25 -0
- package/dist/backend/elements/index.js +5 -0
- package/dist/core/registry.js +20 -0
- package/dist/core/runner.js +136 -0
- package/dist/index.js +10 -0
- package/dist/reporting/index.js +43 -0
- package/package.json +19 -101
- package/LICENSE +0 -21
- package/lib/actions/clickSteps.d.ts +0 -251
- package/lib/actions/clickSteps.js +0 -415
- package/lib/actions/cookieSteps.d.ts +0 -18
- package/lib/actions/cookieSteps.js +0 -93
- package/lib/actions/debugSteps.d.ts +0 -14
- package/lib/actions/debugSteps.js +0 -23
- package/lib/actions/elementFindSteps.d.ts +0 -668
- package/lib/actions/elementFindSteps.js +0 -931
- package/lib/actions/fillFormSteps.d.ts +0 -69
- package/lib/actions/fillFormSteps.js +0 -237
- package/lib/actions/index.d.ts +0 -11
- package/lib/actions/index.js +0 -28
- package/lib/actions/inputSteps.d.ts +0 -218
- package/lib/actions/inputSteps.js +0 -343
- package/lib/actions/interceptionSteps.d.ts +0 -169
- package/lib/actions/interceptionSteps.js +0 -291
- package/lib/actions/miscSteps.d.ts +0 -645
- package/lib/actions/miscSteps.js +0 -1061
- package/lib/actions/mouseSteps.d.ts +0 -143
- package/lib/actions/mouseSteps.js +0 -234
- package/lib/actions/scrollSteps.d.ts +0 -82
- package/lib/actions/scrollSteps.js +0 -123
- package/lib/actions/storageSteps.d.ts +0 -174
- package/lib/actions/storageSteps.js +0 -292
- package/lib/assertions/buttonAndTextVisibilitySteps.d.ts +0 -245
- package/lib/assertions/buttonAndTextVisibilitySteps.js +0 -401
- package/lib/assertions/cookieSteps.d.ts +0 -75
- package/lib/assertions/cookieSteps.js +0 -113
- package/lib/assertions/elementSteps.d.ts +0 -264
- package/lib/assertions/elementSteps.js +0 -388
- package/lib/assertions/formInputSteps.d.ts +0 -248
- package/lib/assertions/formInputSteps.js +0 -350
- package/lib/assertions/index.d.ts +0 -10
- package/lib/assertions/index.js +0 -27
- package/lib/assertions/interceptionRequestsSteps.d.ts +0 -353
- package/lib/assertions/interceptionRequestsSteps.js +0 -593
- package/lib/assertions/locationSteps.d.ts +0 -217
- package/lib/assertions/locationSteps.js +0 -310
- package/lib/assertions/roleTestIdSteps.d.ts +0 -159
- package/lib/assertions/roleTestIdSteps.js +0 -221
- package/lib/assertions/semanticSteps.d.ts +0 -176
- package/lib/assertions/semanticSteps.js +0 -252
- package/lib/assertions/storageSteps.d.ts +0 -149
- package/lib/assertions/storageSteps.js +0 -210
- package/lib/assertions/visualSteps.d.ts +0 -74
- package/lib/assertions/visualSteps.js +0 -209
- package/lib/custom_setups/loginHooks.d.ts +0 -1
- package/lib/custom_setups/loginHooks.js +0 -130
- package/lib/helpers/checkPeerDeps.d.ts +0 -1
- package/lib/helpers/checkPeerDeps.js +0 -19
- package/lib/helpers/compareSnapshots.d.ts +0 -6
- package/lib/helpers/compareSnapshots.js +0 -20
- package/lib/helpers/hooks.d.ts +0 -1
- package/lib/helpers/hooks.js +0 -210
- package/lib/helpers/utils/fakerUtils.d.ts +0 -1
- package/lib/helpers/utils/fakerUtils.js +0 -60
- package/lib/helpers/utils/index.d.ts +0 -4
- package/lib/helpers/utils/index.js +0 -20
- package/lib/helpers/utils/optionsUtils.d.ts +0 -24
- package/lib/helpers/utils/optionsUtils.js +0 -88
- package/lib/helpers/utils/resolveUtils.d.ts +0 -6
- package/lib/helpers/utils/resolveUtils.js +0 -72
- package/lib/helpers/utils/sessionUtils.d.ts +0 -3
- package/lib/helpers/utils/sessionUtils.js +0 -40
- package/lib/helpers/world.d.ts +0 -34
- package/lib/helpers/world.js +0 -110
- package/lib/iframes/frames.d.ts +0 -1
- package/lib/iframes/frames.js +0 -11
- package/lib/index.d.ts +0 -10
- package/lib/index.js +0 -28
- package/lib/register.d.ts +0 -1
- package/lib/register.js +0 -6
- package/src/actions/clickSteps.ts +0 -429
- package/src/actions/cookieSteps.ts +0 -95
- package/src/actions/debugSteps.ts +0 -21
- package/src/actions/elementFindSteps.ts +0 -961
- package/src/actions/fillFormSteps.ts +0 -270
- package/src/actions/index.ts +0 -12
- package/src/actions/inputSteps.ts +0 -354
- package/src/actions/interceptionSteps.ts +0 -325
- package/src/actions/miscSteps.ts +0 -1144
- package/src/actions/mouseSteps.ts +0 -256
- package/src/actions/scrollSteps.ts +0 -122
- package/src/actions/storageSteps.ts +0 -308
- package/src/assertions/buttonAndTextVisibilitySteps.ts +0 -436
- package/src/assertions/cookieSteps.ts +0 -131
- package/src/assertions/elementSteps.ts +0 -432
- package/src/assertions/formInputSteps.ts +0 -377
- package/src/assertions/index.ts +0 -11
- package/src/assertions/interceptionRequestsSteps.ts +0 -640
- package/src/assertions/locationSteps.ts +0 -315
- package/src/assertions/roleTestIdSteps.ts +0 -254
- package/src/assertions/semanticSteps.ts +0 -267
- package/src/assertions/storageSteps.ts +0 -250
- package/src/assertions/visualSteps.ts +0 -275
- package/src/custom_setups/loginHooks.ts +0 -154
- package/src/helpers/checkPeerDeps.ts +0 -19
- package/src/helpers/compareSnapshots.ts +0 -35
- package/src/helpers/hooks.ts +0 -212
- package/src/helpers/utils/fakerUtils.ts +0 -64
- package/src/helpers/utils/index.ts +0 -4
- package/src/helpers/utils/optionsUtils.ts +0 -104
- package/src/helpers/utils/resolveUtils.ts +0 -74
- package/src/helpers/utils/sessionUtils.ts +0 -36
- package/src/helpers/world.ts +0 -119
- package/src/iframes/frames.ts +0 -15
- package/src/index.ts +0 -18
- package/src/register.ts +0 -4
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { Then, DataTable } from "@cucumber/cucumber";
|
|
2
|
-
import { expect } from "@playwright/test";
|
|
3
|
-
import { CustomWorld } from "../helpers/world"; // Assuming this path is correct
|
|
4
|
-
|
|
5
|
-
// ===================================================================================
|
|
6
|
-
// ASSERTIONS: URL
|
|
7
|
-
// ===================================================================================
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Asserts that the current page's full URL exactly matches the expected string.
|
|
11
|
-
*
|
|
12
|
-
* ```gherkin
|
|
13
|
-
* Then I see URL {string}
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @param expectedUrl - The exact URL string expected.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* Then I see URL "https://example.com/dashboard"
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* This step retrieves the current URL from `this.page.url()` and performs a strict equality check.
|
|
23
|
-
* @category URL Assertion Steps
|
|
24
|
-
*/
|
|
25
|
-
export async function Then_I_see_URL(this: CustomWorld, expectedUrl: string) {
|
|
26
|
-
const currentUrl = this.page.url();
|
|
27
|
-
expect(currentUrl).toBe(expectedUrl);
|
|
28
|
-
this.log?.(`✅ Verified URL is exactly: "${expectedUrl}".`);
|
|
29
|
-
}
|
|
30
|
-
Then("I see URL {string}", Then_I_see_URL);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Asserts that the current page's full URL does NOT match the given string.
|
|
34
|
-
*
|
|
35
|
-
* ```gherkin
|
|
36
|
-
* Then I do not see URL {string}
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @param notExpectedUrl - The URL string that is NOT expected.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* Then I do not see URL "https://example.com/login"
|
|
43
|
-
*
|
|
44
|
-
* @remarks
|
|
45
|
-
* This step retrieves the current URL from `this.page.url()` and performs a strict inequality check.
|
|
46
|
-
* @category URL Assertion Steps
|
|
47
|
-
*/
|
|
48
|
-
export async function Then_I_do_not_see_URL(this: CustomWorld, notExpectedUrl: string) {
|
|
49
|
-
const currentUrl = this.page.url();
|
|
50
|
-
expect(currentUrl).not.toBe(notExpectedUrl);
|
|
51
|
-
this.log?.(`✅ Verified URL is NOT: "${notExpectedUrl}".`);
|
|
52
|
-
}
|
|
53
|
-
Then("I do not see URL {string}", Then_I_do_not_see_URL);
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Asserts that the current page's full URL contains the expected substring.
|
|
57
|
-
*
|
|
58
|
-
* ```gherkin
|
|
59
|
-
* Then I see URL contains {string}
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @param expectedPart - The substring expected to be present in the URL.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* Then I see URL contains "/dashboard"
|
|
66
|
-
*
|
|
67
|
-
* @remarks
|
|
68
|
-
* This step retrieves the current URL from `this.page.url()` and checks if it includes the `expectedPart`.
|
|
69
|
-
* @category URL Assertion Steps
|
|
70
|
-
*/
|
|
71
|
-
export async function Then_I_see_URL_contains(this: CustomWorld, expectedPart: string) {
|
|
72
|
-
const currentUrl = this.page.url();
|
|
73
|
-
expect(currentUrl).toContain(expectedPart);
|
|
74
|
-
this.log?.(`✅ Verified URL contains: "${expectedPart}".`);
|
|
75
|
-
}
|
|
76
|
-
Then("I see URL contains {string}", Then_I_see_URL_contains);
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Asserts that the current page's full URL does NOT contain the given substring.
|
|
80
|
-
*
|
|
81
|
-
* ```gherkin
|
|
82
|
-
* Then I do not see URL contains {string}
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* @param notExpectedPart - The substring that is NOT expected to be present in the URL.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* Then I do not see URL contains "/login"
|
|
89
|
-
*
|
|
90
|
-
* @remarks
|
|
91
|
-
* This step retrieves the current URL from `this.page.url()` and asserts that it does not include the `notExpectedPart`.
|
|
92
|
-
* @category URL Assertion Steps
|
|
93
|
-
*/
|
|
94
|
-
export async function Then_I_do_not_see_URL_contains(this: CustomWorld, notExpectedPart: string) {
|
|
95
|
-
const currentUrl = this.page.url();
|
|
96
|
-
expect(currentUrl).not.toContain(notExpectedPart);
|
|
97
|
-
this.log?.(`✅ Verified URL does NOT contain: "${notExpectedPart}".`);
|
|
98
|
-
}
|
|
99
|
-
Then("I do not see URL contains {string}", Then_I_do_not_see_URL_contains);
|
|
100
|
-
|
|
101
|
-
// ===================================================================================
|
|
102
|
-
// ASSERTIONS: LOCATION PARTS (HREF, PATHNAME, HASH, SEARCH)
|
|
103
|
-
// ===================================================================================
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Asserts that the current `window.location.href` (full URL) matches the expected string.
|
|
107
|
-
* This is an alias for "Then I see URL {string}".
|
|
108
|
-
*
|
|
109
|
-
* ```gherkin
|
|
110
|
-
* Then I see location {string}
|
|
111
|
-
* ```
|
|
112
|
-
*
|
|
113
|
-
* @param expectedHref - The exact `window.location.href` string expected.
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* Then I see location "https://example.com/dashboard"
|
|
117
|
-
*
|
|
118
|
-
* @remarks
|
|
119
|
-
* This step executes `window.location.href` in the browser context and compares it strictly.
|
|
120
|
-
* It's functionally identical to {@link Then_I_see_URL | "Then I see URL {string}"}.
|
|
121
|
-
* @category Location Assertion Steps
|
|
122
|
-
*/
|
|
123
|
-
export async function Then_I_see_location(this: CustomWorld, expectedHref: string) {
|
|
124
|
-
const locationHref = await this.page.evaluate(() => window.location.href);
|
|
125
|
-
expect(locationHref).toBe(expectedHref);
|
|
126
|
-
this.log?.(`✅ Verified location href is exactly: "${expectedHref}".`);
|
|
127
|
-
}
|
|
128
|
-
Then("I see location {string}", Then_I_see_location);
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Asserts that the current `window.location.pathname` (path part of URL) matches the expected string.
|
|
132
|
-
*
|
|
133
|
-
* ```gherkin
|
|
134
|
-
* Then I see pathname {string}
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* @param expectedPathname - The exact pathname string expected (e.g., "/dashboard").
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* Then I see pathname "/dashboard"
|
|
141
|
-
*
|
|
142
|
-
* @remarks
|
|
143
|
-
* This step executes `window.location.pathname` in the browser context and compares it strictly.
|
|
144
|
-
* @category Location Assertion Steps
|
|
145
|
-
*/
|
|
146
|
-
export async function Then_I_see_pathname(this: CustomWorld, expectedPathname: string) {
|
|
147
|
-
const pathname = await this.page.evaluate(() => window.location.pathname);
|
|
148
|
-
expect(pathname).toBe(expectedPathname);
|
|
149
|
-
this.log?.(`✅ Verified pathname is exactly: "${expectedPathname}".`);
|
|
150
|
-
}
|
|
151
|
-
Then("I see pathname {string}", Then_I_see_pathname);
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Asserts that the current `window.location.pathname` contains the expected substring.
|
|
155
|
-
*
|
|
156
|
-
* ```gherkin
|
|
157
|
-
* Then I see pathname contains {string}
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @param expectedPart - The substring expected to be present in the pathname.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* Then I see pathname contains "/settings/"
|
|
164
|
-
*
|
|
165
|
-
* @remarks
|
|
166
|
-
* This step executes `window.location.pathname` in the browser context and checks for substring presence.
|
|
167
|
-
* @category Location Assertion Steps
|
|
168
|
-
*/
|
|
169
|
-
export async function Then_I_see_pathname_contains(this: CustomWorld, expectedPart: string) {
|
|
170
|
-
const pathname = await this.page.evaluate(() => window.location.pathname);
|
|
171
|
-
expect(pathname).toContain(expectedPart);
|
|
172
|
-
this.log?.(`✅ Verified pathname contains: "${expectedPart}".`);
|
|
173
|
-
}
|
|
174
|
-
Then("I see pathname contains {string}", Then_I_see_pathname_contains);
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Asserts that the current `window.location.hash` (fragment identifier) matches the expected string.
|
|
178
|
-
*
|
|
179
|
-
* ```gherkin
|
|
180
|
-
* Then I see hash {string}
|
|
181
|
-
* ```
|
|
182
|
-
*
|
|
183
|
-
* @param expectedHash - The exact hash string expected (e.g., "#section-1").
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* Then I see hash "#section"
|
|
187
|
-
*
|
|
188
|
-
* @remarks
|
|
189
|
-
* This step executes `window.location.hash` in the browser context and compares it strictly.
|
|
190
|
-
* @category Location Assertion Steps
|
|
191
|
-
*/
|
|
192
|
-
export async function Then_I_see_hash(this: CustomWorld, expectedHash: string) {
|
|
193
|
-
const hash = await this.page.evaluate(() => window.location.hash);
|
|
194
|
-
expect(hash).toBe(expectedHash);
|
|
195
|
-
this.log?.(`✅ Verified hash is exactly: "${expectedHash}".`);
|
|
196
|
-
}
|
|
197
|
-
Then("I see hash {string}", Then_I_see_hash);
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Asserts that the current `window.location.hash` contains the expected substring.
|
|
201
|
-
*
|
|
202
|
-
* ```gherkin
|
|
203
|
-
* Then I see hash contains {string}
|
|
204
|
-
* ```
|
|
205
|
-
*
|
|
206
|
-
* @param expectedPart - The substring expected to be present in the hash.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* Then I see hash contains "details"
|
|
210
|
-
*
|
|
211
|
-
* @remarks
|
|
212
|
-
* This step executes `window.location.hash` in the browser context and checks for substring presence.
|
|
213
|
-
* @category Location Assertion Steps
|
|
214
|
-
*/
|
|
215
|
-
export async function Then_I_see_hash_contains(this: CustomWorld, expectedPart: string) {
|
|
216
|
-
const hash = await this.page.evaluate(() => window.location.hash);
|
|
217
|
-
expect(hash).toContain(expectedPart);
|
|
218
|
-
this.log?.(`✅ Verified hash contains: "${expectedPart}".`);
|
|
219
|
-
}
|
|
220
|
-
Then("I see hash contains {string}", Then_I_see_hash_contains);
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Asserts that the current `window.location.search` (query string) matches the expected string.
|
|
224
|
-
*
|
|
225
|
-
* ```gherkin
|
|
226
|
-
* Then I see search {string}
|
|
227
|
-
* ```
|
|
228
|
-
*
|
|
229
|
-
* @param expectedSearch - The exact search string expected (e.g., "?q=test&page=1").
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* Then I see search "?q=test"
|
|
233
|
-
*
|
|
234
|
-
* @remarks
|
|
235
|
-
* This step executes `window.location.search` in the browser context and compares it strictly.
|
|
236
|
-
* @category Location Assertion Steps
|
|
237
|
-
*/
|
|
238
|
-
export async function Then_I_see_search(this: CustomWorld, expectedSearch: string) {
|
|
239
|
-
const search = await this.page.evaluate(() => window.location.search);
|
|
240
|
-
expect(search).toBe(expectedSearch);
|
|
241
|
-
this.log?.(`✅ Verified search is exactly: "${expectedSearch}".`);
|
|
242
|
-
}
|
|
243
|
-
Then("I see search {string}", Then_I_see_search);
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Asserts that the current `window.location.search` contains the expected substring.
|
|
247
|
-
*
|
|
248
|
-
* ```gherkin
|
|
249
|
-
* Then I see search contains {string}
|
|
250
|
-
* ```
|
|
251
|
-
*
|
|
252
|
-
* @param expectedPart - The substring expected to be present in the search query.
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* Then I see search contains "q=test"
|
|
256
|
-
*
|
|
257
|
-
* @remarks
|
|
258
|
-
* This step executes `window.location.search` in the browser context and checks for substring presence.
|
|
259
|
-
* @category Location Assertion Steps
|
|
260
|
-
*/
|
|
261
|
-
export async function Then_I_see_search_contains(this: CustomWorld, expectedPart: string) {
|
|
262
|
-
const search = await this.page.evaluate(() => window.location.search);
|
|
263
|
-
expect(search).toContain(expectedPart);
|
|
264
|
-
this.log?.(`✅ Verified search contains: "${expectedPart}".`);
|
|
265
|
-
}
|
|
266
|
-
Then("I see search contains {string}", Then_I_see_search_contains);
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Asserts that multiple parts of the current `window.location` object match expected values from a data table.
|
|
270
|
-
*
|
|
271
|
-
* ```gherkin
|
|
272
|
-
* Then I see location
|
|
273
|
-
* | key | value |
|
|
274
|
-
* | pathname | /dashboard |
|
|
275
|
-
* | hash | #section |
|
|
276
|
-
* ```
|
|
277
|
-
*
|
|
278
|
-
* @param table - A Cucumber DataTable with `key` and `value` columns, where `key` is a `window.location` property (e.g., "pathname", "hash", "origin").
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* Then I see location
|
|
282
|
-
* | key | value |
|
|
283
|
-
* | pathname | /profile |
|
|
284
|
-
* | protocol | https: |
|
|
285
|
-
* | hostname | myapp.com |
|
|
286
|
-
*
|
|
287
|
-
* @remarks
|
|
288
|
-
* This step retrieves various `window.location` properties as an object and then iterates
|
|
289
|
-
* through the data table, asserting that each specified `key` has its corresponding `value`.
|
|
290
|
-
* This allows for flexible and combined assertions on the URL components.
|
|
291
|
-
* @category Location Assertion Steps
|
|
292
|
-
*/
|
|
293
|
-
export async function Then_I_see_location_parts(this: CustomWorld, table: DataTable) {
|
|
294
|
-
const location = await this.page.evaluate(() => ({
|
|
295
|
-
href: window.location.href,
|
|
296
|
-
origin: window.location.origin,
|
|
297
|
-
protocol: window.location.protocol,
|
|
298
|
-
host: window.location.host,
|
|
299
|
-
hostname: window.location.hostname,
|
|
300
|
-
port: window.location.port,
|
|
301
|
-
pathname: window.location.pathname,
|
|
302
|
-
search: window.location.search,
|
|
303
|
-
hash: window.location.hash,
|
|
304
|
-
}));
|
|
305
|
-
|
|
306
|
-
for (const [key, expected] of table.rows()) {
|
|
307
|
-
const actual = location[key as keyof typeof location];
|
|
308
|
-
expect(
|
|
309
|
-
actual,
|
|
310
|
-
`Location part "${key}" mismatch: Expected "${expected}", but got "${actual}".`
|
|
311
|
-
).toBe(expected);
|
|
312
|
-
this.log?.(`✅ Verified location part "${key}" is "${expected}".`);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
Then("I see location", Then_I_see_location_parts);
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { Then } from "@cucumber/cucumber";
|
|
2
|
-
import { expect } from "@playwright/test";
|
|
3
|
-
import { CustomWorld } from "../helpers/world"; // Assuming this path is correct
|
|
4
|
-
|
|
5
|
-
// ===================================================================================
|
|
6
|
-
// ASSERTIONS: ROLE-BASED ELEMENTS
|
|
7
|
-
// ===================================================================================
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Asserts that an element with the given ARIA role and exact accessible name is visible on the page.
|
|
11
|
-
*
|
|
12
|
-
* ```gherkin
|
|
13
|
-
* Then I see role {string} with name {string}
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @param role - The ARIA role of the element (e.g., "button", "heading", "textbox").
|
|
17
|
-
* @param name - The exact accessible name of the element (e.g., button text, label text).
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* Then I see role "button" with name "Submit"
|
|
21
|
-
* Then I see role "heading" with name "Welcome"
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* This step uses Playwright's `page.getByRole()` with `exact: true` for precise matching.
|
|
25
|
-
* It asserts that the matched element is visible in the viewport.
|
|
26
|
-
* @category Role-Based Assertion Steps
|
|
27
|
-
*/
|
|
28
|
-
export async function Then_I_see_role_with_name(this: CustomWorld, role: string, name: string) {
|
|
29
|
-
const locator = this.page.getByRole(role as any, { name, exact: true });
|
|
30
|
-
await expect(locator).toBeVisible({ timeout: 5000 });
|
|
31
|
-
this.log?.(`✅ Verified role "${role}" with name "${name}" is visible.`);
|
|
32
|
-
}
|
|
33
|
-
Then(/^I see role "(.*)" with name "(.*)"$/, Then_I_see_role_with_name);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Asserts that an element with the given ARIA role and exact accessible name does NOT exist in the DOM.
|
|
37
|
-
*
|
|
38
|
-
* ```gherkin
|
|
39
|
-
* Then I do not see role {string} with name {string}
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @param role - The ARIA role of the element.
|
|
43
|
-
* @param name - The exact accessible name of the element.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* Then I do not see role "button" with name "Cancel"
|
|
47
|
-
* Then I do not see role "alert" with name "Error message"
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* This step uses Playwright's `page.getByRole()` with `exact: true` and asserts that
|
|
51
|
-
* no such element exists in the DOM (i.e., its count is 0).
|
|
52
|
-
* @category Role-Based Assertion Steps
|
|
53
|
-
*/
|
|
54
|
-
export async function Then_I_do_not_see_role_with_name(
|
|
55
|
-
this: CustomWorld,
|
|
56
|
-
role: string,
|
|
57
|
-
name: string
|
|
58
|
-
) {
|
|
59
|
-
const locator = this.page.getByRole(role as any, { name, exact: true });
|
|
60
|
-
await expect(locator).toHaveCount(0, { timeout: 5000 });
|
|
61
|
-
this.log?.(`✅ Verified role "${role}" with name "${name}" does NOT exist.`);
|
|
62
|
-
}
|
|
63
|
-
Then(/^I do not see role "(.*)" with name "(.*)"$/, Then_I_do_not_see_role_with_name);
|
|
64
|
-
|
|
65
|
-
// ===================================================================================
|
|
66
|
-
// ASSERTIONS: TEST ID-BASED ELEMENTS
|
|
67
|
-
// ===================================================================================
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Asserts that an element with the given `data-testid` attribute (or configured test ID) is visible on the page.
|
|
71
|
-
*
|
|
72
|
-
* ```gherkin
|
|
73
|
-
* Then I see testid {string}
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @param testId - The value of the `data-testid` attribute.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* Then I see testid "main-content"
|
|
80
|
-
* Then I see testid "user-profile-section"
|
|
81
|
-
*
|
|
82
|
-
* @remarks
|
|
83
|
-
* This step uses Playwright's `page.getByTestId()` and asserts that the matched element is visible.
|
|
84
|
-
* @category Test ID-Based Assertion Steps
|
|
85
|
-
*/
|
|
86
|
-
export async function Then_I_see_testid(this: CustomWorld, testId: string) {
|
|
87
|
-
const locator = this.page.getByTestId(testId);
|
|
88
|
-
await expect(locator).toBeVisible({ timeout: 5000 });
|
|
89
|
-
this.log?.(`✅ Verified test ID "${testId}" is visible.`);
|
|
90
|
-
}
|
|
91
|
-
Then(/^I see testid "(.*)"$/, Then_I_see_testid);
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Asserts that an element with the given `data-testid` attribute (or configured test ID) does NOT exist in the DOM.
|
|
95
|
-
*
|
|
96
|
-
* ```gherkin
|
|
97
|
-
* Then I do not see testid {string}
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* @param testId - The value of the `data-testid` attribute.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* Then I do not see testid "sidebar"
|
|
104
|
-
* Then I do not see testid "legacy-component"
|
|
105
|
-
*
|
|
106
|
-
* @remarks
|
|
107
|
-
* This step uses Playwright's `page.getByTestId()` and asserts that no such element exists (i.e., its count is 0).
|
|
108
|
-
* @category Test ID-Based Assertion Steps
|
|
109
|
-
*/
|
|
110
|
-
export async function Then_I_do_not_see_testid(this: CustomWorld, testId: string) {
|
|
111
|
-
const locator = this.page.getByTestId(testId);
|
|
112
|
-
await expect(locator).toHaveCount(0, { timeout: 5000 });
|
|
113
|
-
this.log?.(`✅ Verified test ID "${testId}" does NOT exist.`);
|
|
114
|
-
}
|
|
115
|
-
Then(/^I do not see testid "(.*)"$/, Then_I_do_not_see_testid);
|
|
116
|
-
|
|
117
|
-
// ===================================================================================
|
|
118
|
-
// ASSERTIONS: ATTRIBUTE-BASED ASSERTIONS (on Test ID elements)
|
|
119
|
-
// ===================================================================================
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Asserts that an element identified by its `data-testid` has a specific attribute with an exact expected value.
|
|
123
|
-
*
|
|
124
|
-
* ```gherkin
|
|
125
|
-
* Then I see testid {string} has attribute {string} with value {string}
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* @param testId - The value of the `data-testid` attribute.
|
|
129
|
-
* @param attr - The name of the attribute (e.g., "data-state", "aria-expanded").
|
|
130
|
-
* @param value - The exact expected value of the attribute.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* Then I see testid "main-content" has attribute "data-state" with value "active"
|
|
134
|
-
* Then I see testid "toggle-button" has attribute "aria-pressed" with value "true"
|
|
135
|
-
*
|
|
136
|
-
* @remarks
|
|
137
|
-
* This step uses Playwright's `page.getByTestId()` to find the element and then
|
|
138
|
-
* `expect(locator).toHaveAttribute()` for the assertion.
|
|
139
|
-
* @category Test ID-Based Attribute Assertion Steps
|
|
140
|
-
*/
|
|
141
|
-
export async function Then_I_see_testid_has_attribute_with_value(
|
|
142
|
-
this: CustomWorld,
|
|
143
|
-
testId: string,
|
|
144
|
-
attr: string,
|
|
145
|
-
value: string
|
|
146
|
-
) {
|
|
147
|
-
const locator = this.page.getByTestId(testId);
|
|
148
|
-
await expect(locator).toHaveAttribute(attr, value, { timeout: 5000 });
|
|
149
|
-
this.log?.(`✅ Verified test ID "${testId}" has attribute "${attr}" with value "${value}".`);
|
|
150
|
-
}
|
|
151
|
-
Then(
|
|
152
|
-
/^I see testid "(.*)" has attribute "(.*)" with value "(.*)"$/,
|
|
153
|
-
Then_I_see_testid_has_attribute_with_value
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Asserts that an element identified by its `data-testid` has a specific attribute, regardless of its value.
|
|
158
|
-
*
|
|
159
|
-
* ```gherkin
|
|
160
|
-
* Then I see testid {string} has attribute {string}
|
|
161
|
-
* ```
|
|
162
|
-
*
|
|
163
|
-
* @param testId - The value of the `data-testid` attribute.
|
|
164
|
-
* @param attr - The name of the attribute expected to exist (e.g., "data-custom-id", "disabled").
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* Then I see testid "main-content" has attribute "data-state"
|
|
168
|
-
* Then I see testid "submit-button" has attribute "disabled"
|
|
169
|
-
*
|
|
170
|
-
* @remarks
|
|
171
|
-
* This step uses Playwright's `page.getByTestId()` to find the element, then retrieves
|
|
172
|
-
* the attribute's value and asserts that it is not `null` (meaning the attribute is present).
|
|
173
|
-
* @category Test ID-Based Attribute Assertion Steps
|
|
174
|
-
*/
|
|
175
|
-
export async function Then_I_see_testid_has_attribute(
|
|
176
|
-
this: CustomWorld,
|
|
177
|
-
testId: string,
|
|
178
|
-
attr: string
|
|
179
|
-
) {
|
|
180
|
-
const locator = this.page.getByTestId(testId);
|
|
181
|
-
const attrValue = await locator.getAttribute(attr, { timeout: 5000 });
|
|
182
|
-
expect(attrValue).not.toBeNull();
|
|
183
|
-
this.log?.(`✅ Verified test ID "${testId}" has attribute "${attr}".`);
|
|
184
|
-
}
|
|
185
|
-
Then(/^I see testid "(.*)" has attribute "(.*)"$/, Then_I_see_testid_has_attribute);
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Asserts that an element identified by its `data-testid` does NOT have a specific attribute.
|
|
189
|
-
*
|
|
190
|
-
* ```gherkin
|
|
191
|
-
* Then I see testid {string} does not have attribute {string}
|
|
192
|
-
* ```
|
|
193
|
-
*
|
|
194
|
-
* @param testId - The value of the `data-testid` attribute.
|
|
195
|
-
* @param attr - The name of the attribute expected NOT to exist.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* Then I see testid "main-content" does not have attribute "data-state"
|
|
199
|
-
* Then I see testid "enabled-button" does not have attribute "disabled"
|
|
200
|
-
*
|
|
201
|
-
* @remarks
|
|
202
|
-
* This step uses Playwright's `page.getByTestId()` to find the element, then retrieves
|
|
203
|
-
* the attribute's value and asserts that it is `null` (meaning the attribute is not present).
|
|
204
|
-
* @category Test ID-Based Attribute Assertion Steps
|
|
205
|
-
*/
|
|
206
|
-
export async function Then_I_see_testid_does_not_have_attribute(
|
|
207
|
-
this: CustomWorld,
|
|
208
|
-
testId: string,
|
|
209
|
-
attr: string
|
|
210
|
-
) {
|
|
211
|
-
const locator = this.page.getByTestId(testId);
|
|
212
|
-
const attrValue = await locator.getAttribute(attr, { timeout: 5000 });
|
|
213
|
-
expect(attrValue).toBeNull();
|
|
214
|
-
this.log?.(`✅ Verified test ID "${testId}" does NOT have attribute "${attr}".`);
|
|
215
|
-
}
|
|
216
|
-
Then(
|
|
217
|
-
/^I see testid "(.*)" does not have attribute "(.*)"$/,
|
|
218
|
-
Then_I_see_testid_does_not_have_attribute
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Asserts that an element identified by its `data-testid` has a specific attribute whose value contains a given substring.
|
|
223
|
-
*
|
|
224
|
-
* ```gherkin
|
|
225
|
-
* Then I see testid {string} attribute {string} contains {string}
|
|
226
|
-
* ```
|
|
227
|
-
*
|
|
228
|
-
* @param testId - The value of the `data-testid` attribute.
|
|
229
|
-
* @param attr - The name of the attribute to check (e.g., "class", "aria-label").
|
|
230
|
-
* @param part - The substring expected to be contained within the attribute's value.
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* Then I see testid "main-content" attribute "class" contains "active"
|
|
234
|
-
* Then I see testid "search-input" attribute "aria-label" contains "search product"
|
|
235
|
-
*
|
|
236
|
-
* @remarks
|
|
237
|
-
* This step uses Playwright's `page.getByTestId()` to find the element and then
|
|
238
|
-
* `expect(locator).toHaveAttribute()` with a regular expression for the contains check.
|
|
239
|
-
* @category Test ID-Based Attribute Assertion Steps
|
|
240
|
-
*/
|
|
241
|
-
export async function Then_I_see_testid_attribute_contains(
|
|
242
|
-
this: CustomWorld,
|
|
243
|
-
testId: string,
|
|
244
|
-
attr: string,
|
|
245
|
-
part: string
|
|
246
|
-
) {
|
|
247
|
-
const locator = this.page.getByTestId(testId);
|
|
248
|
-
await expect(locator).toHaveAttribute(attr, new RegExp(part), { timeout: 5000 });
|
|
249
|
-
this.log?.(`✅ Verified test ID "${testId}" attribute "${attr}" contains "${part}".`);
|
|
250
|
-
}
|
|
251
|
-
Then(
|
|
252
|
-
/^I see testid "(.*)" attribute "(.*)" contains "(.*)"$/,
|
|
253
|
-
Then_I_see_testid_attribute_contains
|
|
254
|
-
);
|