test: split hook transcript locator cases
This commit is contained in:
@@ -58,8 +58,7 @@ async function waitFor(predicate: () => boolean, timeout = 5000, interval = 10):
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('hooks-claude coverage — config option arms + substitution + skip warning', () => {
|
describe('hooks-claude coverage — config option arms + substitution + skip warning', () => {
|
||||||
it('uses the persistence locator for transcript_path and an empty string without one', async () => {
|
async function captureTranscriptPath(sessionRoot?: string): Promise<{ payload: { transcript_path: string }; expected: string | undefined }> {
|
||||||
async function capture(sessionRoot?: string): Promise<{ payload: { transcript_path: string }; expected: string | undefined }> {
|
|
||||||
const d = dir()
|
const d = dir()
|
||||||
const cap = join(d, 'payload')
|
const cap = join(d, 'payload')
|
||||||
const path = hooks(d, { PreToolUse: [{ hooks: [{ type: 'command', command: sh(d, 'capture.sh', `#!/usr/bin/env bash\ncat > "${cap}"\n`) }] }] })
|
const path = hooks(d, { PreToolUse: [{ hooks: [{ type: 'command', command: sh(d, 'capture.sh', `#!/usr/bin/env bash\ncat > "${cap}"\n`) }] }] })
|
||||||
@@ -75,9 +74,13 @@ describe('hooks-claude coverage — config option arms + substitution + skip war
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const located = await capture(dir())
|
it('uses the persistence locator for transcript_path', async () => {
|
||||||
|
const located = await captureTranscriptPath(dir())
|
||||||
expect(located.payload.transcript_path).toBe(located.expected)
|
expect(located.payload.transcript_path).toBe(located.expected)
|
||||||
expect((await capture()).payload.transcript_path).toBe('')
|
})
|
||||||
|
|
||||||
|
it('uses an empty transcript_path without a persistence locator', async () => {
|
||||||
|
expect((await captureTranscriptPath()).payload.transcript_path).toBe('')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('honors pluginRoot + projectDir substitution and warns on a skipped non-command hook', async () => {
|
it('honors pluginRoot + projectDir substitution and warns on a skipped non-command hook', async () => {
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ async function waitFor(predicate: () => boolean, timeout = 5000, interval = 10):
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('hooks-codex coverage — decision mapping paths', () => {
|
describe('hooks-codex coverage — decision mapping paths', () => {
|
||||||
it('uses the persistence locator for transcript_path and null without one', async () => {
|
async function captureTranscriptPath(sessionRoot?: string): Promise<{ payload: { transcript_path: string | null }; expected: string | undefined }> {
|
||||||
async function capture(sessionRoot?: string): Promise<{ payload: { transcript_path: string | null }; expected: string | undefined }> {
|
|
||||||
const d = dir()
|
const d = dir()
|
||||||
const cap = join(d, 'payload')
|
const cap = join(d, 'payload')
|
||||||
const path = hooks(d, { PreToolUse: [{ hooks: [{ type: 'command', command: sh(d, 'capture.sh', `#!/usr/bin/env bash\ncat > "${cap}"\n`) }] }] })
|
const path = hooks(d, { PreToolUse: [{ hooks: [{ type: 'command', command: sh(d, 'capture.sh', `#!/usr/bin/env bash\ncat > "${cap}"\n`) }] }] })
|
||||||
@@ -68,9 +67,13 @@ describe('hooks-codex coverage — decision mapping paths', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const located = await capture(dir())
|
it('uses the persistence locator for transcript_path', async () => {
|
||||||
|
const located = await captureTranscriptPath(dir())
|
||||||
expect(located.payload.transcript_path).toBe(located.expected)
|
expect(located.payload.transcript_path).toBe(located.expected)
|
||||||
expect((await capture()).payload.transcript_path).toBeNull()
|
})
|
||||||
|
|
||||||
|
it('uses null transcript_path without a persistence locator', async () => {
|
||||||
|
expect((await captureTranscriptPath()).payload.transcript_path).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('UserPromptSubmit block (exit 2) → rejected turn; default reason on empty stderr', async () => {
|
it('UserPromptSubmit block (exit 2) → rejected turn; default reason on empty stderr', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user