@atomic-testing/playwright 0.87.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
- import { BlurOption, ClickOption, CssProperty, EnterTextOption, FocusOption, HoverOption, Interactor, MouseDownOption, MouseEnterOption, MouseLeaveOption, MouseMoveOption, MouseOutOption, MouseUpOption, Optional, PartLocator, PressKeyOption, ScenePart, TestEngine, WaitForOption, WaitUntilOption } from "@atomic-testing/core";
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,13 +22,100 @@ 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>;
53
+ /**
54
+ * Set the selected files on a `<input type="file">` element.
55
+ *
56
+ * Playwright's native `setInputFiles` reads the given paths from disk and
57
+ * populates the input's `FileList`, firing the change event — the only way to
58
+ * fill a file input, whose value cannot be set programmatically.
59
+ *
60
+ * @param locator - Locator of the `<input type="file">` element
61
+ * @param files - One or more filesystem paths to upload
62
+ * @throws {ElementNotFoundError} If the element is not found
63
+ */
64
+ setInputFiles(locator: PartLocator, files: string | string[]): Promise<void>;
65
+ /**
66
+ * Scroll the located element into view, no-op if already visible.
67
+ *
68
+ * Delegates to Playwright's `scrollIntoViewIfNeeded`, which performs a real
69
+ * layout-aware scroll in the browser.
70
+ *
71
+ * @param locator - Locator of the element to scroll into view
72
+ * @throws {ElementNotFoundError} If the element is not found
73
+ */
74
+ scrollIntoView(locator: PartLocator): Promise<void>;
75
+ /**
76
+ * Scroll the located element by the given pixel delta.
77
+ *
78
+ * The scroll is performed by evaluating `el.scrollBy(dx, dy)` on the element
79
+ * itself rather than `page.mouse.wheel`. A wheel event scrolls whatever sits
80
+ * under the pointer and is non-deterministic across chromium/firefox/webkit,
81
+ * whereas evaluating `scrollBy` on the resolved element scrolls exactly that
82
+ * element. This is a deliberate deviation from ADR 0001's per-engine table
83
+ * (which lists `page.mouse.wheel`), taking the alternative the step-5 prompt
84
+ * permits ("or evaluate el.scrollBy") for cross-browser determinism.
85
+ *
86
+ * @param locator - Locator of the scrollable element
87
+ * @param delta - Pixel offset to scroll by
88
+ * @throws {ElementNotFoundError} If the element is not found
89
+ */
90
+ scrollBy(locator: PartLocator, delta: Point): Promise<void>;
91
+ /**
92
+ * Drag the source element and drop it onto the target element.
93
+ *
94
+ * Delegates to Playwright's native `Locator.dragTo`, which performs a real,
95
+ * layout-aware drag gesture in the browser.
96
+ *
97
+ * @param source - Locator of the element to drag
98
+ * @param target - Locator of the drop target
99
+ * @throws {ElementNotFoundError} If either the source or target is not found
100
+ */
101
+ dragTo(source: PartLocator, target: PartLocator): Promise<void>;
102
+ /**
103
+ * Drag the located element by the given pixel delta from its center.
104
+ *
105
+ * The gesture is a single uninterrupted `move → down → move → up` sequence
106
+ * computed from the element's center. It deliberately does NOT reuse
107
+ * {@link mouseMove}/{@link mouseDown} — `mouseMove` resets the pointer with
108
+ * `page.mouse.move(0, 0)` after hovering, which would corrupt the drag path
109
+ * (see ADR 0001, option 5). The center comes from {@link getBoundingRect},
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.
113
+ *
114
+ * @param locator - Locator of the element to drag
115
+ * @param delta - Pixel offset to drag by
116
+ * @throws {ElementNotFoundError} If the element has no bounding box
117
+ */
118
+ drag(locator: PartLocator, delta: Point): Promise<void>;
33
119
  /**
34
120
  * Get the value of an `<input>` element.
35
121
  *
@@ -47,7 +133,18 @@ declare class PlaywrightInteractor implements Interactor {
47
133
  getSelectLabels(locator: PartLocator): Promise<Optional<readonly string[]>>;
48
134
  getStyleValue(locator: PartLocator, propertyName: CssProperty): Promise<Optional<string>>;
49
135
  enterText(locator: PartLocator, text: string, option?: Optional<Partial<EnterTextOption>>): Promise<void>;
136
+ setRangeValue(locator: PartLocator, value: number): Promise<void>;
50
137
  click(locator: PartLocator, option?: Partial<ClickOption>): Promise<void>;
138
+ /**
139
+ * Dispatch a right-click on the located element to open its context menu.
140
+ *
141
+ * Delegates to Playwright's native right-button click, which fires a real
142
+ * `contextmenu` event in the browser.
143
+ *
144
+ * @param locator - Locator of the element to right-click
145
+ * @throws {ElementNotFoundError} If the element is not found
146
+ */
147
+ contextMenu(locator: PartLocator): Promise<void>;
51
148
  hover(locator: PartLocator, option?: Partial<HoverOption>): Promise<void>;
52
149
  mouseMove(locator: PartLocator, option?: Partial<MouseMoveOption>): Promise<void>;
53
150
  mouseDown(locator: PartLocator, option?: Partial<MouseDownOption>): Promise<void>;
@@ -58,7 +155,7 @@ declare class PlaywrightInteractor implements Interactor {
58
155
  mouseLeave(locator: PartLocator, _option?: Partial<MouseLeaveOption>): Promise<void>;
59
156
  focus(locator: PartLocator, _option?: Partial<FocusOption>): Promise<void>;
60
157
  blur(locator: PartLocator, _option?: Partial<BlurOption>): Promise<void>;
61
- pressKey(locator: PartLocator, key: string, _option?: Partial<PressKeyOption>): Promise<void>;
158
+ pressKey(locator: PartLocator, key: string, option?: Partial<PressKeyOption>): Promise<void>;
62
159
  activate(locator: PartLocator): Promise<void>;
63
160
  wait(ms: number): Promise<void>;
64
161
  waitUntilComponentState(locator: PartLocator, option?: Partial<Readonly<WaitForOption>>): Promise<void>;
@@ -67,6 +164,18 @@ declare class PlaywrightInteractor implements Interactor {
67
164
  getAttribute(locator: PartLocator, name: string, isMultiple: false): Promise<Optional<string>>;
68
165
  getAttribute(locator: PartLocator, name: string): Promise<Optional<string>>;
69
166
  getText(locator: PartLocator): Promise<Optional<string>>;
167
+ /**
168
+ * Get the located element's bounding rectangle.
169
+ *
170
+ * `boundingBox()` returns `null` for a detached/invisible element rather than
171
+ * auto-waiting, so this throws `ElementNotFoundError` directly (no auto-wait)
172
+ * — matching the unified "element not found" contract (ADR-006).
173
+ *
174
+ * @param locator - Locator of the element to measure
175
+ * @returns The element's bounding rectangle in CSS pixels
176
+ * @throws {ElementNotFoundError} If the element has no bounding box
177
+ */
178
+ getBoundingRect(locator: PartLocator): Promise<BoundingRect>;
70
179
  exists(locator: PartLocator): Promise<boolean>;
71
180
  isChecked(locator: PartLocator): Promise<boolean>;
72
181
  isDisabled(locator: PartLocator): Promise<boolean>;
@@ -78,30 +187,5 @@ declare class PlaywrightInteractor implements Interactor {
78
187
  clone(): Interactor;
79
188
  }
80
189
  //#endregion
81
- //#region src/testRunnerAdapter.d.ts
82
- /**
83
- * Navigate the current Playwright page to the provided URL.
84
- *
85
- * @param url - Destination URL to load.
86
- * @param fixture - Optional test fixture supplying the Playwright page.
87
- */
88
- declare function goto(url: string): Promise<void>;
89
- declare function goto(url: string, fixture: E2eTestRunEnvironmentFixture): Promise<void>;
90
- /**
91
- * Create a {@link TestEngine} bound to the Playwright page in the given fixture.
92
- *
93
- * @param scenePart - Scene definition to drive.
94
- * @param fixture - Fixture providing the Playwright page.
95
- */
96
- declare function playwrightGetTestEngine<T extends ScenePart>(scenePart: T, fixture: E2eTestRunEnvironmentFixture): TestEngine<T>;
97
- /**
98
- * Playwright adapter for the TestFrameworkMapper interface.
99
- */
100
- declare const playWrightTestFrameworkMapper: TestFrameworkMapper;
101
- /**
102
- * Get a typed interface for running end-to-end tests with Playwright.
103
- */
104
- declare function getTestRunnerInterface<T extends ScenePart>(): E2eTestInterface<T>;
105
- //#endregion
106
- export { PlaywrightInteractor, createTestEngine, getTestRunnerInterface, goto, playWrightTestFrameworkMapper, playwrightGetTestEngine };
190
+ export { PlaywrightInteractor, createTestEngine };
107
191
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { BlurOption, ClickOption, CssProperty, EnterTextOption, FocusOption, HoverOption, Interactor, MouseDownOption, MouseEnterOption, MouseLeaveOption, MouseMoveOption, MouseOutOption, MouseUpOption, Optional, PartLocator, PressKeyOption, ScenePart, TestEngine, WaitForOption, WaitUntilOption } from "@atomic-testing/core";
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,13 +22,100 @@ 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>;
53
+ /**
54
+ * Set the selected files on a `<input type="file">` element.
55
+ *
56
+ * Playwright's native `setInputFiles` reads the given paths from disk and
57
+ * populates the input's `FileList`, firing the change event — the only way to
58
+ * fill a file input, whose value cannot be set programmatically.
59
+ *
60
+ * @param locator - Locator of the `<input type="file">` element
61
+ * @param files - One or more filesystem paths to upload
62
+ * @throws {ElementNotFoundError} If the element is not found
63
+ */
64
+ setInputFiles(locator: PartLocator, files: string | string[]): Promise<void>;
65
+ /**
66
+ * Scroll the located element into view, no-op if already visible.
67
+ *
68
+ * Delegates to Playwright's `scrollIntoViewIfNeeded`, which performs a real
69
+ * layout-aware scroll in the browser.
70
+ *
71
+ * @param locator - Locator of the element to scroll into view
72
+ * @throws {ElementNotFoundError} If the element is not found
73
+ */
74
+ scrollIntoView(locator: PartLocator): Promise<void>;
75
+ /**
76
+ * Scroll the located element by the given pixel delta.
77
+ *
78
+ * The scroll is performed by evaluating `el.scrollBy(dx, dy)` on the element
79
+ * itself rather than `page.mouse.wheel`. A wheel event scrolls whatever sits
80
+ * under the pointer and is non-deterministic across chromium/firefox/webkit,
81
+ * whereas evaluating `scrollBy` on the resolved element scrolls exactly that
82
+ * element. This is a deliberate deviation from ADR 0001's per-engine table
83
+ * (which lists `page.mouse.wheel`), taking the alternative the step-5 prompt
84
+ * permits ("or evaluate el.scrollBy") for cross-browser determinism.
85
+ *
86
+ * @param locator - Locator of the scrollable element
87
+ * @param delta - Pixel offset to scroll by
88
+ * @throws {ElementNotFoundError} If the element is not found
89
+ */
90
+ scrollBy(locator: PartLocator, delta: Point): Promise<void>;
91
+ /**
92
+ * Drag the source element and drop it onto the target element.
93
+ *
94
+ * Delegates to Playwright's native `Locator.dragTo`, which performs a real,
95
+ * layout-aware drag gesture in the browser.
96
+ *
97
+ * @param source - Locator of the element to drag
98
+ * @param target - Locator of the drop target
99
+ * @throws {ElementNotFoundError} If either the source or target is not found
100
+ */
101
+ dragTo(source: PartLocator, target: PartLocator): Promise<void>;
102
+ /**
103
+ * Drag the located element by the given pixel delta from its center.
104
+ *
105
+ * The gesture is a single uninterrupted `move → down → move → up` sequence
106
+ * computed from the element's center. It deliberately does NOT reuse
107
+ * {@link mouseMove}/{@link mouseDown} — `mouseMove` resets the pointer with
108
+ * `page.mouse.move(0, 0)` after hovering, which would corrupt the drag path
109
+ * (see ADR 0001, option 5). The center comes from {@link getBoundingRect},
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.
113
+ *
114
+ * @param locator - Locator of the element to drag
115
+ * @param delta - Pixel offset to drag by
116
+ * @throws {ElementNotFoundError} If the element has no bounding box
117
+ */
118
+ drag(locator: PartLocator, delta: Point): Promise<void>;
33
119
  /**
34
120
  * Get the value of an `<input>` element.
35
121
  *
@@ -47,7 +133,18 @@ declare class PlaywrightInteractor implements Interactor {
47
133
  getSelectLabels(locator: PartLocator): Promise<Optional<readonly string[]>>;
48
134
  getStyleValue(locator: PartLocator, propertyName: CssProperty): Promise<Optional<string>>;
49
135
  enterText(locator: PartLocator, text: string, option?: Optional<Partial<EnterTextOption>>): Promise<void>;
136
+ setRangeValue(locator: PartLocator, value: number): Promise<void>;
50
137
  click(locator: PartLocator, option?: Partial<ClickOption>): Promise<void>;
138
+ /**
139
+ * Dispatch a right-click on the located element to open its context menu.
140
+ *
141
+ * Delegates to Playwright's native right-button click, which fires a real
142
+ * `contextmenu` event in the browser.
143
+ *
144
+ * @param locator - Locator of the element to right-click
145
+ * @throws {ElementNotFoundError} If the element is not found
146
+ */
147
+ contextMenu(locator: PartLocator): Promise<void>;
51
148
  hover(locator: PartLocator, option?: Partial<HoverOption>): Promise<void>;
52
149
  mouseMove(locator: PartLocator, option?: Partial<MouseMoveOption>): Promise<void>;
53
150
  mouseDown(locator: PartLocator, option?: Partial<MouseDownOption>): Promise<void>;
@@ -58,7 +155,7 @@ declare class PlaywrightInteractor implements Interactor {
58
155
  mouseLeave(locator: PartLocator, _option?: Partial<MouseLeaveOption>): Promise<void>;
59
156
  focus(locator: PartLocator, _option?: Partial<FocusOption>): Promise<void>;
60
157
  blur(locator: PartLocator, _option?: Partial<BlurOption>): Promise<void>;
61
- pressKey(locator: PartLocator, key: string, _option?: Partial<PressKeyOption>): Promise<void>;
158
+ pressKey(locator: PartLocator, key: string, option?: Partial<PressKeyOption>): Promise<void>;
62
159
  activate(locator: PartLocator): Promise<void>;
63
160
  wait(ms: number): Promise<void>;
64
161
  waitUntilComponentState(locator: PartLocator, option?: Partial<Readonly<WaitForOption>>): Promise<void>;
@@ -67,6 +164,18 @@ declare class PlaywrightInteractor implements Interactor {
67
164
  getAttribute(locator: PartLocator, name: string, isMultiple: false): Promise<Optional<string>>;
68
165
  getAttribute(locator: PartLocator, name: string): Promise<Optional<string>>;
69
166
  getText(locator: PartLocator): Promise<Optional<string>>;
167
+ /**
168
+ * Get the located element's bounding rectangle.
169
+ *
170
+ * `boundingBox()` returns `null` for a detached/invisible element rather than
171
+ * auto-waiting, so this throws `ElementNotFoundError` directly (no auto-wait)
172
+ * — matching the unified "element not found" contract (ADR-006).
173
+ *
174
+ * @param locator - Locator of the element to measure
175
+ * @returns The element's bounding rectangle in CSS pixels
176
+ * @throws {ElementNotFoundError} If the element has no bounding box
177
+ */
178
+ getBoundingRect(locator: PartLocator): Promise<BoundingRect>;
70
179
  exists(locator: PartLocator): Promise<boolean>;
71
180
  isChecked(locator: PartLocator): Promise<boolean>;
72
181
  isDisabled(locator: PartLocator): Promise<boolean>;
@@ -78,30 +187,5 @@ declare class PlaywrightInteractor implements Interactor {
78
187
  clone(): Interactor;
79
188
  }
80
189
  //#endregion
81
- //#region src/testRunnerAdapter.d.ts
82
- /**
83
- * Navigate the current Playwright page to the provided URL.
84
- *
85
- * @param url - Destination URL to load.
86
- * @param fixture - Optional test fixture supplying the Playwright page.
87
- */
88
- declare function goto(url: string): Promise<void>;
89
- declare function goto(url: string, fixture: E2eTestRunEnvironmentFixture): Promise<void>;
90
- /**
91
- * Create a {@link TestEngine} bound to the Playwright page in the given fixture.
92
- *
93
- * @param scenePart - Scene definition to drive.
94
- * @param fixture - Fixture providing the Playwright page.
95
- */
96
- declare function playwrightGetTestEngine<T extends ScenePart>(scenePart: T, fixture: E2eTestRunEnvironmentFixture): TestEngine<T>;
97
- /**
98
- * Playwright adapter for the TestFrameworkMapper interface.
99
- */
100
- declare const playWrightTestFrameworkMapper: TestFrameworkMapper;
101
- /**
102
- * Get a typed interface for running end-to-end tests with Playwright.
103
- */
104
- declare function getTestRunnerInterface<T extends ScenePart>(): E2eTestInterface<T>;
105
- //#endregion
106
- export { PlaywrightInteractor, createTestEngine, getTestRunnerInterface, goto, playWrightTestFrameworkMapper, playwrightGetTestEngine };
190
+ export { PlaywrightInteractor, createTestEngine };
107
191
  //# sourceMappingURL=index.d.mts.map