fix: keep teacher runtime prompts within interface boundary

This commit is contained in:
鲨鱼辣椒 committed 2026-09-28 14:38:58 +08:00
1 parent 998796d77c
commit 54a40d2636
12 files changed
+313 -32

No files matched your search

+34
View File
@@ -112,6 +112,40 @@ async function fixture(value: TeacherTopic) {
}
describe('passive teacher reply history compatibility', () => {
it('retains all four historical shortcuts through read, list and a later save', async () => {
const original = topic(archivedCases[4]);
const historicalReplies = [
'看懂规则|摸头会改变什么?',
'想想作用|我们聊聊摸头的作用。',
'试试结果|怎样知道变化发生了?',
'换个话题|我想先聊别的地方。',
];
original.requests[0].suggestedQuestions = historicalReplies;
const f = await fixture(original);
const loaded = await f.store.read(original.id);
expect(loaded).toEqual(original);
expect(loaded.requests[0].suggestedQuestions).toEqual(historicalReplies);
expect((await f.store.list()).items).toEqual([{
id: original.id, title: original.requests[0].text, updatedAt: original.updatedAt,
version: 31, teacherId: 'selected-agent',
}]);
expect(await new TeacherTopicStore(f.root).read(original.id)).toEqual(original);
await f.unchanged();
loaded.revision++;
loaded.requests.push(request({ id: 'new-turn', presentation: 'reply-v1', suggestedQuestions: [],
discussionError: undefined, unparsedResponse: undefined }));
await f.store.save(loaded);
const expected = JSON.parse(JSON.stringify({ ...original,
revision: original.revision + 1, requests: [...original.requests, loaded.requests[1]],
}));
const saved = JSON.parse(await readFile(f.file, 'utf8'));
expect(saved).toEqual(expected);
expect(saved.requests[0].suggestedQuestions).toEqual(historicalReplies);
expect(await new TeacherTopicStore(f.root).read(original.id)).toEqual(expected);
});
it.each(archivedCases)('keeps $name opaque through read, list and a later save', async archive => {
const original = topic(archive);
const f = await fixture(original);