Skip to content

Commit 18dc875

Browse files
committed
test(server): trim screenshot proxy checks
1 parent e0ba81e commit 18dc875

3 files changed

Lines changed: 3 additions & 42 deletions

File tree

‎apps/server/src/device/DeviceHubOperations.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ const LIST_TIMEOUT_SECONDS = 40;
1919
// expo-device-hub 0.19.1 reports a failed simulator listing only as text; its error ids are hashes.
2020
const SIMULATOR_LIST_FAILED =
2121
/^\[apple-utils\] (?:Failed to (?:run `xcrun simctl list devices|parse JSON output:|list devices:)|`xcrun simctl list devices --json` did not respond within )/;
22-
// expo-device-hub 0.19.1 always passes a numeric `--display`, which Xcode 26's simctl rejects
23-
// (it takes only internal/external). Base64 keeps the PNG intact as text.
24-
// Multi-display simulators need an iOS 27 runtime, where simctl's default display can be the wrong panel.
22+
// The hub passes numeric display IDs that Xcode 26 rejects; iOS 27 needs them for multiple displays.
2523
const runsOnXcode26Runtime = (version: string) => Number(/^iOS (\d+)/.exec(version)?.[1]) <= 26;
2624
const DEFAULT_DISPLAY_SCREENSHOT = `f=$(mktemp -t t3-screenshot) || exit 1
2725
trap 'rm -f "$f"' 0

‎apps/server/src/device/DeviceHubProxy.test.ts‎

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
AuthOrchestrationReadScope,
44
AuthOrchestrationOperateScope,
55
AuthSessionId,
6-
DeviceOperationError,
76
LOCAL_DEVICE_HOST_ID,
87
type AuthEnvironmentScope,
98
} from "@t3tools/contracts";
@@ -25,8 +24,6 @@ const fixture = (
2524
fail = false,
2625
authError?: EnvironmentAuth.ServerAuthCredentialError | EnvironmentAuth.ServerAuthInternalError,
2726
upstream?: DeviceHost.DeviceHostReady["upstream"],
28-
screenshot: DeviceService.DeviceService["Service"]["screenshot"] = () =>
29-
Effect.die(new Error("unexpected screenshot")),
3027
) => {
3128
let finalized = 0;
3229
const requests: string[] = [];
@@ -68,7 +65,6 @@ const fixture = (
6865
hub: { origin: "http://hub.test" },
6966
...(upstream ? { upstream } : {}),
7067
}),
71-
screenshot,
7268
} as DeviceService.DeviceService["Service"]),
7369
),
7470
Layer.provideMerge(Layer.succeed(HttpClient.HttpClient, client)),
@@ -206,7 +202,7 @@ describe("device hub proxy", () => {
206202
undefined,
207203
(hubPath, search) =>
208204
Effect.succeed(
209-
hubPath === "/vendor/serve-sim/api" || hubPath === "/vendor/serve-sim/api/screenshot"
205+
hubPath === "/vendor/serve-sim/api"
210206
? {
211207
url: `https://session.test${hubPath.slice("/vendor/serve-sim".length)}?${search}`,
212208
headers: { authorization: "Bearer session-token" },
@@ -225,42 +221,11 @@ describe("device hub proxy", () => {
225221
await routed.text();
226222
expect(requests).toEqual(["https://session.test/api?device=udid-1"]);
227223
expect(headers[0]?.authorization).toBe("Bearer session-token");
228-
const screenshot = await handler(
229-
new Request(
230-
"http://t3.test/api/device-hub/vendor/serve-sim/api/screenshot?device=udid-1&hostId=eas",
231-
{ method: "POST" },
232-
),
233-
);
234-
expect(screenshot.status).toBe(200);
235-
await screenshot.text();
236-
expect(requests).toEqual([
237-
"https://session.test/api?device=udid-1",
238-
"https://session.test/api/screenshot?device=udid-1",
239-
]);
240224
const unrouted = await handler(
241225
new Request("http://t3.test/api/device-hub/vendor/serve-sim/helper/udid-2/stream.mjpeg"),
242226
);
243227
expect(unrouted.status).toBe(404);
244-
expect(requests).toHaveLength(2);
245-
});
246-
247-
it("keeps simctl diagnostics out of a failed iOS screenshot response", async () => {
248-
const { handler } = fixture([AuthOrchestrationReadScope], false, undefined, undefined, () =>
249-
Effect.fail(
250-
new DeviceOperationError({
251-
operation: "screenshot",
252-
reason: "command_failed",
253-
cause: "simctl failed",
254-
}),
255-
),
256-
);
257-
const failed = await handler(
258-
new Request("http://t3.test/api/device-hub/vendor/serve-sim/api/screenshot?device=udid-2", {
259-
method: "POST",
260-
}),
261-
);
262-
expect(failed.status).toBe(502);
263-
expect(await failed.text()).not.toContain("simctl failed");
228+
expect(requests).toHaveLength(1);
264229
});
265230

266231
it("never forwards the vendor shell endpoint", async () => {

‎apps/server/src/device/DeviceHubProxy.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ const handler = Effect.gen(function* () {
213213
upstreamSearch.delete("wsTicket");
214214
upstreamSearch.delete("hostId");
215215
const search = upstreamSearch.size > 0 ? `?${upstreamSearch.toString()}` : "";
216-
// iOS screenshots go through the service so the Device panel gets its Xcode 26 simctl fallback.
217-
// Hosts with their own upstreams keep their routing; Simlock serves Android through serve-sim too.
218216
const screenshotDevice = upstreamSearch.get("device");
219217
if (
220218
!ready.upstream &&

0 commit comments

Comments
 (0)