Spaces:
Running
Running
| import { describe, expect, it } from 'vitest'; | |
| import { parseReleasePromptMatrix } from './prompt-matrix'; | |
| function fixtures() { | |
| return [ | |
| { id: 'a', messages: [{ role: 'user', content: 'A' }] }, | |
| { id: 'b', messages: [{ role: 'user', content: 'B' }] }, | |
| { id: 'c', messages: [{ role: 'user', content: 'C' }] }, | |
| { id: 'd', messages: [{ role: 'user', content: 'D' }] }, | |
| { | |
| id: 'multiturn', | |
| messages: [ | |
| { role: 'system', content: 'Track facts.' }, | |
| { role: 'user', content: 'One.' }, | |
| { role: 'assistant', content: 'Noted.' }, | |
| { role: 'user', content: 'Repeat.' }, | |
| ], | |
| }, | |
| { | |
| id: 'tool_call', | |
| messages: [{ role: 'user', content: 'Use memory.' }], | |
| tools: [{ | |
| type: 'function', | |
| function: { | |
| name: 'memory', | |
| parameters: { | |
| type: 'object', | |
| properties: { key: { type: 'string' } }, | |
| required: ['key'], | |
| }, | |
| }, | |
| }], | |
| }, | |
| ]; | |
| } | |
| describe('parseReleasePromptMatrix', () => { | |
| it('accepts the locked six-case shape with multi-turn and tool coverage', () => { | |
| const result = parseReleasePromptMatrix(fixtures()); | |
| expect(result).toHaveLength(6); | |
| expect(result.at(-1)?.tools[0]?.function.name).toBe('memory'); | |
| }); | |
| it('rejects a matrix that only looks complete by count', () => { | |
| const value = fixtures().map((fixture) => ({ ...fixture, tools: undefined })); | |
| expect(() => parseReleasePromptMatrix(value)).toThrow(/tool-call case/); | |
| }); | |
| it('rejects duplicate case ids', () => { | |
| const value = fixtures(); | |
| value[1] = { ...value[1]!, id: 'a' }; | |
| expect(() => parseReleasePromptMatrix(value)).toThrow(/Duplicate release prompt id/); | |
| }); | |
| }); | |