| 1 | import assert from "node:assert/strict"; |
| 2 | import { JSDOM } from "jsdom"; |
| 3 | import { app } from "../lib/bridge"; |
| 4 | |
| 5 | const dom = new JSDOM("", { url: "http://localhost/?mock=1" }); |
| 6 | Object.assign(globalThis, { window: dom.window, document: dom.window.document, localStorage: dom.window.localStorage }); |
| 7 | try { |
| 8 | const globalRoot = (await app.ListProjectTree()).find(node => node.kind === "global_folder")?.root; |
| 9 | assert.ok(globalRoot, "the global folder exposes its actual directory"); |
| 10 | const initial = (await app.ListTabs()).find(tab => tab.scope === "global"); |
| 11 | const opened = await app.OpenGlobalTab("fixture-global"); |
| 12 | const blank = await app.EnsureBlankSurface("global", ""); |
| 13 | for (const tab of [initial, opened, blank]) { |
| 14 | assert.equal(tab?.workspaceRoot, globalRoot, "mock global tabs match the native directory identity"); |
| 15 | assert.equal(tab?.workspacePath, globalRoot); |
| 16 | assert.equal(tab?.cwd, globalRoot); |
| 17 | } |
| 18 | console.log("mock global workspace: initial, opened and blank tabs preserve the native directory identity"); |
| 19 | } finally { dom.window.close(); } |
| 20 |