mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 15:39:23 +08:00
Merge pull request #1621 from MohammadHijjawi97/fix/reading-save-to-notebook-route
fix: post reading workspace "Save to notebook" to the backend route
This commit is contained in:
@@ -456,7 +456,7 @@ export async function sendReadingToNotebook(
|
||||
notebookIds: string[],
|
||||
materialIds: string[] = [],
|
||||
): Promise<Record<string, unknown>> {
|
||||
return json(`/workspaces/${workspaceId}/notebooks`, {
|
||||
return json(`/workspaces/${workspaceId}/notebook`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
notebook_ids: notebookIds,
|
||||
|
||||
23
web/tests/reading-notebook-capture.test.ts
Normal file
23
web/tests/reading-notebook-capture.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
function source(file: string): string {
|
||||
return fs.readFileSync(path.resolve(process.cwd(), file), "utf8");
|
||||
}
|
||||
|
||||
test("save to notebook posts to the backend's workspace notebook route", () => {
|
||||
const client = source("lib/reading-workspace-api.ts");
|
||||
const fn = client.slice(
|
||||
client.indexOf("export async function sendReadingToNotebook"),
|
||||
);
|
||||
const match = fn.match(/json\(`(\/workspaces\/\$\{workspaceId\}\/[^`]+)`/);
|
||||
assert.ok(match, "sendReadingToNotebook should call json() with a path");
|
||||
|
||||
const route = `/api/reading${match[1].replace("${workspaceId}", "{workspace_id}")}`;
|
||||
assert.ok(
|
||||
source("contracts/generated/api.ts").includes(`"${route}":`),
|
||||
`${route} is not a backend route`,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user