Skip to content

Commit 360f3e2

Browse files
committed
fix(settings): require the device id a settings refusal reports
SimctlSettingRequest.deviceId is required, so no caller can fall back to the simctl udid ('booted' on Limrun) when reporting a refusal; the local path passes device.id for both.
1 parent 2f152a4 commit 360f3e2

5 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎packages/contracts/src/settings.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ export type SimctlSettingRequest = {
167167
runSimctl: SimctlSettingRunner;
168168
/** The simulator UDID `simctl` addresses, or `booted` where the runner reaches one simulator. */
169169
udid: string;
170-
/** The device id a refusal reports; defaults to `udid`. */
171-
deviceId?: string;
170+
/** The device id a refusal reports to the caller, which `udid` is not on every runner. */
171+
deviceId: string;
172172
setting: SimctlSetting;
173173
state: string;
174174
appBundleId?: string;

‎packages/platform-apple/src/core/__tests__/simctl-settings.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ function request(
1616
runSimctl: SimctlSettingRequest['runSimctl'],
1717
overrides: Partial<SimctlSettingRequest>,
1818
): SimctlSettingRequest {
19-
return { runSimctl, udid: 'SIM-1', setting: 'appearance', state: 'dark', ...overrides };
19+
return {
20+
runSimctl,
21+
udid: 'SIM-1',
22+
deviceId: 'SIM-1',
23+
setting: 'appearance',
24+
state: 'dark',
25+
...overrides,
26+
};
2027
}
2128

2229
test('every simctl argv addresses the udid the runner was given', async () => {

‎packages/platform-apple/src/core/app-settings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export async function setIosSetting(
146146
return await applySimctlSetting({
147147
runSimctl: (args) => runSimctlForDevice(device, args),
148148
udid: device.id,
149+
deviceId: device.id,
149150
setting: normalized,
150151
state,
151152
appBundleId,

‎packages/platform-apple/src/core/simctl-settings.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async function setAppearance({ runSimctl, udid, state }: SimctlSettingRequest):
4747
}
4848

4949
async function setPermission(request: SimctlSettingRequest): Promise<void> {
50-
const { runSimctl, udid, deviceId = udid, state, options } = request;
50+
const { runSimctl, udid, deviceId, state, options } = request;
5151
const appBundleId = requireAppBundleId(request);
5252
const permissionAction = parsePermissionAction(state);
5353
const action = permissionAction === 'deny' ? 'revoke' : permissionAction;

‎src/sdk/limrun-runtime-dependencies.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ test('Limrun iOS settings evaluate the Apple simctl plan module on the first set
254254
const grantPhotos = {
255255
runSimctl,
256256
udid: 'booted',
257+
deviceId: 'limrun:ios:lease-a',
257258
setting: 'permission',
258259
state: 'grant',
259260
appBundleId: 'com.example.app',

0 commit comments

Comments
 (0)