| 1 | import { describe, expect, it } from 'vitest' |
| 2 | import { |
| 3 | buildDeckAgentSystemPrompt, |
| 4 | buildSinglePageGenerationPrompt, |
| 5 | formatAnimationPreferencesForPageWriting |
| 6 | } from '../../../src/main/agent-runtime/prompt' |
| 7 | import type { SessionDeckGenerationContext } from '../../../src/main/agent-runtime/agent' |
| 8 | import { resolveSlideSize } from '../../../src/shared/slide-size' |
| 9 | |
| 10 | const baseContext: SessionDeckGenerationContext = { |
| 11 | sessionId: 'session-1', |
| 12 | projectDir: '/tmp/project', |
| 13 | indexPath: '/tmp/project/index.html', |
| 14 | pageFileMap: { 'page-1': '/tmp/project/page-1.html' }, |
| 15 | topic: 'Quarterly report', |
| 16 | deckTitle: 'Quarterly report', |
| 17 | styleId: 'test-style', |
| 18 | styleSkillPrompt: 'Use a clean business style.', |
| 19 | userMessage: 'Create a quarterly report.', |
| 20 | outlineTitles: ['Overview'], |
| 21 | outlineItems: [{ title: 'Overview', contentOutline: 'Summarize the quarter.' }], |
| 22 | slideSize: resolveSlideSize({ id: 'wide-16-9' }), |
| 23 | appLocale: 'en' |
| 24 | } |
| 25 | |
| 26 | describe('animation preferences prompt', () => { |
| 27 | it('formats selected preferences as page-writing-only guidance', () => { |
| 28 | const prompt = formatAnimationPreferencesForPageWriting({ |
| 29 | ids: ['fade-up', 'wipe', 'pulse-soft'] |
| 30 | }) |
| 31 | |
| 32 | expect(prompt).toContain('oh-my-ppt-data-anim') |
| 33 | expect(prompt).toContain('Do not change slide outline, page count, slide titles') |
| 34 | expect(prompt).toContain('data-anim="fade-up"') |
| 35 | expect(prompt).toContain('data-anim="wipe"') |
| 36 | expect(prompt).toContain('data-anim="pulse-soft"') |
| 37 | expect(prompt).not.toContain('process') |
| 38 | }) |
| 39 | |
| 40 | it('does not emit an addendum for empty preferences', () => { |
| 41 | expect(formatAnimationPreferencesForPageWriting(null)).toBe('') |
| 42 | expect(formatAnimationPreferencesForPageWriting({ ids: [] })).toBe('') |
| 43 | }) |
| 44 | |
| 45 | it('injects animation preferences into the deck system prompt only', () => { |
| 46 | const deckPrompt = buildDeckAgentSystemPrompt('test-style', { |
| 47 | ...baseContext, |
| 48 | animationPreferences: { ids: ['fade'] } |
| 49 | }) |
| 50 | const pagePrompt = buildSinglePageGenerationPrompt({ |
| 51 | topic: 'Quarterly report', |
| 52 | deckTitle: 'Quarterly report', |
| 53 | pageId: 'page-1', |
| 54 | pageNumber: 1, |
| 55 | pageTitle: 'Overview', |
| 56 | pageOutline: 'Summarize the quarter.', |
| 57 | slideSize: baseContext.slideSize |
| 58 | }) |
| 59 | |
| 60 | expect(deckPrompt).toContain('## Animation preferences for page writing only') |
| 61 | expect(deckPrompt).toContain('data-anim="fade"') |
| 62 | expect(pagePrompt).not.toContain('Animation preferences for page writing only') |
| 63 | expect(pagePrompt).not.toContain('quiet text blocks') |
| 64 | }) |
| 65 | }) |
| 66 |