feat: unify workspace sidebar and create Foundry graph pages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { createBoard, loadWorkspaceHome } from "../src/lib/workspace.ts";
|
||||
import { boardHref, createBoard, DEFAULT_BOARD_TITLE, loadWorkspaceHome } from "../src/lib/workspace.ts";
|
||||
|
||||
test("profile and workspace reads both start before either completes", async () => {
|
||||
const calls = [];
|
||||
@@ -80,3 +80,23 @@ test("an existing workspace posts a board directly", async () => {
|
||||
);
|
||||
assert.deepEqual(calls, ["workspaces/existing/materials"]);
|
||||
});
|
||||
|
||||
|
||||
test("new graphs use a default name and retain the Foundry-assigned identity", async () => {
|
||||
const created = await createBoard(async (path, options) => {
|
||||
assert.equal(path, "workspaces/space/materials");
|
||||
assert.deepEqual(JSON.parse(options.body), {
|
||||
kind: "board", title: DEFAULT_BOARD_TITLE, content: { schema_version: 1 },
|
||||
});
|
||||
return { id: "server-generated-id", workspace_id: "space", kind: "board", version: 1 };
|
||||
}, " ", "space", () => assert.fail("unexpected workspace creation"));
|
||||
assert.equal(created.id, "server-generated-id");
|
||||
assert.equal(created.workspace_id, "space");
|
||||
assert.equal(created.title, "未命名图谱");
|
||||
assert.equal(boardHref(created.workspace_id, created.id), "/dashboard/space/server-generated-id");
|
||||
});
|
||||
|
||||
test("graph URLs preserve workspace identity and safely encode route segments", () => {
|
||||
assert.equal(boardHref("space/a", "id?b"), "/dashboard/space%2Fa/id%3Fb");
|
||||
assert.equal(boardHref("demo", "board", true), "/dashboard/demo/board?demo=1");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user