Update editor, workspace, Git services, appearance, and project guides

This commit is contained in:
Knotty Wyvern
2026-10-11 09:41:16 -07:00
parent a8b1defb9d
commit 909894b9c8
153 changed files with 7967 additions and 775 deletions
+152
View File
@@ -0,0 +1,152 @@
import { createRequire } from 'node:module';
import assert from 'node:assert/strict';
import { mkdir } from 'node:fs/promises';
const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || '../node_modules/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.addInitScript(() => {
window.isTauri = true;
const root = 'C:\\kanban-smoke';
const files = new Map([['a.md', '# Alpha\n\nTemplate body.\n'], ['b.md', '# Beta\n'], ['folder/keep.md', '# Keep\n'], ['.runestone/config.json', '{}']]);
const calls = [], callbacks = new Map(); let id = 0;
window.workspaceSmoke = { files, calls, transfer: null };
window.__TAURI_INTERNALS__ = {
metadata: { currentWindow: { label: 'main' }, currentWebview: { label: 'main' } },
transformCallback: callback => { callbacks.set(++id, callback); return id; }, unregisterCallback: id => callbacks.delete(id),
invoke: async (command, args = {}) => {
calls.push({ command, args });
if (command === 'plugin:event|listen') return ++id;
if (command === 'plugin:event|unlisten' || command === 'spelling_menu_install' || command === 'spelling_menu_uninstall') return;
if (command === 'workspace_last_path') return root;
if (command === 'workspace_open') return { root, name: 'kanban-smoke', watch_mode: 'native' };
if (command === 'workspace_read') { if (!files.has(args.rel)) throw Error('File missing'); return files.get(args.rel); }
if (command === 'workspace_write') {
if (args.expected !== undefined && files.get(args.rel) !== args.expected) throw Error('Save conflict');
files.set(args.rel, args.contents); return;
}
if (command === 'workspace_create') { if (files.has(args.rel)) throw Error('Exists'); files.set(args.rel, ''); return; }
if (command === 'workspace_list') {
const prefix = args.rel ? args.rel + '/' : ''; const entries = new Map();
for (const path of files.keys()) {
if (!path.startsWith(prefix) || (!args.rel && path.startsWith('.runestone/') && !args.showInternal)) continue;
const tail = path.slice(prefix.length), name = tail.split('/')[0];
entries.set(name, { name, rel_path: prefix + name, kind: tail.includes('/') ? 'folder' : 'file' });
}
return [...entries.values()];
}
if (command === 'workspace_rename') {
if (files.has(args.to)) throw Error('Destination exists');
const matches = [...files].filter(([path]) => path === args.from || path.startsWith(args.from + '/'));
if (!matches.length) throw Error('Source missing');
for (const [path, contents] of matches) { files.delete(path); files.set(args.to + path.slice(args.from.length), contents); }
return;
}
if (command === 'workspace_copy') {
const path = (args.parent ? args.parent + '/' : '') + args.rel.split('/').pop();
if (files.has(path)) throw Error('Destination exists');
files.set(path, files.get(args.rel)); return { rel_path: path, name: path.split('/').pop(), kind: 'file' };
}
if (command === 'workspace_open_window') { window.workspaceSmoke.transfer = args.transfer; return; }
if (command === 'workspace_abs_path') return root + '\\' + args.rel;
if (command === 'workspace_recent') return [root];
if (command === 'workspace_search') return [];
if (command === 'plugin:dialog|message') return 'Cancel';
if (command === 'plugins_snapshot') return { plugins: [], issues: [] };
if (command.startsWith('plugin:window|') || command === 'workspace_open_terminal' || command === 'workspace_open_default') return;
if (command === 'browser_stop') return;
throw Error('Unhandled IPC: ' + command);
},
};
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener() {} };
});
const page = await context.newPage();
const errors = [];
page.on('pageerror', error => errors.push(error.message));
page.setDefaultTimeout(15000);
const url = process.env.SMOKE_URL || 'http://127.0.0.1:1420';
const row = path => page.locator(`[data-tree-rel="${path}"]`);
const menu = label => page.getByRole('menuitem', { name: label, exact: true });
try {
await page.goto(url);
await row('a.md').click();
await page.locator('.cm-content').waitFor();
await page.locator('.mode-switcher').first().hover();
await page.waitForFunction(() => document.querySelector('.mode-switcher')?.classList.contains('expanded'), null, { timeout: 500 });
await page.mouse.move(500, 400);
await row('a.md').click({ button: 'right' });
await menu('Save as template').click();
await page.getByRole('textbox', { name: 'Template name' }).fill('Meeting');
await page.getByRole('button', { name: 'Continue', exact: true }).click();
await page.waitForFunction(() => window.workspaceSmoke.files.has('.runestone/templates/Meeting.md'));
await page.getByRole('button', { name: 'New tab (Ctrl T)', exact: true }).click();
await page.getByRole('button', { name: 'New note', exact: true }).click();
await menu('Meeting').click();
await page.getByRole('tab', { name: /Meeting/ }).waitFor();
assert.equal(await page.evaluate(() => window.workspaceSmoke.files.get('Meeting.md')), '# Alpha\n\nTemplate body.\n');
const before = await page.getByRole('tab', { selected: true }).getAttribute('data-path');
await page.keyboard.press('Control+Tab');
assert.notEqual(await page.getByRole('tab', { selected: true }).getAttribute('data-path'), before);
await page.keyboard.press('Control+Shift+Tab');
assert.equal(await page.getByRole('tab', { selected: true }).getAttribute('data-path'), before);
await row('b.md').click({ button: 'right' }); await menu('Cut').click();
await row('folder').click({ button: 'right' }); await menu('Paste').click();
await page.waitForFunction(() => window.workspaceSmoke.files.has('folder/b.md'));
await row('folder').click({ button: 'right' }); await menu('Undo file move').click();
await page.waitForFunction(() => window.workspaceSmoke.files.has('b.md'));
await row('folder').click({ button: 'right' }); await menu('Redo file move').click();
await page.waitForFunction(() => window.workspaceSmoke.files.has('folder/b.md'));
await row('folder').focus();
await page.keyboard.press('Control+z');
await page.waitForFunction(() => window.workspaceSmoke.files.has('b.md'));
const sourceBox = await row('b.md').boundingBox(), folderBox = await row('folder').boundingBox();
await page.mouse.move(sourceBox.x + 50, sourceBox.y + sourceBox.height / 2);
await page.mouse.down();
await page.mouse.move(folderBox.x + 70, folderBox.y + folderBox.height / 2, { steps: 12 });
await page.mouse.up();
await page.waitForFunction(() => window.workspaceSmoke.files.has('folder/b.md'));
await page.keyboard.press('Control+z');
await page.waitForFunction(() => window.workspaceSmoke.files.has('b.md'));
await row('folder').click({ button: 'right' }); await menu('Open in terminal').click();
assert.ok(await page.evaluate(() => window.workspaceSmoke.calls.some(call => call.command === 'workspace_open_terminal' && call.args.rel === 'folder')));
await page.keyboard.press('Control+,');
const settingsPage = await context.newPage();
await settingsPage.goto(url + '/?settingsWindow=true');
await settingsPage.getByRole('switch', { name: 'Show .runestone folder' }).check();
await settingsPage.getByRole('button', { name: 'Appearance', exact: true }).click();
const theme = { schema: 1, id: 'smoke', name: 'Smoke theme', light: { bg: '#fefefe', text: '#222222', accent: '#334499' }, dark: { bg: '#181820', text: '#eeeeee', accent: '#aabbff' } };
await settingsPage.locator('input[type=file][aria-label="Theme JSON file"]').setInputFiles({ name: 'smoke.json', mimeType: 'application/json', buffer: Buffer.from(JSON.stringify(theme)) });
await settingsPage.waitForFunction(() => document.documentElement.dataset.palette === 'custom:smoke');
assert.equal(await settingsPage.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--rs-bg').trim()), '#181820');
await settingsPage.getByRole('combobox', { name: 'Appearance', exact: true }).selectOption('light');
assert.equal(await settingsPage.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--rs-bg').trim()), '#fefefe');
await mkdir('.audit', { recursive: true });
await settingsPage.screenshot({ path: '.audit/kanban-custom-theme-light.png' });
await settingsPage.close();
await row('.runestone').waitFor();
await page.getByRole('tab', { name: /Meeting/ }).click();
const editor = page.locator('.cm-content'); await editor.click(); await page.keyboard.press('Control+End'); await page.keyboard.type('Unsaved transfer');
await page.getByRole('tab', { name: /Meeting/ }).click({ button: 'right' });
await menu('Open in new window').click();
await page.waitForFunction(() => window.workspaceSmoke.transfer);
const token = await page.evaluate(() => window.workspaceSmoke.transfer);
const target = await context.newPage();
target.on('pageerror', error => errors.push(error.message));
await target.goto(url + '/?tabTransfer=' + token);
await target.getByRole('tab', { name: /Meeting/ }).waitFor();
await target.waitForFunction(() => document.querySelector('.cm-content')?.textContent.includes('Unsaved transfer'));
await page.getByRole('tab', { name: /Meeting/ }).waitFor({ state: 'detached' });
await page.evaluate(() => { window.workspaceSmoke.transfer = null; });
const draggedTab = page.getByRole('tab').first();
const draggedPath = await draggedTab.getAttribute('data-path');
const tabBox = await draggedTab.boundingBox();
await page.mouse.move(tabBox.x + tabBox.width / 2, tabBox.y + tabBox.height / 2);
await page.mouse.down();
await page.mouse.move(1480, 180, { steps: 12 });
await page.mouse.up();
await page.waitForFunction(() => window.workspaceSmoke.transfer);
assert.notEqual(await page.evaluate(() => window.workspaceSmoke.transfer), token);
assert.equal(await page.locator(`[role="tab"][data-path="${draggedPath}"]`).count(), 1, 'Keep the source tab until the new window accepts it');
assert.equal(errors.length, 0, errors.join('\n'));
console.log('PASS: templates, tab shortcuts, move undo/redo, terminal action, internal folder, theme import, and acknowledged unsaved tab transfer');
} finally { await browser.close(); }