Skip to content

Commit 452c235

Browse files
committed
test(fleet): align automatic hydration expectations
1 parent d51584d commit 452c235

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

test/unit/bootstrap/fetch-session.test.mts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ describe('bootstrap session fetch', () => {
4242
expect(planFetch(repoRoot)).toEqual({ action: 'no-fetcher' })
4343
})
4444

45-
it('plans the local bootstrap fetcher when the payload is absent', () => {
45+
it('plans the local bootstrap current-bundle check', () => {
4646
const fleet = writeFixture('scripts/repo/bootstrap/fleet.mjs', '')
4747

48-
expect(planFetch(repoRoot)).toEqual({ action: 'fetch', fleet })
48+
expect(planFetch(repoRoot)).toEqual({ action: 'ensure', fleet })
4949
})
5050

5151
it('warns without blocking when the fetcher is missing', () => {
@@ -62,7 +62,7 @@ describe('bootstrap session fetch', () => {
6262
'scripts/repo/bootstrap/fleet.mjs',
6363
[
6464
"import { mkdirSync, writeFileSync } from 'node:fs'",
65-
"if (process.argv[2] !== '--if-current') process.exit(12)",
65+
"if (process.argv[2] !== '--ensure-current') process.exit(12)",
6666
"mkdirSync('.claude/hooks/fleet', { recursive: true })",
6767
"writeFileSync('.claude/hooks/fleet/index.cjs', '')",
6868
"process.stdout.write('fixture progress')",
@@ -73,7 +73,10 @@ describe('bootstrap session fetch', () => {
7373
const stdout = vi.spyOn(process.stdout, 'write').mockReturnValue(true)
7474

7575
expect(ensurePayload(repoRoot)).toBe(0)
76-
expect(planFetch(repoRoot)).toEqual({ action: 'present' })
76+
expect(planFetch(repoRoot)).toEqual({
77+
action: 'ensure',
78+
fleet: path.join(repoRoot, 'scripts', 'repo', 'bootstrap', 'fleet.mjs'),
79+
})
7780
expect(stderr).not.toHaveBeenCalled()
7881
expect(stdout).not.toHaveBeenCalled()
7982
})

test/unit/cover/cover.test.mts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
1-
import process from 'node:process'
2-
import path from 'node:path'
31
import { afterEach, describe, expect, it, vi } from 'vitest'
4-
import { spawn } from '@socketsecurity/lib-stable/process/spawn/child'
2+
import { runQuietCommand } from '../../../scripts/fleet/cover-run.mts'
53
import { runQuiet } from '../../../scripts/fleet/cover.mts'
64

7-
vi.mock(import('@socketsecurity/lib-stable/process/spawn/child'))
5+
vi.mock(import('../../../scripts/fleet/cover-run.mts'))
86

97
describe('runQuiet', () => {
108
afterEach(() => {
11-
vi.unstubAllEnvs()
12-
vi.mocked(spawn).mockReset()
9+
vi.mocked(runQuietCommand).mockReset()
1310
})
1411

15-
it('runs pnpm through the current Node executable', async () => {
16-
vi.stubEnv('npm_execpath', '/tmp/pnpm.cjs')
17-
vi.mocked(spawn).mockResolvedValue({
12+
it('delegates command execution to the coverage runner', async () => {
13+
vi.mocked(runQuietCommand).mockResolvedValue({
1814
code: 0,
1915
stderr: '',
2016
stdout: '',
21-
} as Awaited<ReturnType<typeof spawn>>)
17+
})
2218

2319
await runQuiet(['exec', 'vitest', 'run'], { cwd: '/tmp' })
2420

25-
expect(spawn).toHaveBeenCalledWith(
26-
process.execPath,
27-
['/tmp/pnpm.cjs', 'exec', 'vitest', 'run'],
28-
expect.objectContaining({
29-
cwd: '/tmp',
30-
env: expect.objectContaining({
31-
PATH: expect.stringContaining(path.dirname(process.execPath)),
32-
}),
33-
}),
34-
)
21+
expect(runQuietCommand).toHaveBeenCalledWith(['exec', 'vitest', 'run'], {
22+
cwd: '/tmp',
23+
})
3524
})
3625
})

0 commit comments

Comments
 (0)