mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 03:29:23 +08:00
Adapted the migration foundation from PR #1384 while preserving current workspace, caption and turn-admission safeguards. Co-authored-by: XZH <cto@xzh.ai>
39 lines
1.6 KiB
TypeScript
39 lines
1.6 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import test from "node:test";
|
|
|
|
function source(file: string): string {
|
|
return readFileSync(path.resolve(process.cwd(), file), "utf8");
|
|
}
|
|
|
|
/**
|
|
* AssistantResponse is shared by every chat surface and reads both viewer
|
|
* context even when a mastery turn has no reading attachment.
|
|
* Missing the provider makes an existing assistant message throw during
|
|
* render, before the bare `/sessions` route can initialise its new session.
|
|
*/
|
|
test("the mastery study route provides every shared chat viewer context", () => {
|
|
const layout = source("app/(workspace)/layout.tsx");
|
|
const sessionLayout = source("app/(workspace)/learning/mastery/[pathId]/sessions/layout.tsx");
|
|
assert.doesNotMatch(sessionLayout, /ChatRuntimeProvider|ReadingProvider|WatchingProvider/);
|
|
assert.match(sessionLayout, /<QuizFollowupProvider>/);
|
|
assert.match(sessionLayout, /<GeogebraTabProvider>/);
|
|
const response = source("components/common/AssistantResponse.tsx");
|
|
|
|
assert.match(response, /useReading\(\)/);
|
|
assert.match(layout, /import \{ ReadingProvider \}/);
|
|
assert.match(layout, /<ReadingProvider>/);
|
|
assert.match(layout, /<ChatRuntimeProvider>/);
|
|
});
|
|
|
|
test("mastery study exposes the shared transcript navigation and save actions", () => {
|
|
const study = source("components/space/learning/MasteryStudy.tsx");
|
|
|
|
assert.match(study, /<TurnNavigator/);
|
|
assert.match(study, /data-chat-column="true"/);
|
|
assert.match(study, /<SaveToNotebookModal/);
|
|
assert.match(study, /aria-label=\{t\("Save to Notebook"\)\}/);
|
|
assert.match(study, /source: "mastery_path"/);
|
|
});
|