Add completion, browser integration, and workspace improvements
This commit is contained in:
@@ -7,10 +7,15 @@ 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 }, locale: 'en-US', timezoneId: 'America/Vancouver' });
|
||||
const page = await context.newPage();
|
||||
const settingsPage = await context.newPage();
|
||||
settingsPage.setDefaultTimeout(10000);
|
||||
await context.exposeBinding("settingsHostInvoke", (_source, command, args) =>
|
||||
page.evaluate(({ command, args }) => window.__TAURI_INTERNALS__.invoke(command, args), { command, args }));
|
||||
page.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));
|
||||
const manifest = JSON.parse(readFileSync('fixtures/plugins/workspace-overview/plugin.json', 'utf8'));
|
||||
const pluginCode = readFileSync('fixtures/plugins/workspace-overview/main.js', 'utf8') + '\n// Browser cleanup probe\n';
|
||||
await page.context().addInitScript(({ manifest, pluginCode }) => {
|
||||
@@ -38,7 +43,10 @@ await page.context().addInitScript(({ manifest, pluginCode }) => {
|
||||
transformCallback: callback => { const id = ++sequence; callbacks.set(id, callback); return id; },
|
||||
unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (location.search.includes("settingsWindow") && !command.startsWith("plugin:event|") && !command.startsWith("plugin:window|"))
|
||||
return window.settingsHostInvoke(command, args);
|
||||
calls.push({ command, args });
|
||||
if (command === "settings_open_window") return;
|
||||
if (command === "plugin:window|is_maximized") return false;
|
||||
if (command.startsWith("plugin:window|")) return null;
|
||||
if (command === "plugins_snapshot") return snapshot();
|
||||
@@ -117,10 +125,11 @@ async function quickOpen(name) {
|
||||
}
|
||||
|
||||
|
||||
const settingsDialog = page.getByRole('dialog', { name: 'Settings', exact: true });
|
||||
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((process.env.SMOKE_URL || 'http://127.0.0.1:1420') + '/?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(); }
|
||||
@@ -131,13 +140,13 @@ try {
|
||||
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();
|
||||
let review = page.getByRole('dialog', { name: 'Review plugin installation', exact: true });
|
||||
let 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 = page.getByRole('dialog', { name: 'Install from Git link', exact: true });
|
||||
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');
|
||||
@@ -156,8 +165,8 @@ try {
|
||||
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 page.screenshot({ path: '.audit/plugin-manager-installed.png' });
|
||||
await page.keyboard.press('Escape');
|
||||
await settingsPage.screenshot({ path: '.audit/plugin-manager-installed.png' });
|
||||
await settingsPage.keyboard.press('Escape');
|
||||
await page.getByRole('button', { name: 'Plugin commands and views', exact: true }).click();
|
||||
await page.getByRole('button', { name: /Show workspace overview/ }).click();
|
||||
const view = page.getByRole('dialog', { name: 'Workspace overview', exact: true });
|
||||
@@ -165,7 +174,7 @@ try {
|
||||
await view.getByRole('button', { name: 'Close plugin view', exact: true }).click();
|
||||
await settings();
|
||||
await uninstall();
|
||||
const confirmation = page.getByRole('dialog', { name: 'Uninstall Workspace overview?', exact: true });
|
||||
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();
|
||||
@@ -173,27 +182,27 @@ try {
|
||||
assert(await settingsDialog.getByRole('switch', { name: 'Workspace overview', exact: true }).isChecked());
|
||||
await uninstall();
|
||||
await confirmation.waitFor();
|
||||
await page.keyboard.press('Escape');
|
||||
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 page.screenshot({ path: '.audit/plugin-uninstall-confirmation.png' });
|
||||
await settingsPage.screenshot({ path: '.audit/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 page.keyboard.press('Escape');
|
||||
await settingsPage.keyboard.press('Escape');
|
||||
assert.equal(await page.getByRole('button', { name: 'Plugin commands and views', exact: true }).count(), 0);
|
||||
await page.setViewportSize({ width: 590, height: 820 });
|
||||
await settingsPage.setViewportSize({ width: 590, height: 820 });
|
||||
await settings();
|
||||
await page.screenshot({ path: '.audit/plugin-manager-narrow.png' });
|
||||
await settingsPage.screenshot({ path: '.audit/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 page.screenshot({ path: '.audit/plugin-git-narrow.png' });
|
||||
await settingsPage.screenshot({ path: '.audit/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', exact: true }).click();
|
||||
|
||||
Reference in New Issue
Block a user