Skip to content

Commit 4da836f

Browse files
committed
fix(replay): retain platform before deep links
1 parent f521c69 commit 4da836f

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/daemon/__tests__/replay-device-selection.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { test, expect } from 'vitest';
22
import fs from 'node:fs';
33
import os from 'node:os';
44
import path from 'node:path';
5-
import { buildReplayTargetDeviceResolution } from '../replay-device-selection.ts';
5+
import { parseReplayInput } from '../../compat/replay-input.ts';
6+
import {
7+
buildReplayScriptPlatformFlags,
8+
buildReplayTargetDeviceResolution,
9+
} from '../replay-device-selection.ts';
610

711
test('replay leaves deep-link opens to normal device resolution', () => {
812
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-replay-device-selection-'));
@@ -20,6 +24,18 @@ test('replay leaves deep-link opens to normal device resolution', () => {
2024
).toBeUndefined();
2125
});
2226

27+
test('native replay applies its authored platform before a first deep link', () => {
28+
expect(
29+
buildReplayScriptPlatformFlags(
30+
undefined,
31+
parseReplayInput(
32+
'runtime set --platform ios --metro-port 8081\nopen demo://checkout\nopen com.example.demo\n',
33+
undefined,
34+
).actions,
35+
),
36+
).toEqual({ platform: 'ios' });
37+
});
38+
2339
test('native replay uses its authored Android runtime setting without an iOS app probe', () => {
2440
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-replay-device-selection-'));
2541
const replayPath = path.join(root, 'android.ad');

src/daemon/replay-device-selection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ function readScriptReplaySelection(actions: SessionAction[]): {
8989
return { appTarget: undefined, platform };
9090
}
9191

92-
/** Applies a platform configured before the first static app open to replay dispatch. */
92+
/** Applies a platform configured before the first open to replay dispatch. */
9393
export function buildReplayScriptPlatformFlags(
9494
flags: CommandFlags | undefined,
9595
actions: SessionAction[],
9696
): CommandFlags {
9797
const selection = readScriptReplaySelection(actions);
98-
if (flags?.platform !== undefined || !selection.appTarget || !selection.platform) {
98+
if (flags?.platform !== undefined || !selection.platform) {
9999
return flags ?? {};
100100
}
101101
return { ...flags, platform: selection.platform };

0 commit comments

Comments
 (0)