Update editor, workspace, Git services, appearance, and project guides
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { mockFeaturePlugins } from "./pluginMocks.mjs";
|
||||
// Run against `pnpm dev`. PLAYWRIGHT_MODULE may point to a shared installation.
|
||||
import { createRequire } from "node:module";
|
||||
import assert from "node:assert/strict";
|
||||
@@ -70,6 +71,8 @@ await page.addInitScript(() => {
|
||||
window.__TEST__ = { files, calls, emit, root };
|
||||
});
|
||||
|
||||
await mockFeaturePlugins(page);
|
||||
|
||||
async function quickOpen(name) {
|
||||
await page.keyboard.press("Control+p");
|
||||
await page.getByRole("textbox", { name: "Find a file" }).fill(name);
|
||||
@@ -286,6 +289,65 @@ try {
|
||||
assert.equal(await edit.count(), 0);
|
||||
assert.equal(await page.locator('.live-writer .cm-content').evaluate(el => el === document.activeElement), true);
|
||||
|
||||
// Focusing empty and filled cells must not resize rows or columns.
|
||||
const stableSource = '# Stable table\n\n| Column 2 | Column 1 | | |\n| --- | --- | --- | --- |\n| 2cm | Value | | |\n| text | 123 | | |\n| | | | |\n| LongUnbrokenCellValue | **Bold**<br>Two lines | A longer sentence wraps in a narrow table. | `code` |\n\nParagraph one.\nParagraph two.\n';
|
||||
const dimensions = () => table.evaluate(el => [...el.rows].map(row => [...row.cells].map(cell => {
|
||||
const rect = cell.getBoundingClientRect();
|
||||
return { width: rect.width, height: rect.height };
|
||||
})));
|
||||
async function stableDimensions(expected, label) {
|
||||
const actual = await dimensions();
|
||||
for (let r = 0; r < expected.length; r++) for (let c = 0; c < expected[r].length; c++) {
|
||||
for (const axis of ['width', 'height']) assert.ok(Math.abs(expected[r][c][axis] - actual[r][c][axis]) < 1,
|
||||
`${label}: row ${r}, column ${c} ${axis} changed from ${expected[r][c][axis]} to ${actual[r][c][axis]}`);
|
||||
}
|
||||
}
|
||||
for (const theme of ['dark', 'light']) for (const width of [1440, 800]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
await page.evaluate(theme => { document.documentElement.dataset.theme = theme; }, theme);
|
||||
const name = `stable-${theme}-${width}.md`;
|
||||
await page.evaluate(({ name, text }) => {
|
||||
window.__TEST__.files.set(name, text);
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: [name] });
|
||||
}, { name, text: stableSource });
|
||||
await quickOpen(name);
|
||||
await table.waitFor();
|
||||
const initial = await dimensions();
|
||||
for (const [r, c] of [[1, 3], [2, 3], [3, 3], [0, 0], [1, 0], [1, 1], [4, 0], [4, 1], [4, 2], [4, 3], [2, 1]]) {
|
||||
await at(r, c);
|
||||
await stableDimensions(initial, `${theme} ${width} focus ${r},${c}`);
|
||||
}
|
||||
await arrow('Tab', 2, 2);
|
||||
await stableDimensions(initial, `${theme} ${width} Tab`);
|
||||
await arrow('ArrowDown', 3, 2);
|
||||
await stableDimensions(initial, `${theme} ${width} ArrowDown`);
|
||||
await page.keyboard.press('Escape');
|
||||
await stableDimensions(initial, `${theme} ${width} blur`);
|
||||
|
||||
// Delete the blank line through the prose editor, then save and undo/redo.
|
||||
await page.locator('.cm-line').filter({ hasText: 'Paragraph one.' }).click();
|
||||
await page.keyboard.press('Home');
|
||||
await page.keyboard.press('Backspace');
|
||||
await page.waitForFunction(() => document.querySelectorAll('.live-writer table tr').length === 5 &&
|
||||
[...document.querySelectorAll('.cm-line')].some(line => line.textContent === 'Paragraph one.'));
|
||||
await page.keyboard.press('Control+s');
|
||||
const joined = stableSource.replace('\n\nParagraph one.', '\nParagraph one.');
|
||||
await page.waitForFunction(({ name, joined }) => window.__TEST__.files.get(name) === joined, { name, joined });
|
||||
await page.keyboard.press('Control+z');
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(({ name, source }) => window.__TEST__.files.get(name) === source, { name, source: stableSource });
|
||||
await page.keyboard.press('Control+y');
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(({ name, joined }) => window.__TEST__.files.get(name) === joined, { name, joined });
|
||||
assert.equal(await table.locator('tr').count(), 5);
|
||||
await at(1, 0);
|
||||
await edit.fill('updated');
|
||||
await page.keyboard.press('Escape');
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(({ name, joined }) => window.__TEST__.files.get(name) === joined.replace('| 2cm |', '| updated |'), { name, joined });
|
||||
}
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
|
||||
// A line break in a tall table keeps the caret and viewport in the active cell.
|
||||
const tallSource = '# Tall table\n\nBefore.\n\n| Name | Value |\n| --- | --- |\n' +
|
||||
Array.from({ length: 45 }, (_, i) => `| Row ${i + 1} | |`).join('\n') + '\n\nAfter.\n';
|
||||
@@ -342,7 +404,7 @@ try {
|
||||
await page.waitForFunction(({ name, expected }) => window.__TEST__.files.get(name) === expected, { name, expected });
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: arrows, caret positions, row wrapping, empty/formula/header cells, entry/exit in all directions, goal columns, document boundaries, text selection, word movement, multiline/wrapped text, line breaks and scrolling in tall tables, save, undo/redo, Tab and Escape');
|
||||
console.log('PASS: arrows, caret positions, row wrapping, empty/formula/header cells, entry/exit in all directions, goal columns, document boundaries, text selection, word movement, multiline/wrapped text, line breaks and scrolling in tall tables, save, undo/redo, Tab and Escape, stable cell dimensions and table/prose boundaries in both themes at wide/narrow widths');
|
||||
} catch (error) {
|
||||
await page.screenshot({ path: '.audit/table-navigation-failure.png' });
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user