RuneStone 1.0.0

This commit is contained in:
Knotty Wyvern
2026-11-03 00:23:07 -07:00
commit 5557443ed1
818 changed files with 239368 additions and 0 deletions
+168
View File
@@ -0,0 +1,168 @@
// Tree rename undo and redo keep folders expanded; New note templates, native Git navigation, and detached tab layout isolation.
import assert from 'node:assert/strict';
import path from 'node:path';
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
await runSmoke('tree/renameUndo', async ({ browser }) => {
const context = await browser.newContext({ viewport: { width: 1200, height: 850 } });
await mockTauri(context, {
strict: false,
commands: test => {
const ws = test.workspace({
root: 'C:\\host-todo-test',
files: {
'a.md': '# Note\n\nOriginal text.', 'folder/nested/note.md': '# Nested', 'other/keep.md': '# Keep', '.runestone/templates/Daily.md': '# Daily\n\n## Tasks',
'.runestone/marks.json': JSON.stringify({ pins: ['a.md'], bookmarks: ['a.md'], order: { '': ['a.md'] } }),
},
});
const files = ws.files;
const within = (from, path) => path === from || path.startsWith(from + '/');
test.files = files;
return {
workspace_last_path: ws.workspace_last_path,
workspace_open: ws.workspace_open,
workspace_read: ws.workspace_read,
workspace_list: args => ws.workspace_list(args).filter(entry => args.rel || !entry.rel_path.startsWith('.runestone')),
workspace_create: ({ rel }) => { if (files.has(rel)) throw new Error('Destination exists'); files.set(rel, ''); },
workspace_write: ({ rel, contents, expected }) => {
if (expected !== undefined && files.get(rel) !== expected) throw new Error('Changed on disk');
files.set(rel, contents);
},
workspace_rename: ({ from, to }) => {
if (files.has(to)) throw new Error('Destination exists');
if (![...files.keys()].some(path => within(from, path))) throw new Error('Missing file');
for (const [path, contents] of [...files]) if (within(from, path)) { files.set(to + path.slice(from.length), contents); files.delete(path); }
},
workspace_delete: ({ rel }) => { files.delete(rel); },
workspace_search: () => [],
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [] }),
git_status: () => ({ available: true, repository: true, branch: 'main', changes: [] }),
'plugin:window|is_maximized': () => false,
'plugin:dialog|message': () => 'Ok',
};
},
});
const page = await openPage(context, { timeout: 30000 });
const output = await outputDir('tree/renameUndo');
const shot = (target, name) => target.screenshot({ path: path.join(output, name) });
const row = rel => page.locator(`[data-tree-rel="${rel}"]`);
const item = name => page.getByRole('menuitem', { name, exact: true });
const setMode = (target, mode) => target.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode }); }, mode);
async function paneMenu() { await page.getByRole('navigation', { name: 'Workspace files' }).click({ button: 'right', position: { x: 90, y: 360 } }); }
async function rename(rel, name) {
await row(rel).click({ button: 'right' }); await item('Rename').click();
await page.locator('.tree input').fill(name); await page.locator('.tree input').press('Enter');
}
async function expanded(rel) { assert.equal(await row(rel).getAttribute('aria-expanded'), 'true', `${rel} stays expanded`); }
await page.goto(smokeUrl);
await row('folder').click(); await row('folder/nested').click(); await row('other').click();
await rename('folder/nested/note.md', 'renamed.md'); await row('folder/nested/renamed.md').waitFor();
await row('folder/nested/renamed.md').focus(); await page.keyboard.press('Control+z');
await row('folder/nested/note.md').waitFor();
for (const rel of ['folder', 'folder/nested', 'other']) await expanded(rel);
await page.keyboard.press('Control+y'); await row('folder/nested/renamed.md').waitFor();
for (const rel of ['folder', 'folder/nested', 'other']) await expanded(rel);
await rename('folder', 'renamed-folder'); await row('renamed-folder/nested/renamed.md').waitFor();
await row('renamed-folder').focus(); await page.keyboard.press('Control+z');
await row('folder/nested/renamed.md').waitFor();
for (const rel of ['folder', 'folder/nested', 'other']) await expanded(rel);
await page.keyboard.press('Control+y'); await row('renamed-folder/nested/renamed.md').waitFor();
for (const rel of ['renamed-folder', 'renamed-folder/nested', 'other']) await expanded(rel);
await paneMenu(); assert.equal(await item('Manage templates…').isVisible(), false);
await item('New note').click(); await row('untitled.md').waitFor();
assert.equal(await page.evaluate(() => window.__TEST__.files.get('untitled.md')), '');
await paneMenu(); await item('New note').focus(); await page.keyboard.press('ArrowRight');
await item('Daily').click(); await row('Daily.md').waitFor();
assert.equal(await page.evaluate(() => window.__TEST__.files.get('Daily.md')), '# Daily\n\n## Tasks');
await paneMenu(); await item('New note').hover(); await item('Manage templates…').click();
await page.getByRole('button', { name: 'Close templates', exact: true }).click();
for (const mode of ['light', 'dark']) {
await setMode(page, mode);
await paneMenu(); await item('New note').focus(); await page.keyboard.press('ArrowRight');
await shot(page, `note-menu-${mode}.png`);
await page.keyboard.press('Escape'); await page.keyboard.press('Escape');
}
await page.setViewportSize({ width: 600, height: 600 });
// The side pane gives way below 800 pixels. The test opens it again.
await page.locator('aside.left').waitFor({ state: 'detached' });
await page.keyboard.press('Control+Backslash');
await page.locator('aside.left').waitFor();
await paneMenu(); await item('New note').focus(); await page.keyboard.press('ArrowRight');
await shot(page, 'note-menu-dark-narrow.png');
assert.ok(await item('Manage templates…').evaluate(node => node.getBoundingClientRect().right <= innerWidth));
await page.keyboard.press('Escape'); await page.keyboard.press('Escape');
await page.setViewportSize({ width: 1200, height: 850 });
await page.evaluate(() => { window.__TEST__.files.delete('.runestone/templates/Daily.md'); window.dispatchEvent(new Event('runestone-templates-changed')); });
await paneMenu(); await item('New note').focus(); await page.keyboard.press('ArrowRight');
assert.equal(await item('Daily').count(), 0);
await item('Manage templates…').click();
await page.getByRole('button', { name: 'Close templates', exact: true }).click();
const creations = await page.evaluate(() => window.__TEST__.calls.filter(call => call.command === 'workspace_create').length);
await paneMenu(); await item('New note').focus(); await page.keyboard.press('Enter');
await page.waitForFunction(count => window.__TEST__.calls.filter(call => call.command === 'workspace_create').length === count + 1, creations);
await page.getByRole('button', { name: 'Source control', exact: true }).waitFor();
assert.equal(await page.locator('.header-left').getByRole('button', { name: 'Source control', exact: true }).count(), 1);
// Git is a native feature: no plug-in menu lists it, and its graph command is in the command palette.
assert.equal(await page.getByRole('button', { name: 'Plug-in views', exact: true }).count(), 0);
// The new note keeps the focus in its name field. Move the focus out of it before the palette shortcut.
await page.evaluate(() => (document.activeElement instanceof HTMLElement) && document.activeElement.blur());
await page.keyboard.press('Control+Shift+P');
await page.getByRole('textbox', { name: 'Find a command', exact: true }).fill('Git graph');
const graph = page.locator('#command-results .rs-picker-row', { hasText: 'Show Git graph' });
await graph.waitFor();
assert.match(await graph.innerText(), /Git/);
await shot(page, 'real-git-command-dark.png');
await page.keyboard.press('Escape');
await page.evaluate(async () => {
const external = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name);
external.pluginNavigation.set([{ owner: 'pm-test', id: 'pm', title: 'Board fixture', icon: 'kanban', placement: 'editor', toolbar: true }, { owner: 'git-test', id: 'source', title: 'Source control', icon: 'git', placement: 'sidebar', toolbar: true }]);
external.pluginTools.set([{ owner: 'pm-test', id: 'pm', title: 'Board fixture', kind: 'view', surface: 'open' }, { owner: 'git-test', id: 'graph', title: 'Graph view', kind: 'command', surface: 'open', icon: 'git' }]);
external.pluginTools.update(items => [...items, { owner: 'runestone.browser', id: 'new-tab', title: 'New browser tab', kind: 'command', surface: 'open' }]);
const registry = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/registry.ts').name);
registry.pluginHost.get('browser').newTab = async () => { window.__TEST__.browserOpened = true; };
});
// The app tools are in the left ribbon. Plugin view shortcuts stay out of it in this test (src/lib/layout/PluginRibbon.svelte).
await page.locator('.plugin-ribbon').getByRole('button', { name: 'New browser tab', exact: true }).click();
assert.equal(await page.evaluate(() => window.__TEST__.browserOpened), true);
assert.equal(await page.locator('.plugin-ribbon .ribbon-tools').getByRole('button', { name: 'Board fixture', exact: true }).count(), 0);
assert.equal(await page.locator('.header-left').getByRole('button', { name: 'Source control', exact: true }).count(), 1);
assert.equal(await page.locator('.plugin-ribbon .ribbon-tools').getByRole('button', { name: 'Source control', exact: true }).count(), 0);
await page.getByRole('button', { name: 'Plug-in views', exact: true }).click();
assert.equal(await page.getByRole('menuitem', { name: /Board fixture/ }).count(), 1);
assert.equal(await page.getByRole('menuitem', { name: /New browser tab/ }).count(), 0);
await page.getByRole('menuitem', { name: /Graph view/ }).waitFor(); await page.keyboard.press('Escape');
for (const mode of ['light', 'dark']) {
await setMode(page, mode);
await page.getByRole('button', { name: 'Plug-in views', exact: true }).click();
await shot(page, `plugin-navigation-${mode}.png`);
await page.keyboard.press('Escape');
}
const token = '00000000-0000-4000-8000-000000000001';
const saved = await page.evaluate(token => {
const layout = JSON.stringify({ leftOpen: true, rightOpen: true, leftWidth: 280, rightWidth: 260, leftView: 'files' });
localStorage.setItem('runestone.workbenchLayout', layout);
void window.__TAURI_INTERNALS__.invoke('tab_transfer_offer', { id: token, root: 'C:\\host-todo-test', payload: JSON.stringify({ buffer: { id: 'moved', relPath: 'a.md', name: 'a.md', kind: 'text', contents: '# Transferred', saved: '# Note', chrome: 'Writing', pinned: true } }) });
return layout;
}, token);
const detached = await openPage(context, { timeout: 30000 });
await detached.goto(`${smokeUrl}/?tabTransfer=${token}`);
await detached.getByRole('tab', { name: /a.md/ }).waitFor();
await detached.getByText('# Transferred', { exact: true }).waitFor();
assert.equal(await detached.locator('.shell.left-open,.shell.right-open').count(), 0);
assert.equal(await detached.getByRole('button', { name: 'Show outline', exact: true }).count(), 0);
assert.equal(await detached.evaluate(() => localStorage.getItem('runestone.workbenchLayout')), saved);
assert.equal(await detached.getByRole('button', { name: 'Files', exact: true }).count(), 0);
await detached.keyboard.press('Control+Backslash');
await detached.keyboard.press('Control+Shift+f');
assert.equal(await detached.locator('aside.left,aside.right,.plugin-ribbon,.gutter-v').count(), 0);
await detached.keyboard.press('Escape');
assert.equal(await detached.evaluate(() => localStorage.getItem('runestone.workbenchLayout')), saved);
for (const mode of ['light', 'dark']) {
await setMode(detached, mode);
await detached.setViewportSize({ width: 650, height: 600 });
await shot(detached, `detached-${mode}-narrow.png`);
}
assert.deepEqual([...page.errors, ...detached.errors], []);
console.log('Host navigation passed: nested file/folder rename undo/redo, expanded folders, blank New note parent, template submenu, plugin navigation dedup, detached layout isolation.');
});