Skip to content

Commit c0c2b6c

Browse files
committed
test(mothership): keep the draft-run case inside the repo's audits
Uses sleep from @sim/utils/helpers, guards the last wait slice instead of a non-null assertion, gives the probe's startup its own ten-second deadline like the neighbouring controller case, and tells knip the probe path lives in the worker checkout.
1 parent 2e2f613 commit c0c2b6c

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎apps/sim/lib/mothership/agent-cli/saved-run-read.live.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import {
6363
} from '@sim/db/schema'
6464
import type { PermissionType } from '@sim/platform-authz/workspace'
6565
import { authMockFns, envFlagsMock, setEnvFlags } from '@sim/testing'
66+
import { sleep } from '@sim/utils/helpers'
6667
import { generateId } from '@sim/utils/id'
6768
import { eq, is, SQL, sql } from 'drizzle-orm'
6869
import { getTableConfig } from 'drizzle-orm/pg-core'
@@ -3705,13 +3706,15 @@ describe.skipIf(!process.env.MSHIP_TEST_DATABASE_URL)(
37053706
})
37063707
})
37073708
const workerRequests: Array<{ path: string; at: number }> = []
3709+
const startupTimeout = setTimeout(() => child.kill(), 10_000)
37083710
try {
37093711
fixture.workerUrl = await Promise.race([
37103712
ready,
37113713
exited.then(() => {
37123714
throw new Error(`Worker probe exited before readiness: ${diagnostics}`)
37133715
}),
37143716
])
3717+
clearTimeout(startupTimeout)
37153718
vi.stubEnv('COPILOT_API_KEY', 'local-controller-probe-key')
37163719
vi.unstubAllGlobals()
37173720
const nativeFetch = globalThis.fetch
@@ -3832,7 +3835,7 @@ describe.skipIf(!process.env.MSHIP_TEST_DATABASE_URL)(
38323835
expect(seen).toContain('"exitCode":4')
38333836
expect(seen).toMatch(/"status": ?"running"/)
38343837
expect(seen).toContain('sim workflows runs wait')
3835-
await new Promise((resolve) => setTimeout(resolve, 35_000))
3838+
await sleep(35_000)
38363839
return
38373840
}
38383841
// Sim #9469: a still-running (exit 4) slice settles as done, not failed.
@@ -3885,7 +3888,9 @@ describe.skipIf(!process.env.MSHIP_TEST_DATABASE_URL)(
38853888
])
38863889
expect(outcome(call).exitCode).toBe(index === waits.length - 1 ? 0 : 4)
38873890
}
3888-
expect(JSON.parse(outcome(waits.at(-1)!).stdout)).toMatchObject({
3891+
const settledWait = waits.at(-1)
3892+
if (!settledWait) throw new Error('The run never settled through a wait slice')
3893+
expect(JSON.parse(outcome(settledWait).stdout)).toMatchObject({
38893894
runId,
38903895
status: 'completed',
38913896
})
@@ -3913,6 +3918,7 @@ describe.skipIf(!process.env.MSHIP_TEST_DATABASE_URL)(
39133918
}
39143919
expect(endedAt - startedAt).toBeGreaterThan(waitSeconds * 1000)
39153920
} finally {
3921+
clearTimeout(startupTimeout)
39163922
fixture.executionTimeoutMs = 20_000
39173923
child.kill()
39183924
await exited

‎knip.jsonc‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@
9393
// Knip's email CLI plugin infers this transitive preview implementation.
9494
"@react-email/ui"
9595
],
96-
// Live test spawns this path with cwd=MSHIP_WORKER_ROOT (a sibling repo).
97-
"ignoreUnresolved": ["tools/probes/src/controller-run-read.ts"]
96+
// Live tests spawn these paths with cwd=MSHIP_WORKER_ROOT (a sibling repo).
97+
"ignoreUnresolved": [
98+
"tools/probes/src/controller-run-read.ts",
99+
"tools/probes/src/draft-run-slices.ts"
100+
]
98101
},
99102
"apps/realtime": {
100103
"includeEntryExports": false,

0 commit comments

Comments
 (0)