@atomic-testing/playwright 0.88.0 → 0.89.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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { BlurOption, BoundingRect, ClickOption, CssProperty, EnterTextOption, FocusOption, HoverOption, Interactor, MouseDownOption, MouseEnterOption, MouseLeaveOption, MouseMoveOption, MouseOutOption, MouseUpOption, Optional, PartLocator, Point, PressKeyOption, ScenePart, TestEngine, WaitForOption, WaitUntilOption } from "@atomic-testing/core";
2
2
  import { Page } from "@playwright/test";
3
- import { E2eTestInterface, E2eTestRunEnvironmentFixture, TestFrameworkMapper } from "@atomic-testing/internal-test-runner";
4
3
 
5
4
  //#region src/createTestEngine.d.ts
6
5
  /**
@@ -23,11 +22,32 @@ declare class PlaywrightInteractor implements Interactor {
23
22
  * @param page - Playwright page instance used to drive the browser.
24
23
  */
25
24
  constructor(page: Page);
25
+ /**
26
+ * Run a Playwright mutation and normalize a "locator matched nothing" failure
27
+ * into {@link ElementNotFoundError}, so a missing element throws the same error
28
+ * class here as it does in `DOMInteractor`, regardless of environment (the
29
+ * unified contract ratified in ADR-006).
30
+ *
31
+ * Playwright auto-waits for actionability and then throws its own
32
+ * `TimeoutError`. We translate that to `ElementNotFoundError` ONLY when the
33
+ * element genuinely does not exist (count 0) and otherwise rethrow the original
34
+ * error — preserving Playwright's auto-wait for an element that exists but is
35
+ * briefly not actionable (covered, disabled, animating). The trade-off is that
36
+ * a truly-missing element waits out the page's action timeout before throwing;
37
+ * bound it with `page.setDefaultTimeout` when fast failure matters.
38
+ *
39
+ * @param locator - Locator the mutation targets
40
+ * @param action - Method name used in the error message (e.g. `'click'`)
41
+ * @param run - The Playwright action to execute
42
+ * @throws {ElementNotFoundError} If the action fails and the element is absent
43
+ */
44
+ private runMutation;
26
45
  /**
27
46
  * Select the given option values on a `<select>` element.
28
47
  *
29
48
  * @param locator - Locator to the `<select>` element.
30
49
  * @param values - Values to select.
50
+ * @throws {ElementNotFoundError} If the element is not found
31
51
  */
32
52
  selectOptionValue(locator: PartLocator, values: string[]): Promise<void>;
33
53
  /**
@@ -35,23 +55,21 @@ declare class PlaywrightInteractor implements Interactor {
35
55
  *
36
56
  * Playwright's native `setInputFiles` reads the given paths from disk and
37
57
  * populates the input's `FileList`, firing the change event — the only way to
38
- * fill a file input, whose value cannot be set programmatically. Following
39
- * this layer's convention, no `ElementNotFoundError` is fabricated: a missing
40
- * element surfaces through Playwright's own auto-wait timeout.
58
+ * fill a file input, whose value cannot be set programmatically.
41
59
  *
42
60
  * @param locator - Locator of the `<input type="file">` element
43
61
  * @param files - One or more filesystem paths to upload
62
+ * @throws {ElementNotFoundError} If the element is not found
44
63
  */
45
64
  setInputFiles(locator: PartLocator, files: string | string[]): Promise<void>;
46
65
  /**
47
66
  * Scroll the located element into view, no-op if already visible.
48
67
  *
49
68
  * Delegates to Playwright's `scrollIntoViewIfNeeded`, which performs a real
50
- * layout-aware scroll in the browser. Per this layer's convention, no
51
- * `ElementNotFoundError` is fabricated: a missing element surfaces through
52
- * Playwright's own auto-wait timeout.
69
+ * layout-aware scroll in the browser.
53
70
  *
54
71
  * @param locator - Locator of the element to scroll into view
72
+ * @throws {ElementNotFoundError} If the element is not found
55
73
  */
56
74
  scrollIntoView(locator: PartLocator): Promise<void>;
57
75
  /**
@@ -63,24 +81,22 @@ declare class PlaywrightInteractor implements Interactor {
63
81
  * whereas evaluating `scrollBy` on the resolved element scrolls exactly that
64
82
  * element. This is a deliberate deviation from ADR 0001's per-engine table
65
83
  * (which lists `page.mouse.wheel`), taking the alternative the step-5 prompt
66
- * permits ("or evaluate el.scrollBy") for cross-browser determinism. As with
67
- * {@link scrollIntoView}, no `ElementNotFoundError` is fabricated; a missing
68
- * element surfaces through Playwright's own auto-wait timeout.
84
+ * permits ("or evaluate el.scrollBy") for cross-browser determinism.
69
85
  *
70
86
  * @param locator - Locator of the scrollable element
71
87
  * @param delta - Pixel offset to scroll by
88
+ * @throws {ElementNotFoundError} If the element is not found
72
89
  */
73
90
  scrollBy(locator: PartLocator, delta: Point): Promise<void>;
74
91
  /**
75
92
  * Drag the source element and drop it onto the target element.
76
93
  *
77
94
  * Delegates to Playwright's native `Locator.dragTo`, which performs a real,
78
- * layout-aware drag gesture in the browser. Per this layer's convention, no
79
- * `ElementNotFoundError` is fabricated: a missing element surfaces through
80
- * Playwright's own auto-wait timeout.
95
+ * layout-aware drag gesture in the browser.
81
96
  *
82
97
  * @param source - Locator of the element to drag
83
98
  * @param target - Locator of the drop target
99
+ * @throws {ElementNotFoundError} If either the source or target is not found
84
100
  */
85
101
  dragTo(source: PartLocator, target: PartLocator): Promise<void>;
86
102
  /**
@@ -91,9 +107,9 @@ declare class PlaywrightInteractor implements Interactor {
91
107
  * {@link mouseMove}/{@link mouseDown} — `mouseMove` resets the pointer with
92
108
  * `page.mouse.move(0, 0)` after hovering, which would corrupt the drag path
93
109
  * (see ADR 0001, option 5). The center comes from {@link getBoundingRect},
94
- * which throws `ElementNotFoundError` when the element has no box
95
- * (detached/invisible) rather than auto-waiting so this shares that
96
- * "element not found" contract instead of re-deriving the box + guard here.
110
+ * which throws `ElementNotFoundError` when the element has no box, so this
111
+ * shares that "element not found" contract instead of re-deriving the box +
112
+ * guard here.
97
113
  *
98
114
  * @param locator - Locator of the element to drag
99
115
  * @param delta - Pixel offset to drag by
@@ -117,16 +133,16 @@ declare class PlaywrightInteractor implements Interactor {
117
133
  getSelectLabels(locator: PartLocator): Promise<Optional<readonly string[]>>;
118
134
  getStyleValue(locator: PartLocator, propertyName: CssProperty): Promise<Optional<string>>;
119
135
  enterText(locator: PartLocator, text: string, option?: Optional<Partial<EnterTextOption>>): Promise<void>;
136
+ setRangeValue(locator: PartLocator, value: number): Promise<void>;
120
137
  click(locator: PartLocator, option?: Partial<ClickOption>): Promise<void>;
121
138
  /**
122
139
  * Dispatch a right-click on the located element to open its context menu.
123
140
  *
124
141
  * Delegates to Playwright's native right-button click, which fires a real
125
- * `contextmenu` event in the browser. Per this layer's convention, no
126
- * `ElementNotFoundError` is fabricated: a missing element surfaces through
127
- * Playwright's own auto-wait timeout.
142
+ * `contextmenu` event in the browser.
128
143
  *
129
144
  * @param locator - Locator of the element to right-click
145
+ * @throws {ElementNotFoundError} If the element is not found
130
146
  */
131
147
  contextMenu(locator: PartLocator): Promise<void>;
132
148
  hover(locator: PartLocator, option?: Partial<HoverOption>): Promise<void>;
@@ -152,9 +168,8 @@ declare class PlaywrightInteractor implements Interactor {
152
168
  * Get the located element's bounding rectangle.
153
169
  *
154
170
  * `boundingBox()` returns `null` for a detached/invisible element rather than
155
- * auto-waiting, so this is one of the few Playwright methods that throws
156
- * `ElementNotFoundError` — matching the house "element not found" contract
157
- * (ADR 0001).
171
+ * auto-waiting, so this throws `ElementNotFoundError` directly (no auto-wait)
172
+ * — matching the unified "element not found" contract (ADR-006).
158
173
  *
159
174
  * @param locator - Locator of the element to measure
160
175
  * @returns The element's bounding rectangle in CSS pixels
@@ -172,30 +187,5 @@ declare class PlaywrightInteractor implements Interactor {
172
187
  clone(): Interactor;
173
188
  }
174
189
  //#endregion
175
- //#region src/testRunnerAdapter.d.ts
176
- /**
177
- * Navigate the current Playwright page to the provided URL.
178
- *
179
- * @param url - Destination URL to load.
180
- * @param fixture - Optional test fixture supplying the Playwright page.
181
- */
182
- declare function goto(url: string): Promise<void>;
183
- declare function goto(url: string, fixture: E2eTestRunEnvironmentFixture): Promise<void>;
184
- /**
185
- * Create a {@link TestEngine} bound to the Playwright page in the given fixture.
186
- *
187
- * @param scenePart - Scene definition to drive.
188
- * @param fixture - Fixture providing the Playwright page.
189
- */
190
- declare function playwrightGetTestEngine<T extends ScenePart>(scenePart: T, fixture: E2eTestRunEnvironmentFixture): TestEngine<T>;
191
- /**
192
- * Playwright adapter for the TestFrameworkMapper interface.
193
- */
194
- declare const playWrightTestFrameworkMapper: TestFrameworkMapper;
195
- /**
196
- * Get a typed interface for running end-to-end tests with Playwright.
197
- */
198
- declare function getTestRunnerInterface<T extends ScenePart>(): E2eTestInterface<T>;
199
- //#endregion
200
- export { PlaywrightInteractor, createTestEngine, getTestRunnerInterface, goto, playWrightTestFrameworkMapper, playwrightGetTestEngine };
190
+ export { PlaywrightInteractor, createTestEngine };
201
191
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { BlurOption, BoundingRect, ClickOption, CssProperty, EnterTextOption, FocusOption, HoverOption, Interactor, MouseDownOption, MouseEnterOption, MouseLeaveOption, MouseMoveOption, MouseOutOption, MouseUpOption, Optional, PartLocator, Point, PressKeyOption, ScenePart, TestEngine, WaitForOption, WaitUntilOption } from "@atomic-testing/core";
2
2
  import { Page } from "@playwright/test";
3
- import { E2eTestInterface, E2eTestRunEnvironmentFixture, TestFrameworkMapper } from "@atomic-testing/internal-test-runner";
4
3
 
5
4
  //#region src/createTestEngine.d.ts
6
5
  /**
@@ -23,11 +22,32 @@ declare class PlaywrightInteractor implements Interactor {
23
22
  * @param page - Playwright page instance used to drive the browser.
24
23
  */
25
24
  constructor(page: Page);
25
+ /**
26
+ * Run a Playwright mutation and normalize a "locator matched nothing" failure
27
+ * into {@link ElementNotFoundError}, so a missing element throws the same error
28
+ * class here as it does in `DOMInteractor`, regardless of environment (the
29
+ * unified contract ratified in ADR-006).
30
+ *
31
+ * Playwright auto-waits for actionability and then throws its own
32
+ * `TimeoutError`. We translate that to `ElementNotFoundError` ONLY when the
33
+ * element genuinely does not exist (count 0) and otherwise rethrow the original
34
+ * error — preserving Playwright's auto-wait for an element that exists but is
35
+ * briefly not actionable (covered, disabled, animating). The trade-off is that
36
+ * a truly-missing element waits out the page's action timeout before throwing;
37
+ * bound it with `page.setDefaultTimeout` when fast failure matters.
38
+ *
39
+ * @param locator - Locator the mutation targets
40
+ * @param action - Method name used in the error message (e.g. `'click'`)
41
+ * @param run - The Playwright action to execute
42
+ * @throws {ElementNotFoundError} If the action fails and the element is absent
43
+ */
44
+ private runMutation;
26
45
  /**
27
46
  * Select the given option values on a `<select>` element.
28
47
  *
29
48
  * @param locator - Locator to the `<select>` element.
30
49
  * @param values - Values to select.
50
+ * @throws {ElementNotFoundError} If the element is not found
31
51
  */
32
52
  selectOptionValue(locator: PartLocator, values: string[]): Promise<void>;
33
53
  /**
@@ -35,23 +55,21 @@ declare class PlaywrightInteractor implements Interactor {
35
55
  *
36
56
  * Playwright's native `setInputFiles` reads the given paths from disk and
37
57
  * populates the input's `FileList`, firing the change event — the only way to
38
- * fill a file input, whose value cannot be set programmatically. Following
39
- * this layer's convention, no `ElementNotFoundError` is fabricated: a missing
40
- * element surfaces through Playwright's own auto-wait timeout.
58
+ * fill a file input, whose value cannot be set programmatically.
41
59
  *
42
60
  * @param locator - Locator of the `<input type="file">` element
43
61
  * @param files - One or more filesystem paths to upload
62
+ * @throws {ElementNotFoundError} If the element is not found
44
63
  */
45
64
  setInputFiles(locator: PartLocator, files: string | string[]): Promise<void>;
46
65
  /**
47
66
  * Scroll the located element into view, no-op if already visible.
48
67
  *
49
68
  * Delegates to Playwright's `scrollIntoViewIfNeeded`, which performs a real
50
- * layout-aware scroll in the browser. Per this layer's convention, no
51
- * `ElementNotFoundError` is fabricated: a missing element surfaces through
52
- * Playwright's own auto-wait timeout.
69
+ * layout-aware scroll in the browser.
53
70
  *
54
71
  * @param locator - Locator of the element to scroll into view
72
+ * @throws {ElementNotFoundError} If the element is not found
55
73
  */
56
74
  scrollIntoView(locator: PartLocator): Promise<void>;
57
75
  /**
@@ -63,24 +81,22 @@ declare class PlaywrightInteractor implements Interactor {
63
81
  * whereas evaluating `scrollBy` on the resolved element scrolls exactly that
64
82
  * element. This is a deliberate deviation from ADR 0001's per-engine table
65
83
  * (which lists `page.mouse.wheel`), taking the alternative the step-5 prompt
66
- * permits ("or evaluate el.scrollBy") for cross-browser determinism. As with
67
- * {@link scrollIntoView}, no `ElementNotFoundError` is fabricated; a missing
68
- * element surfaces through Playwright's own auto-wait timeout.
84
+ * permits ("or evaluate el.scrollBy") for cross-browser determinism.
69
85
  *
70
86
  * @param locator - Locator of the scrollable element
71
87
  * @param delta - Pixel offset to scroll by
88
+ * @throws {ElementNotFoundError} If the element is not found
72
89
  */
73
90
  scrollBy(locator: PartLocator, delta: Point): Promise<void>;
74
91
  /**
75
92
  * Drag the source element and drop it onto the target element.
76
93
  *
77
94
  * Delegates to Playwright's native `Locator.dragTo`, which performs a real,
78
- * layout-aware drag gesture in the browser. Per this layer's convention, no
79
- * `ElementNotFoundError` is fabricated: a missing element surfaces through
80
- * Playwright's own auto-wait timeout.
95
+ * layout-aware drag gesture in the browser.
81
96
  *
82
97
  * @param source - Locator of the element to drag
83
98
  * @param target - Locator of the drop target
99
+ * @throws {ElementNotFoundError} If either the source or target is not found
84
100
  */
85
101
  dragTo(source: PartLocator, target: PartLocator): Promise<void>;
86
102
  /**
@@ -91,9 +107,9 @@ declare class PlaywrightInteractor implements Interactor {
91
107
  * {@link mouseMove}/{@link mouseDown} — `mouseMove` resets the pointer with
92
108
  * `page.mouse.move(0, 0)` after hovering, which would corrupt the drag path
93
109
  * (see ADR 0001, option 5). The center comes from {@link getBoundingRect},
94
- * which throws `ElementNotFoundError` when the element has no box
95
- * (detached/invisible) rather than auto-waiting so this shares that
96
- * "element not found" contract instead of re-deriving the box + guard here.
110
+ * which throws `ElementNotFoundError` when the element has no box, so this
111
+ * shares that "element not found" contract instead of re-deriving the box +
112
+ * guard here.
97
113
  *
98
114
  * @param locator - Locator of the element to drag
99
115
  * @param delta - Pixel offset to drag by
@@ -117,16 +133,16 @@ declare class PlaywrightInteractor implements Interactor {
117
133
  getSelectLabels(locator: PartLocator): Promise<Optional<readonly string[]>>;
118
134
  getStyleValue(locator: PartLocator, propertyName: CssProperty): Promise<Optional<string>>;
119
135
  enterText(locator: PartLocator, text: string, option?: Optional<Partial<EnterTextOption>>): Promise<void>;
136
+ setRangeValue(locator: PartLocator, value: number): Promise<void>;
120
137
  click(locator: PartLocator, option?: Partial<ClickOption>): Promise<void>;
121
138
  /**
122
139
  * Dispatch a right-click on the located element to open its context menu.
123
140
  *
124
141
  * Delegates to Playwright's native right-button click, which fires a real
125
- * `contextmenu` event in the browser. Per this layer's convention, no
126
- * `ElementNotFoundError` is fabricated: a missing element surfaces through
127
- * Playwright's own auto-wait timeout.
142
+ * `contextmenu` event in the browser.
128
143
  *
129
144
  * @param locator - Locator of the element to right-click
145
+ * @throws {ElementNotFoundError} If the element is not found
130
146
  */
131
147
  contextMenu(locator: PartLocator): Promise<void>;
132
148
  hover(locator: PartLocator, option?: Partial<HoverOption>): Promise<void>;
@@ -152,9 +168,8 @@ declare class PlaywrightInteractor implements Interactor {
152
168
  * Get the located element's bounding rectangle.
153
169
  *
154
170
  * `boundingBox()` returns `null` for a detached/invisible element rather than
155
- * auto-waiting, so this is one of the few Playwright methods that throws
156
- * `ElementNotFoundError` — matching the house "element not found" contract
157
- * (ADR 0001).
171
+ * auto-waiting, so this throws `ElementNotFoundError` directly (no auto-wait)
172
+ * — matching the unified "element not found" contract (ADR-006).
158
173
  *
159
174
  * @param locator - Locator of the element to measure
160
175
  * @returns The element's bounding rectangle in CSS pixels
@@ -172,30 +187,5 @@ declare class PlaywrightInteractor implements Interactor {
172
187
  clone(): Interactor;
173
188
  }
174
189
  //#endregion
175
- //#region src/testRunnerAdapter.d.ts
176
- /**
177
- * Navigate the current Playwright page to the provided URL.
178
- *
179
- * @param url - Destination URL to load.
180
- * @param fixture - Optional test fixture supplying the Playwright page.
181
- */
182
- declare function goto(url: string): Promise<void>;
183
- declare function goto(url: string, fixture: E2eTestRunEnvironmentFixture): Promise<void>;
184
- /**
185
- * Create a {@link TestEngine} bound to the Playwright page in the given fixture.
186
- *
187
- * @param scenePart - Scene definition to drive.
188
- * @param fixture - Fixture providing the Playwright page.
189
- */
190
- declare function playwrightGetTestEngine<T extends ScenePart>(scenePart: T, fixture: E2eTestRunEnvironmentFixture): TestEngine<T>;
191
- /**
192
- * Playwright adapter for the TestFrameworkMapper interface.
193
- */
194
- declare const playWrightTestFrameworkMapper: TestFrameworkMapper;
195
- /**
196
- * Get a typed interface for running end-to-end tests with Playwright.
197
- */
198
- declare function getTestRunnerInterface<T extends ScenePart>(): E2eTestInterface<T>;
199
- //#endregion
200
- export { PlaywrightInteractor, createTestEngine, getTestRunnerInterface, goto, playWrightTestFrameworkMapper, playwrightGetTestEngine };
190
+ export { PlaywrightInteractor, createTestEngine };
201
191
  //# sourceMappingURL=index.d.mts.map