playwright-cucumber-ts-steps 0.1.7 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +21 -11
  2. package/lib/actions/clickSteps.d.ts +251 -1
  3. package/lib/actions/clickSteps.js +297 -47
  4. package/lib/actions/cookieSteps.d.ts +18 -1
  5. package/lib/actions/cookieSteps.js +65 -0
  6. package/lib/actions/debugSteps.d.ts +14 -1
  7. package/lib/actions/debugSteps.js +18 -3
  8. package/lib/actions/elementFindSteps.d.ts +668 -1
  9. package/lib/actions/elementFindSteps.js +808 -94
  10. package/lib/actions/fillFormSteps.d.ts +69 -1
  11. package/lib/actions/fillFormSteps.js +178 -71
  12. package/lib/actions/index.d.ts +11 -0
  13. package/lib/actions/index.js +28 -0
  14. package/lib/actions/inputSteps.d.ts +218 -1
  15. package/lib/actions/inputSteps.js +303 -57
  16. package/lib/actions/interceptionSteps.d.ts +169 -1
  17. package/lib/actions/interceptionSteps.js +258 -38
  18. package/lib/actions/miscSteps.d.ts +645 -1
  19. package/lib/actions/miscSteps.js +898 -157
  20. package/lib/actions/mouseSteps.d.ts +143 -1
  21. package/lib/actions/mouseSteps.js +200 -32
  22. package/lib/actions/scrollSteps.d.ts +82 -1
  23. package/lib/actions/scrollSteps.js +116 -16
  24. package/lib/actions/storageSteps.d.ts +174 -1
  25. package/lib/actions/storageSteps.js +253 -33
  26. package/lib/assertions/buttonAndTextVisibilitySteps.d.ts +245 -1
  27. package/lib/assertions/buttonAndTextVisibilitySteps.js +342 -91
  28. package/lib/assertions/cookieSteps.d.ts +75 -1
  29. package/lib/assertions/cookieSteps.js +97 -29
  30. package/lib/assertions/elementSteps.d.ts +264 -1
  31. package/lib/assertions/elementSteps.js +376 -78
  32. package/lib/assertions/formInputSteps.d.ts +248 -1
  33. package/lib/assertions/formInputSteps.js +342 -79
  34. package/lib/assertions/index.d.ts +10 -0
  35. package/lib/assertions/index.js +27 -0
  36. package/lib/assertions/interceptionRequestsSteps.d.ts +353 -1
  37. package/lib/assertions/interceptionRequestsSteps.js +569 -177
  38. package/lib/assertions/locationSteps.d.ts +217 -1
  39. package/lib/assertions/locationSteps.js +287 -64
  40. package/lib/assertions/roleTestIdSteps.d.ts +159 -1
  41. package/lib/assertions/roleTestIdSteps.js +217 -22
  42. package/lib/assertions/semanticSteps.d.ts +176 -1
  43. package/lib/assertions/semanticSteps.js +245 -60
  44. package/lib/assertions/storageSteps.d.ts +149 -1
  45. package/lib/assertions/storageSteps.js +201 -65
  46. package/lib/assertions/visualSteps.d.ts +74 -1
  47. package/lib/assertions/visualSteps.js +178 -45
  48. package/lib/custom_setups/loginHooks.js +19 -2
  49. package/lib/helpers/world.d.ts +3 -0
  50. package/lib/helpers/world.js +11 -5
  51. package/lib/index.d.ts +3 -21
  52. package/lib/index.js +3 -23
  53. package/package.json +9 -2
  54. package/src/actions/clickSteps.ts +364 -142
  55. package/src/actions/cookieSteps.ts +66 -0
  56. package/src/actions/debugSteps.ts +17 -3
  57. package/src/actions/elementFindSteps.ts +822 -117
  58. package/src/actions/fillFormSteps.ts +234 -177
  59. package/src/actions/index.ts +12 -0
  60. package/src/actions/inputSteps.ts +318 -82
  61. package/src/actions/interceptionSteps.ts +295 -57
  62. package/src/actions/miscSteps.ts +984 -254
  63. package/src/actions/mouseSteps.ts +212 -55
  64. package/src/actions/scrollSteps.ts +114 -16
  65. package/src/actions/storageSteps.ts +267 -42
  66. package/src/assertions/buttonAndTextVisibilitySteps.ts +353 -95
  67. package/src/assertions/cookieSteps.ts +115 -36
  68. package/src/assertions/elementSteps.ts +414 -85
  69. package/src/assertions/formInputSteps.ts +375 -108
  70. package/src/assertions/index.ts +11 -0
  71. package/src/assertions/interceptionRequestsSteps.ts +619 -195
  72. package/src/assertions/locationSteps.ts +280 -64
  73. package/src/assertions/roleTestIdSteps.ts +244 -26
  74. package/src/assertions/semanticSteps.ts +257 -69
  75. package/src/assertions/storageSteps.ts +234 -73
  76. package/src/assertions/visualSteps.ts +245 -68
  77. package/src/custom_setups/loginHooks.ts +21 -2
  78. package/src/helpers/world.ts +30 -4
  79. package/src/index.ts +4 -25
@@ -1 +1,217 @@
1
- export {};
1
+ import { DataTable } from "@cucumber/cucumber";
2
+ import { CustomWorld } from "../helpers/world";
3
+ /**
4
+ * Asserts that the current page's full URL exactly matches the expected string.
5
+ *
6
+ * ```gherkin
7
+ * Then I see URL {string}
8
+ * ```
9
+ *
10
+ * @param expectedUrl - The exact URL string expected.
11
+ *
12
+ * @example
13
+ * Then I see URL "https://example.com/dashboard"
14
+ *
15
+ * @remarks
16
+ * This step retrieves the current URL from `this.page.url()` and performs a strict equality check.
17
+ * @category URL Assertion Steps
18
+ */
19
+ export declare function Then_I_see_URL(this: CustomWorld, expectedUrl: string): Promise<void>;
20
+ /**
21
+ * Asserts that the current page's full URL does NOT match the given string.
22
+ *
23
+ * ```gherkin
24
+ * Then I do not see URL {string}
25
+ * ```
26
+ *
27
+ * @param notExpectedUrl - The URL string that is NOT expected.
28
+ *
29
+ * @example
30
+ * Then I do not see URL "https://example.com/login"
31
+ *
32
+ * @remarks
33
+ * This step retrieves the current URL from `this.page.url()` and performs a strict inequality check.
34
+ * @category URL Assertion Steps
35
+ */
36
+ export declare function Then_I_do_not_see_URL(this: CustomWorld, notExpectedUrl: string): Promise<void>;
37
+ /**
38
+ * Asserts that the current page's full URL contains the expected substring.
39
+ *
40
+ * ```gherkin
41
+ * Then I see URL contains {string}
42
+ * ```
43
+ *
44
+ * @param expectedPart - The substring expected to be present in the URL.
45
+ *
46
+ * @example
47
+ * Then I see URL contains "/dashboard"
48
+ *
49
+ * @remarks
50
+ * This step retrieves the current URL from `this.page.url()` and checks if it includes the `expectedPart`.
51
+ * @category URL Assertion Steps
52
+ */
53
+ export declare function Then_I_see_URL_contains(this: CustomWorld, expectedPart: string): Promise<void>;
54
+ /**
55
+ * Asserts that the current page's full URL does NOT contain the given substring.
56
+ *
57
+ * ```gherkin
58
+ * Then I do not see URL contains {string}
59
+ * ```
60
+ *
61
+ * @param notExpectedPart - The substring that is NOT expected to be present in the URL.
62
+ *
63
+ * @example
64
+ * Then I do not see URL contains "/login"
65
+ *
66
+ * @remarks
67
+ * This step retrieves the current URL from `this.page.url()` and asserts that it does not include the `notExpectedPart`.
68
+ * @category URL Assertion Steps
69
+ */
70
+ export declare function Then_I_do_not_see_URL_contains(this: CustomWorld, notExpectedPart: string): Promise<void>;
71
+ /**
72
+ * Asserts that the current `window.location.href` (full URL) matches the expected string.
73
+ * This is an alias for "Then I see URL {string}".
74
+ *
75
+ * ```gherkin
76
+ * Then I see location {string}
77
+ * ```
78
+ *
79
+ * @param expectedHref - The exact `window.location.href` string expected.
80
+ *
81
+ * @example
82
+ * Then I see location "https://example.com/dashboard"
83
+ *
84
+ * @remarks
85
+ * This step executes `window.location.href` in the browser context and compares it strictly.
86
+ * It's functionally identical to {@link Then_I_see_URL | "Then I see URL {string}"}.
87
+ * @category Location Assertion Steps
88
+ */
89
+ export declare function Then_I_see_location(this: CustomWorld, expectedHref: string): Promise<void>;
90
+ /**
91
+ * Asserts that the current `window.location.pathname` (path part of URL) matches the expected string.
92
+ *
93
+ * ```gherkin
94
+ * Then I see pathname {string}
95
+ * ```
96
+ *
97
+ * @param expectedPathname - The exact pathname string expected (e.g., "/dashboard").
98
+ *
99
+ * @example
100
+ * Then I see pathname "/dashboard"
101
+ *
102
+ * @remarks
103
+ * This step executes `window.location.pathname` in the browser context and compares it strictly.
104
+ * @category Location Assertion Steps
105
+ */
106
+ export declare function Then_I_see_pathname(this: CustomWorld, expectedPathname: string): Promise<void>;
107
+ /**
108
+ * Asserts that the current `window.location.pathname` contains the expected substring.
109
+ *
110
+ * ```gherkin
111
+ * Then I see pathname contains {string}
112
+ * ```
113
+ *
114
+ * @param expectedPart - The substring expected to be present in the pathname.
115
+ *
116
+ * @example
117
+ * Then I see pathname contains "/settings/"
118
+ *
119
+ * @remarks
120
+ * This step executes `window.location.pathname` in the browser context and checks for substring presence.
121
+ * @category Location Assertion Steps
122
+ */
123
+ export declare function Then_I_see_pathname_contains(this: CustomWorld, expectedPart: string): Promise<void>;
124
+ /**
125
+ * Asserts that the current `window.location.hash` (fragment identifier) matches the expected string.
126
+ *
127
+ * ```gherkin
128
+ * Then I see hash {string}
129
+ * ```
130
+ *
131
+ * @param expectedHash - The exact hash string expected (e.g., "#section-1").
132
+ *
133
+ * @example
134
+ * Then I see hash "#section"
135
+ *
136
+ * @remarks
137
+ * This step executes `window.location.hash` in the browser context and compares it strictly.
138
+ * @category Location Assertion Steps
139
+ */
140
+ export declare function Then_I_see_hash(this: CustomWorld, expectedHash: string): Promise<void>;
141
+ /**
142
+ * Asserts that the current `window.location.hash` contains the expected substring.
143
+ *
144
+ * ```gherkin
145
+ * Then I see hash contains {string}
146
+ * ```
147
+ *
148
+ * @param expectedPart - The substring expected to be present in the hash.
149
+ *
150
+ * @example
151
+ * Then I see hash contains "details"
152
+ *
153
+ * @remarks
154
+ * This step executes `window.location.hash` in the browser context and checks for substring presence.
155
+ * @category Location Assertion Steps
156
+ */
157
+ export declare function Then_I_see_hash_contains(this: CustomWorld, expectedPart: string): Promise<void>;
158
+ /**
159
+ * Asserts that the current `window.location.search` (query string) matches the expected string.
160
+ *
161
+ * ```gherkin
162
+ * Then I see search {string}
163
+ * ```
164
+ *
165
+ * @param expectedSearch - The exact search string expected (e.g., "?q=test&page=1").
166
+ *
167
+ * @example
168
+ * Then I see search "?q=test"
169
+ *
170
+ * @remarks
171
+ * This step executes `window.location.search` in the browser context and compares it strictly.
172
+ * @category Location Assertion Steps
173
+ */
174
+ export declare function Then_I_see_search(this: CustomWorld, expectedSearch: string): Promise<void>;
175
+ /**
176
+ * Asserts that the current `window.location.search` contains the expected substring.
177
+ *
178
+ * ```gherkin
179
+ * Then I see search contains {string}
180
+ * ```
181
+ *
182
+ * @param expectedPart - The substring expected to be present in the search query.
183
+ *
184
+ * @example
185
+ * Then I see search contains "q=test"
186
+ *
187
+ * @remarks
188
+ * This step executes `window.location.search` in the browser context and checks for substring presence.
189
+ * @category Location Assertion Steps
190
+ */
191
+ export declare function Then_I_see_search_contains(this: CustomWorld, expectedPart: string): Promise<void>;
192
+ /**
193
+ * Asserts that multiple parts of the current `window.location` object match expected values from a data table.
194
+ *
195
+ * ```gherkin
196
+ * Then I see location
197
+ * | key | value |
198
+ * | pathname | /dashboard |
199
+ * | hash | #section |
200
+ * ```
201
+ *
202
+ * @param table - A Cucumber DataTable with `key` and `value` columns, where `key` is a `window.location` property (e.g., "pathname", "hash", "origin").
203
+ *
204
+ * @example
205
+ * Then I see location
206
+ * | key | value |
207
+ * | pathname | /profile |
208
+ * | protocol | https: |
209
+ * | hostname | myapp.com |
210
+ *
211
+ * @remarks
212
+ * This step retrieves various `window.location` properties as an object and then iterates
213
+ * through the data table, asserting that each specified `key` has its corresponding `value`.
214
+ * This allows for flexible and combined assertions on the URL components.
215
+ * @category Location Assertion Steps
216
+ */
217
+ export declare function Then_I_see_location_parts(this: CustomWorld, table: DataTable): Promise<void>;
@@ -1,75 +1,295 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Then_I_see_URL = Then_I_see_URL;
4
+ exports.Then_I_do_not_see_URL = Then_I_do_not_see_URL;
5
+ exports.Then_I_see_URL_contains = Then_I_see_URL_contains;
6
+ exports.Then_I_do_not_see_URL_contains = Then_I_do_not_see_URL_contains;
7
+ exports.Then_I_see_location = Then_I_see_location;
8
+ exports.Then_I_see_pathname = Then_I_see_pathname;
9
+ exports.Then_I_see_pathname_contains = Then_I_see_pathname_contains;
10
+ exports.Then_I_see_hash = Then_I_see_hash;
11
+ exports.Then_I_see_hash_contains = Then_I_see_hash_contains;
12
+ exports.Then_I_see_search = Then_I_see_search;
13
+ exports.Then_I_see_search_contains = Then_I_see_search_contains;
14
+ exports.Then_I_see_location_parts = Then_I_see_location_parts;
3
15
  const cucumber_1 = require("@cucumber/cucumber");
4
16
  const test_1 = require("@playwright/test");
5
- //
6
- // 🌐 URL
7
- //
8
- (0, cucumber_1.Then)("I see URL {string}", async function (expected) {
9
- const url = this.page.url();
10
- (0, test_1.expect)(url).toBe(expected);
11
- });
12
- (0, cucumber_1.Then)("I do not see URL {string}", async function (notExpected) {
13
- const url = this.page.url();
14
- if (url === notExpected)
15
- throw new Error(`Expected not to be on URL "${notExpected}"`);
16
- });
17
- (0, cucumber_1.Then)("I see URL contains {string}", async function (expected) {
18
- const url = this.page.url();
19
- (0, test_1.expect)(url).toContain(expected);
20
- });
21
- (0, cucumber_1.Then)("I do not see URL contains {string}", async function (notExpected) {
22
- const url = this.page.url();
23
- if (url.includes(notExpected)) {
24
- throw new Error(`URL should not contain "${notExpected}", but got "${url}"`);
25
- }
26
- });
27
- //
28
- // 📍 LOCATION PARTS
29
- //
30
- (0, cucumber_1.Then)("I see location {string}", async function (expected) {
31
- const location = await this.page.evaluate(() => window.location.href);
32
- if (location !== expected) {
33
- throw new Error(`Expected location to be "${expected}", but got "${location}"`);
34
- }
35
- });
36
- (0, cucumber_1.Then)("I see pathname {string}", async function (expected) {
17
+ // ===================================================================================
18
+ // ASSERTIONS: URL
19
+ // ===================================================================================
20
+ /**
21
+ * Asserts that the current page's full URL exactly matches the expected string.
22
+ *
23
+ * ```gherkin
24
+ * Then I see URL {string}
25
+ * ```
26
+ *
27
+ * @param expectedUrl - The exact URL string expected.
28
+ *
29
+ * @example
30
+ * Then I see URL "https://example.com/dashboard"
31
+ *
32
+ * @remarks
33
+ * This step retrieves the current URL from `this.page.url()` and performs a strict equality check.
34
+ * @category URL Assertion Steps
35
+ */
36
+ async function Then_I_see_URL(expectedUrl) {
37
+ const currentUrl = this.page.url();
38
+ (0, test_1.expect)(currentUrl).toBe(expectedUrl);
39
+ this.log?.(`✅ Verified URL is exactly: "${expectedUrl}".`);
40
+ }
41
+ (0, cucumber_1.Then)("I see URL {string}", Then_I_see_URL);
42
+ /**
43
+ * Asserts that the current page's full URL does NOT match the given string.
44
+ *
45
+ * ```gherkin
46
+ * Then I do not see URL {string}
47
+ * ```
48
+ *
49
+ * @param notExpectedUrl - The URL string that is NOT expected.
50
+ *
51
+ * @example
52
+ * Then I do not see URL "https://example.com/login"
53
+ *
54
+ * @remarks
55
+ * This step retrieves the current URL from `this.page.url()` and performs a strict inequality check.
56
+ * @category URL Assertion Steps
57
+ */
58
+ async function Then_I_do_not_see_URL(notExpectedUrl) {
59
+ const currentUrl = this.page.url();
60
+ (0, test_1.expect)(currentUrl).not.toBe(notExpectedUrl);
61
+ this.log?.(`✅ Verified URL is NOT: "${notExpectedUrl}".`);
62
+ }
63
+ (0, cucumber_1.Then)("I do not see URL {string}", Then_I_do_not_see_URL);
64
+ /**
65
+ * Asserts that the current page's full URL contains the expected substring.
66
+ *
67
+ * ```gherkin
68
+ * Then I see URL contains {string}
69
+ * ```
70
+ *
71
+ * @param expectedPart - The substring expected to be present in the URL.
72
+ *
73
+ * @example
74
+ * Then I see URL contains "/dashboard"
75
+ *
76
+ * @remarks
77
+ * This step retrieves the current URL from `this.page.url()` and checks if it includes the `expectedPart`.
78
+ * @category URL Assertion Steps
79
+ */
80
+ async function Then_I_see_URL_contains(expectedPart) {
81
+ const currentUrl = this.page.url();
82
+ (0, test_1.expect)(currentUrl).toContain(expectedPart);
83
+ this.log?.(`✅ Verified URL contains: "${expectedPart}".`);
84
+ }
85
+ (0, cucumber_1.Then)("I see URL contains {string}", Then_I_see_URL_contains);
86
+ /**
87
+ * Asserts that the current page's full URL does NOT contain the given substring.
88
+ *
89
+ * ```gherkin
90
+ * Then I do not see URL contains {string}
91
+ * ```
92
+ *
93
+ * @param notExpectedPart - The substring that is NOT expected to be present in the URL.
94
+ *
95
+ * @example
96
+ * Then I do not see URL contains "/login"
97
+ *
98
+ * @remarks
99
+ * This step retrieves the current URL from `this.page.url()` and asserts that it does not include the `notExpectedPart`.
100
+ * @category URL Assertion Steps
101
+ */
102
+ async function Then_I_do_not_see_URL_contains(notExpectedPart) {
103
+ const currentUrl = this.page.url();
104
+ (0, test_1.expect)(currentUrl).not.toContain(notExpectedPart);
105
+ this.log?.(`✅ Verified URL does NOT contain: "${notExpectedPart}".`);
106
+ }
107
+ (0, cucumber_1.Then)("I do not see URL contains {string}", Then_I_do_not_see_URL_contains);
108
+ // ===================================================================================
109
+ // ASSERTIONS: LOCATION PARTS (HREF, PATHNAME, HASH, SEARCH)
110
+ // ===================================================================================
111
+ /**
112
+ * Asserts that the current `window.location.href` (full URL) matches the expected string.
113
+ * This is an alias for "Then I see URL {string}".
114
+ *
115
+ * ```gherkin
116
+ * Then I see location {string}
117
+ * ```
118
+ *
119
+ * @param expectedHref - The exact `window.location.href` string expected.
120
+ *
121
+ * @example
122
+ * Then I see location "https://example.com/dashboard"
123
+ *
124
+ * @remarks
125
+ * This step executes `window.location.href` in the browser context and compares it strictly.
126
+ * It's functionally identical to {@link Then_I_see_URL | "Then I see URL {string}"}.
127
+ * @category Location Assertion Steps
128
+ */
129
+ async function Then_I_see_location(expectedHref) {
130
+ const locationHref = await this.page.evaluate(() => window.location.href);
131
+ (0, test_1.expect)(locationHref).toBe(expectedHref);
132
+ this.log?.(`✅ Verified location href is exactly: "${expectedHref}".`);
133
+ }
134
+ (0, cucumber_1.Then)("I see location {string}", Then_I_see_location);
135
+ /**
136
+ * Asserts that the current `window.location.pathname` (path part of URL) matches the expected string.
137
+ *
138
+ * ```gherkin
139
+ * Then I see pathname {string}
140
+ * ```
141
+ *
142
+ * @param expectedPathname - The exact pathname string expected (e.g., "/dashboard").
143
+ *
144
+ * @example
145
+ * Then I see pathname "/dashboard"
146
+ *
147
+ * @remarks
148
+ * This step executes `window.location.pathname` in the browser context and compares it strictly.
149
+ * @category Location Assertion Steps
150
+ */
151
+ async function Then_I_see_pathname(expectedPathname) {
37
152
  const pathname = await this.page.evaluate(() => window.location.pathname);
38
- if (pathname !== expected) {
39
- throw new Error(`Expected pathname "${expected}", but got "${pathname}"`);
40
- }
41
- });
42
- (0, cucumber_1.Then)("I see pathname contains {string}", async function (part) {
153
+ (0, test_1.expect)(pathname).toBe(expectedPathname);
154
+ this.log?.(`✅ Verified pathname is exactly: "${expectedPathname}".`);
155
+ }
156
+ (0, cucumber_1.Then)("I see pathname {string}", Then_I_see_pathname);
157
+ /**
158
+ * Asserts that the current `window.location.pathname` contains the expected substring.
159
+ *
160
+ * ```gherkin
161
+ * Then I see pathname contains {string}
162
+ * ```
163
+ *
164
+ * @param expectedPart - The substring expected to be present in the pathname.
165
+ *
166
+ * @example
167
+ * Then I see pathname contains "/settings/"
168
+ *
169
+ * @remarks
170
+ * This step executes `window.location.pathname` in the browser context and checks for substring presence.
171
+ * @category Location Assertion Steps
172
+ */
173
+ async function Then_I_see_pathname_contains(expectedPart) {
43
174
  const pathname = await this.page.evaluate(() => window.location.pathname);
44
- if (!pathname.includes(part)) {
45
- throw new Error(`Pathname does not contain "${part}". Got: "${pathname}"`);
46
- }
47
- });
48
- (0, cucumber_1.Then)("I see hash {string}", async function (expected) {
175
+ (0, test_1.expect)(pathname).toContain(expectedPart);
176
+ this.log?.(`✅ Verified pathname contains: "${expectedPart}".`);
177
+ }
178
+ (0, cucumber_1.Then)("I see pathname contains {string}", Then_I_see_pathname_contains);
179
+ /**
180
+ * Asserts that the current `window.location.hash` (fragment identifier) matches the expected string.
181
+ *
182
+ * ```gherkin
183
+ * Then I see hash {string}
184
+ * ```
185
+ *
186
+ * @param expectedHash - The exact hash string expected (e.g., "#section-1").
187
+ *
188
+ * @example
189
+ * Then I see hash "#section"
190
+ *
191
+ * @remarks
192
+ * This step executes `window.location.hash` in the browser context and compares it strictly.
193
+ * @category Location Assertion Steps
194
+ */
195
+ async function Then_I_see_hash(expectedHash) {
49
196
  const hash = await this.page.evaluate(() => window.location.hash);
50
- if (hash !== expected) {
51
- throw new Error(`Expected hash "${expected}", but got "${hash}"`);
52
- }
53
- });
54
- (0, cucumber_1.Then)("I see hash contains {string}", async function (part) {
197
+ (0, test_1.expect)(hash).toBe(expectedHash);
198
+ this.log?.(`✅ Verified hash is exactly: "${expectedHash}".`);
199
+ }
200
+ (0, cucumber_1.Then)("I see hash {string}", Then_I_see_hash);
201
+ /**
202
+ * Asserts that the current `window.location.hash` contains the expected substring.
203
+ *
204
+ * ```gherkin
205
+ * Then I see hash contains {string}
206
+ * ```
207
+ *
208
+ * @param expectedPart - The substring expected to be present in the hash.
209
+ *
210
+ * @example
211
+ * Then I see hash contains "details"
212
+ *
213
+ * @remarks
214
+ * This step executes `window.location.hash` in the browser context and checks for substring presence.
215
+ * @category Location Assertion Steps
216
+ */
217
+ async function Then_I_see_hash_contains(expectedPart) {
55
218
  const hash = await this.page.evaluate(() => window.location.hash);
56
- if (!hash.includes(part)) {
57
- throw new Error(`Expected hash to contain "${part}", but got "${hash}"`);
58
- }
59
- });
60
- (0, cucumber_1.Then)("I see search {string}", async function (expected) {
219
+ (0, test_1.expect)(hash).toContain(expectedPart);
220
+ this.log?.(`✅ Verified hash contains: "${expectedPart}".`);
221
+ }
222
+ (0, cucumber_1.Then)("I see hash contains {string}", Then_I_see_hash_contains);
223
+ /**
224
+ * Asserts that the current `window.location.search` (query string) matches the expected string.
225
+ *
226
+ * ```gherkin
227
+ * Then I see search {string}
228
+ * ```
229
+ *
230
+ * @param expectedSearch - The exact search string expected (e.g., "?q=test&page=1").
231
+ *
232
+ * @example
233
+ * Then I see search "?q=test"
234
+ *
235
+ * @remarks
236
+ * This step executes `window.location.search` in the browser context and compares it strictly.
237
+ * @category Location Assertion Steps
238
+ */
239
+ async function Then_I_see_search(expectedSearch) {
61
240
  const search = await this.page.evaluate(() => window.location.search);
62
- if (search !== expected) {
63
- throw new Error(`Expected search to be "${expected}", but got "${search}"`);
64
- }
65
- });
66
- (0, cucumber_1.Then)("I see search contains {string}", async function (part) {
241
+ (0, test_1.expect)(search).toBe(expectedSearch);
242
+ this.log?.(`✅ Verified search is exactly: "${expectedSearch}".`);
243
+ }
244
+ (0, cucumber_1.Then)("I see search {string}", Then_I_see_search);
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
+ async function Then_I_see_search_contains(expectedPart) {
67
262
  const search = await this.page.evaluate(() => window.location.search);
68
- if (!search.includes(part)) {
69
- throw new Error(`Search does not contain "${part}". Got: "${search}"`);
70
- }
71
- });
72
- (0, cucumber_1.Then)("I see location", async function (table) {
263
+ (0, test_1.expect)(search).toContain(expectedPart);
264
+ this.log?.(`✅ Verified search contains: "${expectedPart}".`);
265
+ }
266
+ (0, cucumber_1.Then)("I see search contains {string}", Then_I_see_search_contains);
267
+ /**
268
+ * Asserts that multiple parts of the current `window.location` object match expected values from a data table.
269
+ *
270
+ * ```gherkin
271
+ * Then I see location
272
+ * | key | value |
273
+ * | pathname | /dashboard |
274
+ * | hash | #section |
275
+ * ```
276
+ *
277
+ * @param table - A Cucumber DataTable with `key` and `value` columns, where `key` is a `window.location` property (e.g., "pathname", "hash", "origin").
278
+ *
279
+ * @example
280
+ * Then I see location
281
+ * | key | value |
282
+ * | pathname | /profile |
283
+ * | protocol | https: |
284
+ * | hostname | myapp.com |
285
+ *
286
+ * @remarks
287
+ * This step retrieves various `window.location` properties as an object and then iterates
288
+ * through the data table, asserting that each specified `key` has its corresponding `value`.
289
+ * This allows for flexible and combined assertions on the URL components.
290
+ * @category Location Assertion Steps
291
+ */
292
+ async function Then_I_see_location_parts(table) {
73
293
  const location = await this.page.evaluate(() => ({
74
294
  href: window.location.href,
75
295
  origin: window.location.origin,
@@ -82,6 +302,9 @@ const test_1 = require("@playwright/test");
82
302
  hash: window.location.hash,
83
303
  }));
84
304
  for (const [key, expected] of table.rows()) {
85
- (0, test_1.expect)(location[key]).toBe(expected);
305
+ const actual = location[key];
306
+ (0, test_1.expect)(actual, `Location part "${key}" mismatch: Expected "${expected}", but got "${actual}".`).toBe(expected);
307
+ this.log?.(`✅ Verified location part "${key}" is "${expected}".`);
86
308
  }
87
- });
309
+ }
310
+ (0, cucumber_1.Then)("I see location", Then_I_see_location_parts);