Files
RuneStone/tests/smoke/tree/folderActions.smoke.mjs
T
Knotty Wyvern 5d5ba9e1f7 Keep preferences in one settings file and move tab transfer to the host
Keep the user preferences in settings.json in the app config folder.
WebView storage can be lost, and the host cannot read it. The file has
a schema number, a revision number, and one value for each section:
general, appearance, customThemes, customThemesLegacy, and language.
- settings_read gives all sections, the revision, and a one-time
  notice.
- settings_write replaces one section, writes the file atomically, and
  sends settings-changed to all windows. The limit is 8 MiB.
- settings_migrate writes the first file only when no file exists.
- The host moves a damaged file to settings.corrupt-<seconds>.json,
  starts from the defaults, and reports this one time.

Each window loads the sections before its first render. One store in
src/lib/settings/store.ts replaces the storage listeners. When no file
exists, the window normalizes the old localStorage values and migrates
them. The old keys stay in place for one release. The window layout
and the open tabs stay in localStorage on purpose. The browser preview
keeps all preferences in localStorage.

Keep tab transfer offers in host memory, not in localStorage, because
an offer can hold unsaved text. A window takes an offer once. The host
checks the workspace root and a 120 second expiry. When the receiver
accepts the tab, the host sends tab-transfer-accepted to the source
window only. A refused offer stays open, and the source tab stays open.
A new window and a drop on the tab ribbon use one check.

The smoke harness serves the new commands from one shared state for
each browser context. Tests read saved values from the mock settings
file. Rust, unit, and smoke tests cover the changes.
2026-10-27 23:56:00 -07:00

39 lines
2.0 KiB
JavaScript

// 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");
});