From c9a87ee49c595a7fb739d4e9f754e6e59db6a1cd Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 9 Nov 2026 22:48:32 -0800 Subject: [PATCH] test: no casts in the remote-sleep tests' mock state --- .../workspace-resume-slept-elsewhere.test.ts | 6 ++---- src/main/hosted-sandbox/hosted-remote-sleep.test.ts | 13 +++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/ephemeral-vm/workspace-resume-slept-elsewhere.test.ts b/src/main/ephemeral-vm/workspace-resume-slept-elsewhere.test.ts index eda0e2ad74f..56f36520988 100644 --- a/src/main/ephemeral-vm/workspace-resume-slept-elsewhere.test.ts +++ b/src/main/ephemeral-vm/workspace-resume-slept-elsewhere.test.ts @@ -3,10 +3,8 @@ // returning the stale record, and only a resume that ran counts as a quiet wake that woke it. import { afterEach, describe, expect, it, vi } from 'vitest' -const state = vi.hoisted(() => ({ - record: {} as Record, - asleep: false -})) +type MockState = { record: Record; asleep: boolean } +const state = vi.hoisted((): MockState => ({ record: {}, asleep: false })) const mocks = vi.hoisted(() => ({ resume: vi.fn(async () => ({ ok: true, diff --git a/src/main/hosted-sandbox/hosted-remote-sleep.test.ts b/src/main/hosted-sandbox/hosted-remote-sleep.test.ts index 51c75687d0a..ee8469fd921 100644 --- a/src/main/hosted-sandbox/hosted-remote-sleep.test.ts +++ b/src/main/hosted-sandbox/hosted-remote-sleep.test.ts @@ -1,9 +1,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' -const state = vi.hoisted(() => ({ - records: [] as Record[], - updates: [] as { id: string; patch: Record }[] -})) +type MockState = { + records: Record[] + updates: { id: string; patch: Record }[] +} +const state = vi.hoisted((): MockState => ({ records: [], updates: [] })) vi.mock('../../shared/ephemeral-vm-runtime-store', () => ({ listEphemeralVmRuntimes: () => state.records, updateEphemeralVmRuntimeStatus: (_path: string, id: string, patch: Record) => { @@ -38,8 +39,8 @@ const RUNNING = { recipe: { provider: 'orca-cloud' }, recipeResult: { sandboxId: 'sbx_1' } } -// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: only the fields read here. -const record = (patch: Record = {}) => +const record = (patch: Record = {}): EphemeralVmRuntimeRecord => + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the module under test reads only id, status, updatedAt and recipe.provider. ({ ...RUNNING, ...patch }) as unknown as EphemeralVmRuntimeRecord describe('a cloud VM slept from another client', () => {