@delacour/warden-e2e 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE +21 -0
  2. package/chunk-qtkmfjbq.mjs +4585 -0
  3. package/index.d.ts +1 -0
  4. package/index.mjs +998 -0
  5. package/package.json +49 -4
  6. package/preload.d.ts +1 -0
  7. package/preload.mjs +5512 -0
  8. package/types/core/src/allocate.d.ts +23 -0
  9. package/types/core/src/builds/app-option.schema.d.ts +37 -0
  10. package/types/core/src/builds/install.d.ts +95 -0
  11. package/types/core/src/builds/resolve.d.ts +74 -0
  12. package/types/core/src/config.defaults.d.ts +25 -0
  13. package/types/core/src/exec.d.ts +18 -0
  14. package/types/core/src/liveness.d.ts +12 -0
  15. package/types/core/src/providers/android.d.ts +124 -0
  16. package/types/core/src/providers/health.d.ts +45 -0
  17. package/types/core/src/providers/provider.types.d.ts +56 -0
  18. package/types/core/src/store.d.ts +91 -0
  19. package/types/core/src/types.d.ts +106 -0
  20. package/types/e2e/src/alert-buttons.d.ts +41 -0
  21. package/types/e2e/src/alert-reader.d.ts +25 -0
  22. package/types/e2e/src/app.d.ts +62 -0
  23. package/types/e2e/src/device-devtools.d.ts +26 -0
  24. package/types/e2e/src/device-link.d.ts +43 -0
  25. package/types/e2e/src/device.d.ts +82 -0
  26. package/types/e2e/src/devtools/cdp.d.ts +65 -0
  27. package/types/e2e/src/devtools/console.d.ts +59 -0
  28. package/types/e2e/src/devtools/devtools.types.d.ts +169 -0
  29. package/types/e2e/src/devtools/facet.d.ts +28 -0
  30. package/types/e2e/src/devtools/inspector.d.ts +48 -0
  31. package/types/e2e/src/devtools/jsonl.d.ts +4 -0
  32. package/types/e2e/src/devtools/network.d.ts +33 -0
  33. package/types/e2e/src/devtools/network.script.d.ts +24 -0
  34. package/types/e2e/src/devtools/session.d.ts +82 -0
  35. package/types/e2e/src/devtools/tree.d.ts +23 -0
  36. package/types/e2e/src/devtools/tree.script.d.ts +33 -0
  37. package/types/e2e/src/driver/alerts.d.ts +29 -0
  38. package/types/e2e/src/driver/android/adb-session.d.ts +52 -0
  39. package/types/e2e/src/driver/android/android-alert.d.ts +4 -0
  40. package/types/e2e/src/driver/android/android-animations.d.ts +29 -0
  41. package/types/e2e/src/driver/android/android-app.d.ts +32 -0
  42. package/types/e2e/src/driver/android/android-argv.d.ts +122 -0
  43. package/types/e2e/src/driver/android/android-device.d.ts +44 -0
  44. package/types/e2e/src/driver/android/android-driver.d.ts +60 -0
  45. package/types/e2e/src/driver/android/android-dump.d.ts +46 -0
  46. package/types/e2e/src/driver/android/android-state.d.ts +69 -0
  47. package/types/e2e/src/driver/android/uiad-backend.d.ts +63 -0
  48. package/types/e2e/src/driver/android/uiad-client.d.ts +60 -0
  49. package/types/e2e/src/driver/android/uiad-device.d.ts +70 -0
  50. package/types/e2e/src/driver/android/uiad-dex.generated.d.ts +8 -0
  51. package/types/e2e/src/driver/android/uiad-ops.d.ts +62 -0
  52. package/types/e2e/src/driver/android/uiad-protocol.d.ts +209 -0
  53. package/types/e2e/src/driver/android/uiautomator.d.ts +33 -0
  54. package/types/e2e/src/driver/driver.types.d.ts +231 -0
  55. package/types/e2e/src/driver/errors.d.ts +13 -0
  56. package/types/e2e/src/driver/gesture-geometry.d.ts +48 -0
  57. package/types/e2e/src/driver/ios/ios-driver.d.ts +63 -0
  58. package/types/e2e/src/driver/ios/ios-session.d.ts +30 -0
  59. package/types/e2e/src/driver/ios/locate-helper.d.ts +38 -0
  60. package/types/e2e/src/driver/ios/normalize.d.ts +11 -0
  61. package/types/e2e/src/driver/ios/simctl.d.ts +87 -0
  62. package/types/e2e/src/driver/ios/simd-client.d.ts +68 -0
  63. package/types/e2e/src/driver/ios/simd-protocol.d.ts +433 -0
  64. package/types/e2e/src/driver/ios/simd-transport.d.ts +43 -0
  65. package/types/e2e/src/driver/ios/type-budget.d.ts +6 -0
  66. package/types/e2e/src/driver/observation-cache.d.ts +66 -0
  67. package/types/e2e/src/driver/open.d.ts +29 -0
  68. package/types/e2e/src/driver/settle.d.ts +43 -0
  69. package/types/e2e/src/driver/span-detail.d.ts +12 -0
  70. package/types/e2e/src/driver/traced-driver.d.ts +14 -0
  71. package/types/e2e/src/driver/typing.d.ts +48 -0
  72. package/types/e2e/src/driver/unwrap.d.ts +13 -0
  73. package/types/e2e/src/env.d.ts +61 -0
  74. package/types/e2e/src/errors.d.ts +26 -0
  75. package/types/e2e/src/expect/expect.d.ts +27 -0
  76. package/types/e2e/src/expect/matchers.d.ts +72 -0
  77. package/types/e2e/src/fixture-session.d.ts +34 -0
  78. package/types/e2e/src/fixtures.d.ts +14 -0
  79. package/types/e2e/src/index.d.ts +8 -0
  80. package/types/e2e/src/preload.d.ts +29 -0
  81. package/types/e2e/src/runner/artifacts.d.ts +13 -0
  82. package/types/e2e/src/runner/attempt.d.ts +63 -0
  83. package/types/e2e/src/runner/callsite.d.ts +2 -0
  84. package/types/e2e/src/runner/failure.d.ts +28 -0
  85. package/types/e2e/src/runner/fixtures.types.d.ts +60 -0
  86. package/types/e2e/src/runner/results.d.ts +48 -0
  87. package/types/e2e/src/runner/scope.d.ts +62 -0
  88. package/types/e2e/src/runner/span.d.ts +40 -0
  89. package/types/e2e/src/runner/step.d.ts +7 -0
  90. package/types/e2e/src/runner/test.d.ts +52 -0
  91. package/types/e2e/src/runner/trace.d.ts +87 -0
  92. package/types/e2e/src/screen/actions.d.ts +93 -0
  93. package/types/e2e/src/screen/context.d.ts +134 -0
  94. package/types/e2e/src/screen/field.d.ts +121 -0
  95. package/types/e2e/src/screen/locator.d.ts +233 -0
  96. package/types/e2e/src/screen/nodes.d.ts +53 -0
  97. package/types/e2e/src/screen/poll.d.ts +57 -0
  98. package/types/e2e/src/screen/queries.d.ts +34 -0
  99. package/types/e2e/src/screen/query.d.ts +60 -0
  100. package/types/e2e/src/screen/react-locator.d.ts +30 -0
  101. package/types/e2e/src/screen/render.d.ts +42 -0
  102. package/types/e2e/src/screen/roles.d.ts +24 -0
  103. package/types/e2e/src/screen/screen.d.ts +61 -0
  104. package/types/e2e/src/screen/selector.d.ts +38 -0
  105. package/types/e2e/src/screen/text.d.ts +13 -0
  106. package/types/e2e/src/session.d.ts +105 -0
  107. package/types/e2e/src/traced-device.d.ts +9 -0
  108. package/types/e2e/src/version.d.ts +7 -0
  109. package/types/types/src/result.d.ts +12 -0
  110. package/README.md +0 -3
@@ -0,0 +1,105 @@
1
+ import { type DevtoolsFacet, type DevtoolsResult } from "./devtools/devtools.types";
2
+ import type { Driver, DriverResult } from "./driver/driver.types";
3
+ import { type E2eEnv } from "./env";
4
+ import type { AttemptContext, FixtureFactory } from "./runner/fixtures.types";
5
+ import { type ResultsWriter } from "./runner/results";
6
+ import { type SpanRunner } from "./runner/span";
7
+ import type { TraceWriter } from "./runner/trace";
8
+ export type DriverFactory = (env: E2eEnv) => DriverResult<Driver>;
9
+ /** How to attach to the app's dev client; default {@link openDevtools}. Tests inject a stub. */
10
+ export type DevtoolsOpener = (env: E2eEnv) => Promise<DevtoolsResult<DevtoolsFacet>>;
11
+ /**
12
+ * Which inspector page is this env's: the bundle id and the device name. Several devices can share one Metro;
13
+ * without the name the newest page of any device would win and a reload or evaluate would hit another device's app.
14
+ */
15
+ export declare function devtoolsTarget(env: E2eEnv): {
16
+ appId: string;
17
+ deviceName?: string;
18
+ };
19
+ /** Metro's inspector for this env's app (`WARDEN_METRO_URL`), pinned by {@link devtoolsTarget}. */
20
+ export declare const openDevtools: DevtoolsOpener;
21
+ export type Session = {
22
+ readonly env: E2eEnv;
23
+ /** absolute `WARDEN_E2E_OUT` */
24
+ readonly out: string;
25
+ readonly results: ResultsWriter;
26
+ /** builds `app`/`device`/`screen` for each attempt (T4/T6); settable so tests can fake it */
27
+ fixtures: FixtureFactory | undefined;
28
+ /** where the console reporter prints one line; default fd 1 */
29
+ readonly log: (line: string) => void;
30
+ /** the running attempt, if any */
31
+ readonly attempt: AttemptContext | undefined;
32
+ /** aborts at the running attempt's deadline; never aborts outside an attempt. Pass it to every driver call and poll. */
33
+ readonly signal: AbortSignal;
34
+ /** the running attempt's artifacts dir and `trace.jsonl` (read at call time by the `app`/`device` fixtures) */
35
+ readonly attemptDir: string | undefined;
36
+ readonly trace: TraceWriter | undefined;
37
+ /**
38
+ * opened on first call, then shared; a failed open is thrown as `E2eError{code:"DRIVER"}` and retried next call.
39
+ * Every call on it is a `driver.*` span in the running attempt's `trace.jsonl`, except a screen read that the
40
+ * observation cache answers from the snapshot a read just took (`driver/observation-cache.ts`; it offers `observe`).
41
+ */
42
+ driver(): Promise<Driver>;
43
+ /** the driver if it is already open; never opens one (failure capture must not start a device) */
44
+ peekDriver(): Driver | undefined;
45
+ /**
46
+ * The app's devtools (console, network, React tree, evaluate), attached on the first call and shared after;
47
+ * `devtools_unavailable` without `WARDEN_METRO_URL` (a release build). A failed attach is retried on the next call.
48
+ */
49
+ devtools(): Promise<DevtoolsResult<DevtoolsFacet>>;
50
+ /** the facet if it is already attached; never attaches one (failure capture must not connect to anything) */
51
+ peekDevtools(): DevtoolsFacet | undefined;
52
+ /** one reported step (`▸`/`▪` lines, `trace.jsonl`) that gives up when the attempt deadline aborts */
53
+ step<T>(kind: string, label: string, fn: () => Promise<T>): Promise<T>;
54
+ /** times one call as a `span` in the running attempt's `trace.jsonl` (no console line); just runs it outside an attempt */
55
+ span: SpanRunner;
56
+ /**
57
+ * Makes `attempt` the running one. With `replacing`, only when that is still the running one: an attempt's
58
+ * cleanup must not take the slot back from the next test that bun already started.
59
+ */
60
+ enterAttempt(attempt: AttemptContext, replacing?: AttemptContext): void;
61
+ /** Clears the running attempt; with `attempt`, only when that is the running one (never another test's). */
62
+ leaveAttempt(attempt?: AttemptContext): void;
63
+ /** idempotent; closes the driver only if it was opened */
64
+ close(): Promise<void>;
65
+ };
66
+ export type SessionOptions = {
67
+ /** parsed env; default `readEnv(process.env)` (throws `SESSION` when not under warden) */
68
+ env?: E2eEnv;
69
+ /** how to open the device; default {@link setDefaultDriverFactory}'s */
70
+ driverFactory?: DriverFactory;
71
+ /** how to attach devtools; default {@link openDevtools} */
72
+ devtools?: DevtoolsOpener;
73
+ /** fixture factory; default {@link setDefaultFixtureFactory}'s */
74
+ fixtures?: FixtureFactory;
75
+ /** console line sink; default writes to fd 1 (bun test captures `process.stdout`, fd 1 is not captured) */
76
+ log?: (line: string) => void;
77
+ /** close from `process.on("exit")`; default true */
78
+ exitHook?: boolean;
79
+ };
80
+ /** Wires the factory used when `getSession` gets none (`driver/open.ts`'s opener, set by the package entry). */
81
+ export declare function setDefaultDriverFactory(factory: DriverFactory | undefined): void;
82
+ /** Whether a default driver factory is wired (so the preload leaves a test-installed fake alone). */
83
+ export declare function hasDefaultDriverFactory(): boolean;
84
+ /** Wires the `app`/`device`/`screen` factory used when `getSession` gets none. */
85
+ export declare function setDefaultFixtureFactory(factory: FixtureFactory | undefined): void;
86
+ /** Whether a default fixture factory is wired (so the preload leaves a test-installed one alone). */
87
+ export declare function hasDefaultFixtureFactory(): boolean;
88
+ export declare function createSession(opts?: SessionOptions): Session;
89
+ /** Which context one attempt's own fixtures use right now; `finished` once the runner is done with the attempt. */
90
+ export type AttemptBinding = {
91
+ readonly context: AttemptContext;
92
+ readonly finished: boolean;
93
+ };
94
+ /**
95
+ * `session` as one attempt's fixtures see it: `signal`, `attempt`, `attemptDir`, `trace`, `step` and `span` follow
96
+ * `binding` (that attempt's run context, then its cleanup context, then an aborted one), never whichever attempt is
97
+ * running when a call is made. So work the runner gave up on (a timed-out body that swallowed its `TIMEOUT`, an
98
+ * `afterEach` past its limit) fails its next driver call instead of tapping into the next test. Everything else is
99
+ * the shared session.
100
+ */
101
+ export declare function attemptSession(session: Session, binding: () => AttemptBinding): Session;
102
+ /** The process-wide session (`globalThis[Symbol.for("./session")]`), created on first call. */
103
+ export declare function getSession(opts?: SessionOptions): Session;
104
+ /** Closes and forgets the process-wide session, if any. */
105
+ export declare function resetSession(): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import type { Device } from "./device";
2
+ import type { SpanRunner } from "./runner/span";
3
+ /**
4
+ * `device` with every call timed as a `device.<name>` span in the attempt's `trace.jsonl` (trace only: no console
5
+ * line, since a settle or an alert is not a step). The driver calls a device call makes are `driver.*` spans of
6
+ * their own, so a slow `device.openLink` shows what it spent its time on. Without a span runner (a bare
7
+ * `FixtureSession`) the device is returned unchanged.
8
+ */
9
+ export declare function traceDevice(device: Device, span: SpanRunner | undefined): Device;
@@ -0,0 +1,7 @@
1
+ /** What `WARDEN_E2E_VERSION` is when running from the workspace sources: not a published build, so no handshake. */
2
+ export declare const WORKSPACE_VERSION = "0.0.0-workspace";
3
+ /**
4
+ * The version of this `@delacour/warden-e2e`. Published builds carry warden's own version (lock-step);
5
+ * `warden e2e` hands its version to the spec process (`WARDEN_VERSION`) and the preload refuses to run when they differ.
6
+ */
7
+ export declare const WARDEN_E2E_VERSION: string;
@@ -0,0 +1,12 @@
1
+ export type SuccessResult<Success> = {
2
+ success: true;
3
+ data: Success;
4
+ };
5
+ export type ErrorResult<Error = string> = {
6
+ success: false;
7
+ error: Error;
8
+ };
9
+ export type Result<Success, Error = string> = SuccessResult<Success> | ErrorResult<Error>;
10
+ export type AsyncResult<Success, Error = string> = Promise<Result<Success, Error>>;
11
+ export declare function ok<T>(data: T): SuccessResult<T>;
12
+ export declare function err(error: unknown): ErrorResult<string>;
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.