@e2edev/web 0.11.0-canary-20260921180210
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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +112 -0
- package/dist/.build.json +1 -0
- package/dist/actions.d.ts +23 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +174 -0
- package/dist/actions.js.map +1 -0
- package/dist/attempt-session.d.ts +76 -0
- package/dist/attempt-session.d.ts.map +1 -0
- package/dist/attempt-session.js +290 -0
- package/dist/attempt-session.js.map +1 -0
- package/dist/browser-connection.d.ts +34 -0
- package/dist/browser-connection.d.ts.map +1 -0
- package/dist/browser-connection.js +87 -0
- package/dist/browser-connection.js.map +1 -0
- package/dist/capture-scope.d.ts +21 -0
- package/dist/capture-scope.d.ts.map +1 -0
- package/dist/capture-scope.js +61 -0
- package/dist/capture-scope.js.map +1 -0
- package/dist/cdp-recovery.d.ts +29 -0
- package/dist/cdp-recovery.d.ts.map +1 -0
- package/dist/cdp-recovery.js +84 -0
- package/dist/cdp-recovery.js.map +1 -0
- package/dist/cdp-selectors.d.ts +14 -0
- package/dist/cdp-selectors.d.ts.map +1 -0
- package/dist/cdp-selectors.js +48 -0
- package/dist/cdp-selectors.js.map +1 -0
- package/dist/dialogs.d.ts +37 -0
- package/dist/dialogs.d.ts.map +1 -0
- package/dist/dialogs.js +78 -0
- package/dist/dialogs.js.map +1 -0
- package/dist/engine.d.ts +26 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +166 -0
- package/dist/engine.js.map +1 -0
- package/dist/evaluation.d.ts +11 -0
- package/dist/evaluation.d.ts.map +1 -0
- package/dist/evaluation.js +27 -0
- package/dist/evaluation.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +40 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +117 -0
- package/dist/install.js.map +1 -0
- package/dist/locators.d.ts +74 -0
- package/dist/locators.d.ts.map +1 -0
- package/dist/locators.js +260 -0
- package/dist/locators.js.map +1 -0
- package/dist/observation-capture.d.ts +12 -0
- package/dist/observation-capture.d.ts.map +1 -0
- package/dist/observation-capture.js +93 -0
- package/dist/observation-capture.js.map +1 -0
- package/dist/observation.d.ts +63 -0
- package/dist/observation.d.ts.map +1 -0
- package/dist/observation.js +262 -0
- package/dist/observation.js.map +1 -0
- package/dist/observe.d.ts +51 -0
- package/dist/observe.d.ts.map +1 -0
- package/dist/observe.js +104 -0
- package/dist/observe.js.map +1 -0
- package/dist/operation-budget.d.ts +11 -0
- package/dist/operation-budget.d.ts.map +1 -0
- package/dist/operation-budget.js +40 -0
- package/dist/operation-budget.js.map +1 -0
- package/dist/protected-app.d.ts +32 -0
- package/dist/protected-app.d.ts.map +1 -0
- package/dist/protected-app.js +39 -0
- package/dist/protected-app.js.map +1 -0
- package/dist/read-node.d.ts +170 -0
- package/dist/read-node.d.ts.map +1 -0
- package/dist/read-node.js +823 -0
- package/dist/read-node.js.map +1 -0
- package/dist/refs.d.ts +43 -0
- package/dist/refs.d.ts.map +1 -0
- package/dist/refs.js +85 -0
- package/dist/refs.js.map +1 -0
- package/dist/route-pattern.d.ts +15 -0
- package/dist/route-pattern.d.ts.map +1 -0
- package/dist/route-pattern.js +68 -0
- package/dist/route-pattern.js.map +1 -0
- package/dist/support.d.ts +119 -0
- package/dist/support.d.ts.map +1 -0
- package/dist/support.js +299 -0
- package/dist/support.js.map +1 -0
- package/dist/surface.d.ts +257 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +587 -0
- package/dist/surface.js.map +1 -0
- package/dist/video.d.ts +59 -0
- package/dist/video.d.ts.map +1 -0
- package/dist/video.js +115 -0
- package/dist/video.js.map +1 -0
- package/dist/web.d.ts +191 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +354 -0
- package/dist/web.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# @e2edev/web
|
|
2
|
+
|
|
3
|
+
The browser engine for [`e2e`](https://www.npmjs.com/package/e2e), built on
|
|
4
|
+
[Playwright](https://playwright.dev).
|
|
5
|
+
|
|
6
|
+
`e2e` ships no engine of its own: every target names the engine that drives
|
|
7
|
+
it, and this package is the one for browsers. It implements the public
|
|
8
|
+
`e2e/engine` contract, so a device or desktop engine plugs into the same
|
|
9
|
+
seam with no privilege either way.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install --save-dev e2e @e2edev/web playwright
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Bring your own Playwright: `playwright` is a peer dependency (`>=1.63.0 <2`),
|
|
18
|
+
not something this package installs. An app that already depends on Playwright
|
|
19
|
+
keeps its version, one copy in `node_modules`, and one browser cache. A version
|
|
20
|
+
outside the range may be rejected by your package manager as an unmet peer
|
|
21
|
+
(npm's `ERESOLVE`), so upgrade `playwright` within the range.
|
|
22
|
+
|
|
23
|
+
```ts title="e2e.config.ts"
|
|
24
|
+
import type { E2EConfig } from 'e2e';
|
|
25
|
+
import { web } from '@e2edev/web';
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
targets: [{ name: 'web', engine: web({ url: 'http://localhost:3000' }) }],
|
|
29
|
+
} satisfies E2EConfig;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The engine declares the app it drives. App options: `url` (the base URL
|
|
33
|
+
`app.open()` opens; required once a test navigates), `command` (a process the
|
|
34
|
+
runner starts before the run and stops after it, with `readyUrl` to poll,
|
|
35
|
+
default `url`), `environment`
|
|
36
|
+
(`test`, `staging`, `production`; inferred from the host), and `identity` (a
|
|
37
|
+
stable cache and session key when the origin is ephemeral). Browser options:
|
|
38
|
+
`browser` (`chromium`, `firefox`, `webkit`; default `chromium`), `viewport`
|
|
39
|
+
(`{ width, height }`; default 1280x720), `testIdAttribute` (the attribute
|
|
40
|
+
`getByTestId` and a node's `testId` read; default `data-testid`), and
|
|
41
|
+
`connect` — attach to a remote browser over CDP instead of launching a local
|
|
42
|
+
one.
|
|
43
|
+
|
|
44
|
+
### Attaching to a remote browser (`connect`)
|
|
45
|
+
|
|
46
|
+
Set `connect.cdpEndpoint` to attach over the Chrome DevTools Protocol rather
|
|
47
|
+
than launch. The resolver is async and called at worker init, and again at the
|
|
48
|
+
start of any attempt that finds the session dropped, so a hosted browser whose
|
|
49
|
+
endpoint is provisioned per run — a cloud session URL that is not known at
|
|
50
|
+
config load — resolves each time it is needed. The resolver receives an
|
|
51
|
+
`AbortSignal` that fires when the init or attempt is cancelled or exceeds its
|
|
52
|
+
budget; a browser that connects after that is detached, never used. CDP attach
|
|
53
|
+
is chromium-only, and disposing the engine detaches the session without
|
|
54
|
+
killing the remote process the host owns.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
engine: web({
|
|
58
|
+
connect: { cdpEndpoint: async () => acquireCloudBrowserSession() },
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For transport recovery, add `connect.reconnectEndpoint(signal)`. This opts
|
|
63
|
+
into the remote browser's persistent default context. `cdpEndpoint` then
|
|
64
|
+
provisions a fresh, dedicated browser for every attempt, including retries;
|
|
65
|
+
`reconnectEndpoint` must return that same browser after a disconnect. The
|
|
66
|
+
engine verifies the default context ID and active page target ID, clears stale
|
|
67
|
+
references, and never repeats a dispatched operation. A missing target fails
|
|
68
|
+
the attempt. The host owns deleting the remote browser after cleanup.
|
|
69
|
+
|
|
70
|
+
This mode does not support `headers`, `basicAuth`, context reset, or session
|
|
71
|
+
state capture and restore. Recording resumes after reconnect, but a segment
|
|
72
|
+
lost during the disconnect remains unavailable. See the
|
|
73
|
+
[Playwright reference](../../docs/reference/web.mdx#recovering-a-cdp-transport)
|
|
74
|
+
for the lifecycle and ownership contract.
|
|
75
|
+
|
|
76
|
+
## The `web` fixture
|
|
77
|
+
|
|
78
|
+
The engine contributes `web`: navigation, routes, cookies, dialogs, frames,
|
|
79
|
+
downloads, keyboard and mouse, plus `expect(web).toHaveURL()` and
|
|
80
|
+
`toHaveTitle()` and `toHaveClass()`. Import `test` from this package to have it
|
|
81
|
+
typed; it is the same runtime `test` as `e2e`'s.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { test } from '@e2edev/web';
|
|
85
|
+
import { expect } from 'e2e';
|
|
86
|
+
|
|
87
|
+
test('signs in', async ({ app, screen, web }) => {
|
|
88
|
+
await app.open('/login');
|
|
89
|
+
await screen.getByLabel('Email').fill('user@example.test');
|
|
90
|
+
await expect(web).toHaveURL('/dashboard');
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Browsers
|
|
95
|
+
|
|
96
|
+
A missing browser is downloaded once per run, in the runner process, after the
|
|
97
|
+
tests are collected and before the app starts: the progress prints in the run
|
|
98
|
+
log, the run's clock starts only once the download is done, and no launch or
|
|
99
|
+
test timeout ever includes it. Workers launch the browser the runner installed.
|
|
100
|
+
|
|
101
|
+
In CI, install browsers as their own step instead, so the cost is visible and
|
|
102
|
+
cacheable:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npx playwright install chromium --with-deps
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`--with-deps` also installs the system libraries a slim container image lacks.
|
|
109
|
+
|
|
110
|
+
## Documentation
|
|
111
|
+
|
|
112
|
+
Full documentation lives at [e2e.tester.army/docs](https://e2e.tester.army/docs).
|
package/dist/.build.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"0.11.0-canary-20260921180210"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Locator action dispatch for the Playwright engine. */
|
|
2
|
+
import type { Page } from 'playwright';
|
|
3
|
+
import { type LocatorAction, type NodeRef, type PointerAction, type ViewportPoint } from 'e2e/engine';
|
|
4
|
+
import { type ActionTarget } from './support.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Dispatches one deterministic locator action onto a Playwright target with the
|
|
7
|
+
* platform's own actionability checks. `lookup` resolves the second ref of a
|
|
8
|
+
* drag; everything else needs only the target.
|
|
9
|
+
*/
|
|
10
|
+
export declare function dispatchLocatorAction(target: ActionTarget, action: LocatorAction, timeout: number, lookup: (ref: NodeRef) => ActionTarget): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Dispatches one pointer action at a viewport point with nothing resolved
|
|
13
|
+
* behind it: no actionability wait, because there is no element to wait on,
|
|
14
|
+
* and the page decides what the gesture lands on, as it does for a person.
|
|
15
|
+
*/
|
|
16
|
+
export declare function dispatchPointerAction(page: Page, at: ViewportPoint, action: PointerAction): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Classifies a failed action onto the error contract (see the table above
|
|
19
|
+
* `POST_DISPATCH_PATTERN` in support.ts): stale, not actionable, possibly
|
|
20
|
+
* committed, or an engine fault.
|
|
21
|
+
*/
|
|
22
|
+
export declare function classifyActionError(rawCause: unknown, action: LocatorAction): Error;
|
|
23
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAEzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAe,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AACnH,OAAO,EAWL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAKtB;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,YAAY,GACrC,OAAO,CAAC,IAAI,CAAC,CA8Ef;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B/G;AAkBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAG,KAAK,CA4BnF"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/** Locator action dispatch for the Playwright engine. */
|
|
2
|
+
import { EngineError } from 'e2e/engine';
|
|
3
|
+
import { asActionable, isClassified, isPwTimeout, message, nearestPixel, performElementSwipe, performPointDrag, performPointerDrag, performViewportSwipe, POST_DISPATCH_PATTERN, } from './support.js';
|
|
4
|
+
/** How long a long press holds the button when the action names no duration. */
|
|
5
|
+
const DEFAULT_LONG_PRESS_MS = 500;
|
|
6
|
+
/**
|
|
7
|
+
* Dispatches one deterministic locator action onto a Playwright target with the
|
|
8
|
+
* platform's own actionability checks. `lookup` resolves the second ref of a
|
|
9
|
+
* drag; everything else needs only the target.
|
|
10
|
+
*/
|
|
11
|
+
export async function dispatchLocatorAction(target, action, timeout, lookup) {
|
|
12
|
+
const locator = asActionable(target);
|
|
13
|
+
switch (action.kind) {
|
|
14
|
+
case 'tap':
|
|
15
|
+
await locator.click({ timeout });
|
|
16
|
+
return;
|
|
17
|
+
case 'doubleTap':
|
|
18
|
+
await locator.dblclick({ timeout });
|
|
19
|
+
return;
|
|
20
|
+
case 'secondaryTap':
|
|
21
|
+
await locator.click({ button: 'right', timeout });
|
|
22
|
+
return;
|
|
23
|
+
case 'longPress':
|
|
24
|
+
await locator.click({ timeout, delay: action.durationMs ?? DEFAULT_LONG_PRESS_MS });
|
|
25
|
+
return;
|
|
26
|
+
case 'fill':
|
|
27
|
+
await locator.fill(action.value, { timeout });
|
|
28
|
+
return;
|
|
29
|
+
case 'clear':
|
|
30
|
+
await locator.fill('', { timeout });
|
|
31
|
+
return;
|
|
32
|
+
case 'press':
|
|
33
|
+
// Playwright spells keys as the contract grammar does; the harness has
|
|
34
|
+
// already refused anything outside it, so the key is pressed as given.
|
|
35
|
+
await locator.press(action.key, { timeout });
|
|
36
|
+
return;
|
|
37
|
+
case 'check':
|
|
38
|
+
await locator.check({ timeout });
|
|
39
|
+
return;
|
|
40
|
+
case 'uncheck':
|
|
41
|
+
await locator.uncheck({ timeout });
|
|
42
|
+
return;
|
|
43
|
+
case 'focus':
|
|
44
|
+
// ElementHandle.focus takes no timeout: the element is already resolved.
|
|
45
|
+
if (target.kind === 'locator')
|
|
46
|
+
await target.locator.focus({ timeout });
|
|
47
|
+
else
|
|
48
|
+
await target.element.focus();
|
|
49
|
+
return;
|
|
50
|
+
case 'hover':
|
|
51
|
+
await locator.hover({ timeout });
|
|
52
|
+
return;
|
|
53
|
+
case 'scrollIntoView':
|
|
54
|
+
await locator.scrollIntoViewIfNeeded({ timeout });
|
|
55
|
+
return;
|
|
56
|
+
case 'selectOption': {
|
|
57
|
+
const value = action.value;
|
|
58
|
+
if (typeof value === 'string') {
|
|
59
|
+
await locator.selectOption({ label: value }, { timeout });
|
|
60
|
+
}
|
|
61
|
+
else if (value.index !== undefined) {
|
|
62
|
+
await locator.selectOption({ index: value.index }, { timeout });
|
|
63
|
+
}
|
|
64
|
+
else if (value.value !== undefined) {
|
|
65
|
+
await locator.selectOption({ value: value.value }, { timeout });
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
await locator.selectOption({ label: value.label }, { timeout });
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
case 'setInputFiles':
|
|
73
|
+
await locator.setInputFiles([...action.paths], { timeout });
|
|
74
|
+
return;
|
|
75
|
+
case 'dragTo': {
|
|
76
|
+
const other = lookup(action.target);
|
|
77
|
+
// Playwright's own drag when both sides are locators: it waits for
|
|
78
|
+
// actionability on each and reports better failures than a pointer
|
|
79
|
+
// sequence can. Anything else - an observed reference on either side -
|
|
80
|
+
// is dragged with the pointer.
|
|
81
|
+
if (target.kind === 'locator' && other.kind === 'locator') {
|
|
82
|
+
await target.locator.dragTo(other.locator, { timeout });
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
await performPointerDrag(target, other, timeout);
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
case 'swipe':
|
|
90
|
+
// The agent's node scroll and `screen` swipes both arrive here: a wheel
|
|
91
|
+
// gesture over the node, sized by its own box.
|
|
92
|
+
await performElementSwipe(target, action.direction, action.momentum ?? 'none', timeout);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Dispatches one pointer action at a viewport point with nothing resolved
|
|
98
|
+
* behind it: no actionability wait, because there is no element to wait on,
|
|
99
|
+
* and the page decides what the gesture lands on, as it does for a person.
|
|
100
|
+
*/
|
|
101
|
+
export async function dispatchPointerAction(page, at, action) {
|
|
102
|
+
const { mouse } = page;
|
|
103
|
+
const point = nearestPixel(at);
|
|
104
|
+
switch (action.kind) {
|
|
105
|
+
case 'tap':
|
|
106
|
+
await mouse.click(point.x, point.y);
|
|
107
|
+
return;
|
|
108
|
+
case 'doubleTap':
|
|
109
|
+
await mouse.dblclick(point.x, point.y);
|
|
110
|
+
return;
|
|
111
|
+
case 'secondaryTap':
|
|
112
|
+
await mouse.click(point.x, point.y, { button: 'right' });
|
|
113
|
+
return;
|
|
114
|
+
case 'longPress':
|
|
115
|
+
await mouse.click(point.x, point.y, { delay: action.durationMs ?? DEFAULT_LONG_PRESS_MS });
|
|
116
|
+
return;
|
|
117
|
+
case 'hover':
|
|
118
|
+
await mouse.move(point.x, point.y);
|
|
119
|
+
return;
|
|
120
|
+
case 'dragTo':
|
|
121
|
+
case 'swipeTo':
|
|
122
|
+
// A swipe along a path is a pointer drag on a document platform.
|
|
123
|
+
await performPointDrag(mouse, point, action.target);
|
|
124
|
+
return;
|
|
125
|
+
case 'swipe':
|
|
126
|
+
// The pointer moves to the point first so the scrollable under it receives the wheel.
|
|
127
|
+
await mouse.move(point.x, point.y);
|
|
128
|
+
await performViewportSwipe(page, action.direction, action.momentum ?? 'none');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Whether a failure of this action may carry the value it was given. A
|
|
134
|
+
* sensitive fill's plaintext must never leave the engine: its message is
|
|
135
|
+
* scrubbed and the raw Playwright error - whose stack the report would
|
|
136
|
+
* otherwise print - is not attached as a cause.
|
|
137
|
+
*/
|
|
138
|
+
function isSensitive(action) {
|
|
139
|
+
return action.kind === 'fill' && action.sensitive;
|
|
140
|
+
}
|
|
141
|
+
/** Scrubs a sensitive fill value out of text that is about to leave the engine. */
|
|
142
|
+
function redactSensitive(text, action) {
|
|
143
|
+
if (!isSensitive(action) || action.value.length === 0)
|
|
144
|
+
return text;
|
|
145
|
+
return text.replaceAll(action.value, '[redacted]');
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Classifies a failed action onto the error contract (see the table above
|
|
149
|
+
* `POST_DISPATCH_PATTERN` in support.ts): stale, not actionable, possibly
|
|
150
|
+
* committed, or an engine fault.
|
|
151
|
+
*/
|
|
152
|
+
export function classifyActionError(rawCause, action) {
|
|
153
|
+
if (isClassified(rawCause))
|
|
154
|
+
return rawCause;
|
|
155
|
+
const text = redactSensitive(message(rawCause), action);
|
|
156
|
+
const cause = isSensitive(action) ? undefined : rawCause;
|
|
157
|
+
if (/strict mode violation/i.test(text)) {
|
|
158
|
+
return new EngineError('ENGINE_FAILURE', text, { retryable: false, cause });
|
|
159
|
+
}
|
|
160
|
+
if (/element (is |was )?(detached|not attached)/i.test(text)) {
|
|
161
|
+
return new EngineError('NODE_STALE', text, { retryable: true, cause });
|
|
162
|
+
}
|
|
163
|
+
if (/Timeout .*exceeded/i.test(text) || isPwTimeout(rawCause)) {
|
|
164
|
+
if (POST_DISPATCH_PATTERN.test(text)) {
|
|
165
|
+
return new EngineError('ACTION_MAY_HAVE_COMMITTED', `${action.kind} timed out after its input was dispatched: ${text}`, { retryable: false, cause });
|
|
166
|
+
}
|
|
167
|
+
return new EngineError('NOT_ACTIONABLE', `${action.kind} did not become actionable in time: ${text}`, { retryable: false, cause });
|
|
168
|
+
}
|
|
169
|
+
if (/not an? <?(input|checkbox|radio|select)|not editable|not checkable/i.test(text)) {
|
|
170
|
+
return new EngineError('NOT_ACTIONABLE', text, { retryable: false, cause });
|
|
171
|
+
}
|
|
172
|
+
return new EngineError('ENGINE_FAILURE', text, { retryable: false, cause });
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAGzD,OAAO,EAAE,WAAW,EAA4E,MAAM,YAAY,CAAC;AACnH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GAEtB,MAAM,cAAc,CAAC;AAEtB,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAoB,EACpB,MAAqB,EACrB,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SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,gBAAgB,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Browser, BrowserContext, BrowserContextOptions, Page } from 'playwright';
|
|
2
|
+
import { type EngineCleanupContext, type OperationContext, type VideoSegment, type ViewportSize } from 'e2e/engine';
|
|
3
|
+
import { type CdpEndpointResolver, type SessionBinding } from './cdp-recovery.ts';
|
|
4
|
+
import { RefRegistry } from './refs.ts';
|
|
5
|
+
export type StorageState = Exclude<NonNullable<BrowserContextOptions['storageState']>, string>;
|
|
6
|
+
interface SessionOptions {
|
|
7
|
+
readonly artifactsDir: string;
|
|
8
|
+
readonly viewport: ViewportSize;
|
|
9
|
+
readonly contextOptions: BrowserContextOptions;
|
|
10
|
+
readonly acquire: (signal: AbortSignal) => Promise<Browser>;
|
|
11
|
+
readonly configure: (context: BrowserContext) => Promise<void>;
|
|
12
|
+
readonly persistent?: {
|
|
13
|
+
readonly provision: CdpEndpointResolver;
|
|
14
|
+
readonly reconnect: CdpEndpointResolver;
|
|
15
|
+
readonly usedContexts: Set<string>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare class AttemptSession {
|
|
19
|
+
private readonly options;
|
|
20
|
+
readonly refs: RefRegistry;
|
|
21
|
+
private readonly lifetime;
|
|
22
|
+
private readonly video;
|
|
23
|
+
private state;
|
|
24
|
+
private generation;
|
|
25
|
+
private observed;
|
|
26
|
+
private tracing;
|
|
27
|
+
private traceSegments;
|
|
28
|
+
private traceParts;
|
|
29
|
+
constructor(options: SessionOptions);
|
|
30
|
+
/** Captures an immutable connection generation for publication after asynchronous reads. */
|
|
31
|
+
token(): object;
|
|
32
|
+
/** Rejects work belonging to a superseded connection or an ended attempt. */
|
|
33
|
+
check(token: object): void;
|
|
34
|
+
/** An observation commits its references and freshness together against the same generation. */
|
|
35
|
+
observedGeneration(token: object): void;
|
|
36
|
+
/** Observation-backed pointer and keyboard input needs evidence captured after recovery. */
|
|
37
|
+
requireObservation(): void;
|
|
38
|
+
/** Reads the only published binding. Pending work never replaces it halfway through setup. */
|
|
39
|
+
current(): SessionBinding;
|
|
40
|
+
/** Invalidates every asynchronous read and reference at a connection or page transition. */
|
|
41
|
+
private invalidate;
|
|
42
|
+
/** Opens a context for this attempt, publishing only after its handlers are installed. */
|
|
43
|
+
start(signal: AbortSignal): Promise<void>;
|
|
44
|
+
/** Shares one reconnect, then dispatches once with the time that remains. */
|
|
45
|
+
run<T>(operation: OperationContext, label: string, work: (operation: OperationContext) => Promise<T>): Promise<T>;
|
|
46
|
+
/** Owns a candidate through configuration and recording setup, then publishes it once. */
|
|
47
|
+
private transition;
|
|
48
|
+
/** Creates the attempt's active page and records its exact target before exposing it. */
|
|
49
|
+
ensurePage(): Promise<Page>;
|
|
50
|
+
/** Restarts the document while retaining this context's storage. */
|
|
51
|
+
restart(): Promise<void>;
|
|
52
|
+
/** Replaces an ordinary context; persistent recovery never advertises this capability. */
|
|
53
|
+
replace(storageState: StorageState | undefined, operation: OperationContext): Promise<void>;
|
|
54
|
+
/** Ends this attempt immediately; late work can only access this retired owner. */
|
|
55
|
+
close(budget: EngineCleanupContext): Promise<void>;
|
|
56
|
+
/** Ordinary contexts are engine-owned; persistent browser processes belong to the host. */
|
|
57
|
+
private release;
|
|
58
|
+
/** Allocates trace paths inside this attempt's immutable artifact directory. */
|
|
59
|
+
private tracePath;
|
|
60
|
+
/** Saves a replaced context's trace when it can still flush it. */
|
|
61
|
+
private closeTraceSegment;
|
|
62
|
+
/** Begins tracing the currently committed context. */
|
|
63
|
+
startTrace(): Promise<void>;
|
|
64
|
+
/** Returns finalized segments, including any retained before context replacement failed. */
|
|
65
|
+
private stopTrace;
|
|
66
|
+
/** Starts video before tracing can choose the page's screencast size. */
|
|
67
|
+
startVideo(): Promise<void>;
|
|
68
|
+
/** Collects finalized trace segments even when connection replacement failed. */
|
|
69
|
+
collectTrace(operation: OperationContext): Promise<string | readonly string[]>;
|
|
70
|
+
/** Collects this attempt's video independently of a failed connection. */
|
|
71
|
+
collectVideo(operation: OperationContext): Promise<readonly VideoSegment[]>;
|
|
72
|
+
/** Terminal artifact collection needs its own budget, but no successful UI dispatch. */
|
|
73
|
+
private finalize;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=attempt-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attempt-session.d.ts","sourceRoot":"","sources":["../src/attempt-session.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAA+C,KAAK,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACjK,OAAO,EAAoD,KAAK,mBAAmB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEpI,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAE/F,UAAU,cAAc;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;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