| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | import { draftLandingTargetForTab } from "../app-runtime/draftLandingTarget"; |
| 4 | |
| 5 | test("a project surface hands over to its own workspace draft", () => { |
| 6 | assert.deepEqual( |
| 7 | draftLandingTargetForTab({ scope: "project", workspaceRoot: "/repo/agent" }), |
| 8 | { scope: "project", workspaceRoot: "/repo/agent" }, |
| 9 | ); |
| 10 | }); |
| 11 | |
| 12 | test("a global surface keeps its actual directory for UI preferences", () => { |
| 13 | assert.deepEqual( |
| 14 | draftLandingTargetForTab({ scope: "global", workspaceRoot: "/home/user/.reasonix/global" }), |
| 15 | { scope: "global", workspaceRoot: "/home/user/.reasonix/global" }, |
| 16 | ); |
| 17 | }); |
| 18 | |
| 19 | test("remote, rootless and missing surfaces hand over to the global draft", () => { |
| 20 | for (const tab of [ |
| 21 | undefined, |
| 22 | null, |
| 23 | { scope: "global", workspaceRoot: "" }, |
| 24 | { scope: "project", workspaceRoot: "" }, |
| 25 | { scope: "project", workspaceRoot: "/repo/agent", remote: { hostId: "host", workspace: "/w" } }, |
| 26 | ]) { |
| 27 | assert.deepEqual(draftLandingTargetForTab(tab), { scope: "global", workspaceRoot: "" }, JSON.stringify(tab)); |
| 28 | } |
| 29 | }); |
| 30 |