Skip to content

Commit f627203

Browse files
authored
feat: gate watchOS as an explicit unsupported sentinel (closes #977) (#990)
XCUITest cannot drive watchOS UI (no XCUIApplication), so a watchOS device has no runner backend. Today `appleOs: 'watchos'` silently falls through to the iOS runner profile (resolveRunnerPlatformNameForAppleOs). Reject it explicitly at the admission seam — createAppleInteractor — with a clear UNSUPPORTED_PLATFORM error, before any runner work. Discovery never produces watchOS today (resolveAppleOs only yields ios/ipados/tvos/visionos), so this changes no real-device behavior; it makes the "declared but unsupported" watchOS case honest instead of a silent wrong fallback. Per-AppleOS capability-table integration is deferred to d.5 (#978). Adds a focused unit test asserting the watchOS rejection and that a non-watchOS appleOs does not trigger the sentinel.
1 parent 1d1cf0e commit f627203

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { test, expect } from 'vitest';
2+
import { createAppleInteractor } from '../apple.ts';
3+
import type { DeviceInfo } from '../../../kernel/device.ts';
4+
import type { RunnerContext } from '../../interactor-types.ts';
5+
import { AppError } from '../../../kernel/errors.ts';
6+
7+
// watchOS is an explicit unsupported sentinel: XCUITest cannot drive watchOS UI,
8+
// so a `appleOs: 'watchos'` device must be rejected at interactor creation (the
9+
// admission seam) rather than silently falling through to the iOS runner.
10+
const watchOsDevice: DeviceInfo = {
11+
platform: 'ios',
12+
id: 'watch-1',
13+
name: 'Apple Watch Series 10',
14+
kind: 'device',
15+
appleOs: 'watchos',
16+
};
17+
18+
test('createAppleInteractor rejects a watchOS device as UNSUPPORTED_PLATFORM', () => {
19+
// The guard throws before touching runnerContext, so an empty context is fine.
20+
const create = () => createAppleInteractor(watchOsDevice, {} as RunnerContext);
21+
expect(create).toThrow(AppError);
22+
try {
23+
create();
24+
expect.unreachable('expected createAppleInteractor to throw for watchOS');
25+
} catch (error) {
26+
expect(error).toBeInstanceOf(AppError);
27+
expect((error as AppError).code).toBe('UNSUPPORTED_PLATFORM');
28+
expect((error as AppError).message).toMatch(/watchOS/i);
29+
}
30+
});
31+
32+
test('a non-watchOS appleOs does not trigger the watchOS sentinel', () => {
33+
// A tvOS device must not throw the watchOS-specific rejection. (It may still
34+
// fail later on the empty runner context, so we only assert it is not the
35+
// watchOS sentinel error.)
36+
const tvOsDevice: DeviceInfo = {
37+
platform: 'ios',
38+
id: 'tv-1',
39+
name: 'Apple TV 4K',
40+
kind: 'simulator',
41+
target: 'tv',
42+
appleOs: 'tvos',
43+
booted: true,
44+
};
45+
try {
46+
createAppleInteractor(tvOsDevice, {} as RunnerContext);
47+
} catch (error) {
48+
expect((error as AppError).message ?? '').not.toMatch(/watchOS/i);
49+
}
50+
});

‎src/core/interactors/apple.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ export function createAppleInteractor(
2828
device: DeviceInfo,
2929
runnerContext: RunnerContext,
3030
): Interactor {
31+
// watchOS unsupported sentinel: XCUITest cannot drive watchOS UI (no
32+
// XCUIApplication), so a watchOS device has no runner backend. Reject it
33+
// explicitly here rather than letting `appleOs: 'watchos'` silently fall
34+
// through to the iOS runner profile (see resolveRunnerPlatformNameForAppleOs).
35+
if (device.appleOs === 'watchos') {
36+
throw new AppError(
37+
'UNSUPPORTED_PLATFORM',
38+
'watchOS is not supported: XCUITest cannot drive watchOS UI, so this device has no runner backend.',
39+
);
40+
}
3141
const { overrides, runnerOpts } = iosRunnerOverrides(device, runnerContext);
3242
return {
3343
open: (app, options) =>

0 commit comments

Comments
 (0)