GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mobile): e2e landscape poses rotate for real on tablets and folds · pingdotgg/t3code@3e47c1c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • scripts
    • mobile-e2e.ts
    • mobile-e2e
      • device.ts
      • journey.ts
      • poses.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎scripts/mobile-e2e.ts‎

Copy file name to clipboardExpand all lines: scripts/mobile-e2e.ts
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ async function runPose(
139139
async function main() {
140140
const args = NodeProcess.argv.slice(2);
141141
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+
);
143146
return;
144147
}
145148
const values = (flag: string) =>
@@ -150,7 +153,7 @@ async function main() {
150153
const platforms = values("--platform");
151154
const poses = POSES.filter(
152155
(pose) =>
153-
(selected.length === 0 || selected.includes(pose.id)) &&
156+
(selected.length === 0 ? !pose.pending : selected.includes(pose.id)) &&
154157
(platforms.length === 0 || platforms.includes(pose.platform)),
155158
);
156159
const concurrencyFlag = values("--concurrency")[0];
@@ -221,8 +224,15 @@ async function main() {
221224
},
222225
);
223226
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.
225229
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+
);
226236
log("e2e", `bundling for ${platform}`);
227237
await run("curl", [
228238
"-sf",
Collapse file

‎scripts/mobile-e2e/device.ts‎

Copy file name to clipboardExpand all lines: scripts/mobile-e2e/device.ts
+18-2Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ export class Device {
105105
try {
106106
return await this.agentOnce(args, options);
107107
} catch (error) {
108-
if (attempt >= 3 || !(error instanceof AgentDeviceError) || !TRANSIENT.test(error.message))
108+
if (attempt >= 5 || !(error instanceof AgentDeviceError) || !TRANSIENT.test(error.message))
109109
throw error;
110-
await delay(3_000 * attempt);
110+
await delay(5_000 * attempt);
111111
}
112112
}
113113
}
@@ -174,6 +174,22 @@ export class Device {
174174
await this.acceptOpenPrompt();
175175
}
176176

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+
177193
async openUrl(url: string) {
178194
await this.agent(["open", BUNDLE_ID, url]);
179195
await this.acceptOpenPrompt();
Collapse file

‎scripts/mobile-e2e/journey.ts‎

Copy file name to clipboardExpand all lines: scripts/mobile-e2e/journey.ts
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ export async function runJourney(
137137
}
138138
if (!threads) throw new Error("the app did not show the fixture threads after pairing");
139139
// 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");
143142
const tabs = tabBarRect(threads);
144143
const wide = threads.viewport.width > threads.viewport.height;
145144
await capture("threads", threads, [
@@ -270,9 +269,7 @@ export async function runJourney(
270269
await capture("settings", await device.snapshot());
271270

272271
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"));
276273
}
277274
if (device.pose.fold) {
278275
await device.agent(["fold", device.pose.fold === "open" ? "closed" : "open"]);
Collapse file

‎scripts/mobile-e2e/poses.ts‎

Copy file name to clipboardExpand all lines: scripts/mobile-e2e/poses.ts
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface Pose {
99
readonly landscape?: boolean;
1010
readonly fold?: "closed" | "open";
1111
readonly textSize?: "accessibility-large";
12+
/** Why the pose is skipped unless named with --pose. */
13+
readonly pending?: string;
1214
}
1315

1416
const pose = (value: Pose) => value;
@@ -35,6 +37,8 @@ export const POSES: ReadonlyArray<Pose> = [
3537
form: "phone",
3638
appearance: "light",
3739
fold: "closed",
40+
pending:
41+
"agent-device fold refuses simulators outside the default device set, which Simlock uses",
3842
}),
3943
pose({
4044
id: "iphone-duo-unfolded",
@@ -43,6 +47,8 @@ export const POSES: ReadonlyArray<Pose> = [
4347
form: "tablet",
4448
appearance: "dark",
4549
fold: "open",
50+
pending:
51+
"agent-device fold refuses simulators outside the default device set, which Simlock uses",
4652
}),
4753
pose({
4854
id: "ipad-13-portrait",

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.