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,353 @@
1
- export {};
1
+ import type { CustomWorld } from "../helpers/world";
2
+ /**
3
+ * Asserts that the status code of the last API response matches the expected number.
4
+ *
5
+ * ```gherkin
6
+ * Then I should see response status {int}
7
+ * ```
8
+ *
9
+ * @param expectedStatus - The expected HTTP status code (e.g., 200, 404).
10
+ *
11
+ * @example
12
+ * When I make request to "https://api.example.com/data"
13
+ * Then I should see response status 200
14
+ *
15
+ * @remarks
16
+ * This step requires a preceding step that stores the API response in
17
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
18
+ * It uses `expect().toBe()` for robust assertion.
19
+ * @category API Response Assertion Steps
20
+ */
21
+ export declare function Then_I_should_see_response_status(this: CustomWorld, expectedStatus: number): void;
22
+ /**
23
+ * Asserts that the status code of the last API response does NOT match the given number.
24
+ *
25
+ * ```gherkin
26
+ * Then I see response status is not {int}
27
+ * ```
28
+ *
29
+ * @param unexpectedStatus - The HTTP status code that is NOT expected.
30
+ *
31
+ * @example
32
+ * When I make request to "https://api.example.com/data"
33
+ * Then I see response status is not 404
34
+ *
35
+ * @remarks
36
+ * This step requires a preceding step that stores the API response in
37
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
38
+ * It uses `expect().not.toBe()` for robust assertion.
39
+ * @category API Response Assertion Steps
40
+ */
41
+ export declare function Then_I_see_response_status_is_not(this: CustomWorld, unexpectedStatus: number): void;
42
+ /**
43
+ * Asserts that the body of the last API response contains the expected text substring.
44
+ *
45
+ * ```gherkin
46
+ * Then I should see response body contains {string}
47
+ * ```
48
+ *
49
+ * @param expectedText - The substring expected to be present in the response body.
50
+ *
51
+ * @example
52
+ * When I make request to "https://api.example.com/users"
53
+ * Then I should see response body contains "John Doe"
54
+ *
55
+ * @remarks
56
+ * This step requires a preceding step that stores the API response in
57
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
58
+ * It uses `expect().toContain()` for robust assertion.
59
+ * @category API Response Assertion Steps
60
+ */
61
+ export declare function Then_I_should_see_response_body_contains(this: CustomWorld, expectedText: string): void;
62
+ /**
63
+ * Asserts that the body of the last API response strictly matches the expected string.
64
+ *
65
+ * ```gherkin
66
+ * Then I see response body {string}
67
+ * ```
68
+ *
69
+ * @param expectedBody - The exact string expected to be the response body.
70
+ *
71
+ * @example
72
+ * When I make request to "https://api.example.com/status"
73
+ * Then I see response body "OK"
74
+ *
75
+ * @remarks
76
+ * This step requires a preceding step that stores the API response in
77
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
78
+ * It performs a strict equality check on the entire response body string.
79
+ * @category API Response Assertion Steps
80
+ */
81
+ export declare function Then_I_see_response_body(this: CustomWorld, expectedBody: string): void;
82
+ /**
83
+ * Asserts that the body of the last API response does NOT contain the given substring.
84
+ *
85
+ * ```gherkin
86
+ * Then I see response body does not contain {string}
87
+ * ```
88
+ *
89
+ * @param unexpectedPart - The substring expected NOT to be present in the response body.
90
+ *
91
+ * @example
92
+ * When I make request to "https://api.example.com/error"
93
+ * Then I see response body does not contain "internal server error"
94
+ *
95
+ * @remarks
96
+ * This step requires a preceding step that stores the API response in
97
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
98
+ * It checks for the absence of the substring within the response body.
99
+ * @category API Response Assertion Steps
100
+ */
101
+ export declare function Then_I_see_response_body_does_not_contain(this: CustomWorld, unexpectedPart: string): void;
102
+ /**
103
+ * Asserts that the body of the last API response is empty (contains only whitespace or is empty).
104
+ *
105
+ * ```gherkin
106
+ * Then I see response body is empty
107
+ * ```
108
+ *
109
+ * @example
110
+ * When I make request to "https://api.example.com/no-content"
111
+ * Then I see response body is empty
112
+ *
113
+ * @remarks
114
+ * This step requires a preceding step that stores the API response in
115
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
116
+ * It trims whitespace and checks if the resulting string is empty.
117
+ * @category API Response Assertion Steps
118
+ */
119
+ export declare function Then_I_see_response_body_is_empty(this: CustomWorld): void;
120
+ /**
121
+ * Asserts that the body of the last API response is NOT empty (contains non-whitespace characters).
122
+ *
123
+ * ```gherkin
124
+ * Then I see response body is not empty
125
+ * ```
126
+ *
127
+ * @example
128
+ * When I make request to "https://api.example.com/data"
129
+ * Then I see response body is not empty
130
+ *
131
+ * @remarks
132
+ * This step requires a preceding step that stores the API response in
133
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
134
+ * It trims whitespace and checks if the resulting string is not empty.
135
+ * @category API Response Assertion Steps
136
+ */
137
+ export declare function Then_I_see_response_body_is_not_empty(this: CustomWorld): void;
138
+ /**
139
+ * Asserts that the body of the last API response is valid JSON.
140
+ *
141
+ * ```gherkin
142
+ * Then I see response body is JSON
143
+ * ```
144
+ *
145
+ * @example
146
+ * When I make request to "https://api.example.com/json-data"
147
+ * Then I see response body is JSON
148
+ *
149
+ * @remarks
150
+ * This step requires a preceding step that stores the API response in
151
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
152
+ * It attempts to parse the response body as JSON. If parsing fails, the step fails.
153
+ * @category API Response Assertion Steps
154
+ */
155
+ export declare function Then_I_see_response_body_is_JSON(this: CustomWorld): void;
156
+ /**
157
+ * Asserts that the body of the last API response is NOT valid JSON.
158
+ *
159
+ * ```gherkin
160
+ * Then I see response body is not JSON
161
+ * ```
162
+ *
163
+ * @example
164
+ * When I make request to "https://api.example.com/plain-text"
165
+ * Then I see response body is not JSON
166
+ *
167
+ * @remarks
168
+ * This step requires a preceding step that stores the API response in
169
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
170
+ * It attempts to parse the response body as JSON and expects the parsing to fail.
171
+ * @category API Response Assertion Steps
172
+ */
173
+ export declare function Then_I_see_response_body_is_not_JSON(this: CustomWorld): void;
174
+ /**
175
+ * Asserts that the body of the last API response matches the given JSON schema.
176
+ *
177
+ * ```gherkin
178
+ * Then I see response body matches JSON schema {string}
179
+ * ```
180
+ *
181
+ * @param schemaPath - The path to the JSON schema file (e.g., "schemas/responseSchema.js").
182
+ *
183
+ * @example
184
+ * When I make request to "https://api.example.com/users/1"
185
+ * Then I see response body matches JSON schema "schemas/userSchema.js"
186
+ *
187
+ * @remarks
188
+ * This step requires a preceding step that stores the API response in
189
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
190
+ * It dynamically imports the schema file and uses `ajv` to validate the JSON response body.
191
+ * Ensure `ajv` is installed (`npm install ajv`) and your schema files are accessible.
192
+ * @category API Response Assertion Steps
193
+ */
194
+ export declare function Then_I_see_response_body_matches_JSON_schema_path(this: CustomWorld, schemaPath: string): Promise<void>;
195
+ /**
196
+ * Asserts that the body of the last API response matches the given JSON schema object directly provided in the step.
197
+ *
198
+ * ```gherkin
199
+ * Then I see response body matches JSON schema:
200
+ * """
201
+ * { "type": "object", "properties": { "id": { "type": "number" } } }
202
+ * """
203
+ * ```
204
+ *
205
+ * @param schema - The JSON schema object (provided as a Cucumber DocString).
206
+ *
207
+ * @example
208
+ * When I make request to "https://api.example.com/users/latest"
209
+ * Then I see response body matches JSON schema:
210
+ * """
211
+ * {
212
+ * "type": "object",
213
+ * "properties": {
214
+ * "id": { "type": "number" },
215
+ * "name": { "type": "string" }
216
+ * },
217
+ * "required": ["id", "name"]
218
+ * }
219
+ * """
220
+ *
221
+ * @remarks
222
+ * This step requires a preceding step that stores the API response in
223
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
224
+ * It expects the schema as a direct JSON string (DocString) in the Gherkin step.
225
+ * Uses `ajv` to validate the JSON response body against this inline schema.
226
+ * Ensure `ajv` is installed (`npm install ajv`).
227
+ * @category API Response Assertion Steps
228
+ */
229
+ export declare function Then_I_see_response_body_matches_JSON_schema_object(this: CustomWorld, schemaString: string): Promise<void>;
230
+ /**
231
+ * Asserts that a specific header in the last API response strictly equals an expected value.
232
+ *
233
+ * ```gherkin
234
+ * Then I see response header {string} equals {string}
235
+ * ```
236
+ *
237
+ * @param headerName - The name of the header (case-insensitive, e.g., "Content-Type").
238
+ * @param expectedValue - The exact expected value of the header.
239
+ *
240
+ * @example
241
+ * When I make request to "https://api.example.com/data"
242
+ * Then I see response header "content-type" equals "application/json"
243
+ *
244
+ * @remarks
245
+ * This step requires a preceding step that stores the API response in
246
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
247
+ * It retrieves the header value and performs a strict equality check.
248
+ * @category API Response Assertion Steps
249
+ */
250
+ export declare function Then_I_see_response_header_equals(this: CustomWorld, headerName: string, expectedValue: string): void;
251
+ /**
252
+ * Asserts that a specific header in the last API response contains a given substring.
253
+ *
254
+ * ```gherkin
255
+ * Then I see response header {string} contains {string}
256
+ * ```
257
+ *
258
+ * @param headerName - The name of the header (case-insensitive, e.g., "Set-Cookie").
259
+ * @param expectedPart - The substring expected to be contained within the header's value.
260
+ *
261
+ * @example
262
+ * When I make request to "https://api.example.com/login"
263
+ * Then I see response header "set-cookie" contains "session_id"
264
+ *
265
+ * @remarks
266
+ * This step requires a preceding step that stores the API response in
267
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
268
+ * It retrieves the header value and checks if it includes the `expectedPart`.
269
+ * @category API Response Assertion Steps
270
+ */
271
+ export declare function Then_I_see_response_header_contains(this: CustomWorld, headerName: string, expectedPart: string): void;
272
+ /**
273
+ * Asserts that a specific header in the last API response does NOT contain a given substring.
274
+ *
275
+ * ```gherkin
276
+ * Then I see response header {string} does not contain {string}
277
+ * ```
278
+ *
279
+ * @param headerName - The name of the header (case-insensitive).
280
+ * @param unexpectedPart - The substring expected NOT to be present within the header's value.
281
+ *
282
+ * @example
283
+ * When I make request to "https://api.example.com/no-cache"
284
+ * Then I see response header "cache-control" does not contain "no-store"
285
+ *
286
+ * @remarks
287
+ * This step requires a preceding step that stores the API response in
288
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
289
+ * It retrieves the header value and asserts that it does not include the `unexpectedPart`.
290
+ * @category API Response Assertion Steps
291
+ */
292
+ export declare function Then_I_see_response_header_does_not_contain(this: CustomWorld, headerName: string, unexpectedPart: string): void;
293
+ /**
294
+ * Asserts that a specific header in the last API response does NOT strictly equal a given value.
295
+ *
296
+ * ```gherkin
297
+ * Then I see response header {string} does not equal {string}
298
+ * ```
299
+ *
300
+ * @param headerName - The name of the header (case-insensitive).
301
+ * @param unexpectedValue - The value that is NOT expected for the header.
302
+ *
303
+ * @example
304
+ * When I make request to "https://api.example.com/html-page"
305
+ * Then I see response header "content-type" does not equal "application/json"
306
+ *
307
+ * @remarks
308
+ * This step requires a preceding step that stores the API response in
309
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
310
+ * It retrieves the header value and asserts that it does not strictly match `unexpectedValue`.
311
+ * @category API Response Assertion Steps
312
+ */
313
+ export declare function Then_I_see_response_header_does_not_equal(this: CustomWorld, headerName: string, unexpectedValue: string): void;
314
+ /**
315
+ * Asserts that a specific header in the last API response exists (is present).
316
+ *
317
+ * ```gherkin
318
+ * Then I see response header {string} exists
319
+ * ```
320
+ *
321
+ * @param headerName - The name of the header expected to exist.
322
+ *
323
+ * @example
324
+ * When I make request to "https://api.example.com/data"
325
+ * Then I see response header "content-length" exists
326
+ *
327
+ * @remarks
328
+ * This step requires a preceding step that stores the API response in
329
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
330
+ * It checks if the header value is defined (not `undefined` or `null`).
331
+ * @category API Response Assertion Steps
332
+ */
333
+ export declare function Then_I_see_response_header_exists(this: CustomWorld, headerName: string): void;
334
+ /**
335
+ * Asserts that a specific header in the last API response does NOT exist (is not present).
336
+ *
337
+ * ```gherkin
338
+ * Then I see response header {string} does not exist
339
+ * ```
340
+ *
341
+ * @param headerName - The name of the header expected NOT to exist.
342
+ *
343
+ * @example
344
+ * When I make request to "https://api.example.com/simple"
345
+ * Then I see response header "x-powered-by" does not exist
346
+ *
347
+ * @remarks
348
+ * This step requires a preceding step that stores the API response in
349
+ * {@link CustomWorld.data.lastResponse | this.data.lastResponse}.
350
+ * It checks if the header value is `undefined` or `null`.
351
+ * @category API Response Assertion Steps
352
+ */
353
+ export declare function Then_I_see_response_header_does_not_exist(this: CustomWorld, headerName: string): void;