test(companion): add pending work snapshot integration coverage

This commit is contained in:
William Valentin
2026-02-16 21:58:03 -08:00
parent b4cef5235e
commit c2395ced75
2 changed files with 41 additions and 0 deletions
+11
View File
@@ -979,6 +979,17 @@
],
"test_status": "pnpm test:run src/companion/runtimeClient.test.ts src/companion/platformClients.test.ts src/companion/heartbeatLoop.test.ts src/companion/platformClients.integration.test.ts + pnpm typecheck passing"
},
"companion-platform-pending-work-snapshot-integration-coverage": {
"status": "completed",
"date": "2026-02-17",
"updated": "2026-02-17",
"summary": "Added platform integration coverage for `getPendingWorkSnapshot()` across active waiter and teardown lifecycle transitions.",
"files_modified": [
"src/companion/platformClients.integration.test.ts",
"docs/plans/state.json"
],
"test_status": "pnpm test:run src/companion/platformClients.integration.test.ts src/companion/platformClients.test.ts src/companion/runtimeClient.test.ts src/companion/heartbeatLoop.test.ts + pnpm typecheck passing"
},
"browser-tools-activation-clarity": {
"status": "completed",
"date": "2026-02-17",
@@ -171,6 +171,36 @@ describe('platform clients integration', () => {
expect(client.hasPendingWork).toBe(false);
});
it('platform getPendingWorkSnapshot reflects waiter lifecycle', async () => {
if (!LISTEN_ALLOWED) {
return;
}
const runtime = createRuntime();
const client = new IOSCompanionClient({ runtime, nodeId: 'ios-snapshot-e2e' });
expect(client.getPendingWorkSnapshot()).toEqual({
pendingRequestCount: 0,
pendingEventWaitCount: 0,
hasPendingWork: false,
});
const pending = client.waitForAnyEvent(['agent.stream'], { timeoutMs: 10_000 }).catch(() => undefined);
expect(client.getPendingWorkSnapshot()).toEqual({
pendingRequestCount: 0,
pendingEventWaitCount: 1,
hasPendingWork: true,
});
client.clearEventSubscriptions();
await pending;
expect(client.getPendingWorkSnapshot()).toEqual({
pendingRequestCount: 0,
pendingEventWaitCount: 0,
hasPendingWork: false,
});
});
it('platform connected reflects runtime connection lifecycle', async () => {
if (!LISTEN_ALLOWED) {
return;