RuneStone 1.0.0
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
// Full-app plug-ins: compact header, navigation, dynamic and restored tabs, dialogs, settings forms across windows, and disable cleanup.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("plugins/access", async ({ browser }) => {
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
||||
await mockTauri(context, {
|
||||
commands: test => {
|
||||
const manifest = (id, name) => ({ schemaVersion: 1, id, name, author: "Test", description: "Access test", version: "1.0.0", apiVersion: 1, entry: "main.js", access: "full-app" });
|
||||
const plugins = [manifest("runestone.local-autocomplete", "Local Autocomplete"), manifest("org.example.browser", "Browser"), manifest("org.example.tasks", "Tasks")];
|
||||
const modules = {
|
||||
"runestone.local-autocomplete": `export function activate(api) {
|
||||
window.accessTest = { mounts: 0, disposed: 0, settings: 0 };
|
||||
api.settings.subscribe?.(() => { window.accessTest.settings++; });
|
||||
api.registerView({ id: 'settings', title: 'Local Autocomplete', placement: 'editor', mount(container, context) {
|
||||
window.accessTest.mounts++;
|
||||
container.innerHTML = '<h2>Local Autocomplete</h2><label>Model<input aria-label="Model"></label><button>Save model</button><p class="mount-context"></p>';
|
||||
container.querySelector('p').textContent = context?.surface;
|
||||
container.querySelector('button').onclick = () => api.settings.write({ model: container.querySelector('input').value });
|
||||
return () => { window.accessTest.disposed++; };
|
||||
}});
|
||||
api.registerCommand({ id: 'configure', title: 'Configure Local Autocomplete', run: () => api.openView('settings') });
|
||||
api.registerCommand({ id: 'fail', title: 'Failed command', run: () => { throw Error('Command failed for test'); } });
|
||||
}`,
|
||||
"org.example.browser": `export function activate(api) {
|
||||
api.registerCommand({ id: 'new-tab', title: 'New browser tab', category: 'open', run() {
|
||||
const id = 'tab-' + Date.now(); api.registerView({ id, title: 'Browser instance', placement: 'editor', mount(container) { container.textContent = 'Browser content'; } }); api.openView(id);
|
||||
}});
|
||||
}`,
|
||||
"org.example.tasks": `export function activate(api) {
|
||||
api.registerView({ id: 'tasks', title: 'All tasks', icon: 'list', navigation: true, placement: 'editor', launch() { api.openView('default-board'); }, mount(container) { container.textContent = 'Task content'; } });
|
||||
api.registerView({ id: 'default-board', title: 'Default board', launcher: false, placement: 'editor', mount(container) { container.textContent = 'Default board content'; } });
|
||||
window.taskTestApi = api;
|
||||
api.registerView({ id: 'dialog', title: 'Task summary', mount(container) { container.textContent = 'Task summary content'; } });
|
||||
}`,
|
||||
};
|
||||
// Settings and the enabled state live in localStorage, so both windows of the context share them.
|
||||
window.addEventListener("storage", event => {
|
||||
if (event.key?.startsWith("settings:")) test.emit("plugin-settings-changed", event.key.slice(9));
|
||||
if (event.key === "disabled") test.emit("plugins-changed", {});
|
||||
});
|
||||
return {
|
||||
browser_connect: () => "test-session",
|
||||
workspace_last_path: () => null,
|
||||
plugins_snapshot: () => ({ root: "C:/test/plugins", plugins: plugins.map(manifest => ({ manifest, hash: "test", enabled: !(manifest.id === "runestone.local-autocomplete" && localStorage.getItem("disabled")), installedAt: 1, path: "C:/test/plugins/" + manifest.id, error: null, removal: false })) }),
|
||||
plugins_load: ({ id }) => modules[id],
|
||||
plugins_data: ({ id, value }) => {
|
||||
if (value !== null) { localStorage.setItem("settings:" + id, value); test.emit("plugin-settings-changed", id); }
|
||||
return localStorage.getItem("settings:" + id) || "null";
|
||||
},
|
||||
plugins_set_enabled: ({ enabled }) => { if (!enabled) localStorage.setItem("disabled", "true"); test.emit("plugins-changed", {}); },
|
||||
plugins_release: () => null,
|
||||
"plugin:window|is_maximized": () => false,
|
||||
};
|
||||
},
|
||||
});
|
||||
const output = await outputDir("plugins/access");
|
||||
const main = await openPage(context), settings = await openPage(context);
|
||||
const external = page => page.evaluate(() => performance.getEntriesByType("resource").find(entry => new URL(entry.name).pathname === "/src/lib/plugins/external.ts").name);
|
||||
try {
|
||||
await main.goto(smokeUrl);
|
||||
await main.getByRole("navigation", { name: "Plugin shortcuts" }).getByRole("button", { name: "All tasks", exact: true }).waitFor();
|
||||
assert.equal(await main.getByRole("button", { name: "Open tab or view", exact: true }).count(), 0);
|
||||
assert.equal(await main.getByRole("button", { name: "Commands", exact: true }).count(), 1);
|
||||
await main.getByRole("navigation", { name: "Plugin shortcuts" }).getByRole("button", { name: "All tasks", exact: true }).click();
|
||||
await main.getByText("Default board content", { exact: true }).waitFor();
|
||||
await main.evaluate(() => window.taskTestApi.openView("tasks"));
|
||||
await main.getByText("Task content", { exact: true }).waitFor();
|
||||
const module = await external(main);
|
||||
await main.evaluate(async module => {
|
||||
const { closePluginEditor, pluginTabState, pluginView, restorePluginTab } = await import(module);
|
||||
let view;
|
||||
const off = pluginView.subscribe(value => { view = value; }); off();
|
||||
const transfer = pluginTabState(view);
|
||||
closePluginEditor(view.key);
|
||||
if (!await restorePluginTab(transfer)) throw Error("Tab restore failed");
|
||||
}, module);
|
||||
await main.getByText("Task content", { exact: true }).waitFor();
|
||||
await main.evaluate(async module => { await (await import(module)).runPluginCommand("org.example.browser", "new-tab"); }, module);
|
||||
await main.getByText("Browser content", { exact: true }).waitFor();
|
||||
await main.evaluate(async module => { (await import(module)).openPluginView("org.example.tasks", "dialog"); }, module);
|
||||
await main.getByRole("dialog", { name: "Task summary" }).waitFor();
|
||||
await main.keyboard.press("Escape");
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await main.evaluate(theme => document.documentElement.dataset.theme = theme, theme);
|
||||
await main.screenshot({ path: path.join(output, `plugin-access-${theme}.png`) });
|
||||
}
|
||||
await settings.goto(smokeUrl + "/?settingsWindow=true");
|
||||
await settings.getByRole("button", { name: "Local Autocomplete", exact: true }).click();
|
||||
await settings.getByRole("textbox", { name: "Model", exact: true }).fill("unsaved-model");
|
||||
assert.equal(await settings.locator(".mount-context").innerText(), "settings");
|
||||
await settings.waitForTimeout(5500);
|
||||
assert.equal(await settings.getByRole("textbox", { name: "Model", exact: true }).inputValue(), "unsaved-model");
|
||||
assert.equal(await settings.evaluate(() => window.accessTest.mounts), 1);
|
||||
await settings.getByRole("button", { name: "Save model", exact: true }).click();
|
||||
await main.waitForFunction(() => window.accessTest.settings === 1);
|
||||
await settings.screenshot({ path: path.join(output, "plugin-access-settings.png") });
|
||||
await settings.getByRole("button", { name: "General", exact: true }).click();
|
||||
await settings.waitForFunction(() => window.accessTest.disposed === 1);
|
||||
await settings.getByRole("textbox", { name: "Search settings" }).fill("Local");
|
||||
await settings.getByRole("textbox", { name: "Model", exact: true }).waitFor();
|
||||
await settings.getByRole("textbox", { name: "Search settings" }).fill("");
|
||||
await settings.getByRole("button", { name: "Plug-ins", exact: true }).click();
|
||||
await settings.getByRole("switch", { name: "Local Autocomplete", exact: true }).uncheck();
|
||||
await settings.getByRole("button", { name: "Local Autocomplete", exact: true }).waitFor({ state: "detached" });
|
||||
await main.getByRole("button", { name: "Commands", exact: true }).waitFor({ state: "detached" });
|
||||
assert.deepEqual([...main.errors, ...settings.errors], []);
|
||||
} catch (error) {
|
||||
await settings.screenshot({ path: path.join(output, "plugin-access-failure.png") });
|
||||
console.log(await settings.locator("body").innerText(), await settings.evaluate(() => window.accessTest), [...main.errors, ...settings.errors]);
|
||||
throw error;
|
||||
}
|
||||
console.log("Plugin access smoke passed: compact header, navigation, dynamic tabs, dialog, settings search, stable forms, cross-window settings, disable cleanup.");
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
// Local Autocomplete settings choices use the shared action menu in a modal: keyboard choice, saving, focus return, and cleanup.
|
||||
// @requires repo:RuneStone_Local_Autocomplete/src
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { outputDir, pluginRepo, runSmoke, smokeUrl } from '../_harness/index.mjs';
|
||||
|
||||
const autocompleteSource = path.join(pluginRepo('RuneStone_Local_Autocomplete'), 'src');
|
||||
|
||||
await runSmoke('plugins/choiceMenus', async ({ page }) => {
|
||||
const output = await outputDir('plugins/choiceMenus');
|
||||
await page.route('**/__choice-audit__', route => route.fulfill({ contentType: 'text/html', body: '<link rel="stylesheet" href="/src/lib/theme/tokens.css"><link rel="stylesheet" href="/src/lib/ui/menu.css"><style>dialog{inset:0;margin:0;max-width:none;max-height:none;width:100%;height:100%;box-sizing:border-box;background:var(--rs-bg);color:var(--rs-text);padding:0;border:0}</style><dialog><main></main></dialog>' }));
|
||||
await page.route('**/__autocomplete__/*.mjs', async route => {
|
||||
const name = new URL(route.request().url()).pathname.split('/').pop();
|
||||
assert.ok(['main.mjs', 'engine.mjs'].includes(name));
|
||||
await route.fulfill({ contentType: 'application/javascript', body: await readFile(path.join(autocompleteSource, name), 'utf8') });
|
||||
});
|
||||
for (const theme of ['light', 'dark']) for (const width of [1100, 390]) {
|
||||
await page.setViewportSize({ width, height: 850 });
|
||||
await page.goto(smokeUrl + '/__choice-audit__');
|
||||
await page.evaluate(async theme => {
|
||||
document.documentElement.dataset.theme = theme;
|
||||
const { showActionMenu } = await import('/src/lib/ui/managedActionMenu.ts');
|
||||
const { activate } = await import('/__autocomplete__/main.mjs');
|
||||
let view;
|
||||
window.choiceAudit = { saved: null };
|
||||
await activate({ ui: { showActionMenu }, completion: { version: 1, transport() {}, invalidate() {}, registerProvider() { return () => {}; }, registerInput() { return { dispose() {}, request() {} }; } },
|
||||
settings: { read: async () => ({}), write: async value => { window.choiceAudit.saved = value; } },
|
||||
onDispose() {}, registerCommand() {}, registerView(value) { view = value; } });
|
||||
document.querySelector('dialog').showModal();
|
||||
window.choiceAudit.dispose = view.mount(document.querySelector('main'), { surface: 'settings' });
|
||||
}, theme);
|
||||
const trigger = page.getByRole('button', { name: 'Server type', exact: true });
|
||||
await trigger.click();
|
||||
const menu = page.getByRole('menu', { name: 'Server type', exact: true });
|
||||
assert.equal(await menu.evaluate(node => !!node.closest('dialog[open]')), true);
|
||||
await page.keyboard.press('End');
|
||||
assert.equal(await page.getByRole('menuitemradio', { name: 'Ollama', exact: true }).evaluate(node => node === document.activeElement), true);
|
||||
await page.screenshot({ path: path.join(output, `autocomplete-${theme}-${width}.png`) });
|
||||
await page.keyboard.press('Enter');
|
||||
assert.match(await trigger.innerText(), /Ollama/);
|
||||
await page.getByRole('button', { name: 'Save settings', exact: true }).click();
|
||||
await page.waitForFunction(() => window.choiceAudit.saved?.adapter === 'ollama');
|
||||
await trigger.click(); await page.keyboard.press('Escape');
|
||||
assert.equal(await trigger.evaluate(node => node === document.activeElement), true);
|
||||
await trigger.click(); await page.evaluate(() => window.choiceAudit.dispose());
|
||||
assert.equal(await page.locator('.rs-menu').count(), 0);
|
||||
}
|
||||
console.log('PASS: Local Autocomplete shared choices, modal input, saved adapter, focus return, and cleanup in both themes at 1100/390px.');
|
||||
}, { timeout: 30000 });
|
||||
@@ -0,0 +1,189 @@
|
||||
// Plug-in installation: ZIP and Git-link review, download errors, token clearing, updates, disabled installs, cleanup, and uninstall.
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { mockTauri, openPage, outputDir, repoRoot, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const fixture = path.join(repoRoot, "fixtures", "plugins", "workspace-overview");
|
||||
const manifest = JSON.parse(readFileSync(path.join(fixture, "plugin.json"), "utf8"));
|
||||
const pluginCode = readFileSync(path.join(fixture, "main.js"), "utf8") + "\n// Browser cleanup probe\n";
|
||||
|
||||
await runSmoke("plugins/install", async ({ browser }) => {
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 1000 }, locale: "en-US", timezoneId: "America/Vancouver" });
|
||||
const page = await openPage(context);
|
||||
const settingsPage = await openPage(context);
|
||||
page.on("console", message => { if (message.type() === "error" || message.type() === "warning") console.log(message.type(), message.text()); });
|
||||
// The settings window forwards plug-in commands to the main window, which owns the installed state.
|
||||
await context.exposeBinding("settingsHostInvoke", (_source, command, args) =>
|
||||
page.evaluate(({ command, args }) => window.__TAURI_INTERNALS__.invoke(command, args), { command, args }));
|
||||
await mockTauri(context, {
|
||||
state: { manifest, pluginCode },
|
||||
commands: test => {
|
||||
const { manifest, pluginCode } = test.state;
|
||||
const isMaximized = () => false;
|
||||
if (location.search.includes("settingsWindow")) {
|
||||
return new Proxy({}, { get: (_table, command) => command === "plugin:window|is_maximized" ? isMaximized : args => window.settingsHostInvoke(command, args) });
|
||||
}
|
||||
let installed = [];
|
||||
let removalPrepared = false;
|
||||
const data = { preserved: true };
|
||||
const pluginPath = "C:\\AppData\\RuneStone\\plugins\\" + manifest.id;
|
||||
const changed = () => test.emit("plugins-changed", null);
|
||||
Object.assign(test, { data, cleaned: false, released: false });
|
||||
const ws = test.workspace({
|
||||
root: "C:\\smoke-workspace",
|
||||
files: {
|
||||
"notes/welcome.md": "---\ntitle: Welcome\n---\n\n# Working notes\n\nFirst paragraph.\n\n- [ ] A task\n\n[[second]]\n",
|
||||
"notes/second.md": "# Second note\n",
|
||||
"src/hello.py": "print('hello')\n",
|
||||
},
|
||||
writeEvents: true,
|
||||
});
|
||||
return {
|
||||
...ws,
|
||||
"plugin:window|is_maximized": isMaximized,
|
||||
settings_open_window: () => null,
|
||||
plugins_snapshot: () => ({ root: "C:\\AppData\\RuneStone\\plugins", plugins: installed }),
|
||||
plugins_choose: () => [{ token: "candidate", source: "C:/Downloads/overview.zip", manifest, error: null }],
|
||||
plugins_from_git: ({ url, tag }) => {
|
||||
if (tag === "missing") throw new Error("Release not found. Publish a release with one plugin ZIP.");
|
||||
return [{ token: "git-candidate", source: url + " @ " + (tag || "v1.0.0"), manifest, error: null }];
|
||||
},
|
||||
plugins_cancel: () => { removalPrepared = false; },
|
||||
plugins_install: ({ enabled }) => {
|
||||
const previous = installed[0];
|
||||
installed = [{ manifest, hash: "reviewed-hash", enabled: previous ? previous.enabled : enabled, installedAt: Date.parse("2026-10-05T18:24:36Z"), path: pluginPath, error: null, removal: false }];
|
||||
changed();
|
||||
return [{ name: manifest.name, error: null }];
|
||||
},
|
||||
plugins_load: () => {
|
||||
test.cleaned = false; test.released = false;
|
||||
return pluginCode.replace("export function activate(api) {", "export function activate(api) { api.onDispose(() => { window.__TEST__.cleaned = true; });");
|
||||
},
|
||||
plugins_release: () => { test.released = true; },
|
||||
plugins_prepare_remove: () => { removalPrepared = true; return { token: "remove-plan", plugin: installed[0] }; },
|
||||
plugins_remove: async () => {
|
||||
if (!removalPrepared) throw Error("Missing removal plan");
|
||||
removalPrepared = false;
|
||||
installed[0].enabled = false; changed();
|
||||
for (let i = 0; i < 100 && !test.released; i++) await new Promise(resolve => setTimeout(resolve, 50));
|
||||
if (!test.cleaned || !test.released) throw Error("Cleanup was not acknowledged");
|
||||
installed = []; changed();
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
const output = await outputDir("plugins/install");
|
||||
const shot = name => settingsPage.screenshot({ path: path.join(output, name) });
|
||||
const settingsDialog = settingsPage.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const count = command => page.evaluate(command => window.__TEST__.calls.filter(call => call.command === command).length, command);
|
||||
async function settings() {
|
||||
await page.getByRole("button", { name: "Settings (Ctrl+,)", exact: true }).click();
|
||||
await settingsPage.goto(smokeUrl + "/?settingsWindow=true");
|
||||
await settingsDialog.getByRole("button", { name: "Plug-ins", exact: true }).click();
|
||||
}
|
||||
async function uninstall() { await settingsDialog.locator(".card").filter({ hasText: "Workspace overview" }).getByRole("button", { name: "Uninstall", exact: true }).click(); }
|
||||
|
||||
try {
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText("smoke-workspace", { exact: true }).waitFor();
|
||||
await settings();
|
||||
assert.equal(await settingsDialog.getByRole("button", { name: "Install from folder", exact: true }).count(), 0);
|
||||
assert.equal(await settingsDialog.getByRole("button", { name: "Install from file", exact: true }).count(), 0);
|
||||
await settingsDialog.getByRole("button", { name: "Install plugin ZIP", exact: true }).click();
|
||||
const review = settingsPage.getByRole("dialog", { name: "Review plugin installation", exact: true });
|
||||
await review.getByText("Source: C:/Downloads/overview.zip", { exact: true }).waitFor();
|
||||
await review.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
assert.equal(await count("plugins_install"), 0);
|
||||
const gitButton = settingsDialog.getByRole("button", { name: "Install from Git link", exact: true });
|
||||
await gitButton.click();
|
||||
const gitDialog = settingsPage.getByRole("dialog", { name: "Install from Git link", exact: true });
|
||||
await gitDialog.getByLabel("Repository link", { exact: true }).fill("https://git.example/owner/plugin.git");
|
||||
await gitDialog.getByLabel("Release tag (optional)", { exact: true }).fill("missing");
|
||||
await gitDialog.getByLabel("Access token (optional)", { exact: true }).fill("test-token");
|
||||
await gitDialog.getByRole("button", { name: "Review release", exact: true }).click();
|
||||
await gitDialog.getByRole("alert").getByText(/Release not found/).waitFor();
|
||||
assert.equal(await gitDialog.getByLabel("Access token (optional)", { exact: true }).inputValue(), "");
|
||||
await gitDialog.getByLabel("Release tag (optional)", { exact: true }).fill("v1.0.0");
|
||||
await gitDialog.getByRole("button", { name: "Review release", exact: true }).click();
|
||||
await review.getByText("Source: https://git.example/owner/plugin.git @ v1.0.0", { exact: true }).waitFor();
|
||||
await review.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
assert.equal(await count("plugins_install"), 0);
|
||||
assert(await gitButton.evaluate(element => element === document.activeElement));
|
||||
await settingsDialog.getByRole("button", { name: "Install plugin ZIP", exact: true }).click();
|
||||
await review.getByRole("button", { name: "Install and enable", exact: true }).click();
|
||||
await settingsDialog.getByRole("switch", { name: "Workspace overview", exact: true }).waitFor();
|
||||
assert(await settingsDialog.getByRole("switch", { name: "Workspace overview", exact: true }).isChecked());
|
||||
assert.equal(await settingsDialog.locator("time").getAttribute("datetime"), "2026-10-05T18:24:36.000Z");
|
||||
assert.match(await settingsDialog.locator("time").innerText(), /Oct 5, 2026.*11:24:36 AM PDT/);
|
||||
await shot("plugin-manager-installed.png");
|
||||
await settingsPage.keyboard.press("Escape");
|
||||
await page.getByRole("button", { name: "Commands", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: /Show workspace overview/ }).click();
|
||||
const view = page.getByRole("dialog", { name: "Workspace overview", exact: true });
|
||||
await view.getByText(/files and folders in this workspace/).waitFor();
|
||||
await view.getByRole("button", { name: "Close plugin view", exact: true }).click();
|
||||
await settings();
|
||||
await settingsDialog.getByRole("button", { name: "Install plugin ZIP", exact: true }).click();
|
||||
await review.getByText(/Update .* → .*Settings and enabled state stay the same/).waitFor();
|
||||
assert.equal(await review.getByRole("button", { name: "Install and enable", exact: true }).count(), 0);
|
||||
for (const mode of ["dark", "light"]) {
|
||||
await settingsPage.evaluate(async mode => {
|
||||
const { saveAppearance } = await import("/src/lib/theme/appearance.ts");
|
||||
saveAppearance({ theme: "default", mode });
|
||||
}, mode);
|
||||
for (const width of [1440, 590]) {
|
||||
await settingsPage.setViewportSize({ width, height: width === 590 ? 820 : 1000 });
|
||||
await shot(`plugin-update-review-${mode}-${width}.png`);
|
||||
assert.equal(await review.evaluate(element => element.scrollWidth > element.clientWidth), false);
|
||||
}
|
||||
}
|
||||
await review.getByRole("button", { name: "Apply packages", exact: true }).click();
|
||||
assert(await settingsDialog.getByRole("switch", { name: "Workspace overview", exact: true }).isChecked());
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.data.preserved), true);
|
||||
assert.equal(await count("plugins_remove"), 0);
|
||||
await settingsPage.setViewportSize({ width: 1440, height: 1000 });
|
||||
await uninstall();
|
||||
const confirmation = settingsPage.getByRole("dialog", { name: "Uninstall Workspace overview?", exact: true });
|
||||
assert(await confirmation.getByRole("button", { name: "Cancel", exact: true }).evaluate(el => el === document.activeElement));
|
||||
assert.equal(await confirmation.getByRole("button", { name: "Continue", exact: true }).count(), 0);
|
||||
await confirmation.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
assert.equal(await count("plugins_remove"), 0);
|
||||
assert(await settingsDialog.getByRole("switch", { name: "Workspace overview", exact: true }).isChecked());
|
||||
await uninstall();
|
||||
await confirmation.waitFor();
|
||||
await settingsPage.keyboard.press("Escape");
|
||||
assert(await settingsDialog.isVisible());
|
||||
assert(await settingsDialog.getByRole("switch", { name: "Workspace overview", exact: true }).isChecked());
|
||||
assert.equal(await count("plugins_remove"), 0);
|
||||
await uninstall();
|
||||
await confirmation.waitFor();
|
||||
await shot("plugin-uninstall-confirmation.png");
|
||||
await confirmation.getByRole("button", { name: "Uninstall and delete files", exact: true }).click();
|
||||
await settingsDialog.getByText("No plugins installed.", { exact: true }).waitFor();
|
||||
assert.equal(await count("plugins_remove"), 1);
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.cleaned), true);
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.data.preserved), true);
|
||||
await settingsPage.keyboard.press("Escape");
|
||||
assert.equal(await page.getByRole("button", { name: "Plugin commands and views", exact: true }).count(), 0);
|
||||
await settingsPage.setViewportSize({ width: 590, height: 820 });
|
||||
await settings();
|
||||
await shot("plugin-manager-narrow.png");
|
||||
assert.equal(await settingsDialog.evaluate(element => element.scrollWidth > element.clientWidth), false);
|
||||
await gitButton.click();
|
||||
await gitDialog.getByLabel("Repository link", { exact: true }).fill("https://git.example/owner/plugin.git");
|
||||
await shot("plugin-git-narrow.png");
|
||||
assert.equal(await gitDialog.evaluate(element => element.scrollWidth > element.clientWidth), false);
|
||||
await gitDialog.getByRole("button", { name: "Review release", exact: true }).click();
|
||||
await review.getByRole("button", { name: "Install, keep disabled", exact: true }).click();
|
||||
await settingsDialog.getByRole("switch", { name: "Workspace overview", exact: true }).waitFor();
|
||||
assert.equal(await settingsDialog.getByRole("switch", { name: "Workspace overview", exact: true }).isChecked(), false);
|
||||
assert.equal(await count("plugins_from_git"), 3);
|
||||
assert.deepEqual([...page.errors, ...settingsPage.errors], []);
|
||||
} catch (error) {
|
||||
console.log("Main page:", await page.locator("body").innerText());
|
||||
console.log("Page errors:", [...page.errors, ...settingsPage.errors]);
|
||||
throw error;
|
||||
}
|
||||
console.log("External plugin smoke passed: ZIP and Git-link review, download errors, token clearing, disabled installation, code loading, cancellation, focus, cleanup, and uninstall.");
|
||||
});
|
||||
@@ -0,0 +1,179 @@
|
||||
// Feature lifecycle: the built-in Table formulas setting and the native Terminal feature turn off, persist, and turn on again across windows.
|
||||
// Terminal off asks first while a shell runs, and then ends the shells of each window.
|
||||
// An old Table Formulas package stays inactive, shows that the feature is built in, and uninstalls without restoration.
|
||||
import assert from 'node:assert/strict';
|
||||
import path from 'node:path';
|
||||
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
|
||||
import { mockInstalledPlugins, oldTableFormulasRow } from '../_harness/pluginMocks.mjs';
|
||||
|
||||
await runSmoke('plugins/lifecycle', async ({ browser }) => {
|
||||
const context = await browser.newContext({ viewport: { width: 1440, height: 1000 } });
|
||||
await context.route('**/__settings-closed', route => route.fulfill({ contentType: 'text/html', body: '<!doctype html><title>Closed settings</title>' }));
|
||||
const page = await openPage(context);
|
||||
const settingsPage = await openPage(context);
|
||||
page.on('console', message => { if (message.type() === 'error' || message.type() === 'warning') console.log(message.type(), message.text()); });
|
||||
await mockTauri(context, {
|
||||
commands: test => {
|
||||
const ws = test.workspace({
|
||||
root: 'C:\\smoke-workspace',
|
||||
files: {
|
||||
'notes/welcome.md': '---\ntitle: Welcome\n---\n\n# Working notes\n\nFirst paragraph.\n\n- [ ] A task\n\n[[second]]\n',
|
||||
'notes/second.md': '# Second note\n',
|
||||
'src/hello.py': "print('hello')\n",
|
||||
},
|
||||
});
|
||||
const files = ws.files;
|
||||
test.files = files;
|
||||
return {
|
||||
...ws,
|
||||
workspace_write: ({ rel, contents, expected }) => {
|
||||
if (expected !== undefined && files.get(rel) !== expected) throw new Error('Save blocked: file changed on disk');
|
||||
files.set(rel, contents);
|
||||
test.emit('workspace-event', { root: ws.root, kind: 'modify', paths: [rel] });
|
||||
},
|
||||
settings_open_window: () => null,
|
||||
// Terminal off asks first while a shell runs (src/lib/layout/SettingsDialog.svelte).
|
||||
'plugin:dialog|message': args => { test.state.prompts = [...test.state.prompts ?? [], args.message]; return 'Ok'; },
|
||||
};
|
||||
},
|
||||
});
|
||||
await mockInstalledPlugins(context, [oldTableFormulasRow]);
|
||||
const output = await outputDir('plugins/lifecycle');
|
||||
const source = '# Formulas\n\n| A | B |\n| --- | --- |\n| 2 | =A2*3 |\n\nAfter.\n';
|
||||
const table = page.locator('.live-writer table');
|
||||
const dialog = settingsPage.getByRole('dialog', { name: 'Settings', exact: true });
|
||||
const switchFor = name => dialog.getByRole('switch', { name, exact: true });
|
||||
const ptyCalled = command => window.__TEST__.calls.some(call => call.command === command);
|
||||
const count = command => page.evaluate(command => window.__TEST__.calls.filter(call => call.command === command).length, command);
|
||||
async function quickOpen(name) {
|
||||
await page.keyboard.press('Control+p');
|
||||
await page.getByRole('textbox', { name: 'Find a file' }).fill(name);
|
||||
await page.getByRole('dialog').getByRole('button').filter({ hasText: name }).first().click();
|
||||
await page.locator('.live-writer').waitFor();
|
||||
}
|
||||
async function settings(category = 'Plug-ins') {
|
||||
await page.getByRole('button', { name: 'Settings (Ctrl+,)', exact: true }).click();
|
||||
await settingsPage.goto(smokeUrl + '/?settingsWindow=true');
|
||||
await dialog.getByRole('button', { name: category, exact: true }).click();
|
||||
}
|
||||
// The switch of an old package of a built-in feature stays disabled.
|
||||
const idle = () => settingsPage.waitForFunction(() => [...document.querySelectorAll('input[role="switch"]')].every(input => !input.disabled || input.id === 'external-runestone.table-formulas'));
|
||||
async function closeSettings() {
|
||||
await idle();
|
||||
await settingsPage.goto(smokeUrl + '/__settings-closed');
|
||||
await page.bringToFront();
|
||||
}
|
||||
|
||||
try {
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText('smoke-workspace', { exact: true }).waitFor();
|
||||
await page.evaluate(text => window.__TEST__.files.set('formulas.md', text), source);
|
||||
await quickOpen('formulas.md');
|
||||
await table.waitFor();
|
||||
assert.equal(await table.locator('.md-table-formula').innerText(), '6');
|
||||
assert(!await page.evaluate(() => window.__TEST__.calls.some(call => call.command === 'plugins_load' && call.args.id === 'runestone.table-formulas')), 'The old Table Formulas package does not load');
|
||||
await settings('General');
|
||||
await switchFor('Table formulas').uncheck();
|
||||
await closeSettings();
|
||||
await page.waitForFunction(() => !document.querySelector('.md-table-formula'));
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.settings('general').tableFormulas), false, 'The settings file stores the choice');
|
||||
assert.match(await table.innerText(), /=A2\*3/);
|
||||
assert.equal(await page.locator('.table-formula-tools').count(), 0);
|
||||
await table.locator('td').last().click();
|
||||
await page.locator('.writer-cell-editor').fill('=A2*4');
|
||||
await page.keyboard.press('Enter');
|
||||
await settings('General');
|
||||
await switchFor('Table formulas').check();
|
||||
await closeSettings();
|
||||
await page.waitForFunction(() => document.querySelector('.md-table-formula')?.textContent === '8');
|
||||
await page.getByRole('radiogroup', { name: 'View', exact: true }).getByRole('radio', { checked: true }).press('End');
|
||||
const preview = page.locator('.md-page table').first();
|
||||
await preview.locator('.md-table-formula').waitFor();
|
||||
await settings('General');
|
||||
await switchFor('Table formulas').uncheck();
|
||||
await closeSettings();
|
||||
await page.waitForFunction(() => !document.querySelector('.md-page .md-table-formula'));
|
||||
assert.match(await preview.innerText(), /=A2\*4/);
|
||||
await settings('General');
|
||||
await switchFor('Table formulas').check();
|
||||
await closeSettings();
|
||||
await preview.locator('.md-table-formula').waitFor();
|
||||
assert.equal(await preview.locator('.md-table-formula').innerText(), '8');
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(() => window.__TEST__.files.get('formulas.md').includes('=A2*4'));
|
||||
assert(!await page.evaluate(() => window.__TEST__.files.get('formulas.md').includes('>8<')));
|
||||
|
||||
await page.getByRole('button', { name: 'Terminal', exact: true }).click();
|
||||
await page.waitForFunction(ptyCalled, 'pty_open');
|
||||
await settings();
|
||||
const oldPackage = dialog.locator('.card').filter({ has: settingsPage.getByRole('switch', { name: 'Table Formulas', exact: true }) });
|
||||
await oldPackage.getByText('Included with RuneStone', { exact: true }).waitFor();
|
||||
await oldPackage.getByText(/Table Formulas is now built in\. You can remove this old package\./).waitFor();
|
||||
assert(await oldPackage.getByRole('switch').isDisabled(), 'The old package cannot be enabled');
|
||||
assert.equal(await switchFor('Terminal').count(), 0, 'Terminal is a feature, not a plugin');
|
||||
await dialog.getByRole('button', { name: 'Features', exact: true }).click();
|
||||
await switchFor('Terminal').uncheck();
|
||||
await page.waitForFunction(ptyCalled, 'pty_close');
|
||||
const prompts = await settingsPage.evaluate(() => window.__TEST__.state.prompts);
|
||||
assert.deepEqual(prompts, ['Terminal sessions will end.\nTurn off Terminal?'], 'Terminal off asks first while a shell runs');
|
||||
assert.equal(await settingsPage.evaluate(() => window.__TEST__.settings('features').terminal), false);
|
||||
await settingsPage.screenshot({ path: path.join(output, 'features-terminal-off.png') });
|
||||
await closeSettings();
|
||||
assert.equal(await page.getByRole('button', { name: 'Terminal', exact: true }).count(), 0);
|
||||
const opened = await count('pty_open');
|
||||
await page.keyboard.press('Control+j');
|
||||
await page.keyboard.press('Control+Shift+Backquote');
|
||||
assert.equal(await count('pty_open'), opened);
|
||||
await page.reload();
|
||||
await page.getByText('smoke-workspace', { exact: true }).waitFor();
|
||||
assert.equal(await page.getByRole('button', { name: 'Terminal', exact: true }).count(), 0);
|
||||
await settings('Features');
|
||||
assert(!await switchFor('Terminal').isChecked());
|
||||
assert.equal(await dialog.getByRole('button', { name: 'Terminal', exact: true }).count(), 0, 'Settings → Terminal shows only while Terminal is on');
|
||||
|
||||
const standalone = await openPage(context);
|
||||
await standalone.goto(smokeUrl + '?terminalWindow=C%3A%5Csmoke-workspace');
|
||||
await standalone.getByText('Terminal is off. Turn it on in Settings → Features.', { exact: true }).waitFor();
|
||||
await switchFor('Terminal').check();
|
||||
await standalone.locator('.xterm').waitFor();
|
||||
await standalone.waitForFunction(ptyCalled, 'pty_open');
|
||||
await dialog.getByRole('button', { name: 'Terminal', exact: true }).waitFor();
|
||||
await switchFor('Terminal').uncheck();
|
||||
await standalone.getByText('Terminal is off. Turn it on in Settings → Features.', { exact: true }).waitFor();
|
||||
await standalone.waitForFunction(ptyCalled, 'pty_close');
|
||||
assert.equal((await settingsPage.evaluate(() => window.__TEST__.state.prompts)).length, 1, 'The shell of the terminal window gives a prompt too');
|
||||
page.errors.push(...standalone.errors);
|
||||
await standalone.close();
|
||||
await switchFor('Terminal').check();
|
||||
await closeSettings();
|
||||
await page.getByRole('button', { name: 'Terminal', exact: true }).click();
|
||||
await page.locator('.xterm').waitFor();
|
||||
await page.evaluate(text => window.__TEST__.files.set('formulas.md', text.replace('=A2*3', '=A2*4')), source);
|
||||
await page.getByRole('button', { name: 'Terminal', exact: true }).focus();
|
||||
await quickOpen('formulas.md');
|
||||
await settings();
|
||||
assert.equal(await dialog.getByRole('heading', { name: 'Bundled plugins' }).count(), 0);
|
||||
await idle();
|
||||
await dialog.locator('.card').filter({ has: settingsPage.getByRole('switch', { name: 'Table Formulas', exact: true }) }).getByRole('button', { name: 'Uninstall', exact: true }).click();
|
||||
const confirmation = settingsPage.getByRole('dialog', { name: 'Uninstall Table Formulas?', exact: true });
|
||||
await confirmation.getByRole('button', { name: 'Uninstall and delete files', exact: true }).click();
|
||||
await confirmation.waitFor({ state: 'hidden' });
|
||||
await switchFor('Table Formulas').waitFor({ state: 'detached' });
|
||||
await closeSettings();
|
||||
assert.equal(await page.locator('.xterm').count(), 1, 'The package removal does not touch the Terminal feature');
|
||||
assert.equal(await table.locator('.md-table-formula').innerText(), '8', 'Removing the old package keeps the built-in formulas');
|
||||
await page.reload();
|
||||
await page.getByText('smoke-workspace', { exact: true }).waitFor();
|
||||
await settings();
|
||||
await dialog.getByText('No plugins installed.', { exact: true }).waitFor();
|
||||
assert.deepEqual([...page.errors, ...settingsPage.errors], []);
|
||||
} catch (error) {
|
||||
await settingsPage.screenshot({ path: path.join(output, 'plugins-settings-failure.png') });
|
||||
console.log('Settings page:', settingsPage.url(), await settingsPage.locator('body').innerText());
|
||||
await page.screenshot({ path: path.join(output, 'plugins-failure.png') });
|
||||
console.log(await page.locator('.md-page').allTextContents());
|
||||
console.log([...page.errors, ...settingsPage.errors]);
|
||||
throw error;
|
||||
}
|
||||
console.log('Plugin smoke passed: formula setting, source preservation, inactive old package, Terminal off with a prompt, persistence, shortcuts, the terminal window, removal, and no automatic restoration.');
|
||||
});
|
||||
Reference in New Issue
Block a user