Skip to content

Commit e10ead9

Browse files
committed
test(interactors): narrow the optional members at pinned implementation call sites
The Vega, Apple-runner-provider, and core interactor tests drive interactors that really do carry home/appSwitcher/tvRemote/readClipboard/writeClipboard, but the factory hands them an Interactor, and those members are optional now. Same `!` narrowing #2715 and #2807 applied at their own pinned call sites: the assertion still runs the real method, and an owner that ever stopped carrying it would fail in the factory's own test rather than silently skipping the press.
1 parent 45367ca commit e10ead9

4 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎packages/contracts/src/tv-remote-runtime.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ test('a local binding drives the interactor with the button and duration', async
4646
test('a press whose fact admitted but whose interactor cannot serve it fails closed', async () => {
4747
const resolveInteractor = vi.fn(async () => ({}) as unknown as Interactor);
4848

49-
const operations = bindTvRemote(new AbortController().signal, localInteractorSource({ device, resolveInteractor }));
49+
const operations = bindTvRemote(
50+
new AbortController().signal,
51+
localInteractorSource({ device, resolveInteractor }),
52+
);
5053
await expect(operations.tvRemote({ button: 'up' })).rejects.toSatisfy(
5154
(error: unknown) =>
5255
error instanceof AppError &&

‎packages/platform-apple/src/__tests__/interactor-runner-provider.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ const RUNNER_TRANSPORT_METHODS: Record<
7171
},
7272
findText: { invoke: (i) => i.findText!('Ready'), runnerCommand: 'findText' },
7373
back: { invoke: (i) => i.back(), runnerCommand: 'backInApp' },
74-
home: { invoke: (i) => i.home(), runnerCommand: 'home' },
74+
home: { invoke: (i) => i.home!(), runnerCommand: 'home' },
7575
setOrientation: { invoke: (i) => i.setOrientation('portrait'), runnerCommand: 'rotate' },
76-
appSwitcher: { invoke: (i) => i.appSwitcher(), runnerCommand: 'appSwitcher' },
76+
appSwitcher: { invoke: (i) => i.appSwitcher!(), runnerCommand: 'appSwitcher' },
7777
actionButton: { invoke: (i) => i.actionButton!(), runnerCommand: 'actionButton' },
78-
tvRemote: { invoke: (i) => i.tvRemote('select'), runnerCommand: 'remotePress' },
78+
tvRemote: { invoke: (i) => i.tvRemote!('select'), runnerCommand: 'remotePress' },
7979
keyboardDismiss: { invoke: (i) => i.keyboardDismiss!(), runnerCommand: 'keyboardDismiss' },
8080
keyboardEnter: { invoke: (i) => i.keyboardEnter!(), runnerCommand: 'keyboardReturn' },
8181
// R59: same reading as `readTextAtPoint` — the macOS-helper branch is reachable only for a
@@ -92,8 +92,8 @@ const LOCAL_TOOL_METHODS: Record<string, (interactor: Interactor) => Promise<unk
9292
openDevice: (i) => i.openDevice(),
9393
close: (i) => i.close('com.example.app'),
9494
screenshot: (i) => i.screenshot('/dev/null'),
95-
readClipboard: (i) => i.readClipboard(),
96-
writeClipboard: (i) => i.writeClipboard('hi'),
95+
readClipboard: (i) => i.readClipboard!(),
96+
writeClipboard: (i) => i.writeClipboard!('hi'),
9797
setSetting: (i) => i.setSetting('wifi', 'on'),
9898
// `simctl ui ... content_size` is local Apple tooling like the write leg beside it, so a provider-owned
9999
// device has no way to answer a text-size read.

‎packages/platform-vega/src/__tests__/interactor.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ beforeEach(() => {
4242
test('tvRemote, back, and home share the Vega remote primitive', async () => {
4343
const interactor = createVegaInteractor(VEGA_VVD, {});
4444

45-
await interactor.tvRemote('left', 250);
45+
await interactor.tvRemote!('left', 250);
4646
await interactor.back('system');
47-
await interactor.home();
47+
await interactor.home!();
4848

4949
assert.deepEqual(mockPressVegaTvRemote.mock.calls, [
5050
[VEGA_VVD, 'left', 250],
@@ -129,9 +129,9 @@ test('required unproven Vega operations share typed unsupported behavior', async
129129
['screenshot', () => interactor.screenshot('/tmp/vega.png')],
130130
['snapshot', () => interactor.snapshot()],
131131
['setOrientation', () => interactor.setOrientation('portrait')],
132-
['appSwitcher', () => interactor.appSwitcher()],
133-
['readClipboard', () => interactor.readClipboard()],
134-
['writeClipboard', () => interactor.writeClipboard('text')],
132+
['appSwitcher', () => interactor.appSwitcher!()],
133+
['readClipboard', () => interactor.readClipboard!()],
134+
['writeClipboard', () => interactor.writeClipboard!('text')],
135135
['setSetting', () => interactor.setSetting('wifi', 'on')],
136136
];
137137

‎src/core/__tests__/interactors.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ test('tvOS home navigates focus via the remote Home button', async () => {
217217
});
218218
const interactor = await getInteractor(tvOsSimulator, { appBundleId: 'com.example.app' });
219219

220-
await withRunner(() => interactor.home(), tvOsSimulator);
220+
await withRunner(() => interactor.home!(), tvOsSimulator);
221221

222222
assert.deepEqual(commands, [
223223
{ command: 'remotePress', remoteButton: 'home', appBundleId: 'com.example.app' },

0 commit comments

Comments
 (0)