@delacour/warden-e2e 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/{chunk-zk3wxa70.mjs → chunk-e3cry5br.mjs} +287 -37
  2. package/index.mjs +32 -3
  3. package/package.json +2 -2
  4. package/preload.mjs +304 -30
  5. package/types/core/src/affected/affected.schema.d.ts +5 -0
  6. package/types/core/src/builds/builds.defaults.d.ts +8 -0
  7. package/types/core/src/builds/config.schema.d.ts +9 -0
  8. package/types/core/src/builds/define-config.d.ts +9 -1
  9. package/types/core/src/conditions/conditions.config.d.ts +6 -1
  10. package/types/core/src/conditions/conditions.types.d.ts +21 -0
  11. package/types/core/src/conditions/inject-state.d.ts +3 -2
  12. package/types/e2e/src/a11y/a11y-target.d.ts +2 -0
  13. package/types/e2e/src/conditions/condition-events.d.ts +6 -1
  14. package/types/e2e/src/conditions/device-conditions.d.ts +8 -2
  15. package/types/e2e/src/device.d.ts +10 -2
  16. package/types/e2e/src/driver/android/android-settings.d.ts +9 -2
  17. package/types/e2e/src/driver/ax-wedge.d.ts +38 -0
  18. package/types/e2e/src/driver/bridge-stall.d.ts +4 -0
  19. package/types/e2e/src/driver/driver.types.d.ts +30 -1
  20. package/types/e2e/src/driver/ios/inject.d.ts +17 -2
  21. package/types/e2e/src/driver/ios/ios-driver.d.ts +7 -2
  22. package/types/e2e/src/driver/ios/ios-keyboard.d.ts +39 -0
  23. package/types/e2e/src/driver/ios/simd-protocol.d.ts +99 -0
  24. package/types/e2e/src/driver/keyboard-state.d.ts +9 -0
  25. package/types/e2e/src/driver/physical-conditions.d.ts +1 -1
  26. package/types/e2e/src/driver/read-deadline.d.ts +4 -0
  27. package/types/e2e/src/driver/settle.d.ts +3 -1
  28. package/types/e2e/src/expect/a11y-matchers.d.ts +7 -0
  29. package/types/e2e/src/index.d.ts +2 -1
  30. package/types/e2e/src/screen/actions.d.ts +7 -0
  31. package/types/e2e/src/screen/context.d.ts +3 -1
  32. package/types/e2e/src/screen/keyboard-cover.d.ts +26 -0
  33. package/types/e2e/src/screen/locator.d.ts +16 -7
  34. package/types/e2e/src/session.d.ts +6 -0
package/index.mjs CHANGED
@@ -46,11 +46,12 @@ import {
46
46
  registrationDefaults,
47
47
  markOnly,
48
48
  WARDEN_E2E_VERSION2
49
- } from "./chunk-zk3wxa70.mjs";
49
+ } from "./chunk-e3cry5br.mjs";
50
50
  // ../../packages/e2e/src/expect/expect.ts
51
51
  import { expect as bunExpect } from "bun:test";
52
52
 
53
53
  // ../../packages/e2e/src/expect/a11y-matchers.ts
54
+ var KEYBOARD_POLL_MS = 100;
54
55
  function show(match) {
55
56
  return typeof match === "string" ? JSON.stringify(match) : String(match);
56
57
  }
@@ -125,6 +126,30 @@ class DeviceAssertions {
125
126
  ]);
126
127
  });
127
128
  }
129
+ async toHaveKeyboard(options = {}) {
130
+ for (const key of Object.keys(options)) {
131
+ if (key !== "timeout")
132
+ throw new E2eError2("INVALID_ARGUMENT", `toHaveKeyboard does not take "${key}"; it takes timeout`);
133
+ }
134
+ checkMillis("toHaveKeyboard", "timeout", options.timeout);
135
+ const timeoutMs = options.timeout ?? this.target.assertionTimeout();
136
+ const want = !this.context.negate;
137
+ return this.run("toHaveKeyboard()", async () => {
138
+ const deadline = Date.now() + timeoutMs;
139
+ let visible = await this.target.keyboardVisible();
140
+ while (visible !== want && Date.now() < deadline) {
141
+ await new Promise((resolve) => setTimeout(resolve, KEYBOARD_POLL_MS));
142
+ visible = await this.target.keyboardVisible();
143
+ }
144
+ if (visible === want)
145
+ return;
146
+ throw await this.failure([
147
+ `expect(device)${this.context.negate ? ".not" : ""}.toHaveKeyboard()`,
148
+ `Expected: ${want ? "a keyboard on screen" : "no keyboard on screen"} within ${timeoutMs} ms`,
149
+ `Received: ${visible ? "a keyboard on screen" : "no keyboard on screen"}`
150
+ ]);
151
+ });
152
+ }
128
153
  async failure(lines) {
129
154
  const screen = await this.target.a11yScreen();
130
155
  const head = lines.join(`
@@ -1224,15 +1249,19 @@ async function concludeAttempt(session, spec, ctx, run, outcome, print, clock) {
1224
1249
  ctx.files.add(shot);
1225
1250
  const result = buildResult(spec, ctx, run, outcome.failed ? { failed: true, error: outcome.failure, timedOut: outcome.deadlineHit } : { failed: false });
1226
1251
  print(formatConsoleLine({ type: "test-end", result }, { clock }));
1227
- if (outcome.failed && session.recoverHid !== undefined && isRecoverableLoss(outcome.failure, session.env.deviceKind) && await session.recoverHid()) {
1252
+ if (outcome.failed && await recovered(session, outcome.failure, run.startedAt))
1228
1253
  return "again";
1229
- }
1230
1254
  if (!outcome.failed || spec.final)
1231
1255
  session.results.append(result);
1232
1256
  if (outcome.failed)
1233
1257
  throw outcome.failure instanceof Error ? outcome.failure : new Error(String(outcome.failure));
1234
1258
  return;
1235
1259
  }
1260
+ async function recovered(session, failure, startedAt) {
1261
+ if (session.recoverHid !== undefined && isRecoverableLoss(failure, session.env.deviceKind) && await session.recoverHid())
1262
+ return true;
1263
+ return session.recoverAxWedge !== undefined && await session.recoverAxWedge(Date.now() - startedAt);
1264
+ }
1236
1265
  function softFailureError(failures) {
1237
1266
  if (failures.length === 1 && failures[0] !== undefined)
1238
1267
  return failures[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delacour/warden-e2e",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "TypeScript e2e testing for React Native and Expo on iOS simulators and Android emulators, run by `warden e2e`: test, expect, screen, device, app",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -41,7 +41,7 @@
41
41
  "LICENSE"
42
42
  ],
43
43
  "peerDependencies": {
44
- "@delacour/warden": "0.14.0"
44
+ "@delacour/warden": "0.15.0"
45
45
  },
46
46
  "dependencies": {
47
47
  "zod": "^4.4.3"