Add completion, browser integration, and workspace improvements

This commit is contained in:
Knotty Wyvern
2026-10-07 11:25:17 -07:00
parent dd9fc64676
commit a8b1defb9d
86 changed files with 3524 additions and 203 deletions
+39 -29
View File
@@ -9,8 +9,10 @@ const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
const context = await browser.newContext({ viewport: { width: 1100, height: 800 } });
const page = await context.newPage();
const settingsPage = await context.newPage();
const errors = [];
page.on("pageerror", error => errors.push(error.message));
settingsPage.on("pageerror", error => errors.push(error.message));
await context.addInitScript(() => {
window.isTauri = true;
const disk = { "note.txt": "Original note" };
@@ -32,8 +34,18 @@ await context.addInitScript(() => {
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
});
const url = process.env.SMOKE_URL || "http://127.0.0.1:1420";
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
const settings = settingsPage.getByRole("dialog", { name: "Settings", exact: true });
const trigger = page.getByRole("button", { name: "Settings (Ctrl+,)", exact: true });
async function showSettings(shortcut = false) {
if (shortcut) await page.keyboard.press("Control+,");
else await trigger.click();
await settingsPage.goto(`${url}/?settingsWindow=true`);
await settings.waitFor();
}
async function closeSettings() {
await settingsPage.goto("about:blank");
await page.bringToFront();
}
const interval = settings.getByRole("spinbutton", { name: "Auto-save interval" });
const enabled = settings.getByRole("switch", { name: "Auto-save", exact: true });
async function changeSeconds(value) {
@@ -51,15 +63,14 @@ try {
await page.clock.install();
await page.goto(url);
await page.locator(".ws").filter({ hasText: "Notes" }).waitFor();
await trigger.click();
await showSettings();
assert.equal(await interval.inputValue(), "5");
assert(await enabled.isChecked());
await changeSeconds(2);
await settings.getByRole("status").filter({ hasText: "Changes saved." }).waitFor();
await page.keyboard.press("Escape");
assert(await trigger.evaluate(element => element === document.activeElement), "Closing restores focus");
await closeSettings();
await page.reload();
await trigger.click();
await showSettings();
assert.equal(await interval.inputValue(), "2", "Interval survives reload");
await changeSeconds(0);
await settings.getByRole("alert").filter({ hasText: "whole number" }).waitFor();
@@ -71,17 +82,17 @@ try {
await settings.getByRole("textbox", { name: "Search settings" }).fill("no such setting");
await settings.getByText("No settings found", { exact: true }).waitFor();
await settings.getByRole("button", { name: "Clear search" }).click();
await page.screenshot({ path: ".audit/settings-general.png" });
await page.keyboard.press("Escape");
await settingsPage.screenshot({ path: ".audit/settings-general.png" });
await closeSettings();
await page.keyboard.press("Control+p");
await page.getByRole("textbox", { name: "Find a file" }).fill("note.txt");
await page.getByRole("dialog").getByRole("button").filter({ hasText: "note.txt" }).first().click();
await page.locator(".monaco-editor textarea").waitFor();
await page.clock.pauseAt(new Date(await page.evaluate(() => Date.now()) + 1000));
await trigger.click();
await showSettings();
await changeSeconds(3);
await page.keyboard.press("Escape");
await closeSettings();
await edit("Saved at three seconds");
const before = await writes();
await page.clock.runFor(2100);
@@ -90,53 +101,52 @@ try {
assert.equal(await writes(), before + 1, "New interval saves the dirty buffer");
await page.clock.runFor(3100);
assert.equal(await writes(), before + 1, "Clean files are not rewritten");
await trigger.click();
await showSettings();
await enabled.uncheck();
assert(await interval.isDisabled());
await page.keyboard.press("Escape");
await closeSettings();
await edit("Manual save while auto-save is disabled");
await page.clock.runFor(10000);
assert.equal(await writes(), before + 1);
await page.keyboard.press("Control+s");
await page.waitForFunction(count => window.__TEST__.writes.length === count, before + 2);
await page.locator(".monaco-editor textarea").focus();
await page.keyboard.press("Control+,");
await showSettings(true);
await settings.waitFor();
await page.keyboard.press("Escape");
await closeSettings();
await page.locator(".monaco-editor textarea").focus();
await page.keyboard.press("F1");
await page.getByRole("dialog", { name: "Help and about", exact: true }).waitFor();
await page.keyboard.press("Escape");
const other = await context.newPage();
await other.goto(url);
await other.getByRole("button", { name: "Settings (Ctrl+,)" }).click();
await other.goto(`${url}/?settingsWindow=true`);
assert.equal(await other.getByRole("spinbutton", { name: "Auto-save interval" }).inputValue(), "3");
assert.equal(await other.getByRole("switch", { name: "Auto-save", exact: true }).isChecked(), false);
await other.getByRole("button", { name: "Restore defaults" }).click();
await page.waitForFunction(() => JSON.parse(localStorage.getItem("runestone.settings")).autosaveEnabled);
await trigger.click();
await showSettings();
await enabled.waitFor();
assert(await enabled.isChecked(), "Other windows receive changes");
assert.equal(await interval.inputValue(), "5");
await page.keyboard.press("Escape");
await closeSettings();
await edit("Auto-save enabled from another window");
await page.clock.runFor(5100);
assert.equal(await writes(), before + 3);
await other.close();
await trigger.click();
await page.evaluate(() => {
await showSettings();
await settingsPage.evaluate(() => {
window.__SET_ITEM__ = Storage.prototype.setItem;
Storage.prototype.setItem = () => { throw new Error("Storage unavailable"); };
});
await changeSeconds(7);
await settings.getByRole("alert").filter({ hasText: "Could not save" }).waitFor();
await page.evaluate(() => { Storage.prototype.setItem = window.__SET_ITEM__; });
await page.keyboard.press("Escape");
await trigger.click();
await settingsPage.evaluate(() => { Storage.prototype.setItem = window.__SET_ITEM__; });
await closeSettings();
await showSettings();
assert.equal(await interval.inputValue(), "5", "Failed writes preserve applied settings");
await page.keyboard.press("Escape");
await closeSettings();
await page.getByRole("button", { name: "Help and about (F1)" }).click();
const help = page.getByRole("dialog", { name: "Help and about", exact: true });
@@ -145,19 +155,19 @@ try {
await page.screenshot({ path: ".audit/settings-help.png" });
await page.keyboard.press("Escape");
await page.keyboard.press("Control+b");
await page.keyboard.press("Control+,");
await showSettings(true);
await settings.waitFor();
await page.keyboard.press("Escape");
await closeSettings();
await page.keyboard.press("F1");
await help.waitFor();
await page.keyboard.press("Escape");
await page.setViewportSize({ width: 420, height: 650 });
await page.keyboard.press("Control+,");
await settingsPage.setViewportSize({ width: 540, height: 420 });
await showSettings(true);
await settings.waitFor();
assert(await settings.evaluate(el => el.scrollWidth === el.clientWidth), "Narrow layout fits");
await page.screenshot({ path: ".audit/settings-narrow.png" });
await settingsPage.screenshot({ path: ".audit/settings-narrow.png" });
for (let i = 0; i < 12; i++) {
await page.keyboard.press("Tab");
await settingsPage.keyboard.press("Tab");
assert(await settings.evaluate(el => el.contains(document.activeElement)), "Focus stays in the modal");
}
assert.deepEqual(errors, []);