GeezerVison is showing github.com — fix(mobile): e2e landscape poses rotate for real on tablets and folds · pingdotgg/t3code@3e47c1c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: scripts/mobile-e2e.ts +13-3Lines changed: 13 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -139,7 +139,10 @@ async function runPose( | 139 | 139 | async function main() { | 140 | 140 | const args = NodeProcess.argv.slice(2); | 141 | 141 | if (args.includes("--list")) { | 142 | | - for (const pose of POSES) NodeProcess.stdout.write(`${pose.id}\t${pose.device}\n`); | | 142 | + for (const pose of POSES) | | 143 | + NodeProcess.stdout.write( | | 144 | + `${pose.id}\t${pose.device}${pose.pending ? `\t(pending: ${pose.pending})` : ""}\n`, | | 145 | + ); | 143 | 146 | return; | 144 | 147 | } | 145 | 148 | const values = (flag: string) => | @@ -150,7 +153,7 @@ async function main() { | 150 | 153 | const platforms = values("--platform"); | 151 | 154 | const poses = POSES.filter( | 152 | 155 | (pose) => | 153 | | - (selected.length === 0 || selected.includes(pose.id)) && | | 156 | + (selected.length === 0 ? !pose.pending : selected.includes(pose.id)) && | 154 | 157 | (platforms.length === 0 || platforms.includes(pose.platform)), | 155 | 158 | ); | 156 | 159 | const concurrencyFlag = values("--concurrency")[0]; | @@ -221,8 +224,15 @@ async function main() { | 221 | 224 | }, | 222 | 225 | ); | 223 | 226 | await waitForPort(metroPort, "Metro", 120_000); | 224 | | - // Warm each platform's bundle once, instead of on every device at once. | | 227 | + // Warm each platform's bundle once, instead of on every device at once, and have its dev | | 228 | + // client cached before any lease: a cache miss builds, which can outlast a lease. | 225 | 229 | for (const platform of new Set(poses.map((pose) => pose.platform))) { | | 230 | + log("e2e", `preparing the ${platform} dev client`); | | 231 | + await run( | | 232 | + NodeProcess.execPath, | | 233 | + ["scripts/mobile-native-client.ts", "ensure", platform, "--prepare"], | | 234 | + { cwd: REPO_ROOT, timeoutMs: 1_800_000 }, | | 235 | + ); | 226 | 236 | log("e2e", `bundling for ${platform}`); | 227 | 237 | await run("curl", [ | 228 | 238 | "-sf", | |
Collapse file Copy file name to clipboardExpand all lines: scripts/mobile-e2e/device.ts +18-2Lines changed: 18 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -105,9 +105,9 @@ export class Device { | 105 | 105 | try { | 106 | 106 | return await this.agentOnce(args, options); | 107 | 107 | } catch (error) { | 108 | | - if (attempt >= 3 || !(error instanceof AgentDeviceError) || !TRANSIENT.test(error.message)) | | 108 | + if (attempt >= 5 || !(error instanceof AgentDeviceError) || !TRANSIENT.test(error.message)) | 109 | 109 | throw error; | 110 | | - await delay(3_000 * attempt); | | 110 | + await delay(5_000 * attempt); | 111 | 111 | } | 112 | 112 | } | 113 | 113 | } | @@ -174,6 +174,22 @@ export class Device { | 174 | 174 | await this.acceptOpenPrompt(); | 175 | 175 | } | 176 | 176 |
| | 177 | + /** | | 178 | + * agent-device names rotations relative to the device's natural orientation, which is | | 179 | + * landscape on tablets and unfolded folds, so try each name until the screen has the shape. | | 180 | + */ | | 181 | + async orient(shape: "landscape" | "portrait"): Promise<Snapshot> { | | 182 | + let snapshot = await this.snapshot(); | | 183 | + for (const name of ["landscape-left", "portrait", "landscape-right"]) { | | 184 | + const { width, height } = snapshot.viewport; | | 185 | + if (width > height === (shape === "landscape")) return snapshot; | | 186 | + await this.agent(["orientation", name]); | | 187 | + await delay(2_000); | | 188 | + snapshot = await this.snapshot(); | | 189 | + } | | 190 | + return snapshot; | | 191 | + } | | 192 | + | 177 | 193 | async openUrl(url: string) { | 178 | 194 | await this.agent(["open", BUNDLE_ID, url]); | 179 | 195 | await this.acceptOpenPrompt(); | |
Collapse file Copy file name to clipboardExpand all lines: scripts/mobile-e2e/journey.ts +3-6Lines changed: 3 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -137,9 +137,8 @@ export async function runJourney( | 137 | 137 | } | 138 | 138 | if (!threads) throw new Error("the app did not show the fixture threads after pairing"); | 139 | 139 | // Rotated only once the app is up: a rotation during launch is lost. | 140 | | - if (device.pose.landscape) await device.agent(["orientation", "landscape-left"]); | 141 | | - await delay(device.pose.landscape ? 2_000 : 1_000); | 142 | | - threads = await device.snapshot(); | | 140 | + await delay(1_000); | | 141 | + threads = await device.orient(device.pose.landscape ? "landscape" : "portrait"); | 143 | 142 | const tabs = tabBarRect(threads); | 144 | 143 | const wide = threads.viewport.width > threads.viewport.height; | 145 | 144 | await capture("threads", threads, [ | @@ -270,9 +269,7 @@ export async function runJourney( | 270 | 269 | await capture("settings", await device.snapshot()); | 271 | 270 |
| 272 | 271 | if (device.pose.form === "tablet" && !device.pose.fold) { | 273 | | - await device.agent(["orientation", device.pose.landscape ? "portrait" : "landscape-left"]); | 274 | | - await delay(2_000); | 275 | | - await capture("rotated", await device.snapshot()); | | 272 | + await capture("rotated", await device.orient(device.pose.landscape ? "portrait" : "landscape")); | 276 | 273 | } | 277 | 274 | if (device.pose.fold) { | 278 | 275 | await device.agent(["fold", device.pose.fold === "open" ? "closed" : "open"]); | |
Collapse file Copy file name to clipboardExpand all lines: scripts/mobile-e2e/poses.ts +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,8 @@ export interface Pose { | 9 | 9 | readonly landscape?: boolean; | 10 | 10 | readonly fold?: "closed" | "open"; | 11 | 11 | readonly textSize?: "accessibility-large"; | | 12 | + /** Why the pose is skipped unless named with --pose. */ | | 13 | + readonly pending?: string; | 12 | 14 | } | 13 | 15 |
| 14 | 16 | const pose = (value: Pose) => value; | @@ -35,6 +37,8 @@ export const POSES: ReadonlyArray<Pose> = [ | 35 | 37 | form: "phone", | 36 | 38 | appearance: "light", | 37 | 39 | fold: "closed", | | 40 | + pending: | | 41 | + "agent-device fold refuses simulators outside the default device set, which Simlock uses", | 38 | 42 | }), | 39 | 43 | pose({ | 40 | 44 | id: "iphone-duo-unfolded", | @@ -43,6 +47,8 @@ export const POSES: ReadonlyArray<Pose> = [ | 43 | 47 | form: "tablet", | 44 | 48 | appearance: "dark", | 45 | 49 | fold: "open", | | 50 | + pending: | | 51 | + "agent-device fold refuses simulators outside the default device set, which Simlock uses", | 46 | 52 | }), | 47 | 53 | pose({ | 48 | 54 | id: "ipad-13-portrait", | |
|