RuneStone 1.0.0

This commit is contained in:
Knotty Wyvern
2026-11-16 04:21:21 -07:00
commit b52eeb14a1
827 changed files with 241421 additions and 0 deletions
+153
View File
@@ -0,0 +1,153 @@
// Table cell selection: drag and Shift-click ranges, keyboard ranges, and clearing or deleting cells, rows, columns, and tables, in both themes and a narrow window.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("tables/selection", async ({ page }) => {
const output = await outputDir("tables/selection");
await mockTauri(page, {
commands: test => ({
...test.workspace({ root: "C:\\smoke-workspace", files: { "notes/welcome.md": "---\ntitle: Welcome\n---\n\n# Working notes\n\nFirst paragraph.\n\n- [ ] A task\n\n[[second]]\n" }, writeEvents: true }),
spelling_menu_install: () => null,
}),
});
await page.goto(smokeUrl);
await page.getByText('smoke-workspace', { exact: true }).waitFor();
await page.keyboard.press('Control+p');
await page.getByRole('textbox', { name: 'Find a file' }).fill('welcome.md');
await page.getByRole('dialog').getByRole('button').filter({ hasText: 'welcome.md' }).first().click();
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
await page.evaluate(async () => {
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
window.__CM__ = EditorView.findFromDOM(document.querySelector('.cm-content'));
});
const source = '# Table selection\n\n| Name | Value | Notes |\n| --- | :---: | ---: |\n| Alpha | 10 | First |\n| Beta | 20 | Second |\n| Gamma | 30 | Third |\n\nAfter.\n';
const table = page.locator('.live-writer table');
const cell = (r,c) => table.locator('tr').nth(r).locator('th,td').nth(c);
const selected = table.locator('.is-cell-selected');
async function reset() {
await page.evaluate(source => window.__CM__.dispatch({ changes: { from: 0, to: window.__CM__.state.doc.length, insert: source }, selection: { anchor: 0 } }), source);
await table.waitFor();
}
const contents = () => page.evaluate(() => window.__CM__.state.sliceDoc());
const shot = name => page.screenshot({ path: path.join(output, `${name}.png`) });
async function drag(r,c,r2,c2) {
const start = await cell(r,c).boundingBox(), end = await cell(r2,c2).boundingBox();
await page.mouse.move(start.x+start.width/2,start.y+start.height/2);
await page.mouse.down();
await page.mouse.move(end.x+end.width/2,end.y+end.height/2,{steps:8});
await page.mouse.up();
}
await reset();
await drag(1,0,2,1);
assert.equal(await selected.count(),4);
assert.deepEqual(await selected.evaluateAll(cells => cells.map(c => c.getAttribute('data-selection-edges'))),['top left','top right','bottom left','bottom right']);
await page.keyboard.press('Delete');
assert.ok((await contents()).includes('| First | | |\n| Second | | |'));
assert.equal(await selected.count(),1);
await page.keyboard.press('Control+z');
await page.waitForFunction(source => window.__CM__.state.sliceDoc() === source,source);
await drag(2,1,1,0);
await page.keyboard.press('Backspace');
assert.ok((await contents()).includes('| First | | |\n| Second | | |'));
await reset();
await drag(1,0,2,1);
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Clear cells',exact:true}).click();
assert.equal(await contents(),source.replace('Alpha','').replace('10','').replace('Beta','').replace('20',''));
assert.equal(await selected.count(),4);
await reset();
await cell(1,0).click();
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Select cell',exact:true}).click();
assert.equal(await selected.count(),1);
await page.keyboard.press('Shift+ArrowRight');
await page.keyboard.press('Shift+ArrowDown');
assert.equal(await selected.count(),4);
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Delete cells',exact:true}).click();
assert.ok((await contents()).includes('| First | | |\n| Second | | |'));
await reset();
await cell(1,0).click();
await cell(2,2).click({modifiers:['Shift']});
assert.equal(await selected.count(),6);
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Delete cells',exact:true}).click();
assert.equal(await table.locator('tr').count(),2);
assert.ok((await contents()).includes('Gamma'));
await reset();
await drag(0,1,3,1);
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Delete cells',exact:true}).click();
assert.equal(await table.locator('th').count(),2);
assert.ok(!(await contents()).includes('Value'));
const emptyColumns = '# Empty columns\n\n| Column 2 | Column 1 | | | | |\n| --- | --- | --- | --- | --- | --- |\n| 2cm | Value | | | | |\n| text | 123 | | | | |\n| | | | | | |\n| | | | | | |\n\nAfter.\n';
for (const theme of ['light','dark']) for (const width of [1440,760]) {
await page.setViewportSize({width,height:900});
await page.evaluate(async theme => { const {applyAppearance} = await import('/src/lib/theme/appearance.ts'); applyAppearance({theme:'default',mode:theme}); },theme);
await reset();
await cell(0,1).click();
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Select cell',exact:true}).click();
await page.keyboard.press('Shift+ArrowRight');
for (let row = 0; row < 3; row++) await page.keyboard.press('Shift+ArrowDown');
assert.equal(await selected.count(),8);
assert.ok(await selected.evaluateAll(cells => cells.every(c => getComputedStyle(c).borderRadius === '0px')));
await shot(`selection-${theme}-${width}`);
await page.keyboard.press('Shift+F10');
await shot(`menu-${theme}-${width}`);
await page.keyboard.press('Escape');
assert.equal(await page.locator('.writer-table').evaluate(el => document.activeElement === el),true);
await page.evaluate(source => window.__CM__.dispatch({ changes: { from: 0, to: window.__CM__.state.doc.length, insert: source }, selection: { anchor: 0 } }), emptyColumns);
await table.waitFor();
await cell(0,0).click();
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Select cell',exact:true}).click();
for (let col = 0; col < 3; col++) await page.keyboard.press('ArrowRight');
for (let col = 0; col < 2; col++) await page.keyboard.press('Shift+ArrowRight');
for (let row = 0; row < 4; row++) await page.keyboard.press('Shift+ArrowDown');
assert.equal(await selected.count(),15);
await shot(`empty-columns-selected-${theme}-${width}`);
await page.keyboard.press('Delete');
assert.equal(await table.locator('th').count(),3);
assert.equal(await table.locator('tr').count(),5);
assert.equal(await selected.count(),1);
assert.ok((await contents()).includes('| 2cm | Value | |'));
await shot(`empty-columns-deleted-${theme}-${width}`);
await page.keyboard.press('Control+z');
await page.waitForFunction(source => window.__CM__.state.sliceDoc() === source,emptyColumns);
await cell(0,0).click();
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Select cell',exact:true}).click();
for (let col = 0; col < 3; col++) await page.keyboard.press('ArrowRight');
for (let col = 0; col < 2; col++) await page.keyboard.press('Shift+ArrowRight');
for (let row = 0; row < 4; row++) await page.keyboard.press('Shift+ArrowDown');
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Delete cells',exact:true}).click();
assert.equal(await table.locator('th').count(),3);
await reset();
await cell(2,0).click();
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Select cell',exact:true}).click();
await page.keyboard.press('Shift+ArrowRight');
await page.keyboard.press('Shift+ArrowRight');
await page.keyboard.press('Shift+ArrowDown');
await page.keyboard.press('Backspace');
assert.equal(await table.locator('tr').count(),2);
assert.ok((await contents()).includes('Alpha'));
assert.ok(!(await contents()).includes('Beta'));
await reset();
await cell(0,0).click();
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Select cell',exact:true}).click();
await page.keyboard.press('Shift+ArrowRight');
await page.keyboard.press('Shift+ArrowRight');
await page.keyboard.press('Delete');
assert.equal(await table.locator('th').first().innerText(),'Alpha');
await page.keyboard.press('Control+a');
await page.keyboard.press('Shift+F10');
await page.getByRole('menuitem',{name:'Delete cells',exact:true}).click();
assert.equal(await table.count(),0);
assert.ok((await contents()).includes('After.'));
}
});