@vickbk/tests 0.0.0-stage → 0.2.0

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 (59) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE +21 -0
  3. package/README.md +225 -2
  4. package/dist/console-Cf1taTRK.mjs +39 -0
  5. package/dist/console-Cf1taTRK.mjs.map +1 -0
  6. package/dist/dom-DeHbD1ni.mjs +459 -0
  7. package/dist/dom-DeHbD1ni.mjs.map +1 -0
  8. package/dist/index-CKsosUpb.d.mts +249 -0
  9. package/dist/index-CKsosUpb.d.mts.map +1 -0
  10. package/dist/index-DtGBqDev.d.mts +25 -0
  11. package/dist/index-DtGBqDev.d.mts.map +1 -0
  12. package/dist/index.cjs +3 -0
  13. package/dist/index.d.cts +6 -0
  14. package/dist/index.d.cts.map +1 -0
  15. package/dist/index.d.mts +6 -0
  16. package/dist/index.d.mts.map +1 -0
  17. package/dist/index.mjs +1 -0
  18. package/dist/pattern-to-regex-BrMJtzu8.cjs +19 -0
  19. package/dist/pattern-to-regex-BrMJtzu8.cjs.map +1 -0
  20. package/dist/pattern-to-regex-CO5Y0oDU.mjs +14 -0
  21. package/dist/pattern-to-regex-CO5Y0oDU.mjs.map +1 -0
  22. package/dist/playwright.cjs +327 -0
  23. package/dist/playwright.cjs.map +1 -0
  24. package/dist/playwright.d.cts +254 -0
  25. package/dist/playwright.d.cts.map +1 -0
  26. package/dist/playwright.d.mts +254 -0
  27. package/dist/playwright.d.mts.map +1 -0
  28. package/dist/playwright.mjs +308 -0
  29. package/dist/playwright.mjs.map +1 -0
  30. package/dist/promises.cjs +45 -0
  31. package/dist/promises.cjs.map +1 -0
  32. package/dist/promises.d.cts +34 -0
  33. package/dist/promises.d.cts.map +1 -0
  34. package/dist/promises.d.mts +34 -0
  35. package/dist/promises.d.mts.map +1 -0
  36. package/dist/promises.mjs +43 -0
  37. package/dist/promises.mjs.map +1 -0
  38. package/dist/react.cjs +173 -0
  39. package/dist/react.cjs.map +1 -0
  40. package/dist/react.d.cts +17 -0
  41. package/dist/react.d.cts.map +1 -0
  42. package/dist/react.d.mts +17 -0
  43. package/dist/react.d.mts.map +1 -0
  44. package/dist/react.mjs +170 -0
  45. package/dist/react.mjs.map +1 -0
  46. package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
  47. package/dist/types-BlSFP07Z.d.cts +8 -0
  48. package/dist/types-BlSFP07Z.d.cts.map +1 -0
  49. package/dist/types-BlSFP07Z.d.mts +8 -0
  50. package/dist/types-BlSFP07Z.d.mts.map +1 -0
  51. package/dist/vitest/console.d.mts +2 -0
  52. package/dist/vitest/console.mjs +1 -0
  53. package/dist/vitest/dom.d.mts +2 -0
  54. package/dist/vitest/dom.mjs +1 -0
  55. package/dist/vitest.d.mts +49 -0
  56. package/dist/vitest.d.mts.map +1 -0
  57. package/dist/vitest.mjs +57 -0
  58. package/dist/vitest.mjs.map +1 -0
  59. package/package.json +165 -3
@@ -0,0 +1,254 @@
1
+ import { i as TEXT_WITH_NTH, n as TEXT_MATCHER, r as TEXT_PATTERN, t as LABEL_LOCATOR } from "./types-BlSFP07Z.mjs";
2
+ import { Locator, Page } from "@playwright/test";
3
+ //#region src/features/playwright/modules/assertions/utils/isChecked.d.ts
4
+ /**
5
+ * Asserts that the element selected by the CSS selector is checked.
6
+ *
7
+ * @param page The Playwright page to search.
8
+ * @param selector CSS selector for a checkbox or radio input.
9
+ * @returns The checked locator.
10
+ * @example
11
+ * ```ts
12
+ * const checkbox = await isChecked(page, "#terms");
13
+ * ```
14
+ */
15
+ export declare function isChecked(page: Page, selector: string): Promise<Locator>;
16
+ //#endregion
17
+ //#region src/features/playwright/modules/assertions/utils/isNotChecked.d.ts
18
+ /**
19
+ * Asserts that the element selected by the CSS selector is not checked.
20
+ *
21
+ * @param page The Playwright page to search.
22
+ * @param selector CSS selector for a checkbox or radio input.
23
+ * @returns The unchecked locator.
24
+ * @example
25
+ * ```ts
26
+ * const checkbox = await isNotChecked(page, "#terms");
27
+ * ```
28
+ */
29
+ export declare function isNotChecked(page: Page, selector: string): Promise<Locator>;
30
+ //#endregion
31
+ //#region src/features/playwright/modules/assertions/utils/shouldNotSee.d.ts
32
+ /**
33
+ * Asserts that each text matcher is not visible on the page.
34
+ *
35
+ * @param page The Playwright page to inspect.
36
+ * @param textes Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.
37
+ * @returns A promise that resolves when every matching element is not visible.
38
+ * @example
39
+ * ```ts
40
+ * await shouldNotSee(page, "Error message");
41
+ * ```
42
+ */
43
+ export declare function shouldNotSee(page: Page, ...textes: TEXT_MATCHER[]): Promise<void>;
44
+ //#endregion
45
+ //#region src/features/playwright/modules/assertions/utils/shouldSee.d.ts
46
+ /**
47
+ * Asserts that each text matcher is visible on the page.
48
+ *
49
+ * @param page The Playwright page to inspect.
50
+ * @param textes Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.
51
+ * @returns A promise that resolves when every matching element is visible.
52
+ * @example
53
+ * ```ts
54
+ * await shouldSee(page, "Welcome", [/Saved/i, 0]);
55
+ * ```
56
+ */
57
+ export declare function shouldSee(page: Page, ...textes: TEXT_MATCHER[]): Promise<void>;
58
+ //#endregion
59
+ //#region src/features/playwright/modules/interactions/utils/clickBodyCorner.d.ts
60
+ /**
61
+ * Clicks the top-left corner of the page body.
62
+ *
63
+ * @param page The Playwright page to interact with.
64
+ * @returns A promise that resolves after the click.
65
+ * @example
66
+ * ```ts
67
+ * await clickBodyCorner(page);
68
+ * ```
69
+ */
70
+ export declare function clickBodyCorner(page: Page): Promise<void>;
71
+ //#endregion
72
+ //#region src/features/playwright/modules/interactions/utils/clickButton.d.ts
73
+ /**
74
+ * Clicks a button matching the supplied text.
75
+ *
76
+ * @param page The Playwright page to search.
77
+ * @param hasText Text or regular expression contained by the button.
78
+ * @returns A promise that resolves after the button is clicked.
79
+ * @example
80
+ * ```ts
81
+ * await clickButton(page, "Save");
82
+ * ```
83
+ */
84
+ export declare function clickButton(page: Page, hasText: TEXT_PATTERN): Promise<void>;
85
+ //#endregion
86
+ //#region src/features/playwright/modules/interactions/utils/clickLabelInput.d.ts
87
+ /**
88
+ * Clicks the label matching the supplied text.
89
+ *
90
+ * @param page The Playwright page to search.
91
+ * @param labelText Text or regular expression contained by the label.
92
+ * @returns A promise that resolves after the label is clicked.
93
+ * @example
94
+ * ```ts
95
+ * await clickLabelInput(page, "Subscribe");
96
+ * ```
97
+ */
98
+ export declare function clickLabelInput(page: Page, labelText: TEXT_PATTERN): Promise<void>;
99
+ //#endregion
100
+ //#region src/features/playwright/modules/interactions/utils/clickLink.d.ts
101
+ /**
102
+ * Clicks a link matching the supplied accessible name.
103
+ *
104
+ * @param page The Playwright page to search.
105
+ * @param hasText Text or regular expression matching the link name.
106
+ * @returns A promise that resolves after the link is clicked.
107
+ * @example
108
+ * ```ts
109
+ * await clickLink(page, "Documentation");
110
+ * ```
111
+ */
112
+ export declare function clickLink(page: Page, hasText: TEXT_PATTERN): Promise<void>;
113
+ //#endregion
114
+ //#region src/features/playwright/modules/interactions/utils/clickMultipleLabelInputs.d.ts
115
+ /**
116
+ * Clicks each matching label in the supplied order.
117
+ *
118
+ * @param page The Playwright page to search.
119
+ * @param labelTexts Text or regular expressions for the labels to click.
120
+ * @returns A promise that resolves after all labels are clicked.
121
+ * @example
122
+ * ```ts
123
+ * await clickMultipleLabelInputs(page, ["Email", "Subscribe"]);
124
+ * ```
125
+ */
126
+ export declare function clickMultipleLabelInputs(page: Page, labelTexts: TEXT_PATTERN[]): Promise<void>;
127
+ //#endregion
128
+ //#region src/features/playwright/modules/interactions/utils/fillLocatorWith.d.ts
129
+ /**
130
+ * Clicks a locator and fills it with the supplied value.
131
+ *
132
+ * @param locator The input-like locator to fill.
133
+ * @param value The value to enter.
134
+ * @returns A promise that resolves after the locator is filled.
135
+ * @example
136
+ * ```ts
137
+ * await fillLocatorWith(page.getByLabel("Email"), "user@example.com");
138
+ * ```
139
+ */
140
+ export declare function fillLocatorWith(locator: Locator, value: string): Promise<void>;
141
+ //#endregion
142
+ //#region src/features/playwright/modules/interactions/utils/setLocatorValue.d.ts
143
+ /**
144
+ * Clicks the label matching the pattern and fills it with the supplied value.
145
+ *
146
+ * @param page The Playwright page to search.
147
+ * @param locatorAndValue Label text or pattern paired with the value to fill.
148
+ * @returns A promise that resolves after the matching label is filled.
149
+ * @example
150
+ * ```ts
151
+ * await setLocatorValue(page, ["Email", "user@example.com"]);
152
+ * ```
153
+ */
154
+ export declare function setLocatorValue(page: Page, [locator, value]: LABEL_LOCATOR): Promise<void>;
155
+ //#endregion
156
+ //#region src/features/playwright/modules/interactions/utils/setValueForLocators.d.ts
157
+ /**
158
+ * Sets values for a sequence of label/value pairs in order.
159
+ *
160
+ * @param page The Playwright page to search.
161
+ * @param locatorsAndValues Label text or pattern paired with its value.
162
+ * @returns A promise that resolves after all values are set.
163
+ * @example
164
+ * ```ts
165
+ * await setValueForLocators(page, [
166
+ * ["Email", "user@example.com"],
167
+ * ["Name", "Alex"],
168
+ * ]);
169
+ * ```
170
+ */
171
+ export declare function setValueForLocators(page: Page, locatorsAndValues: LABEL_LOCATOR[]): Promise<void>;
172
+ //#endregion
173
+ //#region src/features/playwright/modules/runners/types.d.ts
174
+ type TestRunner = (page: Page) => void | Promise<void>;
175
+ type SimpleTest = [string, ...TestRunner[]];
176
+ //#endregion
177
+ //#region src/features/playwright/modules/runners/utils/runSimilarTests.d.ts
178
+ /**
179
+ * Registers tests that share the same page navigation and setup.
180
+ *
181
+ * @param tests Tuples of test names followed by page callbacks.
182
+ * @returns Nothing; registers one Playwright test for each tuple.
183
+ * @example
184
+ * ```ts
185
+ * runSimilarTests([
186
+ * ["shows the home page", async (page) => {
187
+ * await page.getByRole("heading", { name: "Home" }).waitFor();
188
+ * }],
189
+ * ]);
190
+ * ```
191
+ */
192
+ export declare function runSimilarTests(...tests: SimpleTest[]): void;
193
+ //#endregion
194
+ //#region src/features/playwright/shared/locators/utils/getButton.d.ts
195
+ /**
196
+ * Locates a button by its contained text.
197
+ *
198
+ * @param page The Playwright page to search.
199
+ * @param hasText Text or regular expression contained by the button.
200
+ * @returns A locator for the matching button.
201
+ * @example
202
+ * ```ts
203
+ * const saveButton = getButton(page, "Save");
204
+ * ```
205
+ */
206
+ export declare function getButton(page: Page, hasText: TEXT_PATTERN): import("@playwright/test").Locator;
207
+ //#endregion
208
+ //#region src/features/playwright/shared/locators/utils/getLabel.d.ts
209
+ /**
210
+ * Locates a label by its contained text.
211
+ *
212
+ * @param page The Playwright page to search.
213
+ * @param hasText Text or regular expression contained by the label.
214
+ * @returns A locator for the matching label.
215
+ * @example
216
+ * ```ts
217
+ * const emailLabel = getLabel(page, "Email");
218
+ * ```
219
+ */
220
+ export declare function getLabel(page: Page, hasText: TEXT_PATTERN): import("@playwright/test").Locator;
221
+ //#endregion
222
+ //#region src/features/playwright/shared/locators/utils/getLink.d.ts
223
+ /**
224
+ * Locates a link by its accessible name.
225
+ *
226
+ * @param page The Playwright page to search.
227
+ * @param hasText Text or regular expression matching the link's accessible name.
228
+ * @returns A locator for the matching link.
229
+ * @example
230
+ * ```ts
231
+ * const documentationLink = getLink(page, "Documentation");
232
+ * ```
233
+ */
234
+ export declare function getLink(page: Page, hasText: TEXT_PATTERN): import("@playwright/test").Locator;
235
+ //#endregion
236
+ //#region src/features/playwright/shared/locators/types.d.ts
237
+ type LocatorWithText = [string, TEXT_PATTERN];
238
+ //#endregion
239
+ //#region src/features/playwright/shared/locators/utils/getLocatorByText.d.ts
240
+ /**
241
+ * Locates elements matching a selector and text pattern.
242
+ *
243
+ * @param page The Playwright page to search.
244
+ * @param locator Selector paired with text that the element must contain.
245
+ * @returns A locator matching the selector and text.
246
+ * @example
247
+ * ```ts
248
+ * const save = getLocatorByText(page, ["button", "Save"]);
249
+ * ```
250
+ */
251
+ export declare function getLocatorByText(page: Page, [locator, hasText]: LocatorWithText): import("@playwright/test").Locator;
252
+ //#endregion
253
+ export type { LABEL_LOCATOR, LocatorWithText, SimpleTest, TEXT_MATCHER, TEXT_PATTERN, TEXT_WITH_NTH, TestRunner };
254
+ //# sourceMappingURL=playwright.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.d.mts","names":[],"sources":["../src/features/playwright/modules/assertions/utils/isChecked.ts","../src/features/playwright/modules/assertions/utils/isNotChecked.ts","../src/features/playwright/modules/assertions/utils/shouldNotSee.ts","../src/features/playwright/modules/assertions/utils/shouldSee.ts","../src/features/playwright/modules/interactions/utils/clickBodyCorner.ts","../src/features/playwright/modules/interactions/utils/clickButton.ts","../src/features/playwright/modules/interactions/utils/clickLabelInput.ts","../src/features/playwright/modules/interactions/utils/clickLink.ts","../src/features/playwright/modules/interactions/utils/clickMultipleLabelInputs.ts","../src/features/playwright/modules/interactions/utils/fillLocatorWith.ts","../src/features/playwright/modules/interactions/utils/setLocatorValue.ts","../src/features/playwright/modules/interactions/utils/setValueForLocators.ts","../src/features/playwright/modules/runners/types.ts","../src/features/playwright/modules/runners/utils/runSimilarTests.ts","../src/features/playwright/shared/locators/utils/getButton.ts","../src/features/playwright/shared/locators/utils/getLabel.ts","../src/features/playwright/shared/locators/utils/getLink.ts","../src/features/playwright/shared/locators/types.ts","../src/features/playwright/shared/locators/utils/getLocatorByText.ts"],"mappings":";;;;;;;;;;;;;;wBAcsB,UACpB,MAAM,MACN,mBACC,QAAQ;;;;;;;;;;;;;;wBCHW,aACpB,MAAM,MACN,mBACC,QAAQ;;;;;;;;;;;;;;wBCFW,aAAa,MAAM,SAAS,QAAQ,iBAAc;;;;;;;;;;;;;;wBCAlD,UAAU,MAAM,SAAS,QAAQ,iBAAc;;;;;;;;;;;;;wBCH/C,gBAAgB,MAAM,OAAI;;;;;;;;;;;;;;wBCG1B,YAAY,MAAM,MAAM,SAAS,eAAY;;;;;;;;;;;;;;wBCA7C,gBAAgB,MAAM,MAAM,WAAW,eAAY;;;;;;;;;;;;;;wBCAnD,UAAU,MAAM,MAAM,SAAS,eAAY;;;;;;;;;;;;;;wBCA3C,yBACpB,MAAM,MACN,YAAY,iBAAc;;;;;;;;;;;;;;wBCJN,gBAAgB,SAAS,SAAS,gBAAa;;;;;;;;;;;;;;wBCC/C,gBACpB,MAAM,OACL,SAAS,QAAQ,gBAAa;;;;;;;;;;;;;;;;;wBCEX,oBACpB,MAAM,MACN,mBAAmB,kBAAe;;;KClBxB,cAAc,MAAM,gBAAgB;KACpC,yBAAyB;;;;;;;;;;;;;;;;;wBCcrB,mBAAmB,OAAO;;;;;;;;;;;;;;wBCF1B,UAAU,MAAM,MAAM,SAAS,0CAAY;;;;;;;;;;;;;;wBCA3C,SAAS,MAAM,MAAM,SAAS,0CAAY;;;;;;;;;;;;;;wBCD1C,QAAQ,MAAM,MAAM,SAAS,0CAAY;;;KCZ7C,2BAA2B;;;;;;;;;;;;;;wBCYvB,iBACd,MAAM,OACL,SAAS,UAAU,6CAAe"}
@@ -0,0 +1,308 @@
1
+ import { t as patternToRegex } from "./pattern-to-regex-CO5Y0oDU.mjs";
2
+ import test, { expect } from "@playwright/test";
3
+ //#region src/features/playwright/modules/assertions/utils/isChecked.ts
4
+ /**
5
+ * Asserts that the element selected by the CSS selector is checked.
6
+ *
7
+ * @param page The Playwright page to search.
8
+ * @param selector CSS selector for a checkbox or radio input.
9
+ * @returns The checked locator.
10
+ * @example
11
+ * ```ts
12
+ * const checkbox = await isChecked(page, "#terms");
13
+ * ```
14
+ */
15
+ async function isChecked(page, selector) {
16
+ const locator = page.locator(selector);
17
+ await expect(locator).toBeChecked();
18
+ return locator;
19
+ }
20
+ //#endregion
21
+ //#region src/features/playwright/modules/assertions/utils/isNotChecked.ts
22
+ /**
23
+ * Asserts that the element selected by the CSS selector is not checked.
24
+ *
25
+ * @param page The Playwright page to search.
26
+ * @param selector CSS selector for a checkbox or radio input.
27
+ * @returns The unchecked locator.
28
+ * @example
29
+ * ```ts
30
+ * const checkbox = await isNotChecked(page, "#terms");
31
+ * ```
32
+ */
33
+ async function isNotChecked(page, selector) {
34
+ const locator = page.locator(selector);
35
+ await expect(locator).not.toBeChecked();
36
+ return locator;
37
+ }
38
+ //#endregion
39
+ //#region src/features/playwright/modules/assertions/utils/getMatcher.ts
40
+ function getMatcher(page, ...textes) {
41
+ return textes.map((text) => {
42
+ if (Array.isArray(text)) {
43
+ const [matcher, nth] = text;
44
+ return expect(page.getByText(patternToRegex(matcher)).nth(nth));
45
+ }
46
+ return expect(page.getByText(text));
47
+ });
48
+ }
49
+ //#endregion
50
+ //#region src/features/playwright/modules/assertions/utils/shouldNotSee.ts
51
+ /**
52
+ * Asserts that each text matcher is not visible on the page.
53
+ *
54
+ * @param page The Playwright page to inspect.
55
+ * @param textes Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.
56
+ * @returns A promise that resolves when every matching element is not visible.
57
+ * @example
58
+ * ```ts
59
+ * await shouldNotSee(page, "Error message");
60
+ * ```
61
+ */
62
+ async function shouldNotSee(page, ...textes) {
63
+ const matchers = getMatcher(page, ...textes);
64
+ for (let i = 0; i < matchers.length; i++) await matchers[i].not.toBeVisible();
65
+ }
66
+ //#endregion
67
+ //#region src/features/playwright/modules/assertions/utils/shouldSee.ts
68
+ /**
69
+ * Asserts that each text matcher is visible on the page.
70
+ *
71
+ * @param page The Playwright page to inspect.
72
+ * @param textes Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.
73
+ * @returns A promise that resolves when every matching element is visible.
74
+ * @example
75
+ * ```ts
76
+ * await shouldSee(page, "Welcome", [/Saved/i, 0]);
77
+ * ```
78
+ */
79
+ async function shouldSee(page, ...textes) {
80
+ const matchers = getMatcher(page, ...textes);
81
+ for (let i = 0; i < matchers.length; i++) await matchers[i].toBeVisible();
82
+ }
83
+ //#endregion
84
+ //#region src/features/playwright/modules/interactions/utils/clickBodyCorner.ts
85
+ /**
86
+ * Clicks the top-left corner of the page body.
87
+ *
88
+ * @param page The Playwright page to interact with.
89
+ * @returns A promise that resolves after the click.
90
+ * @example
91
+ * ```ts
92
+ * await clickBodyCorner(page);
93
+ * ```
94
+ */
95
+ async function clickBodyCorner(page) {
96
+ await page.locator("body").click({ position: {
97
+ x: 0,
98
+ y: 0
99
+ } });
100
+ }
101
+ //#endregion
102
+ //#region src/features/playwright/shared/locators/utils/getLocatorByText.ts
103
+ /**
104
+ * Locates elements matching a selector and text pattern.
105
+ *
106
+ * @param page The Playwright page to search.
107
+ * @param locator Selector paired with text that the element must contain.
108
+ * @returns A locator matching the selector and text.
109
+ * @example
110
+ * ```ts
111
+ * const save = getLocatorByText(page, ["button", "Save"]);
112
+ * ```
113
+ */
114
+ function getLocatorByText(page, [locator, hasText]) {
115
+ return page.locator(locator, { hasText });
116
+ }
117
+ //#endregion
118
+ //#region src/features/playwright/shared/locators/utils/getButton.ts
119
+ /**
120
+ * Locates a button by its contained text.
121
+ *
122
+ * @param page The Playwright page to search.
123
+ * @param hasText Text or regular expression contained by the button.
124
+ * @returns A locator for the matching button.
125
+ * @example
126
+ * ```ts
127
+ * const saveButton = getButton(page, "Save");
128
+ * ```
129
+ */
130
+ function getButton(page, hasText) {
131
+ return getLocatorByText(page, ["button", hasText]);
132
+ }
133
+ //#endregion
134
+ //#region src/features/playwright/shared/locators/utils/getLabel.ts
135
+ /**
136
+ * Locates a label by its contained text.
137
+ *
138
+ * @param page The Playwright page to search.
139
+ * @param hasText Text or regular expression contained by the label.
140
+ * @returns A locator for the matching label.
141
+ * @example
142
+ * ```ts
143
+ * const emailLabel = getLabel(page, "Email");
144
+ * ```
145
+ */
146
+ function getLabel(page, hasText) {
147
+ return getLocatorByText(page, ["label", hasText]);
148
+ }
149
+ //#endregion
150
+ //#region src/features/playwright/shared/locators/utils/getLink.ts
151
+ /**
152
+ * Locates a link by its accessible name.
153
+ *
154
+ * @param page The Playwright page to search.
155
+ * @param hasText Text or regular expression matching the link's accessible name.
156
+ * @returns A locator for the matching link.
157
+ * @example
158
+ * ```ts
159
+ * const documentationLink = getLink(page, "Documentation");
160
+ * ```
161
+ */
162
+ function getLink(page, hasText) {
163
+ return page.getByRole("link", { name: hasText });
164
+ }
165
+ //#endregion
166
+ //#region src/features/playwright/modules/interactions/utils/clickButton.ts
167
+ /**
168
+ * Clicks a button matching the supplied text.
169
+ *
170
+ * @param page The Playwright page to search.
171
+ * @param hasText Text or regular expression contained by the button.
172
+ * @returns A promise that resolves after the button is clicked.
173
+ * @example
174
+ * ```ts
175
+ * await clickButton(page, "Save");
176
+ * ```
177
+ */
178
+ async function clickButton(page, hasText) {
179
+ await getButton(page, hasText).click();
180
+ }
181
+ //#endregion
182
+ //#region src/features/playwright/modules/interactions/utils/clickLabelInput.ts
183
+ /**
184
+ * Clicks the label matching the supplied text.
185
+ *
186
+ * @param page The Playwright page to search.
187
+ * @param labelText Text or regular expression contained by the label.
188
+ * @returns A promise that resolves after the label is clicked.
189
+ * @example
190
+ * ```ts
191
+ * await clickLabelInput(page, "Subscribe");
192
+ * ```
193
+ */
194
+ async function clickLabelInput(page, labelText) {
195
+ await getLabel(page, labelText).click();
196
+ }
197
+ //#endregion
198
+ //#region src/features/playwright/modules/interactions/utils/clickLink.ts
199
+ /**
200
+ * Clicks a link matching the supplied accessible name.
201
+ *
202
+ * @param page The Playwright page to search.
203
+ * @param hasText Text or regular expression matching the link name.
204
+ * @returns A promise that resolves after the link is clicked.
205
+ * @example
206
+ * ```ts
207
+ * await clickLink(page, "Documentation");
208
+ * ```
209
+ */
210
+ async function clickLink(page, hasText) {
211
+ await getLink(page, hasText).click();
212
+ }
213
+ //#endregion
214
+ //#region src/features/playwright/modules/interactions/utils/clickMultipleLabelInputs.ts
215
+ /**
216
+ * Clicks each matching label in the supplied order.
217
+ *
218
+ * @param page The Playwright page to search.
219
+ * @param labelTexts Text or regular expressions for the labels to click.
220
+ * @returns A promise that resolves after all labels are clicked.
221
+ * @example
222
+ * ```ts
223
+ * await clickMultipleLabelInputs(page, ["Email", "Subscribe"]);
224
+ * ```
225
+ */
226
+ async function clickMultipleLabelInputs(page, labelTexts) {
227
+ for (const labelText of labelTexts) await clickLabelInput(page, labelText);
228
+ }
229
+ //#endregion
230
+ //#region src/features/playwright/modules/interactions/utils/fillLocatorWith.ts
231
+ /**
232
+ * Clicks a locator and fills it with the supplied value.
233
+ *
234
+ * @param locator The input-like locator to fill.
235
+ * @param value The value to enter.
236
+ * @returns A promise that resolves after the locator is filled.
237
+ * @example
238
+ * ```ts
239
+ * await fillLocatorWith(page.getByLabel("Email"), "user@example.com");
240
+ * ```
241
+ */
242
+ async function fillLocatorWith(locator, value) {
243
+ await locator.click();
244
+ await locator.fill(value);
245
+ }
246
+ //#endregion
247
+ //#region src/features/playwright/modules/interactions/utils/setLocatorValue.ts
248
+ /**
249
+ * Clicks the label matching the pattern and fills it with the supplied value.
250
+ *
251
+ * @param page The Playwright page to search.
252
+ * @param locatorAndValue Label text or pattern paired with the value to fill.
253
+ * @returns A promise that resolves after the matching label is filled.
254
+ * @example
255
+ * ```ts
256
+ * await setLocatorValue(page, ["Email", "user@example.com"]);
257
+ * ```
258
+ */
259
+ async function setLocatorValue(page, [locator, value]) {
260
+ const element = page.locator("label", { hasText: patternToRegex(locator) });
261
+ await element.click();
262
+ await element.fill(value);
263
+ }
264
+ //#endregion
265
+ //#region src/features/playwright/modules/interactions/utils/setValueForLocators.ts
266
+ /**
267
+ * Sets values for a sequence of label/value pairs in order.
268
+ *
269
+ * @param page The Playwright page to search.
270
+ * @param locatorsAndValues Label text or pattern paired with its value.
271
+ * @returns A promise that resolves after all values are set.
272
+ * @example
273
+ * ```ts
274
+ * await setValueForLocators(page, [
275
+ * ["Email", "user@example.com"],
276
+ * ["Name", "Alex"],
277
+ * ]);
278
+ * ```
279
+ */
280
+ async function setValueForLocators(page, locatorsAndValues) {
281
+ for (const locatorAndValue of locatorsAndValues) await setLocatorValue(page, locatorAndValue);
282
+ }
283
+ //#endregion
284
+ //#region src/features/playwright/modules/runners/utils/runSimilarTests.ts
285
+ /**
286
+ * Registers tests that share the same page navigation and setup.
287
+ *
288
+ * @param tests Tuples of test names followed by page callbacks.
289
+ * @returns Nothing; registers one Playwright test for each tuple.
290
+ * @example
291
+ * ```ts
292
+ * runSimilarTests([
293
+ * ["shows the home page", async (page) => {
294
+ * await page.getByRole("heading", { name: "Home" }).waitFor();
295
+ * }],
296
+ * ]);
297
+ * ```
298
+ */
299
+ function runSimilarTests(...tests) {
300
+ tests.forEach(([testName, ...testFunctions]) => test(testName, async ({ page }) => {
301
+ await page.goto("/");
302
+ for (const testFunction of testFunctions) await testFunction(page);
303
+ }));
304
+ }
305
+ //#endregion
306
+ export { clickBodyCorner, clickButton, clickLabelInput, clickLink, clickMultipleLabelInputs, fillLocatorWith, getButton, getLabel, getLink, getLocatorByText, isChecked, isNotChecked, runSimilarTests, setLocatorValue, setValueForLocators, shouldNotSee, shouldSee };
307
+
308
+ //# sourceMappingURL=playwright.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.mjs","names":[],"sources":["../src/features/playwright/modules/assertions/utils/isChecked.ts","../src/features/playwright/modules/assertions/utils/isNotChecked.ts","../src/features/playwright/modules/assertions/utils/getMatcher.ts","../src/features/playwright/modules/assertions/utils/shouldNotSee.ts","../src/features/playwright/modules/assertions/utils/shouldSee.ts","../src/features/playwright/modules/interactions/utils/clickBodyCorner.ts","../src/features/playwright/shared/locators/utils/getLocatorByText.ts","../src/features/playwright/shared/locators/utils/getButton.ts","../src/features/playwright/shared/locators/utils/getLabel.ts","../src/features/playwright/shared/locators/utils/getLink.ts","../src/features/playwright/modules/interactions/utils/clickButton.ts","../src/features/playwright/modules/interactions/utils/clickLabelInput.ts","../src/features/playwright/modules/interactions/utils/clickLink.ts","../src/features/playwright/modules/interactions/utils/clickMultipleLabelInputs.ts","../src/features/playwright/modules/interactions/utils/fillLocatorWith.ts","../src/features/playwright/modules/interactions/utils/setLocatorValue.ts","../src/features/playwright/modules/interactions/utils/setValueForLocators.ts","../src/features/playwright/modules/runners/utils/runSimilarTests.ts"],"sourcesContent":["import type { Locator, Page } from \"@playwright/test\";\nimport { expect } from \"@playwright/test\";\n\n/**\n * Asserts that the element selected by the CSS selector is checked.\n *\n * @param page The Playwright page to search.\n * @param selector CSS selector for a checkbox or radio input.\n * @returns The checked locator.\n * @example\n * ```ts\n * const checkbox = await isChecked(page, \"#terms\");\n * ```\n */\nexport async function isChecked(\n page: Page,\n selector: string,\n): Promise<Locator> {\n const locator = page.locator(selector);\n await expect(locator).toBeChecked();\n return locator;\n}\n","import type { Locator, Page } from \"@playwright/test\";\nimport { expect } from \"@playwright/test\";\n\n/**\n * Asserts that the element selected by the CSS selector is not checked.\n *\n * @param page The Playwright page to search.\n * @param selector CSS selector for a checkbox or radio input.\n * @returns The unchecked locator.\n * @example\n * ```ts\n * const checkbox = await isNotChecked(page, \"#terms\");\n * ```\n */\nexport async function isNotChecked(\n page: Page,\n selector: string,\n): Promise<Locator> {\n const locator = page.locator(selector);\n await expect(locator).not.toBeChecked();\n return locator;\n}\n","import { patternToRegex } from \"@/shared/regex\";\nimport { expect, type Locator, type Page } from \"@playwright/test\";\nimport { TEXT_MATCHER } from \"../types\";\n\nexport function getMatcher(\n page: Page,\n ...textes: TEXT_MATCHER[]\n): ReturnType<typeof expect<Locator>>[] {\n return textes.map((text) => {\n if (Array.isArray(text)) {\n const [matcher, nth] = text;\n return expect(page.getByText(patternToRegex(matcher)).nth(nth));\n }\n return expect(page.getByText(text));\n });\n}\n","import type { Page } from \"@playwright/test\";\nimport type { TEXT_MATCHER } from \"../types\";\nimport { getMatcher } from \"./getMatcher\";\n\n/**\n * Asserts that each text matcher is not visible on the page.\n *\n * @param page The Playwright page to inspect.\n * @param textes Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.\n * @returns A promise that resolves when every matching element is not visible.\n * @example\n * ```ts\n * await shouldNotSee(page, \"Error message\");\n * ```\n */\nexport async function shouldNotSee(page: Page, ...textes: TEXT_MATCHER[]) {\n const matchers = getMatcher(page, ...textes);\n for (let i = 0; i < matchers.length; i++) {\n await matchers[i].not.toBeVisible();\n }\n}\n","import type { Page } from \"@playwright/test\";\nimport type { TEXT_MATCHER } from \"../types\";\nimport { getMatcher } from \"./getMatcher\";\n\n/**\n * Asserts that each text matcher is visible on the page.\n *\n * @param page The Playwright page to inspect.\n * @param textes Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.\n * @returns A promise that resolves when every matching element is visible.\n * @example\n * ```ts\n * await shouldSee(page, \"Welcome\", [/Saved/i, 0]);\n * ```\n */\nexport async function shouldSee(page: Page, ...textes: TEXT_MATCHER[]) {\n const matchers = getMatcher(page, ...textes);\n for (let i = 0; i < matchers.length; i++) {\n await matchers[i].toBeVisible();\n }\n}\n","import type { Page } from \"@playwright/test\";\n\n/**\n * Clicks the top-left corner of the page body.\n *\n * @param page The Playwright page to interact with.\n * @returns A promise that resolves after the click.\n * @example\n * ```ts\n * await clickBodyCorner(page);\n * ```\n */\nexport async function clickBodyCorner(page: Page) {\n await page.locator(\"body\").click({ position: { x: 0, y: 0 } });\n}\n","import type { Page } from \"@playwright/test\";\nimport type { LocatorWithText } from \"../types\";\n\n/**\n * Locates elements matching a selector and text pattern.\n *\n * @param page The Playwright page to search.\n * @param locator Selector paired with text that the element must contain.\n * @returns A locator matching the selector and text.\n * @example\n * ```ts\n * const save = getLocatorByText(page, [\"button\", \"Save\"]);\n * ```\n */\nexport function getLocatorByText(\n page: Page,\n [locator, hasText]: LocatorWithText,\n) {\n return page.locator(locator, { hasText });\n}\n","import { TEXT_PATTERN } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\nimport { getLocatorByText } from \"./getLocatorByText\";\n\n/**\n * Locates a button by its contained text.\n *\n * @param page The Playwright page to search.\n * @param hasText Text or regular expression contained by the button.\n * @returns A locator for the matching button.\n * @example\n * ```ts\n * const saveButton = getButton(page, \"Save\");\n * ```\n */\nexport function getButton(page: Page, hasText: TEXT_PATTERN) {\n return getLocatorByText(page, [\"button\", hasText]);\n}\n","import { TEXT_PATTERN } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\nimport { getLocatorByText } from \"./getLocatorByText\";\n\n/**\n * Locates a label by its contained text.\n *\n * @param page The Playwright page to search.\n * @param hasText Text or regular expression contained by the label.\n * @returns A locator for the matching label.\n * @example\n * ```ts\n * const emailLabel = getLabel(page, \"Email\");\n * ```\n */\nexport function getLabel(page: Page, hasText: TEXT_PATTERN) {\n return getLocatorByText(page, [\"label\", hasText]);\n}\n","import { TEXT_PATTERN } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\n\n/**\n * Locates a link by its accessible name.\n *\n * @param page The Playwright page to search.\n * @param hasText Text or regular expression matching the link's accessible name.\n * @returns A locator for the matching link.\n * @example\n * ```ts\n * const documentationLink = getLink(page, \"Documentation\");\n * ```\n */\nexport function getLink(page: Page, hasText: TEXT_PATTERN) {\n return page.getByRole(\"link\", { name: hasText });\n}\n","import { getButton } from \"@/features/playwright/shared/locators\";\nimport { TEXT_PATTERN } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\n\n/**\n * Clicks a button matching the supplied text.\n *\n * @param page The Playwright page to search.\n * @param hasText Text or regular expression contained by the button.\n * @returns A promise that resolves after the button is clicked.\n * @example\n * ```ts\n * await clickButton(page, \"Save\");\n * ```\n */\nexport async function clickButton(page: Page, hasText: TEXT_PATTERN) {\n await getButton(page, hasText).click();\n}\n","import { getLabel } from \"@/features/playwright/shared/locators\";\nimport { TEXT_PATTERN } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\n\n/**\n * Clicks the label matching the supplied text.\n *\n * @param page The Playwright page to search.\n * @param labelText Text or regular expression contained by the label.\n * @returns A promise that resolves after the label is clicked.\n * @example\n * ```ts\n * await clickLabelInput(page, \"Subscribe\");\n * ```\n */\nexport async function clickLabelInput(page: Page, labelText: TEXT_PATTERN) {\n await getLabel(page, labelText).click();\n}\n","import { getLink } from \"@/features/playwright/shared/locators\";\nimport { TEXT_PATTERN } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\n\n/**\n * Clicks a link matching the supplied accessible name.\n *\n * @param page The Playwright page to search.\n * @param hasText Text or regular expression matching the link name.\n * @returns A promise that resolves after the link is clicked.\n * @example\n * ```ts\n * await clickLink(page, \"Documentation\");\n * ```\n */\nexport async function clickLink(page: Page, hasText: TEXT_PATTERN) {\n await getLink(page, hasText).click();\n}\n","import { TEXT_PATTERN } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\nimport { clickLabelInput } from \"./clickLabelInput\";\n\n/**\n * Clicks each matching label in the supplied order.\n *\n * @param page The Playwright page to search.\n * @param labelTexts Text or regular expressions for the labels to click.\n * @returns A promise that resolves after all labels are clicked.\n * @example\n * ```ts\n * await clickMultipleLabelInputs(page, [\"Email\", \"Subscribe\"]);\n * ```\n */\nexport async function clickMultipleLabelInputs(\n page: Page,\n labelTexts: TEXT_PATTERN[],\n) {\n for (const labelText of labelTexts) {\n await clickLabelInput(page, labelText);\n }\n}\n","import type { Locator } from \"@playwright/test\";\n\n/**\n * Clicks a locator and fills it with the supplied value.\n *\n * @param locator The input-like locator to fill.\n * @param value The value to enter.\n * @returns A promise that resolves after the locator is filled.\n * @example\n * ```ts\n * await fillLocatorWith(page.getByLabel(\"Email\"), \"user@example.com\");\n * ```\n */\nexport async function fillLocatorWith(locator: Locator, value: string) {\n await locator.click();\n await locator.fill(value);\n}\n","import { type LABEL_LOCATOR, patternToRegex } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\n\n/**\n * Clicks the label matching the pattern and fills it with the supplied value.\n *\n * @param page The Playwright page to search.\n * @param locatorAndValue Label text or pattern paired with the value to fill.\n * @returns A promise that resolves after the matching label is filled.\n * @example\n * ```ts\n * await setLocatorValue(page, [\"Email\", \"user@example.com\"]);\n * ```\n */\nexport async function setLocatorValue(\n page: Page,\n [locator, value]: LABEL_LOCATOR,\n) {\n const element = page.locator(\"label\", { hasText: patternToRegex(locator) });\n await element.click();\n await element.fill(value);\n}\n","import { LABEL_LOCATOR } from \"@/shared/regex\";\nimport type { Page } from \"@playwright/test\";\nimport { setLocatorValue } from \"./setLocatorValue\";\n\n/**\n * Sets values for a sequence of label/value pairs in order.\n *\n * @param page The Playwright page to search.\n * @param locatorsAndValues Label text or pattern paired with its value.\n * @returns A promise that resolves after all values are set.\n * @example\n * ```ts\n * await setValueForLocators(page, [\n * [\"Email\", \"user@example.com\"],\n * [\"Name\", \"Alex\"],\n * ]);\n * ```\n */\nexport async function setValueForLocators(\n page: Page,\n locatorsAndValues: LABEL_LOCATOR[],\n) {\n for (const locatorAndValue of locatorsAndValues) {\n await setLocatorValue(page, locatorAndValue);\n }\n}\n","import test from \"@playwright/test\";\nimport type { SimpleTest } from \"../types\";\n\n/**\n * Registers tests that share the same page navigation and setup.\n *\n * @param tests Tuples of test names followed by page callbacks.\n * @returns Nothing; registers one Playwright test for each tuple.\n * @example\n * ```ts\n * runSimilarTests([\n * [\"shows the home page\", async (page) => {\n * await page.getByRole(\"heading\", { name: \"Home\" }).waitFor();\n * }],\n * ]);\n * ```\n */\nexport function runSimilarTests(...tests: SimpleTest[]) {\n tests.forEach(([testName, ...testFunctions]) =>\n test(testName, async ({ page }) => {\n await page.goto(\"/\");\n for (const testFunction of testFunctions) await testFunction(page);\n }),\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,45 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/features/promises/utils/resolvedPromise.ts
3
+ /**
4
+ * Creates a fulfilled promise augmented with Vitest's fulfilled-promise metadata.
5
+ *
6
+ * @param value The value with which the promise is fulfilled.
7
+ * @returns A fulfilled Promise<T> with `status: "fulfilled"` and its `value`.
8
+ * @example
9
+ * ```ts
10
+ * const payload = await resolvedPromise({ id: 1 });
11
+ * expect(payload).toEqual({ id: 1 });
12
+ * ```
13
+ */
14
+ function resolvedPromise(value) {
15
+ const promise = Promise.resolve(value);
16
+ return Object.assign(promise, {
17
+ status: "fulfilled",
18
+ value
19
+ });
20
+ }
21
+ //#endregion
22
+ //#region src/features/promises/utils/rejectedPromise.ts
23
+ /**
24
+ * Creates a rejected promise augmented with Vitest's rejected-promise metadata.
25
+ *
26
+ * @param reason The rejection reason, preserved as an unknown value; defaults to `undefined`.
27
+ * @returns A rejected Promise<never> with `status: "rejected"` and its `reason`.
28
+ * @example
29
+ * ```ts
30
+ * await expect(rejectedPromise(new Error("Request failed"))).rejects.toThrow("Request failed");
31
+ * ```
32
+ */
33
+ function rejectedPromise(reason = void 0) {
34
+ const promise = Promise.reject(reason);
35
+ promise.catch((error) => error);
36
+ return Object.assign(promise, {
37
+ status: "rejected",
38
+ reason
39
+ });
40
+ }
41
+ //#endregion
42
+ exports.rejectedPromise = rejectedPromise;
43
+ exports.resolvedPromise = resolvedPromise;
44
+
45
+ //# sourceMappingURL=promises.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promises.cjs","names":[],"sources":["../src/features/promises/utils/resolvedPromise.ts","../src/features/promises/utils/rejectedPromise.ts"],"sourcesContent":["/**\n * Creates a fulfilled promise augmented with Vitest's fulfilled-promise metadata.\n *\n * @param value The value with which the promise is fulfilled.\n * @returns A fulfilled Promise<T> with `status: \"fulfilled\"` and its `value`.\n * @example\n * ```ts\n * const payload = await resolvedPromise({ id: 1 });\n * expect(payload).toEqual({ id: 1 });\n * ```\n */\nexport function resolvedPromise<T>(\n value: T,\n): Promise<T> & { status: \"fulfilled\"; value: T } {\n const promise = Promise.resolve(value);\n return Object.assign(promise, { status: \"fulfilled\" as const, value });\n}\n","/**\n * Creates a rejected promise augmented with Vitest's rejected-promise metadata.\n *\n * @param reason The rejection reason, preserved as an unknown value; defaults to `undefined`.\n * @returns A rejected Promise<never> with `status: \"rejected\"` and its `reason`.\n * @example\n * ```ts\n * await expect(rejectedPromise(new Error(\"Request failed\"))).rejects.toThrow(\"Request failed\");\n * ```\n */\nexport function rejectedPromise(\n reason: unknown = undefined,\n): Promise<never> & { status: \"rejected\"; reason: unknown } {\n const promise = Promise.reject<never>(reason);\n\n promise.catch((error) => error);\n\n return Object.assign(promise, { status: \"rejected\" as const, reason });\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,gBACd,OACgD;CAChD,MAAM,UAAU,QAAQ,QAAQ,KAAK;CACrC,OAAO,OAAO,OAAO,SAAS;EAAE,QAAQ;EAAsB;CAAM,CAAC;AACvE;;;;;;;;;;;;;ACNA,SAAgB,gBACd,SAAkB,KAAA,GACwC;CAC1D,MAAM,UAAU,QAAQ,OAAc,MAAM;CAE5C,QAAQ,OAAO,UAAU,KAAK;CAE9B,OAAO,OAAO,OAAO,SAAS;EAAE,QAAQ;EAAqB;CAAO,CAAC;AACvE"}