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
+16 -8
View File
@@ -6,11 +6,15 @@ const require = createRequire(import.meta.url);
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: 1440, height: 1000 } });
await context.route('**/__settings-closed', route => route.fulfill({ contentType: 'text/html', body: '<!doctype html><title>Closed settings</title>' }));
const page = await context.newPage();
const settingsPage = await context.newPage();
page.setDefaultTimeout(10000);
settingsPage.setDefaultTimeout(10000);
const errors = [];
page.on("console", message => { if (message.type() === "error" || message.type() === "warning") console.log(message.type(), message.text()); });
page.on("pageerror", error => errors.push(error.message));
settingsPage.on("pageerror", error => errors.push(error.message));
await page.context().addInitScript(() => {
window.isTauri = true;
const root = "C:\\smoke-workspace";
@@ -32,6 +36,7 @@ await page.context().addInitScript(() => {
unregisterCallback: id => callbacks.delete(id),
invoke: async (command, args = {}) => {
calls.push({ command, args });
if (command === "settings_open_window") return;
if (command === "plugin:event|listen") {
const list = listeners.get(args.event) || []; list.push(args.handler); listeners.set(args.event, list); return args.handler;
}
@@ -83,16 +88,17 @@ async function quickOpen(name) {
const source = '# Formulas\n\n| A | B |\n| --- | --- |\n| 2 | =A2*3 |\n\nAfter.\n';
const table = page.locator('.live-writer table');
const dialog = page.getByRole('dialog', { name: 'Settings', exact: true });
const dialog = settingsPage.getByRole('dialog', { name: 'Settings', exact: true });
const switchFor = name => dialog.getByRole('switch', { name, exact: true });
async function settings() {
await page.getByRole('button', { name: 'Settings (Ctrl+,)', exact: true }).click();
await settingsPage.goto((process.env.SMOKE_URL || 'http://127.0.0.1:1420') + '/?settingsWindow=true');
await dialog.getByRole('button', { name: 'Plug-ins', exact: true }).click();
}
async function closeSettings() {
await page.waitForFunction(() => [...document.querySelectorAll('input[role="switch"]')].every(input => !input.disabled));
await page.keyboard.press('Escape');
await dialog.waitFor({ state: 'hidden' });
await settingsPage.waitForFunction(() => [...document.querySelectorAll('input[role="switch"]')].every(input => !input.disabled));
await settingsPage.goto((process.env.SMOKE_URL || 'http://127.0.0.1:1420') + '/__settings-closed');
await page.bringToFront();
}
const count = command => page.evaluate(command => window.__TEST__.calls.filter(call => call.command === command).length, command);
try {
@@ -137,7 +143,7 @@ try {
await settings();
await switchFor('Terminal').uncheck();
await page.waitForFunction(() => window.__TEST__.calls.some(call => call.command === 'pty_close'));
await page.screenshot({ path: '.audit/plugins-settings.png' });
await settingsPage.screenshot({ path: '.audit/plugins-settings.png' });
await closeSettings();
assert.equal(await page.getByRole('button', { name: 'Terminal', exact: true }).count(), 0);
const opened = await count('pty_open');
@@ -169,9 +175,9 @@ try {
await settings();
assert.equal(await dialog.getByRole('heading', { name: 'Bundled plugins' }).count(), 0);
for (const name of ['Terminal', 'Table formulas']) {
await page.waitForFunction(() => [...document.querySelectorAll('input[role="switch"]')].every(input => !input.disabled));
await dialog.locator('.card').filter({ has: page.getByRole('switch', { name, exact: true }) }).getByRole('button', { name: 'Uninstall', exact: true }).click();
const confirmation = page.getByRole('dialog', { name: `Uninstall ${name}?`, exact: true });
await settingsPage.waitForFunction(() => [...document.querySelectorAll('input[role="switch"]')].every(input => !input.disabled));
await dialog.locator('.card').filter({ has: settingsPage.getByRole('switch', { name, exact: true }) }).getByRole('button', { name: 'Uninstall', exact: true }).click();
const confirmation = settingsPage.getByRole('dialog', { name: `Uninstall ${name}?`, exact: true });
await confirmation.getByRole('button', { name: 'Uninstall and delete files', exact: true }).click();
await confirmation.waitFor({ state: 'hidden' });
await switchFor(name).waitFor({ state: 'detached' });
@@ -187,6 +193,8 @@ try {
assert.deepEqual(errors, []);
console.log('Plugin smoke passed: formulas, source preservation, terminal shutdown, persistence, shortcuts, cross-window enable controls, removal, and no automatic restoration.');
} catch (error) {
await settingsPage.screenshot({ path: ".audit/plugins-settings-failure.png" });
console.log("Settings page:", settingsPage.url(), await settingsPage.locator('body').innerText());
await page.screenshot({ path: ".audit/plugins-failure.png" });
console.log(await page.locator('.md-page').allTextContents());
console.log(errors);