Phase 5-2. - Ctrl+Shift+P opens the command palette: every workbench command with its shortcut, then the plugin commands (UI-048). - In Write, Ctrl+B, Ctrl+I, Ctrl+Shift+X, and Ctrl+Shift+H format the selection, and Ctrl+K inserts a Markdown link. The Format menu shows these shortcuts. - Ctrl+\ toggles the side pane. It matches the physical key on every keyboard layout. Ctrl+B now belongs to Write. - Help lists every shortcut in groups, open by default. The list comes from the command table. - src/lib/ui/shortcuts.ts writes shortcut labels for the platform: Ctrl+Shift+P on Windows and Linux, and the macOS symbols on a Mac. The catalog uses placeholders, so no translation contains "Ctrl". - 19 new catalog rows, and 10 rows converted to placeholders, in French, Japanese, and Simplified Chinese. - Docs: UI-048, the user guide keyboard tables, and a label rule in ui-design.md. New tests: layout/commands, tests/unit/ui/shortcuts.spec.ts, and new cases in workbenchKeys.spec.ts. Tests that read the old labels or pressed Ctrl+B for the side pane now use the new names and Ctrl+\. The smoke harness raises the resource timing buffer to 5000 entries. The new modules pushed the CodeMirror language module past the default 250 entries, so editor/markdownPaste could not find its URL.
80 lines
4.0 KiB
JavaScript
80 lines
4.0 KiB
JavaScript
// Sidebar layout persistence: the hidden outline, resized sidebars, and the navigation view survive layout changes, reloads, and reopened windows.
|
|
import assert from "node:assert/strict";
|
|
import { mockTauri, openPage, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
|
|
|
await runSmoke("layout/outline", async ({ browser }) => {
|
|
// Pages share one context, so a reopened window keeps the saved layout.
|
|
const context = await browser.newContext({ viewport: { width: 1280, height: 800 } });
|
|
// Unknown commands return null, as the original mock did.
|
|
await mockTauri(context, {
|
|
strict: false,
|
|
commands: test => ({
|
|
...test.workspace({ root: "D:\\LayoutTest", files: { "note.md": "# Layout test\n\nA note.\n" } }),
|
|
plugins_snapshot: () => ({ root: "D:\\LayoutTest\\plugins", plugins: [] }),
|
|
}),
|
|
});
|
|
const errors = [];
|
|
let page;
|
|
async function ready() { await page.getByRole("button", { name: /^(Hide|Show) outline$/ }).waitFor(); }
|
|
async function reopen() {
|
|
if (page) { errors.push(...page.errors); await page.close(); }
|
|
page = await openPage(context, { timeout: 5000 });
|
|
await page.goto(smokeUrl);
|
|
await ready();
|
|
}
|
|
async function resize(index, x) {
|
|
const box = await page.locator(".gutter-v").nth(index).boundingBox();
|
|
await page.mouse.move(box.x + box.width / 2, box.y + 60);
|
|
await page.mouse.down();
|
|
await page.mouse.move(x, box.y + 60);
|
|
await page.mouse.up();
|
|
}
|
|
async function widths() {
|
|
return page.locator(".shell").evaluate(element => [element.style.getPropertyValue("--left"), element.style.getPropertyValue("--right")]);
|
|
}
|
|
await reopen();
|
|
await page.getByText("LayoutTest", { exact: true }).waitFor();
|
|
await page.keyboard.press("Control+p");
|
|
await page.getByRole("textbox", { name: "Find a file" }).fill("note.md");
|
|
await page.getByRole("dialog").getByRole("button").filter({ hasText: "note.md" }).click();
|
|
await page.locator(".cm-content").waitFor();
|
|
await page.getByRole("button", { name: "Hide outline", exact: true }).click();
|
|
await page.keyboard.press("Control+e");
|
|
await page.locator(".source-editor .cm-content").waitFor();
|
|
assert.equal(await page.locator(".right").count(), 0);
|
|
await page.keyboard.press("Control+e");
|
|
await page.locator(".cm-content").waitFor();
|
|
assert.equal(await page.locator(".right").count(), 0);
|
|
console.log("PASS: hidden outline stays hidden across Writer and IDE changes");
|
|
await page.reload();
|
|
await page.getByRole("button", { name: "Show outline", exact: true }).waitFor();
|
|
assert.equal(await page.locator(".right").count(), 0);
|
|
await reopen();
|
|
await page.getByRole("button", { name: "Show outline", exact: true }).waitFor();
|
|
console.log("PASS: hidden outline survives reload and window reopen");
|
|
|
|
await page.getByRole("button", { name: "Show outline", exact: true }).click();
|
|
await resize(0, 330);
|
|
await resize(1, 970);
|
|
const resized = await widths();
|
|
assert.deepEqual(resized, ["330px", "310px"]);
|
|
await page.getByRole("button", { name: "Bookmarks", exact: true }).click();
|
|
await reopen();
|
|
assert.deepEqual(await widths(), resized);
|
|
assert.equal(await page.getByRole("button", { name: "Bookmarks", exact: true }).getAttribute("aria-pressed"), "true");
|
|
await page.getByRole("button", { name: "Hide outline", exact: true }).waitFor();
|
|
console.log("PASS: resized sidebars and chosen navigation view survive reopen");
|
|
|
|
await page.getByRole("button", { name: "Bookmarks", exact: true }).click();
|
|
await page.getByRole("button", { name: "Hide outline", exact: true }).click();
|
|
await reopen();
|
|
assert.equal(await page.locator(".left, .right").count(), 0);
|
|
await page.keyboard.press("Control+Backslash");
|
|
assert.equal(await page.getByRole("button", { name: "Bookmarks", exact: true }).getAttribute("aria-pressed"), "true");
|
|
await page.getByRole("button", { name: "Show outline", exact: true }).click();
|
|
assert.deepEqual(await widths(), resized);
|
|
console.log("PASS: collapsed sidebars retain their sizes and navigation view");
|
|
errors.push(...page.errors);
|
|
assert.deepEqual(errors, []);
|
|
});
|