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.
Files changed (132) hide show
  1. package/README.md +195 -256
  2. package/dist/backend/actions/index.js +4 -0
  3. package/dist/backend/actions/interactions.js +23 -0
  4. package/dist/backend/actions/navigation.js +19 -0
  5. package/dist/backend/api/assertions.js +26 -0
  6. package/dist/backend/api/index.js +4 -0
  7. package/dist/backend/api/requests.js +24 -0
  8. package/dist/backend/api/state.js +15 -0
  9. package/dist/backend/assertions/expectVisible.js +8 -0
  10. package/dist/backend/assertions/index.js +5 -0
  11. package/dist/backend/assertions/pageState.js +25 -0
  12. package/dist/backend/assertions/text.js +20 -0
  13. package/dist/backend/assertions/visibility.js +20 -0
  14. package/dist/backend/auth/index.js +71 -0
  15. package/dist/backend/elements/alerts.js +21 -0
  16. package/dist/backend/elements/forms.js +59 -0
  17. package/dist/backend/elements/frames.js +25 -0
  18. package/dist/backend/elements/index.js +5 -0
  19. package/dist/core/registry.js +20 -0
  20. package/dist/core/runner.js +136 -0
  21. package/dist/index.js +10 -0
  22. package/dist/reporting/index.js +43 -0
  23. package/package.json +19 -101
  24. package/LICENSE +0 -21
  25. package/lib/actions/clickSteps.d.ts +0 -251
  26. package/lib/actions/clickSteps.js +0 -415
  27. package/lib/actions/cookieSteps.d.ts +0 -18
  28. package/lib/actions/cookieSteps.js +0 -93
  29. package/lib/actions/debugSteps.d.ts +0 -14
  30. package/lib/actions/debugSteps.js +0 -23
  31. package/lib/actions/elementFindSteps.d.ts +0 -668
  32. package/lib/actions/elementFindSteps.js +0 -931
  33. package/lib/actions/fillFormSteps.d.ts +0 -69
  34. package/lib/actions/fillFormSteps.js +0 -237
  35. package/lib/actions/index.d.ts +0 -11
  36. package/lib/actions/index.js +0 -28
  37. package/lib/actions/inputSteps.d.ts +0 -218
  38. package/lib/actions/inputSteps.js +0 -343
  39. package/lib/actions/interceptionSteps.d.ts +0 -169
  40. package/lib/actions/interceptionSteps.js +0 -291
  41. package/lib/actions/miscSteps.d.ts +0 -645
  42. package/lib/actions/miscSteps.js +0 -1061
  43. package/lib/actions/mouseSteps.d.ts +0 -143
  44. package/lib/actions/mouseSteps.js +0 -234
  45. package/lib/actions/scrollSteps.d.ts +0 -82
  46. package/lib/actions/scrollSteps.js +0 -123
  47. package/lib/actions/storageSteps.d.ts +0 -174
  48. package/lib/actions/storageSteps.js +0 -292
  49. package/lib/assertions/buttonAndTextVisibilitySteps.d.ts +0 -245
  50. package/lib/assertions/buttonAndTextVisibilitySteps.js +0 -401
  51. package/lib/assertions/cookieSteps.d.ts +0 -75
  52. package/lib/assertions/cookieSteps.js +0 -113
  53. package/lib/assertions/elementSteps.d.ts +0 -264
  54. package/lib/assertions/elementSteps.js +0 -388
  55. package/lib/assertions/formInputSteps.d.ts +0 -248
  56. package/lib/assertions/formInputSteps.js +0 -350
  57. package/lib/assertions/index.d.ts +0 -10
  58. package/lib/assertions/index.js +0 -27
  59. package/lib/assertions/interceptionRequestsSteps.d.ts +0 -353
  60. package/lib/assertions/interceptionRequestsSteps.js +0 -593
  61. package/lib/assertions/locationSteps.d.ts +0 -217
  62. package/lib/assertions/locationSteps.js +0 -310
  63. package/lib/assertions/roleTestIdSteps.d.ts +0 -159
  64. package/lib/assertions/roleTestIdSteps.js +0 -221
  65. package/lib/assertions/semanticSteps.d.ts +0 -176
  66. package/lib/assertions/semanticSteps.js +0 -252
  67. package/lib/assertions/storageSteps.d.ts +0 -149
  68. package/lib/assertions/storageSteps.js +0 -210
  69. package/lib/assertions/visualSteps.d.ts +0 -74
  70. package/lib/assertions/visualSteps.js +0 -209
  71. package/lib/custom_setups/loginHooks.d.ts +0 -1
  72. package/lib/custom_setups/loginHooks.js +0 -130
  73. package/lib/helpers/checkPeerDeps.d.ts +0 -1
  74. package/lib/helpers/checkPeerDeps.js +0 -19
  75. package/lib/helpers/compareSnapshots.d.ts +0 -6
  76. package/lib/helpers/compareSnapshots.js +0 -20
  77. package/lib/helpers/hooks.d.ts +0 -1
  78. package/lib/helpers/hooks.js +0 -210
  79. package/lib/helpers/utils/fakerUtils.d.ts +0 -1
  80. package/lib/helpers/utils/fakerUtils.js +0 -60
  81. package/lib/helpers/utils/index.d.ts +0 -4
  82. package/lib/helpers/utils/index.js +0 -20
  83. package/lib/helpers/utils/optionsUtils.d.ts +0 -24
  84. package/lib/helpers/utils/optionsUtils.js +0 -88
  85. package/lib/helpers/utils/resolveUtils.d.ts +0 -6
  86. package/lib/helpers/utils/resolveUtils.js +0 -72
  87. package/lib/helpers/utils/sessionUtils.d.ts +0 -3
  88. package/lib/helpers/utils/sessionUtils.js +0 -40
  89. package/lib/helpers/world.d.ts +0 -34
  90. package/lib/helpers/world.js +0 -110
  91. package/lib/iframes/frames.d.ts +0 -1
  92. package/lib/iframes/frames.js +0 -11
  93. package/lib/index.d.ts +0 -10
  94. package/lib/index.js +0 -28
  95. package/lib/register.d.ts +0 -1
  96. package/lib/register.js +0 -6
  97. package/src/actions/clickSteps.ts +0 -429
  98. package/src/actions/cookieSteps.ts +0 -95
  99. package/src/actions/debugSteps.ts +0 -21
  100. package/src/actions/elementFindSteps.ts +0 -961
  101. package/src/actions/fillFormSteps.ts +0 -270
  102. package/src/actions/index.ts +0 -12
  103. package/src/actions/inputSteps.ts +0 -354
  104. package/src/actions/interceptionSteps.ts +0 -325
  105. package/src/actions/miscSteps.ts +0 -1144
  106. package/src/actions/mouseSteps.ts +0 -256
  107. package/src/actions/scrollSteps.ts +0 -122
  108. package/src/actions/storageSteps.ts +0 -308
  109. package/src/assertions/buttonAndTextVisibilitySteps.ts +0 -436
  110. package/src/assertions/cookieSteps.ts +0 -131
  111. package/src/assertions/elementSteps.ts +0 -432
  112. package/src/assertions/formInputSteps.ts +0 -377
  113. package/src/assertions/index.ts +0 -11
  114. package/src/assertions/interceptionRequestsSteps.ts +0 -640
  115. package/src/assertions/locationSteps.ts +0 -315
  116. package/src/assertions/roleTestIdSteps.ts +0 -254
  117. package/src/assertions/semanticSteps.ts +0 -267
  118. package/src/assertions/storageSteps.ts +0 -250
  119. package/src/assertions/visualSteps.ts +0 -275
  120. package/src/custom_setups/loginHooks.ts +0 -154
  121. package/src/helpers/checkPeerDeps.ts +0 -19
  122. package/src/helpers/compareSnapshots.ts +0 -35
  123. package/src/helpers/hooks.ts +0 -212
  124. package/src/helpers/utils/fakerUtils.ts +0 -64
  125. package/src/helpers/utils/index.ts +0 -4
  126. package/src/helpers/utils/optionsUtils.ts +0 -104
  127. package/src/helpers/utils/resolveUtils.ts +0 -74
  128. package/src/helpers/utils/sessionUtils.ts +0 -36
  129. package/src/helpers/world.ts +0 -119
  130. package/src/iframes/frames.ts +0 -15
  131. package/src/index.ts +0 -18
  132. package/src/register.ts +0 -4
@@ -1,217 +0,0 @@
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,310 +0,0 @@
1
- "use strict";
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;
15
- const cucumber_1 = require("@cucumber/cucumber");
16
- const test_1 = require("@playwright/test");
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) {
152
- const pathname = await this.page.evaluate(() => window.location.pathname);
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) {
174
- const pathname = await this.page.evaluate(() => window.location.pathname);
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) {
196
- const hash = await this.page.evaluate(() => window.location.hash);
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) {
218
- const hash = await this.page.evaluate(() => window.location.hash);
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) {
240
- const search = await this.page.evaluate(() => window.location.search);
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) {
262
- const search = await this.page.evaluate(() => window.location.search);
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) {
293
- const location = await this.page.evaluate(() => ({
294
- href: window.location.href,
295
- origin: window.location.origin,
296
- protocol: window.location.protocol,
297
- host: window.location.host,
298
- hostname: window.location.hostname,
299
- port: window.location.port,
300
- pathname: window.location.pathname,
301
- search: window.location.search,
302
- hash: window.location.hash,
303
- }));
304
- for (const [key, expected] of table.rows()) {
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}".`);
308
- }
309
- }
310
- (0, cucumber_1.Then)("I see location", Then_I_see_location_parts);
@@ -1,159 +0,0 @@
1
- import { CustomWorld } from "../helpers/world";
2
- /**
3
- * Asserts that an element with the given ARIA role and exact accessible name is visible on the page.
4
- *
5
- * ```gherkin
6
- * Then I see role {string} with name {string}
7
- * ```
8
- *
9
- * @param role - The ARIA role of the element (e.g., "button", "heading", "textbox").
10
- * @param name - The exact accessible name of the element (e.g., button text, label text).
11
- *
12
- * @example
13
- * Then I see role "button" with name "Submit"
14
- * Then I see role "heading" with name "Welcome"
15
- *
16
- * @remarks
17
- * This step uses Playwright's `page.getByRole()` with `exact: true` for precise matching.
18
- * It asserts that the matched element is visible in the viewport.
19
- * @category Role-Based Assertion Steps
20
- */
21
- export declare function Then_I_see_role_with_name(this: CustomWorld, role: string, name: string): Promise<void>;
22
- /**
23
- * Asserts that an element with the given ARIA role and exact accessible name does NOT exist in the DOM.
24
- *
25
- * ```gherkin
26
- * Then I do not see role {string} with name {string}
27
- * ```
28
- *
29
- * @param role - The ARIA role of the element.
30
- * @param name - The exact accessible name of the element.
31
- *
32
- * @example
33
- * Then I do not see role "button" with name "Cancel"
34
- * Then I do not see role "alert" with name "Error message"
35
- *
36
- * @remarks
37
- * This step uses Playwright's `page.getByRole()` with `exact: true` and asserts that
38
- * no such element exists in the DOM (i.e., its count is 0).
39
- * @category Role-Based Assertion Steps
40
- */
41
- export declare function Then_I_do_not_see_role_with_name(this: CustomWorld, role: string, name: string): Promise<void>;
42
- /**
43
- * Asserts that an element with the given `data-testid` attribute (or configured test ID) is visible on the page.
44
- *
45
- * ```gherkin
46
- * Then I see testid {string}
47
- * ```
48
- *
49
- * @param testId - The value of the `data-testid` attribute.
50
- *
51
- * @example
52
- * Then I see testid "main-content"
53
- * Then I see testid "user-profile-section"
54
- *
55
- * @remarks
56
- * This step uses Playwright's `page.getByTestId()` and asserts that the matched element is visible.
57
- * @category Test ID-Based Assertion Steps
58
- */
59
- export declare function Then_I_see_testid(this: CustomWorld, testId: string): Promise<void>;
60
- /**
61
- * Asserts that an element with the given `data-testid` attribute (or configured test ID) does NOT exist in the DOM.
62
- *
63
- * ```gherkin
64
- * Then I do not see testid {string}
65
- * ```
66
- *
67
- * @param testId - The value of the `data-testid` attribute.
68
- *
69
- * @example
70
- * Then I do not see testid "sidebar"
71
- * Then I do not see testid "legacy-component"
72
- *
73
- * @remarks
74
- * This step uses Playwright's `page.getByTestId()` and asserts that no such element exists (i.e., its count is 0).
75
- * @category Test ID-Based Assertion Steps
76
- */
77
- export declare function Then_I_do_not_see_testid(this: CustomWorld, testId: string): Promise<void>;
78
- /**
79
- * Asserts that an element identified by its `data-testid` has a specific attribute with an exact expected value.
80
- *
81
- * ```gherkin
82
- * Then I see testid {string} has attribute {string} with value {string}
83
- * ```
84
- *
85
- * @param testId - The value of the `data-testid` attribute.
86
- * @param attr - The name of the attribute (e.g., "data-state", "aria-expanded").
87
- * @param value - The exact expected value of the attribute.
88
- *
89
- * @example
90
- * Then I see testid "main-content" has attribute "data-state" with value "active"
91
- * Then I see testid "toggle-button" has attribute "aria-pressed" with value "true"
92
- *
93
- * @remarks
94
- * This step uses Playwright's `page.getByTestId()` to find the element and then
95
- * `expect(locator).toHaveAttribute()` for the assertion.
96
- * @category Test ID-Based Attribute Assertion Steps
97
- */
98
- export declare function Then_I_see_testid_has_attribute_with_value(this: CustomWorld, testId: string, attr: string, value: string): Promise<void>;
99
- /**
100
- * Asserts that an element identified by its `data-testid` has a specific attribute, regardless of its value.
101
- *
102
- * ```gherkin
103
- * Then I see testid {string} has attribute {string}
104
- * ```
105
- *
106
- * @param testId - The value of the `data-testid` attribute.
107
- * @param attr - The name of the attribute expected to exist (e.g., "data-custom-id", "disabled").
108
- *
109
- * @example
110
- * Then I see testid "main-content" has attribute "data-state"
111
- * Then I see testid "submit-button" has attribute "disabled"
112
- *
113
- * @remarks
114
- * This step uses Playwright's `page.getByTestId()` to find the element, then retrieves
115
- * the attribute's value and asserts that it is not `null` (meaning the attribute is present).
116
- * @category Test ID-Based Attribute Assertion Steps
117
- */
118
- export declare function Then_I_see_testid_has_attribute(this: CustomWorld, testId: string, attr: string): Promise<void>;
119
- /**
120
- * Asserts that an element identified by its `data-testid` does NOT have a specific attribute.
121
- *
122
- * ```gherkin
123
- * Then I see testid {string} does not have attribute {string}
124
- * ```
125
- *
126
- * @param testId - The value of the `data-testid` attribute.
127
- * @param attr - The name of the attribute expected NOT to exist.
128
- *
129
- * @example
130
- * Then I see testid "main-content" does not have attribute "data-state"
131
- * Then I see testid "enabled-button" does not have attribute "disabled"
132
- *
133
- * @remarks
134
- * This step uses Playwright's `page.getByTestId()` to find the element, then retrieves
135
- * the attribute's value and asserts that it is `null` (meaning the attribute is not present).
136
- * @category Test ID-Based Attribute Assertion Steps
137
- */
138
- export declare function Then_I_see_testid_does_not_have_attribute(this: CustomWorld, testId: string, attr: string): Promise<void>;
139
- /**
140
- * Asserts that an element identified by its `data-testid` has a specific attribute whose value contains a given substring.
141
- *
142
- * ```gherkin
143
- * Then I see testid {string} attribute {string} contains {string}
144
- * ```
145
- *
146
- * @param testId - The value of the `data-testid` attribute.
147
- * @param attr - The name of the attribute to check (e.g., "class", "aria-label").
148
- * @param part - The substring expected to be contained within the attribute's value.
149
- *
150
- * @example
151
- * Then I see testid "main-content" attribute "class" contains "active"
152
- * Then I see testid "search-input" attribute "aria-label" contains "search product"
153
- *
154
- * @remarks
155
- * This step uses Playwright's `page.getByTestId()` to find the element and then
156
- * `expect(locator).toHaveAttribute()` with a regular expression for the contains check.
157
- * @category Test ID-Based Attribute Assertion Steps
158
- */
159
- export declare function Then_I_see_testid_attribute_contains(this: CustomWorld, testId: string, attr: string, part: string): Promise<void>;