@e2edev/mobile 0.8.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 +149 -0
- package/dist/.build.json +1 -0
- package/dist/actions.d.ts +29 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +62 -0
- package/dist/actions.js.map +1 -0
- package/dist/bindings.d.ts +57 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +79 -0
- package/dist/bindings.js.map +1 -0
- package/dist/device.d.ts +77 -0
- package/dist/device.d.ts.map +1 -0
- package/dist/device.js +101 -0
- package/dist/device.js.map +1 -0
- package/dist/engine.d.ts +17 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +92 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +30 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +95 -0
- package/dist/errors.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/locate.d.ts +11 -0
- package/dist/locate.d.ts.map +1 -0
- package/dist/locate.js +115 -0
- package/dist/locate.js.map +1 -0
- package/dist/nodes.d.ts +86 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +315 -0
- package/dist/nodes.js.map +1 -0
- package/dist/options.d.ts +93 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +7 -0
- package/dist/options.js.map +1 -0
- package/dist/png.d.ts +4 -0
- package/dist/png.d.ts.map +1 -0
- package/dist/png.js +25 -0
- package/dist/png.js.map +1 -0
- package/dist/pool.d.ts +72 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +185 -0
- package/dist/pool.js.map +1 -0
- package/dist/provider.d.ts +105 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +98 -0
- package/dist/provider.js.map +1 -0
- package/dist/selector.d.ts +17 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +84 -0
- package/dist/selector.js.map +1 -0
- package/dist/support.d.ts +58 -0
- package/dist/support.d.ts.map +1 -0
- package/dist/support.js +82 -0
- package/dist/support.js.map +1 -0
- package/dist/surface.d.ts +243 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +837 -0
- package/dist/surface.js.map +1 -0
- package/dist/tools.d.ts +24 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +90 -0
- package/dist/tools.js.map +1 -0
- package/package.json +83 -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,149 @@
|
|
|
1
|
+
# @e2edev/mobile
|
|
2
|
+
|
|
3
|
+
The mobile engine for [`e2e`](https://www.npmjs.com/package/e2e), built on
|
|
4
|
+
[agent-device](https://github.com/callstack/agent-device): iOS simulators and
|
|
5
|
+
Android emulators through the same `e2e/engine` contract the browser engine
|
|
6
|
+
implements. A test written against `screen`, `expect`, `app`, and `agent` runs
|
|
7
|
+
on a device target unchanged; nothing in `e2e` core knows this package exists.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Run `npx e2e init` and choose **Mobile (iOS/Android)** for a Settings
|
|
12
|
+
example with optional AI testing. Init defaults to iOS on macOS and Android
|
|
13
|
+
elsewhere; change the platform in `e2e.config.ts` when needed.
|
|
14
|
+
Or add the packages to an existing project:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install --save-dev e2e @e2edev/mobile
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`agent-device` needs Xcode with an iOS simulator runtime, or the Android SDK
|
|
21
|
+
with an emulator. Run `npx agent-device doctor` once before handing the target
|
|
22
|
+
to the runner.
|
|
23
|
+
|
|
24
|
+
```ts title="e2e.config.ts"
|
|
25
|
+
import type { E2EConfig } from 'e2e';
|
|
26
|
+
import { createAgent } from 'e2e/agent';
|
|
27
|
+
import { mobile } from '@e2edev/mobile';
|
|
28
|
+
import { mobileTools } from '@e2edev/mobile/tools';
|
|
29
|
+
|
|
30
|
+
const iphone = mobile({ platform: 'ios', app: 'Settings' });
|
|
31
|
+
const pixel = mobile({ platform: 'android', app: 'com.android.settings' });
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
targets: [
|
|
35
|
+
{ name: 'iphone', engine: iphone },
|
|
36
|
+
{ name: 'pixel', engine: pixel },
|
|
37
|
+
],
|
|
38
|
+
workers: 1,
|
|
39
|
+
agents: { default: { executor: createAgent({ tools: mobileTools(iphone, pixel) }) } },
|
|
40
|
+
} satisfies E2EConfig;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
A test written against `agent`, `app`, `screen`, and `device` runs on both
|
|
44
|
+
targets unchanged. Only a check that names a platform label (`General` on iOS,
|
|
45
|
+
`Network & internet` on Android) needs `platforms: ['ios']` or
|
|
46
|
+
`platforms: ['android']` on the test.
|
|
47
|
+
|
|
48
|
+
Options:
|
|
49
|
+
|
|
50
|
+
| Option | Meaning |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `platform` | `'ios'` or `'android'`. |
|
|
53
|
+
| `app` | Bundle id, package, or display name opened fresh at the start of every attempt. Also unlocks `app.restart()` and `app.clearState()`. |
|
|
54
|
+
| `appPath` | An iOS `.app` bundle or Android `.apk` installed once per worker before the first attempt, resolved against the project root. Without `app`, the installed bundle id or package is the app opened per attempt. |
|
|
55
|
+
| `device` | Simulator or emulator name or UDID. A list is a pool: one worker per entry, worker slot `n` driving the `n`th. Omitted, every booted device of the platform is the pool, as many as the run has slots. |
|
|
56
|
+
| `session` | agent-device session name, before the worker slot: slot `n` drives its device under `<session>-<n>`, `e2e-<target name>-<n>` by default. One run per session at a time. |
|
|
57
|
+
| `snapshot` | `'full'` (default, includes static text) or `'interactive'` (actionable nodes only). |
|
|
58
|
+
| `settle` | For agent actions: milliseconds the UI must hold still after an action before the agent observes again, default `150`; `false` skips the wait. A test's own steps never settle; `expect` verifies their outcome. |
|
|
59
|
+
| `transition` | For a test's steps: milliseconds a control that appeared or moved with the last action gets to finish arriving before it is acted on, default `500`. Controls already in place before the action are acted on at once. |
|
|
60
|
+
|
|
61
|
+
Every optional value also accepts `undefined`, so a config passes
|
|
62
|
+
`device: process.env.E2E_DEVICE` or `appPath: process.env.E2E_APP_PATH`
|
|
63
|
+
straight through, with no conditional spread.
|
|
64
|
+
|
|
65
|
+
## What the engine declares
|
|
66
|
+
|
|
67
|
+
- **Observation**: the accessibility tree, projected onto the role vocabulary
|
|
68
|
+
(iOS `Button` becomes `button`, `TextField` becomes `textbox`, `Cell` becomes
|
|
69
|
+
`listitem`; Android `android.widget.TextView` becomes `text`, `EditText`
|
|
70
|
+
becomes `textbox`, `Switch` becomes `switch`), with rects, a viewport, and
|
|
71
|
+
pixels on request with every secure field painted over. Element identifiers
|
|
72
|
+
(`ABOUT`, `android:id/title`) surface as the configured test id attribute.
|
|
73
|
+
- **Actions**: tap, double tap, long press, fill, clear, check/uncheck (when
|
|
74
|
+
the tree exposes the checked state; Android switches do not), focus on
|
|
75
|
+
editable fields, `Enter`, single-character keys, swipe within a node, drag.
|
|
76
|
+
`selectOption`, `setInputFiles`, focus on a control, and other keys fail
|
|
77
|
+
with `UNSUPPORTED_CAPABILITY`.
|
|
78
|
+
- **Location**: every `screen` query, plus agent-device selectors through
|
|
79
|
+
`device.locator('role=NavigationBar id=General')`.
|
|
80
|
+
- **Viewport swipe**, `app.back()`, `app.restart()`, `app.clearState()`, and
|
|
81
|
+
redacted screenshots under the attempt artifact directory: the bounds of
|
|
82
|
+
every secure field are painted black before the file is kept, and a
|
|
83
|
+
screenshot that cannot be redacted is not written. No `state` capability: a
|
|
84
|
+
simulator has no portable session snapshot.
|
|
85
|
+
|
|
86
|
+
## Trace cache
|
|
87
|
+
|
|
88
|
+
The runner caches `agent.act` steps by their location anchor, and a device has
|
|
89
|
+
no address bar. This engine reports one anyway: `<bundle id> / <screen
|
|
90
|
+
title>`, with the title read off the navigation bar on iOS and the collapsing
|
|
91
|
+
toolbar on Android. The app identity is part of the location, so two apps with
|
|
92
|
+
a "General" screen never share an anchor. A step recorded on
|
|
93
|
+
`com.apple.Preferences / General` replays only when that app is on that
|
|
94
|
+
screen again, and a flow that stays within tap, type, and scroll replays with
|
|
95
|
+
zero model calls. Pin `app` so every attempt starts on the same screen, and
|
|
96
|
+
prefer the grammar over the `open_app` tool inside a step: a tool call is a
|
|
97
|
+
replay gap.
|
|
98
|
+
|
|
99
|
+
## The `device` fixture
|
|
100
|
+
|
|
101
|
+
Deterministic device management, recorded as `device.<method>` steps. Import
|
|
102
|
+
`test` from this package to have it typed.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { test } from '@e2edev/mobile';
|
|
106
|
+
import { expect } from 'e2e';
|
|
107
|
+
|
|
108
|
+
test('shows the version offline in dark mode', async ({ agent, device, screen }) => {
|
|
109
|
+
await device.setAppearance('dark');
|
|
110
|
+
await device.setNetwork('offline');
|
|
111
|
+
await agent.act('go to General, then About');
|
|
112
|
+
await expect(screen.getByRole('button', { name: /^iOS Version/ })).toBeVisible();
|
|
113
|
+
await expect(device.locator('role=NavigationBar id=About')).toBeVisible();
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Methods: `setNetwork`, `setAirplaneMode`, `setPermission`, `setLocation`,
|
|
118
|
+
`clearLocation`, `setAppearance`, `setOrientation`, `setBiometrics`,
|
|
119
|
+
`enrollBiometrics`, `installApp`, `openApp`, `closeApp`, `foregroundApp`,
|
|
120
|
+
`home`, `back`, `alert`, `dismissKeyboard`, `clipboard`, `setClipboard`, and
|
|
121
|
+
the `locator` accessor.
|
|
122
|
+
|
|
123
|
+
`installApp(appPath, { app, reinstall })` puts a build on the device from a
|
|
124
|
+
test, for upgrade and fresh-install paths the `appPath` option cannot express.
|
|
125
|
+
A plain install replaces the binary and keeps its data; `reinstall: true`
|
|
126
|
+
removes the app named by `app` (default: the pinned app) first. It resolves to
|
|
127
|
+
the bundle id or package to `openApp` the build by.
|
|
128
|
+
|
|
129
|
+
## Agent tools
|
|
130
|
+
|
|
131
|
+
`@e2edev/mobile/tools` exports `mobileTools(...engines)`:
|
|
132
|
+
`open_app`, `swipe` (free-form, in logical pixels), `type_text` (into the
|
|
133
|
+
focused field, for editors that hide it from the tree), `alert`, and
|
|
134
|
+
`screenshot` (the model sees the image). Pass every device engine the config
|
|
135
|
+
declares: tool names are fixed, so two packs cannot be merged, and the pack
|
|
136
|
+
dispatches each call to the engine whose attempt is running. Tools are scoped
|
|
137
|
+
to the platforms of those engines, so a suite that mixes web and device
|
|
138
|
+
targets can hand the pack to one `createAgent`.
|
|
139
|
+
|
|
140
|
+
## Secrets
|
|
141
|
+
|
|
142
|
+
Secret fills need an origin the runner can check, and a device location is
|
|
143
|
+
not a URL, so it has no origin an allowlist can name: `type_secret` is denied
|
|
144
|
+
on a device target before any plaintext reaches the device. Fill credentials
|
|
145
|
+
through a deterministic `screen` action in a setup step instead.
|
|
146
|
+
|
|
147
|
+
## Documentation
|
|
148
|
+
|
|
149
|
+
Full documentation lives at [e2e.tester.army/docs](https://e2e.tester.army/docs).
|
package/dist/.build.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"0.8.0-canary-20260921180210"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** The action kinds a device surface declares, and the pointer dispatch that agrees with them. */
|
|
2
|
+
import type { LocatorActionKind, PointerAction, PointerActionKind, ViewportPoint } from 'e2e/engine';
|
|
3
|
+
import type { AgentDeviceClient } from './options.ts';
|
|
4
|
+
/**
|
|
5
|
+
* The action kinds a device honors, declared so the harness offers exactly
|
|
6
|
+
* these: no `select` verb on a device (`selectOption`, `setInputFiles`, and
|
|
7
|
+
* `scrollIntoView` have no touch equivalent), and `perform` still refuses a
|
|
8
|
+
* declared kind one node cannot take (`check` on a toggle whose state is
|
|
9
|
+
* unknown, `focus` on anything but a field).
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEVICE_ACTIONS: readonly LocatorActionKind[];
|
|
12
|
+
/**
|
|
13
|
+
* The pointer actions a device honors at a bare point: agent-device presses
|
|
14
|
+
* and swipes by coordinates, so taps, double taps, long presses, and a swipe
|
|
15
|
+
* to another point land anywhere. A coordinate hover, secondary tap, or drag
|
|
16
|
+
* (a hold before the move, unlike a swipe) has no touch equivalent it exposes
|
|
17
|
+
* without a node, and a directional swipe at a bare point has no length, so
|
|
18
|
+
* only the screen root scrolls that way.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEVICE_POINTER_ACTIONS: readonly PointerActionKind[];
|
|
21
|
+
/**
|
|
22
|
+
* Issues one pointer action at a screen point in logical pixels. `settle` is
|
|
23
|
+
* the device's quiet-wait options, spread onto the interaction as the node
|
|
24
|
+
* actions do. The kinds outside `DEVICE_POINTER_ACTIONS` never arrive: the
|
|
25
|
+
* harness routes only declared kinds. They are refused here so the switch
|
|
26
|
+
* stays exhaustive against the contract.
|
|
27
|
+
*/
|
|
28
|
+
export declare function pointerInteraction(client: AgentDeviceClient, point: ViewportPoint, action: PointerAction, settle: Record<string, unknown>): Promise<unknown>;
|
|
29
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAElG,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,iBAAiB,EAatD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,iBAAiB,EAAiD,CAAC;AAEjH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,CAqBlB"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** The action kinds a device surface declares, and the pointer dispatch that agrees with them. */
|
|
2
|
+
import { unsupported } from './support.js';
|
|
3
|
+
/**
|
|
4
|
+
* The action kinds a device honors, declared so the harness offers exactly
|
|
5
|
+
* these: no `select` verb on a device (`selectOption`, `setInputFiles`, and
|
|
6
|
+
* `scrollIntoView` have no touch equivalent), and `perform` still refuses a
|
|
7
|
+
* declared kind one node cannot take (`check` on a toggle whose state is
|
|
8
|
+
* unknown, `focus` on anything but a field).
|
|
9
|
+
*/
|
|
10
|
+
export const DEVICE_ACTIONS = [
|
|
11
|
+
'tap',
|
|
12
|
+
'doubleTap',
|
|
13
|
+
'longPress',
|
|
14
|
+
'fill',
|
|
15
|
+
'clear',
|
|
16
|
+
'press',
|
|
17
|
+
'check',
|
|
18
|
+
'uncheck',
|
|
19
|
+
'focus',
|
|
20
|
+
'hover',
|
|
21
|
+
'dragTo',
|
|
22
|
+
'swipe',
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* The pointer actions a device honors at a bare point: agent-device presses
|
|
26
|
+
* and swipes by coordinates, so taps, double taps, long presses, and a swipe
|
|
27
|
+
* to another point land anywhere. A coordinate hover, secondary tap, or drag
|
|
28
|
+
* (a hold before the move, unlike a swipe) has no touch equivalent it exposes
|
|
29
|
+
* without a node, and a directional swipe at a bare point has no length, so
|
|
30
|
+
* only the screen root scrolls that way.
|
|
31
|
+
*/
|
|
32
|
+
export const DEVICE_POINTER_ACTIONS = ['tap', 'doubleTap', 'longPress', 'swipeTo'];
|
|
33
|
+
/**
|
|
34
|
+
* Issues one pointer action at a screen point in logical pixels. `settle` is
|
|
35
|
+
* the device's quiet-wait options, spread onto the interaction as the node
|
|
36
|
+
* actions do. The kinds outside `DEVICE_POINTER_ACTIONS` never arrive: the
|
|
37
|
+
* harness routes only declared kinds. They are refused here so the switch
|
|
38
|
+
* stays exhaustive against the contract.
|
|
39
|
+
*/
|
|
40
|
+
export function pointerInteraction(client, point, action, settle) {
|
|
41
|
+
const at = { x: point.x, y: point.y };
|
|
42
|
+
switch (action.kind) {
|
|
43
|
+
case 'tap':
|
|
44
|
+
return client.interactions.press({ ...at, ...settle });
|
|
45
|
+
case 'doubleTap':
|
|
46
|
+
return client.interactions.press({ ...at, doubleTap: true, ...settle });
|
|
47
|
+
case 'longPress':
|
|
48
|
+
return client.interactions.longPress({
|
|
49
|
+
...at,
|
|
50
|
+
...settle,
|
|
51
|
+
...(action.durationMs === undefined ? {} : { durationMs: action.durationMs }),
|
|
52
|
+
});
|
|
53
|
+
case 'swipeTo':
|
|
54
|
+
return client.interactions.swipe({ from: at, to: { x: action.target.x, y: action.target.y } });
|
|
55
|
+
case 'secondaryTap':
|
|
56
|
+
case 'hover':
|
|
57
|
+
case 'dragTo':
|
|
58
|
+
case 'swipe':
|
|
59
|
+
throw unsupported(`agent-device cannot perform "${action.kind}" at a bare point`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,kGAAkG;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AE,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjG,KAAK,cAAc,CAAC;QACpB,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ,CAAC;QACd,KAAK,OAAO;YACV,MAAM,WAAW,CAAC,gCAAgC,MAAM,CAAC,IAAI,mBAAmB,CAAC,CAAC;IACtF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one worker slot drives, and how it travels from the runner's `prepare`
|
|
3
|
+
* to the worker's `init`. Every way a pool comes by devices (a configured
|
|
4
|
+
* list, the booted devices it discovered, the leases a provider granted) is
|
|
5
|
+
* one `DeviceSource` that ends in one `SlotBinding` per slot, so the worker
|
|
6
|
+
* reads one shape through one environment variable, whatever produced it.
|
|
7
|
+
*/
|
|
8
|
+
import { type EngineFinishInfo, type EnginePrepareInfo } from 'e2e/engine';
|
|
9
|
+
import type { MobileOptions } from './options.ts';
|
|
10
|
+
/** An agent-device daemon other than the local one. */
|
|
11
|
+
export interface DeviceDaemon {
|
|
12
|
+
/** Base URL answering agent-device's `GET /health` and `POST /rpc`. */
|
|
13
|
+
readonly baseUrl: string;
|
|
14
|
+
/** Bearer token the daemon expects, when it wants one. */
|
|
15
|
+
readonly authToken?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** What one worker slot drives; `{}` leaves every choice to the local daemon. */
|
|
18
|
+
export interface SlotBinding {
|
|
19
|
+
/** Device to select, by name or UDID; absent, the daemon picks a booted one. */
|
|
20
|
+
readonly device?: string | undefined;
|
|
21
|
+
/** The agent-device daemon to connect to; absent, the local one. */
|
|
22
|
+
readonly daemon?: DeviceDaemon | undefined;
|
|
23
|
+
/** App a provider already installed from `appPath`, so the worker installs nothing and opens this. */
|
|
24
|
+
readonly installedApp?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Where a pool's devices come from. `bind` runs once per run and target in
|
|
28
|
+
* `prepare`; `finish` releases what `bind` acquired, when anything was.
|
|
29
|
+
*/
|
|
30
|
+
export interface DeviceSource {
|
|
31
|
+
/** Workers served per target, one per device, when known before `prepare`. */
|
|
32
|
+
readonly size?: number | undefined;
|
|
33
|
+
/** What a worker drives when its run had no `prepare`; `undefined` leaves the choice to the local daemon. */
|
|
34
|
+
readonly fallback?: readonly SlotBinding[] | undefined;
|
|
35
|
+
/** One binding per worker slot the run will use, `info.slots` at most and never none. */
|
|
36
|
+
bind(info: EnginePrepareInfo): Promise<readonly SlotBinding[]>;
|
|
37
|
+
finish?(info: EngineFinishInfo): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The app a slot opens fresh per attempt: the `app` option, else the app the
|
|
41
|
+
* build `appPath` installed. `undefined` while a build still awaits its
|
|
42
|
+
* install in `init`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function pinnedApp(options: Pick<MobileOptions, 'app' | 'appPath'>, installedApp: string | undefined): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The environment variable a target's bindings travel to the workers in: the
|
|
47
|
+
* name made environment-safe for reading, plus a digest of the exact name so
|
|
48
|
+
* `ios-a` and `ios.a` never share a key.
|
|
49
|
+
*/
|
|
50
|
+
export declare function bindingsVariable(targetName: string): string;
|
|
51
|
+
/** Serializes the bindings for the environment: declared fields only, bounded. */
|
|
52
|
+
export declare function encodeBindings(bindings: readonly SlotBinding[]): string;
|
|
53
|
+
/** The bindings a `prepare` left in the environment, or `undefined` when there are none it can read. */
|
|
54
|
+
export declare function decodeBindings(raw: string | undefined): readonly SlotBinding[] | undefined;
|
|
55
|
+
/** A binding as JSON parses it back, or as a provider returned it: nothing the engine did not write is trusted. */
|
|
56
|
+
export declare function isSlotBinding(value: unknown): value is SlotBinding;
|
|
57
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
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,SAAS,CAG/H;AASD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAI3D;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAmBvE;AAED,wGAAwG;AACxG,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,WAAW,EAAE,GAAG,SAAS,CAS1F;AAMD,mHAAmH;AACnH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAIlE"}
|
package/dist/bindings.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one worker slot drives, and how it travels from the runner's `prepare`
|
|
3
|
+
* to the worker's `init`. Every way a pool comes by devices (a configured
|
|
4
|
+
* list, the booted devices it discovered, the leases a provider granted) is
|
|
5
|
+
* one `DeviceSource` that ends in one `SlotBinding` per slot, so the worker
|
|
6
|
+
* reads one shape through one environment variable, whatever produced it.
|
|
7
|
+
*/
|
|
8
|
+
import { createHash } from 'node:crypto';
|
|
9
|
+
import { EngineError, obj } from 'e2e/engine';
|
|
10
|
+
/**
|
|
11
|
+
* The app a slot opens fresh per attempt: the `app` option, else the app the
|
|
12
|
+
* build `appPath` installed. `undefined` while a build still awaits its
|
|
13
|
+
* install in `init`.
|
|
14
|
+
*/
|
|
15
|
+
export function pinnedApp(options, installedApp) {
|
|
16
|
+
if (options.appPath !== undefined && installedApp === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
return options.app ?? installedApp;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The most the serialized bindings of one target may occupy in a worker's
|
|
22
|
+
* environment: a lease comes from third-party code, and an oversized
|
|
23
|
+
* environment fails the worker spawn with an opaque error.
|
|
24
|
+
*/
|
|
25
|
+
const MAX_BINDINGS_ENV_BYTES = 16 * 1024;
|
|
26
|
+
/**
|
|
27
|
+
* The environment variable a target's bindings travel to the workers in: the
|
|
28
|
+
* name made environment-safe for reading, plus a digest of the exact name so
|
|
29
|
+
* `ios-a` and `ios.a` never share a key.
|
|
30
|
+
*/
|
|
31
|
+
export function bindingsVariable(targetName) {
|
|
32
|
+
const readable = targetName.replace(/[^A-Za-z0-9]/g, '_').toUpperCase();
|
|
33
|
+
const digest = createHash('sha256').update(targetName).digest('hex').slice(0, 8).toUpperCase();
|
|
34
|
+
return `E2E_AGENT_DEVICE_POOL_${readable}_${digest}`;
|
|
35
|
+
}
|
|
36
|
+
/** Serializes the bindings for the environment: declared fields only, bounded. */
|
|
37
|
+
export function encodeBindings(bindings) {
|
|
38
|
+
const encoded = JSON.stringify(bindings.map((binding) => obj({
|
|
39
|
+
device: binding.device,
|
|
40
|
+
daemon: binding.daemon === undefined ? undefined : obj({ baseUrl: binding.daemon.baseUrl, authToken: binding.daemon.authToken }),
|
|
41
|
+
installedApp: binding.installedApp,
|
|
42
|
+
})));
|
|
43
|
+
const bytes = Buffer.byteLength(encoded);
|
|
44
|
+
if (bytes > MAX_BINDINGS_ENV_BYTES) {
|
|
45
|
+
throw new EngineError('ENGINE_FAILURE', `the device bindings take ${bytes} bytes; the worker environment carries at most ${MAX_BINDINGS_ENV_BYTES}`, { retryable: false });
|
|
46
|
+
}
|
|
47
|
+
return encoded;
|
|
48
|
+
}
|
|
49
|
+
/** The bindings a `prepare` left in the environment, or `undefined` when there are none it can read. */
|
|
50
|
+
export function decodeBindings(raw) {
|
|
51
|
+
if (raw === undefined)
|
|
52
|
+
return undefined;
|
|
53
|
+
try {
|
|
54
|
+
const parsed = JSON.parse(raw);
|
|
55
|
+
if (Array.isArray(parsed) && parsed.every(isSlotBinding))
|
|
56
|
+
return parsed;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Not ours to read.
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
function isOptionalString(value) {
|
|
64
|
+
return value === undefined || typeof value === 'string';
|
|
65
|
+
}
|
|
66
|
+
/** A binding as JSON parses it back, or as a provider returned it: nothing the engine did not write is trusted. */
|
|
67
|
+
export function isSlotBinding(value) {
|
|
68
|
+
if (typeof value !== 'object' || value === null)
|
|
69
|
+
return false;
|
|
70
|
+
const { device, daemon, installedApp } = value;
|
|
71
|
+
return isOptionalString(device) && isOptionalString(installedApp) && (daemon === undefined || isDaemon(daemon));
|
|
72
|
+
}
|
|
73
|
+
function isDaemon(value) {
|
|
74
|
+
if (typeof value !== 'object' || value === null)
|
|
75
|
+
return false;
|
|
76
|
+
const { baseUrl, authToken } = value;
|
|
77
|
+
return typeof baseUrl === 'string' && isOptionalString(authToken);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAiD,MAAM,YAAY,CAAC;AAmC7F;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,OAA+C,EAAE,YAAgC;IACzG,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAClF,OAAO,OAAO,CAAC,GAAG,IAAI,YAAY,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IACxE,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MA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