mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
51bed41381
* test(contracts): one typed conformance helper for the runtime-family suites Extracts the shared binding-rule mechanics that ten *-runtime.test.ts files repeated by copy into interactor-operation-conformance.fixtures.ts. Each module keeps its own expected table and calls the helper with it; the helper owns no expectations. * chore(gates): add cross-module completeness test for interactor operation conformance Asserts both directions against the production registry: every catalog operation has exactly one conformance table naming it, and every named operation is registered in the catalog. * docs(contracts): note the interactor conformance gate's coordinated-deletion blind spot Review on PR #2301 (P2): the two-direction completeness check in interactor-operation-conformance.test.ts can't catch a catalog row and its conformance rows being deleted together in one change — both sets shrink in lockstep and neither assertion trips. No behavior change; documents the limitation for a future maintainer who wants to close it with an independent count. * test(contracts): drive interactor-operation conformance from the catalog itself The completeness gate read raw test sources and regex-matched operation literals, so a commented-out row still counted as conformed while nothing executed it. The three binding rules now live in one test file that walks INTERACTOR_OPERATIONS and binds through each catalog row's own bind and label, with the per-operation expectations (interactor method, minimal input) in a table typed over every catalog operation. A missing, duplicated or unregistered row fails typecheck and the table-vs-catalog test; every row is executed by construction. The conformance fixture and the per-facet conformInteractorOperations blocks are gone; each facet test keeps only its dedicated tests.
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { expect, test, vi } from 'vitest';
|
|
import { bindBack, backRuntimeOperationFacts } from './back-runtime.ts';
|
|
import type { Interactor } from './interactor-types.ts';
|
|
import { localInteractorSource } from './interactor-operation-binding.ts';
|
|
|
|
const device = {
|
|
platform: 'android',
|
|
id: 'emulator-5554',
|
|
name: 'Pixel',
|
|
kind: 'emulator',
|
|
booted: true,
|
|
} as const;
|
|
|
|
test('builds the exact back operation fact catalog', () => {
|
|
const back = { available: true } as const;
|
|
expect(backRuntimeOperationFacts({ back })).toEqual({ back });
|
|
});
|
|
|
|
test('a local binding drives the interactor with the requested mode', async () => {
|
|
const back = vi.fn(async () => undefined);
|
|
const resolveInteractor = vi.fn(async () => ({ back }) as unknown as Interactor);
|
|
const signal = new AbortController().signal;
|
|
|
|
const operations = bindBack(signal, localInteractorSource({ device, resolveInteractor }));
|
|
await operations.back({
|
|
mode: 'system',
|
|
options: { appBundleId: 'com.example.app' },
|
|
execution: { logPath: '/tmp/daemon.log', requestId: 'back-1' },
|
|
});
|
|
|
|
expect(resolveInteractor).toHaveBeenCalledWith(device, {
|
|
logPath: '/tmp/daemon.log',
|
|
requestId: 'back-1',
|
|
appBundleId: 'com.example.app',
|
|
signal,
|
|
});
|
|
expect(back).toHaveBeenCalledWith('system');
|
|
});
|