Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -25,6 +25,7 @@ await page.addInitScript(() => {
|
||||
if (command === "plugin:event|listen") { listeners.set(args.event, args.handler); return ++sequence; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("spelling_menu_")) { window.spellingTest.commands.push({ method: command, ...args }); return; }
|
||||
if (command === "spelling_suggestions") return { language: "en-US", words: [], misspelled: false };
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
@@ -70,13 +71,36 @@ try {
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await page.evaluate(async mode => {
|
||||
const { saveAppearance } = await import('/src/lib/theme/appearance.ts');
|
||||
saveAppearance({ theme: 'default', mode });
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 800; canvas.height = 600;
|
||||
const context = canvas.getContext('2d');
|
||||
const gradient = context.createLinearGradient(0, 0, 800, 600);
|
||||
gradient.addColorStop(0, '#628ba8'); gradient.addColorStop(1, '#b47796');
|
||||
context.fillStyle = gradient; context.fillRect(0, 0, 800, 600);
|
||||
saveAppearance({ theme: 'default', mode, newTabBackground: { image: canvas.toDataURL(), overlay: 0.15, position: 'center', size: 'cover' } });
|
||||
}, theme);
|
||||
await row.focus();
|
||||
await row.click({ button: "right" });
|
||||
const file = menu("File actions");
|
||||
await file.waitFor();
|
||||
const reference = await metrics(file);
|
||||
assert.equal(reference.row[1], "24px", "Menus use compact shared rows");
|
||||
assert.equal(reference.row[0], "2px 10px");
|
||||
const compactHeight = await file.evaluate(node => node.getBoundingClientRect().height);
|
||||
await page.evaluate(() => {
|
||||
document.documentElement.style.setProperty('--rs-menu-row-height', '30px');
|
||||
document.documentElement.style.setProperty('--rs-menu-row-padding', '4px 10px');
|
||||
});
|
||||
const previousHeight = await file.evaluate(node => node.getBoundingClientRect().height);
|
||||
await page.screenshot({ path: '.audit/todo-2026-10-14/menu-spacing-before-' + theme + '.png' });
|
||||
await page.evaluate(() => {
|
||||
document.documentElement.style.removeProperty('--rs-menu-row-height');
|
||||
document.documentElement.style.removeProperty('--rs-menu-row-padding');
|
||||
});
|
||||
assert.ok(compactHeight < previousHeight * .85, 'The same actions use at least 15% less vertical space');
|
||||
console.log(JSON.stringify({ theme, compactHeight, previousHeight }));
|
||||
await page.screenshot({ path: '.audit/todo-2026-10-14/menu-spacing-after-' + theme + '.png' });
|
||||
assert.ok(reference.panel[2].includes('/ 0.82') || /rgba\(.+, 0\.82\)/.test(reference.panel[2]), "Shared menus retain an 82% surface tint");
|
||||
assert.ok(reference.inset >= 5, "Rows need an inset from the panel border");
|
||||
assert.equal(await item("Pin").locator("svg.action-icon").count(), 1);
|
||||
const offsets = await file.locator(":scope > button").evaluateAll(nodes => nodes.map(node => Math.round(node.querySelector(".action-label").getBoundingClientRect().left - node.getBoundingClientRect().left)));
|
||||
@@ -131,6 +155,20 @@ try {
|
||||
return { x: bounds.left + bounds.width / 2, y: bounds.top + bounds.height / 2 };
|
||||
});
|
||||
await page.mouse.click(wordPoint.x, wordPoint.y, { button: "right" });
|
||||
await editor.waitFor();
|
||||
assert.deepEqual(await metrics(editor), reference, "Word and blank-space menus share styles");
|
||||
assert.equal(await item("Format").count(), 1, "Words retain the Markdown actions");
|
||||
await dismiss();
|
||||
await page.evaluate(() => {
|
||||
const input = document.createElement("input");
|
||||
input.id = "native-spelling-test";
|
||||
input.spellcheck = true;
|
||||
input.value = "Original";
|
||||
Object.assign(input.style, { position: "fixed", left: "500px", top: "100px" });
|
||||
document.body.append(input);
|
||||
input.focus();
|
||||
input.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true }));
|
||||
});
|
||||
await page.evaluate(() => window.spellingTest.emit({ request: "spelling-1", items: [
|
||||
{ id: 71, name: "suggestion", label: "Original", shortcut: "", kind: 0, enabled: true, checked: false, children: [] },
|
||||
{ id: 72, name: "addToDictionary", label: "Add to dictionary", shortcut: "", kind: 0, enabled: true, checked: false, children: [] },
|
||||
@@ -152,7 +190,7 @@ try {
|
||||
await page.keyboard.press("Enter");
|
||||
await spelling.waitFor({ state: "detached" });
|
||||
assert.deepEqual(await page.evaluate(() => window.spellingTest.commands.at(-1)), { method: "spelling_menu_select", request: "spelling-1", command: 71 });
|
||||
assert.equal(await page.locator(".cm-content").evaluate(node => node === document.activeElement), true);
|
||||
assert.equal(await page.locator("#native-spelling-test").evaluate(node => node === document.activeElement), true);
|
||||
async function emitSpelling(request) {
|
||||
await page.evaluate(request => window.spellingTest.emit({ request, items: [
|
||||
{ id: 81, name: "suggestion", label: "Replacement", shortcut: "", kind: 0, enabled: true, checked: false, children: [] },
|
||||
@@ -170,6 +208,7 @@ try {
|
||||
await emitSpelling("new");
|
||||
assert.deepEqual(await page.evaluate(() => window.spellingTest.commands.at(-1)), { method: "spelling_menu_select", request: "old", command: null });
|
||||
await dismiss();
|
||||
await page.locator("#native-spelling-test").evaluate(node => node.remove());
|
||||
await page.evaluate(() => {
|
||||
const input = document.createElement("input");
|
||||
input.spellcheck = false;
|
||||
@@ -216,6 +255,35 @@ try {
|
||||
assert.equal(await item("Action 29").evaluate(node => node === document.activeElement), true);
|
||||
await page.screenshot({ path: ".audit/menu-edge.png" });
|
||||
await dismiss();
|
||||
await page.evaluate(async () => {
|
||||
const { actionMenu } = await import("/src/lib/ui/actionMenu.ts");
|
||||
const dialog = document.createElement("dialog");
|
||||
dialog.id = "menu-modal-test";
|
||||
dialog.style.cssText = "height:220px;width:320px;overflow:auto";
|
||||
const content = document.createElement("div");
|
||||
content.style.height = "600px";
|
||||
dialog.append(content);
|
||||
document.body.append(dialog);
|
||||
dialog.showModal();
|
||||
dialog.scrollTop = 160;
|
||||
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
||||
window.menuModalScroll = dialog.scrollTop;
|
||||
const root = actionMenu(180, 280, Array.from({ length: 30 }, (_, index) => ({ label: `Modal action ${index}`, icon: "copy" })), () => root.remove(), "Modal scrolling test", dialog);
|
||||
const dismissOnAncestorScroll = event => { if (!root.contains(event.target)) root.remove(); };
|
||||
dialog.addEventListener("scroll", dismissOnAncestorScroll, true);
|
||||
});
|
||||
await page.keyboard.press("End");
|
||||
const modalMenu = menu("Modal scrolling test");
|
||||
await modalMenu.waitFor();
|
||||
assert.equal(await item("Modal action 29").evaluate(node => node === document.activeElement), true);
|
||||
assert.equal(await page.locator("#menu-modal-test").evaluate(dialog => dialog.scrollTop), await page.evaluate(() => window.menuModalScroll), "Keyboard traversal scrolls only the menu panel");
|
||||
const modalBounds = await modalMenu.boundingBox(), lastBounds = await item("Modal action 29").boundingBox();
|
||||
assert.ok(lastBounds.y >= modalBounds.y && lastBounds.y + lastBounds.height <= modalBounds.y + modalBounds.height + 1, "End keeps the last row visible inside a short modal");
|
||||
await page.screenshot({ path: ".audit/menu-modal-end.png" });
|
||||
await page.keyboard.press("Home");
|
||||
assert.equal(await item("Modal action 0").evaluate(node => node === document.activeElement), true);
|
||||
await dismiss();
|
||||
await page.locator("#menu-modal-test").evaluate(dialog => { dialog.close(); dialog.remove(); });
|
||||
assert.deepEqual(errors, []);
|
||||
console.log("PASS: menu styles, dark/light themes, icons, disabled rows, focus return, submenus, scrolling, and viewport edges");
|
||||
} finally { await browser.close(); }
|
||||
|
||||
Reference in New Issue
Block a user