48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { describe, expect, test, vi } from 'vitest';
|
|
import {
|
|
applyClassroomOutlineMode,
|
|
buildInteractiveClassroomOutlinePrompt,
|
|
} from '@/lib/server/classroom-outline-mode';
|
|
|
|
describe('server classroom outline mode', () => {
|
|
test('keeps the package AI call unchanged for standard generation', () => {
|
|
const baseAiCall = vi.fn(
|
|
async (_systemPrompt: string, _userPrompt: string, _images?: unknown) => 'ok',
|
|
);
|
|
expect(applyClassroomOutlineMode(baseAiCall, { requirement: 'Teach recursion' })).toBe(
|
|
baseAiCall,
|
|
);
|
|
});
|
|
|
|
test('reuses the original Interactive Mode prompt for background generation', async () => {
|
|
const baseAiCall = vi.fn(
|
|
async (_systemPrompt: string, _userPrompt: string, _images?: unknown) => 'interactive result',
|
|
);
|
|
const requirements = {
|
|
requirement: '用互动实验讲解抛体运动',
|
|
interactiveMode: true,
|
|
};
|
|
const prompt = buildInteractiveClassroomOutlinePrompt(requirements, {
|
|
pdfText: '参考材料',
|
|
researchContext: '研究资料',
|
|
teacherContext: '教师采用苏格拉底式追问。',
|
|
imageGenerationEnabled: true,
|
|
});
|
|
const outlineAiCall = applyClassroomOutlineMode(baseAiCall, requirements, {
|
|
pdfText: '参考材料',
|
|
researchContext: '研究资料',
|
|
teacherContext: '教师采用苏格拉底式追问。',
|
|
imageGenerationEnabled: true,
|
|
});
|
|
|
|
await outlineAiCall('standard package system', 'standard package user');
|
|
|
|
expect(prompt.system).toContain('Interactive Mode Outline Generator');
|
|
expect(prompt.user).toContain('70% interactive scenes');
|
|
expect(prompt.user).toContain('用互动实验讲解抛体运动');
|
|
expect(prompt.user).toContain('教师采用苏格拉底式追问');
|
|
expect(baseAiCall).toHaveBeenCalledWith(prompt.system, prompt.user, undefined);
|
|
expect(baseAiCall.mock.calls[0]?.[0]).not.toBe('standard package system');
|
|
});
|
|
});
|