playwright-cucumber-ts-steps 1.1.8 → 1.1.10

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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/dist/backend/actions/click.d.ts +132 -1
  3. package/dist/backend/actions/click.d.ts.map +1 -1
  4. package/dist/backend/actions/click.js +122 -53
  5. package/dist/backend/actions/find.d.ts +243 -1
  6. package/dist/backend/actions/find.d.ts.map +1 -1
  7. package/dist/backend/actions/find.js +196 -72
  8. package/dist/backend/actions/form.d.ts +37 -1
  9. package/dist/backend/actions/form.d.ts.map +1 -1
  10. package/dist/backend/actions/form.js +55 -3
  11. package/dist/backend/actions/formTable.d.ts +25 -1
  12. package/dist/backend/actions/formTable.d.ts.map +1 -1
  13. package/dist/backend/actions/formTable.js +27 -5
  14. package/dist/backend/actions/frames.d.ts +53 -1
  15. package/dist/backend/actions/frames.d.ts.map +1 -1
  16. package/dist/backend/actions/frames.js +48 -11
  17. package/dist/backend/actions/inputs.d.ts +139 -1
  18. package/dist/backend/actions/inputs.d.ts.map +1 -1
  19. package/dist/backend/actions/inputs.js +113 -43
  20. package/dist/backend/actions/interactions.d.ts +61 -1
  21. package/dist/backend/actions/interactions.d.ts.map +1 -1
  22. package/dist/backend/actions/interactions.js +65 -10
  23. package/dist/backend/actions/keyboard.d.ts +70 -1
  24. package/dist/backend/actions/keyboard.d.ts.map +1 -1
  25. package/dist/backend/actions/keyboard.js +59 -23
  26. package/dist/backend/actions/misc.d.ts +134 -1
  27. package/dist/backend/actions/misc.d.ts.map +1 -1
  28. package/dist/backend/actions/misc.js +106 -42
  29. package/dist/backend/actions/mobile.d.ts +74 -1
  30. package/dist/backend/actions/mobile.d.ts.map +1 -1
  31. package/dist/backend/actions/mobile.js +74 -13
  32. package/dist/backend/actions/mouse.d.ts +79 -1
  33. package/dist/backend/actions/mouse.d.ts.map +1 -1
  34. package/dist/backend/actions/mouse.js +66 -21
  35. package/dist/backend/actions/navigation.d.ts +48 -1
  36. package/dist/backend/actions/navigation.d.ts.map +1 -1
  37. package/dist/backend/actions/navigation.js +42 -15
  38. package/dist/backend/actions/waits.d.ts +55 -1
  39. package/dist/backend/actions/waits.d.ts.map +1 -1
  40. package/dist/backend/actions/waits.js +49 -17
  41. package/dist/backend/api/assertions.d.ts +32 -1
  42. package/dist/backend/api/assertions.d.ts.map +1 -1
  43. package/dist/backend/api/assertions.js +37 -9
  44. package/dist/backend/api/mock.d.ts +34 -1
  45. package/dist/backend/api/mock.d.ts.map +1 -1
  46. package/dist/backend/api/mock.js +37 -10
  47. package/dist/backend/api/network.d.ts +60 -1
  48. package/dist/backend/api/network.d.ts.map +1 -1
  49. package/dist/backend/api/network.js +53 -21
  50. package/dist/backend/api/requests.d.ts +43 -1
  51. package/dist/backend/api/requests.d.ts.map +1 -1
  52. package/dist/backend/api/requests.js +49 -17
  53. package/dist/backend/assertions/pageState.d.ts +40 -1
  54. package/dist/backend/assertions/pageState.d.ts.map +1 -1
  55. package/dist/backend/assertions/pageState.js +33 -12
  56. package/dist/backend/assertions/text.d.ts +46 -1
  57. package/dist/backend/assertions/text.d.ts.map +1 -1
  58. package/dist/backend/assertions/text.js +51 -8
  59. package/dist/backend/assertions/visibility.d.ts +102 -1
  60. package/dist/backend/assertions/visibility.d.ts.map +1 -1
  61. package/dist/backend/assertions/visibility.js +86 -36
  62. package/dist/backend/auth/index.js +2 -2
  63. package/dist/backend/db/steps.d.ts +35 -1
  64. package/dist/backend/db/steps.d.ts.map +1 -1
  65. package/dist/backend/db/steps.js +48 -15
  66. package/dist/backend/elements/alerts.d.ts +35 -1
  67. package/dist/backend/elements/alerts.d.ts.map +1 -1
  68. package/dist/backend/elements/alerts.js +39 -6
  69. package/dist/backend/elements/forms.d.ts +44 -1
  70. package/dist/backend/elements/forms.d.ts.map +1 -1
  71. package/dist/backend/elements/forms.js +50 -11
  72. package/dist/backend/elements/frames.d.ts +36 -1
  73. package/dist/backend/elements/frames.d.ts.map +1 -1
  74. package/dist/backend/elements/frames.js +43 -13
  75. package/dist/core/runner.d.ts.map +1 -1
  76. package/dist/core/runner.js +3 -4
  77. package/package.json +51 -12
@@ -1,2 +1,54 @@
1
- export {};
1
+ /**
2
+ * Attempts to switch the logical context to a specific iframe.
3
+ *
4
+ * ```gherkin
5
+ * When I switch to frame "#payment-iframe"
6
+ * ```
7
+ *
8
+ * @param selector - The CSS selector of the iframe element.
9
+ * @remarks
10
+ * **Limitation:** In the current architecture, "switching" the global page context permanently
11
+ * is complex. This step currently verifies the frame exists but logs a warning
12
+ * that subsequent steps might not automatically target this frame unless you use
13
+ * the specific `I find element ... in frame ...` step.
14
+ *
15
+ * @example
16
+ * When I switch to frame "iframe[name='payment']"
17
+ */
18
+ export declare const SwitchToFrame: void;
19
+ /**
20
+ * Finds an element inside a specific iframe and sets it as the active element.
21
+ * This is the robust way to interact with iframe content (e.g., Stripe forms, embedded videos).
22
+ *
23
+ * ```gherkin
24
+ * When I find element {string} in frame {string}
25
+ * ```
26
+ *
27
+ * @param elementSelector - The selector of the element INSIDE the iframe.
28
+ * @param frameSelector - The selector of the iframe element itself.
29
+ *
30
+ * @example
31
+ * When I find element "#card-number" in frame "#stripe-element"
32
+ * Then I type "4242 4242..."
33
+ */
34
+ export declare const FindElementInFrame: void;
35
+ /**
36
+ * Waits for a new browser tab (popup) to open.
37
+ * Useful for validating `target="_blank"` links.
38
+ *
39
+ * ```gherkin
40
+ * When I switch to new tab
41
+ * ```
42
+ *
43
+ * @remarks
44
+ * **Limitation:** This step verifies that a new tab was opened (e.g., after a click),
45
+ * but it does **not** swap the global `page` variable for subsequent steps due to runner limitations.
46
+ * It is primarily used for verification (ensuring a popup appeared).
47
+ *
48
+ * @example
49
+ * When I click on link "Open Dashboard"
50
+ * And I switch to new tab
51
+ * # (Implicitly validates the tab opened successfully)
52
+ */
53
+ export declare const SwitchToNewTab: void;
2
54
  //# sourceMappingURL=frames.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"frames.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/frames.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"frames.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/frames.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,MAoBxB,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,MAU9B,CAAC;AAMF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc,MAazB,CAAC"}
@@ -1,16 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SwitchToNewTab = exports.FindElementInFrame = exports.SwitchToFrame = void 0;
3
4
  const registry_1 = require("../../core/registry");
4
5
  const state_1 = require("../utils/state");
5
6
  // =============================
6
7
  // IFRAME HANDLING
7
8
  // =============================
8
9
  /**
9
- * Switches context to a specific iframe by its selector.
10
- * Subsequent "I find element" steps will search INSIDE this frame.
11
- * Pattern: When I switch to frame "#payment-frame"
10
+ * Attempts to switch the logical context to a specific iframe.
11
+ *
12
+ * ```gherkin
13
+ * When I switch to frame "#payment-iframe"
14
+ * ```
15
+ *
16
+ * @param selector - The CSS selector of the iframe element.
17
+ * @remarks
18
+ * **Limitation:** In the current architecture, "switching" the global page context permanently
19
+ * is complex. This step currently verifies the frame exists but logs a warning
20
+ * that subsequent steps might not automatically target this frame unless you use
21
+ * the specific `I find element ... in frame ...` step.
22
+ *
23
+ * @example
24
+ * When I switch to frame "iframe[name='payment']"
12
25
  */
13
- (0, registry_1.Step)("I switch to frame {string}", async (page, selector) => {
26
+ exports.SwitchToFrame = (0, registry_1.Step)("I switch to frame {string}", async (page, selector) => {
14
27
  const frameElement = page.locator(selector);
15
28
  const frame = frameElement.contentFrame();
16
29
  // We can't actually "switch" the global 'page' object easily in this architecture,
@@ -28,10 +41,21 @@ const state_1 = require("../utils/state");
28
41
  console.log(`⚠️ Switching Frames requires a Scope manager. For now, use 'I find element ... in frame ...'`);
29
42
  });
30
43
  /**
31
- * A specialized finder that looks INSIDE a frame.
32
- * Pattern: When I find element "#card-number" in frame "#stripe-iframe"
44
+ * Finds an element inside a specific iframe and sets it as the active element.
45
+ * This is the robust way to interact with iframe content (e.g., Stripe forms, embedded videos).
46
+ *
47
+ * ```gherkin
48
+ * When I find element {string} in frame {string}
49
+ * ```
50
+ *
51
+ * @param elementSelector - The selector of the element INSIDE the iframe.
52
+ * @param frameSelector - The selector of the iframe element itself.
53
+ *
54
+ * @example
55
+ * When I find element "#card-number" in frame "#stripe-element"
56
+ * Then I type "4242 4242..."
33
57
  */
34
- (0, registry_1.Step)("I find element {string} in frame {string}", async (page, elementSelector, frameSelector) => {
58
+ exports.FindElementInFrame = (0, registry_1.Step)("I find element {string} in frame {string}", async (page, elementSelector, frameSelector) => {
35
59
  const frame = page.frameLocator(frameSelector);
36
60
  const element = frame.locator(elementSelector).first();
37
61
  await element.waitFor();
@@ -42,11 +66,24 @@ const state_1 = require("../utils/state");
42
66
  // TAB / WINDOW HANDLING
43
67
  // =============================
44
68
  /**
45
- * Waits for a new tab (popup) to open and brings it to front.
46
- * Use this after clicking a link with target="_blank".
47
- * Pattern: When I switch to new tab
69
+ * Waits for a new browser tab (popup) to open.
70
+ * Useful for validating `target="_blank"` links.
71
+ *
72
+ * ```gherkin
73
+ * When I switch to new tab
74
+ * ```
75
+ *
76
+ * @remarks
77
+ * **Limitation:** This step verifies that a new tab was opened (e.g., after a click),
78
+ * but it does **not** swap the global `page` variable for subsequent steps due to runner limitations.
79
+ * It is primarily used for verification (ensuring a popup appeared).
80
+ *
81
+ * @example
82
+ * When I click on link "Open Dashboard"
83
+ * And I switch to new tab
84
+ * # (Implicitly validates the tab opened successfully)
48
85
  */
49
- (0, registry_1.Step)("I switch to new tab", async (page) => {
86
+ exports.SwitchToNewTab = (0, registry_1.Step)("I switch to new tab", async (page) => {
50
87
  // This is tricky: Playwright 'page' object passed to steps is usually fixed.
51
88
  // To support multi-tab, we'd need to update the Runner to allow swapping the 'page' reference.
52
89
  //
@@ -1,2 +1,140 @@
1
- export {};
1
+ /**
2
+ * Fills the currently stored (active) input element with specific text.
3
+ * Supports variable aliases using the "@" prefix.
4
+ *
5
+ * ```gherkin
6
+ * When I type "hello world"
7
+ * When I type "@storedPassword"
8
+ * ```
9
+ *
10
+ * @param textOrAlias - The text to type OR a variable key prefixed with "@".
11
+ * @param table - Optional data table for options (e.g., force: true).
12
+ */
13
+ export declare const TypeText: void;
14
+ /**
15
+ * Fills the active input with a value explicitly retrieved from the variable store.
16
+ * Unlike `I type`, this does not require the "@" prefix in the step text.
17
+ *
18
+ * ```gherkin
19
+ * When I type stored "userEmail"
20
+ * ```
21
+ *
22
+ * @param alias - The key of the stored variable.
23
+ */
24
+ export declare const TypeStoredText: void;
25
+ /**
26
+ * Types text character-by-character with a 100ms delay.
27
+ * Useful for testing auto-complete fields or search bars that listen for keystrokes.
28
+ *
29
+ * ```gherkin
30
+ * When I slowly type "Playwright"
31
+ * ```
32
+ *
33
+ * @param text - The text to type sequentially.
34
+ */
35
+ export declare const TypeSlowly: void;
36
+ /**
37
+ * Sets the value of an input directly (alias for filling).
38
+ *
39
+ * ```gherkin
40
+ * When I set value "12345"
41
+ * ```
42
+ *
43
+ * @param value - The value to set.
44
+ */
45
+ export declare const SetInputValue: void;
46
+ /**
47
+ * Clears the text content of the active input field.
48
+ *
49
+ * ```gherkin
50
+ * When I clear
51
+ * ```
52
+ */
53
+ export declare const ClearInput: void;
54
+ /**
55
+ * Simulates pressing a specific keyboard key on the active element.
56
+ * Useful for "Enter" to submit, or "ArrowDown" for dropdowns.
57
+ *
58
+ * ```gherkin
59
+ * When I press "Enter"
60
+ * When I press "Tab"
61
+ * ```
62
+ *
63
+ * @param key - The key name (e.g., "Enter", "Escape", "ArrowDown").
64
+ */
65
+ export declare const PressKeyOnInput: void;
66
+ /**
67
+ * Checks the currently active checkbox or radio button.
68
+ *
69
+ * ```gherkin
70
+ * When I check
71
+ * ```
72
+ */
73
+ export declare const CheckElement: void;
74
+ /**
75
+ * Unchecks the currently active checkbox.
76
+ *
77
+ * ```gherkin
78
+ * When I uncheck
79
+ * ```
80
+ */
81
+ export declare const UncheckElement: void;
82
+ /**
83
+ * Legacy alias for `I check`.
84
+ *
85
+ * ```gherkin
86
+ * When I check input
87
+ * ```
88
+ */
89
+ export declare const CheckInputAlias: void;
90
+ /**
91
+ * Legacy alias for `I uncheck`.
92
+ *
93
+ * ```gherkin
94
+ * When I uncheck input
95
+ * ```
96
+ */
97
+ export declare const UncheckInputAlias: void;
98
+ /**
99
+ * Selects an option in a `<select>` dropdown by its visible label.
100
+ *
101
+ * ```gherkin
102
+ * When I select option "California"
103
+ * ```
104
+ *
105
+ * @param option - The visible text label of the option to select.
106
+ */
107
+ export declare const SelectOption: void;
108
+ /**
109
+ * Submits the form related to the active element.
110
+ *
111
+ * **Logic:**
112
+ * 1. Tries to find the parent `<form>` of the currently stored element.
113
+ * 2. If no parent form is found (or no element is active), it finds the *first* form on the page.
114
+ *
115
+ * ```gherkin
116
+ * When I submit
117
+ * ```
118
+ */
119
+ export declare const SubmitForm: void;
120
+ /**
121
+ * Uploads a file to the active file input element.
122
+ *
123
+ * ```gherkin
124
+ * When I select file "data/invoice.pdf"
125
+ * ```
126
+ *
127
+ * @param filePath - The path to the file (relative to the project root).
128
+ */
129
+ export declare const SelectFile: void;
130
+ /**
131
+ * Alias for `I select file`.
132
+ *
133
+ * ```gherkin
134
+ * When I upload file "images/logo.png"
135
+ * ```
136
+ *
137
+ * @param filePath - The path to the file.
138
+ */
139
+ export declare const UploadFileAlias: void;
2
140
  //# sourceMappingURL=inputs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/inputs.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/inputs.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,MAgBnB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,MASzB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,MAIrB,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,MAKxB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,MAIrB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,MAI1B,CAAC;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,MAKvB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,MAKzB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,MAK1B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,MAK5B,CAAC;AAMH;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,MAOvB,CAAC;AAMH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,MAoBrB,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,MAIrB,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,MAI1B,CAAC"}
@@ -1,16 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UploadFileAlias = exports.SelectFile = exports.SubmitForm = exports.SelectOption = exports.UncheckInputAlias = exports.CheckInputAlias = exports.UncheckElement = exports.CheckElement = exports.PressKeyOnInput = exports.ClearInput = exports.SetInputValue = exports.TypeSlowly = exports.TypeStoredText = exports.TypeText = void 0;
3
4
  const registry_1 = require("../../core/registry");
4
5
  const state_1 = require("../utils/state");
5
6
  // =============================
6
7
  // 1. TYPING & FILLING
7
8
  // =============================
8
9
  /**
9
- * Types text into the currently stored element.
10
- * Supports aliases (e.g. "@password")
11
- * Pattern: When I type "hello"
10
+ * Fills the currently stored (active) input element with specific text.
11
+ * Supports variable aliases using the "@" prefix.
12
+ *
13
+ * ```gherkin
14
+ * When I type "hello world"
15
+ * When I type "@storedPassword"
16
+ * ```
17
+ *
18
+ * @param textOrAlias - The text to type OR a variable key prefixed with "@".
19
+ * @param table - Optional data table for options (e.g., force: true).
12
20
  */
13
- (0, registry_1.Step)("I type {string}", async (page, textOrAlias, table) => {
21
+ exports.TypeText = (0, registry_1.Step)("I type {string}", async (page, textOrAlias, table) => {
14
22
  const element = (0, state_1.getActiveElement)(page);
15
23
  const options = (0, state_1.parseClickOptions)(table); // Reusing generic options parser
16
24
  let text = textOrAlias;
@@ -26,10 +34,16 @@ const state_1 = require("../utils/state");
26
34
  console.log(`⌨️ Filled element with: "${text}"`);
27
35
  });
28
36
  /**
29
- * Types the value stored in a variable (Explicit version).
30
- * Pattern: When I type stored "userEmail"
37
+ * Fills the active input with a value explicitly retrieved from the variable store.
38
+ * Unlike `I type`, this does not require the "@" prefix in the step text.
39
+ *
40
+ * ```gherkin
41
+ * When I type stored "userEmail"
42
+ * ```
43
+ *
44
+ * @param alias - The key of the stored variable.
31
45
  */
32
- (0, registry_1.Step)("I type stored {string}", async (page, alias, table) => {
46
+ exports.TypeStoredText = (0, registry_1.Step)("I type stored {string}", async (page, alias, table) => {
33
47
  const element = (0, state_1.getActiveElement)(page);
34
48
  const options = (0, state_1.parseClickOptions)(table);
35
49
  const val = (0, state_1.getVariable)(page, alias);
@@ -39,38 +53,59 @@ const state_1 = require("../utils/state");
39
53
  console.log(`⌨️ Typed stored value from "${alias}"`);
40
54
  });
41
55
  /**
42
- * Slowly types text (mimics real keystrokes).
43
- * Pattern: When I slowly type "hello"
56
+ * Types text character-by-character with a 100ms delay.
57
+ * Useful for testing auto-complete fields or search bars that listen for keystrokes.
58
+ *
59
+ * ```gherkin
60
+ * When I slowly type "Playwright"
61
+ * ```
62
+ *
63
+ * @param text - The text to type sequentially.
44
64
  */
45
- (0, registry_1.Step)("I slowly type {string}", async (page, text) => {
65
+ exports.TypeSlowly = (0, registry_1.Step)("I slowly type {string}", async (page, text) => {
46
66
  const element = (0, state_1.getActiveElement)(page);
47
67
  await element.pressSequentially(text, { delay: 100 });
48
68
  console.log(`⌨️ Slowly typed: "${text}"`);
49
69
  });
50
70
  /**
51
- * Sets the value directly (Alias for Type, but semantically "Paste").
52
- * Pattern: When I set value "hello"
71
+ * Sets the value of an input directly (alias for filling).
72
+ *
73
+ * ```gherkin
74
+ * When I set value "12345"
75
+ * ```
76
+ *
77
+ * @param value - The value to set.
53
78
  */
54
- (0, registry_1.Step)("I set value {string}", async (page, value, table) => {
79
+ exports.SetInputValue = (0, registry_1.Step)("I set value {string}", async (page, value, table) => {
55
80
  const element = (0, state_1.getActiveElement)(page);
56
81
  const options = (0, state_1.parseClickOptions)(table);
57
82
  await element.fill(value, options);
58
83
  console.log(`📝 Set value to: "${value}"`);
59
84
  });
60
85
  /**
61
- * Clears the input field.
62
- * Pattern: When I clear input
86
+ * Clears the text content of the active input field.
87
+ *
88
+ * ```gherkin
89
+ * When I clear
90
+ * ```
63
91
  */
64
- (0, registry_1.Step)("I clear", async (page) => {
92
+ exports.ClearInput = (0, registry_1.Step)("I clear", async (page) => {
65
93
  const element = (0, state_1.getActiveElement)(page);
66
94
  await element.fill("");
67
95
  console.log("🧹 Cleared input");
68
96
  });
69
97
  /**
70
- * Press a keyboard key.
71
- * Pattern: When I press "Enter"
98
+ * Simulates pressing a specific keyboard key on the active element.
99
+ * Useful for "Enter" to submit, or "ArrowDown" for dropdowns.
100
+ *
101
+ * ```gherkin
102
+ * When I press "Enter"
103
+ * When I press "Tab"
104
+ * ```
105
+ *
106
+ * @param key - The key name (e.g., "Enter", "Escape", "ArrowDown").
72
107
  */
73
- (0, registry_1.Step)("I press {string}", async (page, key) => {
108
+ exports.PressKeyOnInput = (0, registry_1.Step)("I press {string}", async (page, key) => {
74
109
  const element = (0, state_1.getActiveElement)(page);
75
110
  await element.press(key);
76
111
  console.log(`🎹 Pressed key: "${key}"`);
@@ -79,38 +114,52 @@ const state_1 = require("../utils/state");
79
114
  // 2. CHECKBOXES & RADIOS
80
115
  // =============================
81
116
  /**
82
- * Checks the stored checkbox or radio button.
83
- * Pattern: When I check
117
+ * Checks the currently active checkbox or radio button.
118
+ *
119
+ * ```gherkin
120
+ * When I check
121
+ * ```
84
122
  */
85
- (0, registry_1.Step)("I check", async (page, table) => {
123
+ exports.CheckElement = (0, registry_1.Step)("I check", async (page, table) => {
86
124
  const element = (0, state_1.getActiveElement)(page);
87
125
  const options = (0, state_1.parseClickOptions)(table);
88
126
  await element.check(options);
89
127
  console.log("✅ Checked element");
90
128
  });
91
129
  /**
92
- * Unchecks the stored checkbox.
93
- * Pattern: When I uncheck
130
+ * Unchecks the currently active checkbox.
131
+ *
132
+ * ```gherkin
133
+ * When I uncheck
134
+ * ```
94
135
  */
95
- (0, registry_1.Step)("I uncheck", async (page, table) => {
136
+ exports.UncheckElement = (0, registry_1.Step)("I uncheck", async (page, table) => {
96
137
  const element = (0, state_1.getActiveElement)(page);
97
138
  const options = (0, state_1.parseClickOptions)(table);
98
139
  await element.uncheck(options);
99
140
  console.log("⬜ Unchecked element");
100
141
  });
101
142
  /**
102
- * Legacy Alias: When I check input
143
+ * Legacy alias for `I check`.
144
+ *
145
+ * ```gherkin
146
+ * When I check input
147
+ * ```
103
148
  */
104
- (0, registry_1.Step)("I check input", async (page, table) => {
149
+ exports.CheckInputAlias = (0, registry_1.Step)("I check input", async (page, table) => {
105
150
  const element = (0, state_1.getActiveElement)(page);
106
151
  const options = (0, state_1.parseClickOptions)(table);
107
152
  await element.check(options);
108
153
  console.log("✅ Checked input");
109
154
  });
110
155
  /**
111
- * Legacy Alias: When I uncheck input
156
+ * Legacy alias for `I uncheck`.
157
+ *
158
+ * ```gherkin
159
+ * When I uncheck input
160
+ * ```
112
161
  */
113
- (0, registry_1.Step)("I uncheck input", async (page, table) => {
162
+ exports.UncheckInputAlias = (0, registry_1.Step)("I uncheck input", async (page, table) => {
114
163
  const element = (0, state_1.getActiveElement)(page);
115
164
  const options = (0, state_1.parseClickOptions)(table);
116
165
  await element.uncheck(options);
@@ -120,10 +169,15 @@ const state_1 = require("../utils/state");
120
169
  // 3. DROPDOWNS & SELECTS
121
170
  // =============================
122
171
  /**
123
- * Selects an option by visible text/label.
124
- * Pattern: When I select option "United States"
172
+ * Selects an option in a `<select>` dropdown by its visible label.
173
+ *
174
+ * ```gherkin
175
+ * When I select option "California"
176
+ * ```
177
+ *
178
+ * @param option - The visible text label of the option to select.
125
179
  */
126
- (0, registry_1.Step)("I select option {string}", async (page, option, table) => {
180
+ exports.SelectOption = (0, registry_1.Step)("I select option {string}", async (page, option, table) => {
127
181
  const element = (0, state_1.getActiveElement)(page);
128
182
  const options = (0, state_1.parseClickOptions)(table);
129
183
  // Playwright selects by value or label automatically
@@ -134,18 +188,24 @@ const state_1 = require("../utils/state");
134
188
  // 4. FORMS & FILES
135
189
  // =============================
136
190
  /**
137
- * Submits the form containing the current element.
138
- * If no element is stored, tries to find the first form on page.
139
- * Pattern: When I submit
191
+ * Submits the form related to the active element.
192
+ *
193
+ * **Logic:**
194
+ * 1. Tries to find the parent `<form>` of the currently stored element.
195
+ * 2. If no parent form is found (or no element is active), it finds the *first* form on the page.
196
+ *
197
+ * ```gherkin
198
+ * When I submit
199
+ * ```
140
200
  */
141
- (0, registry_1.Step)("I submit", async (page) => {
201
+ exports.SubmitForm = (0, registry_1.Step)("I submit", async (page) => {
142
202
  let formLocator;
143
203
  try {
144
204
  const element = (0, state_1.getActiveElement)(page);
145
205
  // Try to find the parent form of the stored element
146
206
  formLocator = element.locator("xpath=ancestor-or-self::form");
147
207
  }
148
- catch (e) {
208
+ catch (_e) {
149
209
  // If no element stored, find first form on page
150
210
  formLocator = page.locator("form").first();
151
211
  }
@@ -158,19 +218,29 @@ const state_1 = require("../utils/state");
158
218
  console.log("📨 Submitted form");
159
219
  });
160
220
  /**
161
- * Uploads a file to a file input.
162
- * Pattern: When I upload file "docs/resume.pdf"
221
+ * Uploads a file to the active file input element.
222
+ *
223
+ * ```gherkin
224
+ * When I select file "data/invoice.pdf"
225
+ * ```
226
+ *
227
+ * @param filePath - The path to the file (relative to the project root).
163
228
  */
164
- (0, registry_1.Step)("I select file {string}", async (page, filePath) => {
229
+ exports.SelectFile = (0, registry_1.Step)("I select file {string}", async (page, filePath) => {
165
230
  const element = (0, state_1.getActiveElement)(page);
166
231
  await element.setInputFiles(filePath);
167
232
  console.log(`📂 Selected file: "${filePath}"`);
168
233
  });
169
234
  /**
170
- * Alias for upload.
171
- * Pattern: When I upload file "..."
235
+ * Alias for `I select file`.
236
+ *
237
+ * ```gherkin
238
+ * When I upload file "images/logo.png"
239
+ * ```
240
+ *
241
+ * @param filePath - The path to the file.
172
242
  */
173
- (0, registry_1.Step)("I upload file {string}", async (page, filePath) => {
243
+ exports.UploadFileAlias = (0, registry_1.Step)("I upload file {string}", async (page, filePath) => {
174
244
  const element = (0, state_1.getActiveElement)(page);
175
245
  await element.setInputFiles(filePath);
176
246
  console.log(`📂 Uploaded file: "${filePath}"`);
@@ -1,2 +1,62 @@
1
- export {};
1
+ /**
2
+ * Performs a standard click on the element matching the selector.
3
+ *
4
+ * ```gherkin
5
+ * When I click "#submit-button"
6
+ * ```
7
+ *
8
+ * @param selector - The CSS or XPath selector of the element to click.
9
+ */
10
+ export declare const ClickElement: void;
11
+ /**
12
+ * Performs a forced click on the element, bypassing visibility checks.
13
+ * Useful for elements obscured by overlays or technically "hidden" but interactable.
14
+ *
15
+ * ```gherkin
16
+ * When I force click "#hidden-checkbox"
17
+ * ```
18
+ *
19
+ * @param selector - The CSS or XPath selector.
20
+ * @remarks
21
+ * **Warning:** Use this sparingly. It disables Playwright's "actionability" checks,
22
+ * meaning it might click an element that a real user technically cannot click.
23
+ */
24
+ export declare const ForceClickElement: void;
25
+ /**
26
+ * Fills an input field with the specified value.
27
+ *
28
+ * ```gherkin
29
+ * When I fill "#username" with "testuser"
30
+ * ```
31
+ *
32
+ * @param selector - The CSS selector of the input field.
33
+ * @param value - The text value to type/fill.
34
+ */
35
+ export declare const FillElement: void;
36
+ /**
37
+ * Presses a specific key on the keyboard globally.
38
+ * Useful for submitting forms (Enter) or closing modals (Escape).
39
+ *
40
+ * ```gherkin
41
+ * When I press "Enter"
42
+ * When I press "Escape"
43
+ * ```
44
+ *
45
+ * @param key - The name of the key (e.g., "Enter", "Tab", "ArrowDown").
46
+ */
47
+ export declare const PressKeyGlobal: void;
48
+ /**
49
+ * Pauses the test execution for a fixed amount of time.
50
+ *
51
+ * ```gherkin
52
+ * When I wait for 5000 milliseconds
53
+ * ```
54
+ *
55
+ * @param ms - The duration to wait in milliseconds.
56
+ * @remarks
57
+ * **Anti-Pattern Warning:** Avoid using hard waits whenever possible.
58
+ * They make tests slower and flaky. Prefer `I wait for element to be visible`
59
+ * or `I wait for network idle` instead.
60
+ */
61
+ export declare const HardWait: void;
2
62
  //# sourceMappingURL=interactions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,MAEvB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,MAE5B,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,MAEtB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,MAEzB,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,MAEnB,CAAC"}