| 1 | import { describe, expect, it } from 'vitest' |
| 2 | import { buildDesignContractSystemPrompt } from '../../../src/main/agent-runtime/prompt' |
| 3 | import { resolveSlideSize } from '../../../src/shared/slide-size' |
| 4 | |
| 5 | describe('size-aware design contract prompt', () => { |
| 6 | it('uses the exact target size to adapt layoutMotif without injecting layout skills', () => { |
| 7 | const prompt = buildDesignContractSystemPrompt({ |
| 8 | styleSkill: 'A blue editorial style originally observed on a 16:9 canvas.', |
| 9 | slideSize: resolveSlideSize({ |
| 10 | id: 'vertical-9-16', |
| 11 | width: 1080, |
| 12 | height: 1920 |
| 13 | }) |
| 14 | }) |
| 15 | |
| 16 | expect(prompt).toContain('Slide size id: vertical-9-16') |
| 17 | expect(prompt).toContain('Exact dimensions: 1080x1920') |
| 18 | expect(prompt).toContain('Generate layoutMotif for this exact canvas') |
| 19 | expect(prompt).toContain( |
| 20 | 'layoutMotif must combine the style specification with the exact target canvas above' |
| 21 | ) |
| 22 | expect(prompt).not.toMatch(/\{\{[^}]+\}\}/) |
| 23 | expect(prompt).not.toContain('layout-skill') |
| 24 | expect(prompt).not.toContain('catalog') |
| 25 | expect(prompt).not.toContain('checklist') |
| 26 | }) |
| 27 | |
| 28 | it('keeps square dimensions explicit for a square design contract', () => { |
| 29 | const prompt = buildDesignContractSystemPrompt({ |
| 30 | styleSkill: 'Use restrained monochrome geometry.', |
| 31 | slideSize: resolveSlideSize({ id: 'square-1-1' }) |
| 32 | }) |
| 33 | |
| 34 | expect(prompt).toContain('Slide size id: square-1-1') |
| 35 | expect(prompt).toContain('Exact dimensions: 1200x1200') |
| 36 | }) |
| 37 | |
| 38 | it('keeps conditional font guidance and serialized font inventory in the composer', () => { |
| 39 | const prompt = buildDesignContractSystemPrompt({ |
| 40 | styleSkill: 'Use clear editorial hierarchy.', |
| 41 | availableFonts: [ |
| 42 | { family: 'Noto Sans SC', roles: ['title', 'body'] }, |
| 43 | { family: 'Inter', roles: ['body'] } |
| 44 | ], |
| 45 | requestedFontPair: { titleFont: 'Noto Sans SC', bodyFont: 'Inter' }, |
| 46 | languageHint: 'zh-CN', |
| 47 | slideSize: resolveSlideSize({ id: 'wide-16-9' }) |
| 48 | }) |
| 49 | |
| 50 | expect(prompt).toContain('titleFont and bodyFont are fixed by the user selection') |
| 51 | expect(prompt).toContain('titleFont: Noto Sans SC') |
| 52 | expect(prompt).toContain('bodyFont: Inter') |
| 53 | expect(prompt).toContain('languageHint: zh-CN') |
| 54 | expect(prompt).toContain('"family":"Noto Sans SC"') |
| 55 | expect(prompt).not.toMatch(/\{\{[^}]+\}\}/) |
| 56 | }) |
| 57 | }) |
| 58 |