TypeScript
chore(mobile): e2e poses for current devices, Duo and landscape fixes
Julius Marminge911091ba7efc
diff --git a/scripts/mobile-e2e/device.ts b/scripts/mobile-e2e/device.tsindex 9397d739a3c..a2638b10d9a 100644--- a/scripts/mobile-e2e/device.ts+++ b/scripts/mobile-e2e/device.ts@@ -65,7 +65,7 @@ export class AgentDeviceError extends Error {}// A shared pool's workers drop off the gateway and stall under load for seconds at a time.const TRANSIENT =- /Remote daemon is unavailable|not connected to the gateway|still finishing a previous command|Invalid daemon response|Daemon request timed out/i;+ /Remote daemon is unavailable|not connected to the gateway|still finishing a previous command|Invalid daemon response|Daemon request timed out|no worker connected/i;export class Device {readonly pose: Pose;@@ -172,7 +172,6 @@ export class Device {{ timeoutMs: 180_000 },);await this.acceptOpenPrompt();- if (this.pose.landscape) await this.agent(["orientation", "landscape-left"]);}async openUrl(url: string) {diff --git a/scripts/mobile-e2e/journey.ts b/scripts/mobile-e2e/journey.tsindex 70198aaca73..49e6dfb90fd 100644--- a/scripts/mobile-e2e/journey.ts+++ b/scripts/mobile-e2e/journey.ts@@ -71,9 +71,19 @@ export async function runJourney(steps: StepResult[],): Promise<void> {const phone = device.pose.form === "phone";- const tap = (node: SnapshotNode | undefined, label: string) => {- if (!node?.ref) throw new Error(`no ${label} to tap`);- return device.agent(["press", `@${node.ref}`]);+ const tap = async (node: SnapshotNode | undefined, label: string) => {+ if (!node?.ref || !node.rect) throw new Error(`no ${label} to tap`);+ // agent-device refuses refs it considers covered, such as on the unfolded Duo's inner+ // display; the element's centre still takes the tap.+ await device+ .agent(["press", `@${node.ref}`])+ .catch(() =>+ device.agent([+ "press",+ String(Math.round(node.rect!.x + node.rect!.width / 2)),+ String(Math.round(node.rect!.y + node.rect!.height / 2)),+ ]),+ );};/** Screenshot and check the settled screen, and record it as a step. */@@ -126,10 +136,18 @@ export async function runJourney(.catch(() => null);}if (!threads) throw new Error("the app did not show the fixture threads after pairing");- await delay(1_000);+ // Rotated only once the app is up: a rotation during launch is lost.+ if (device.pose.landscape) await device.agent(["orientation", "landscape-left"]);+ await delay(device.pose.landscape ? 2_000 : 1_000);threads = await device.snapshot();const tabs = tabBarRect(threads);+ const wide = threads.viewport.width > threads.viewport.height;await capture("threads", threads, [+ check(+ device.pose.landscape ? "in landscape" : "in portrait",+ wide === Boolean(device.pose.landscape),+ `${Math.round(threads.viewport.width)}×${Math.round(threads.viewport.height)}`,+ ),check("thread list visible", threadRow(threads) !== undefined, "fixture threads"),...(phone ? [check("tab bar visible", inside(tabs, threads), describeRect(tabs))] : []),]);diff --git a/scripts/mobile-e2e/poses.ts b/scripts/mobile-e2e/poses.tsindex a1714cd5e10..0586d08e9ee 100644--- a/scripts/mobile-e2e/poses.ts+++ b/scripts/mobile-e2e/poses.ts@@ -5,7 +5,7 @@ export interface Pose {readonly device: string;readonly form: "phone" | "tablet";readonly appearance: "light" | "dark";- /** Phones are portrait-only; tablets also run rotated. */+ /** Phones are portrait-locked; tablets and an unfolded Fold can start rotated. */readonly landscape?: boolean;readonly fold?: "closed" | "open";readonly textSize?: "accessibility-large";@@ -22,79 +22,83 @@ export const POSES: ReadonlyArray<Pose> = [appearance: "light",}),pose({- id: "iphone-13-mini-dark",+ id: "iphone-18-pro-dark",platform: "ios",- device: "iPhone 13 mini",+ device: "iPhone 18 Pro",form: "phone",appearance: "dark",}),pose({- id: "iphone-17-pro",+ id: "iphone-duo-folded",platform: "ios",- device: "iPhone 17 Pro",+ device: "iPhone Duo",form: "phone",appearance: "light",+ fold: "closed",}),pose({- id: "iphone-17-pro-max-large-text",+ id: "iphone-duo-unfolded",platform: "ios",- device: "iPhone 17 Pro Max",- form: "phone",+ device: "iPhone Duo",+ form: "tablet",appearance: "dark",- textSize: "accessibility-large",+ fold: "open",}),pose({- id: "ipad-mini",+ id: "ipad-13-portrait",platform: "ios",- device: "iPad mini (A17 Pro)",+ device: "iPad Pro 13-inch (M5)",form: "tablet",appearance: "light",}),pose({- id: "ipad-pro-13-landscape",+ id: "ipad-13-landscape-large-text",platform: "ios",device: "iPad Pro 13-inch (M5)",form: "tablet",appearance: "dark",landscape: true,+ textSize: "accessibility-large",}),pose({- id: "pixel-9",+ id: "pixel-10-pro-large-text",platform: "android",- device: "Pixel 9",+ device: "Pixel 10 Pro",form: "phone",appearance: "light",+ textSize: "accessibility-large",}),pose({- id: "small-phone-dark",+ id: "pixel-fold-folded-dark",platform: "android",- device: "Small Phone",+ device: "Pixel 10 Pro Fold",form: "phone",appearance: "dark",+ fold: "closed",}),pose({- id: "pixel-9-large-text",+ id: "pixel-fold-unfolded",platform: "android",- device: "Pixel 9",- form: "phone",+ device: "Pixel 10 Pro Fold",+ form: "tablet",appearance: "light",- textSize: "accessibility-large",+ fold: "open",}),pose({- id: "pixel-fold-closed",+ id: "pixel-fold-unfolded-landscape",platform: "android",- device: "Pixel 9 Pro Fold",- form: "phone",- appearance: "light",- fold: "closed",+ device: "Pixel 10 Pro Fold",+ form: "tablet",+ appearance: "dark",+ fold: "open",+ landscape: true,}),pose({- id: "pixel-fold-open",+ id: "pixel-tablet-portrait",platform: "android",- device: "Pixel 9 Pro Fold",+ device: "Pixel Tablet",form: "tablet",appearance: "dark",- fold: "open",}),pose({id: "pixel-tablet-landscape",