mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-04 05:49:44 +08:00
Remove course pages, APIs and the course_study capability. Add anchored note threads and reviewed learning-block generation, queued and withdrawable chat messages, quote attachments, side chats, and the calendar/favorites/navigation updates. Keep preview's existing backend architecture. Wire the new features through its Python application and existing chat engine, retain legacy selected-text requests, persist mid-turn messages in replay, and restore note context when regenerating. Leave stored user data intact. Validate frontend contracts, dependency boundaries, types, 1290 node tests, 840 rendered tests, lint, localization and the production build. Exercise session/notes/API regressions, 53 chat-engine tests and 20 Python/native integration tests with isolated runtime data.
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
browserReturnPath,
|
|
inheritLoginHash,
|
|
loginHref,
|
|
normalizeInternalReturnPath,
|
|
} from "../shared/auth/return-url";
|
|
|
|
test("return URLs preserve path, query, and fragment", () => {
|
|
const destination = browserReturnPath({
|
|
pathname: "/notebooks/notes-1",
|
|
search: "?record=record-2",
|
|
hash: "#notes",
|
|
});
|
|
assert.equal(destination, "/notebooks/notes-1?record=record-2#notes");
|
|
assert.equal(
|
|
loginHref(destination),
|
|
"/login?next=%2Fnotebooks%2Fnotes-1%3Frecord%3Drecord-2%23notes",
|
|
);
|
|
});
|
|
|
|
test("return URLs reject external and ambiguous navigation", () => {
|
|
for (const unsafe of [
|
|
"https://example.com",
|
|
"//example.com/path",
|
|
"/\\example.com/path",
|
|
"/%2f%2fexample.com/path",
|
|
"/chat%0a/next",
|
|
"javascript:alert(1)",
|
|
"/chat\n/next",
|
|
]) {
|
|
assert.equal(normalizeInternalReturnPath(unsafe), "/", unsafe);
|
|
}
|
|
});
|
|
|
|
test("login inherits a server-invisible fragment without replacing an explicit one", () => {
|
|
assert.equal(inheritLoginHash("/settings", "#tools"), "/settings#tools");
|
|
assert.equal(
|
|
inheritLoginHash("/settings#appearance", "#tools"),
|
|
"/settings#appearance",
|
|
);
|
|
});
|