// Folder actions in the tree: Open in terminal, and the Show .runestone folder setting from the settings window. import assert from "node:assert/strict"; import { mockTauri, openPage, runSmoke, smokeUrl } from "../_harness/index.mjs"; await runSmoke("tree/folderActions", async ({ browser }) => { // The settings window shares the mock settings file with the main window, so both pages need one context. const context = await browser.newContext({ viewport: { width: 1440, height: 1000 } }); await mockTauri(context, { commands: test => { const workspace = test.workspace({ root: "C:\\folder-actions", files: { "a.md": "# Alpha\n", "folder/keep.md": "# Keep\n", ".runestone/config.json": "{}" } }); return { ...workspace, workspace_list: args => workspace.workspace_list(args).filter(entry => args.rel || args.showInternal || entry.rel_path !== ".runestone"), workspace_open_terminal: () => null, settings_open_window: () => null, plugins_snapshot: () => ({ plugins: [], issues: [] }), spelling_menu_install: () => null, }; }, }); const page = await openPage(context, { timeout: 15000 }); const row = path => page.locator(`[data-tree-rel="${path}"]`); await page.goto(smokeUrl); await row("folder").click({ button: "right" }); await page.getByRole("menuitem", { name: "Open in terminal", exact: true }).click(); assert.ok(await page.evaluate(() => window.__TEST__.calls.some(call => call.command === "workspace_open_terminal" && call.args.rel === "folder"))); console.log("PASS: Open in terminal"); await page.keyboard.press("Control+,"); const settings = await openPage(context, { timeout: 15000 }); await settings.goto(smokeUrl + "/?settingsWindow=true"); await settings.getByRole("switch", { name: "Show .runestone folder" }).check(); await settings.close(); await row(".runestone").waitFor(); const errors = [...page.errors, ...settings.errors]; assert.deepEqual(errors, []); console.log("PASS: Show .runestone folder reveals the internal folder"); });