Fix paste ownership, input bounds, and IPC validation
Supersedes #5745, #5746, and #5747.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { buildCommitMessagePrompt, splitGeneratedCommitMessage } from './commit-message-generation'
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('buildCommitMessagePrompt', () => {
|
||||
it('builds a prompt from staged context instead of asking the agent to inspect git', () => {
|
||||
const prompt = buildCommitMessagePrompt(
|
||||
@@ -61,4 +65,19 @@ describe('splitGeneratedCommitMessage', () => {
|
||||
message: 'Fix source control generation\n\n- Move planning into main'
|
||||
})
|
||||
})
|
||||
|
||||
it('extracts subject and body from newline-heavy output without line-array splitting', () => {
|
||||
const splitSpy = vi.spyOn(String.prototype, 'split')
|
||||
const body = '- Explain one generated change\n'.repeat(10_000).trimEnd()
|
||||
|
||||
const result = splitGeneratedCommitMessage(`Add generated paste protection\n\n${body}`)
|
||||
|
||||
expect(result.subject).toBe('Add generated paste protection')
|
||||
expect(result.body.startsWith('- Explain one generated change\n')).toBe(true)
|
||||
expect(result.body.endsWith('- Explain one generated change')).toBe(true)
|
||||
const usedLineSplit = splitSpy.mock.calls.some(
|
||||
([separator]) => typeof separator === 'string' && separator === '\n'
|
||||
)
|
||||
expect(usedLineSplit).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user