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.
50 lines
3.1 KiB
JavaScript
50 lines
3.1 KiB
JavaScript
// The empty tab background image: set it in Settings, keep it after a reload, remove it, and leave Reset background disabled.
|
|
import assert from "node:assert/strict";
|
|
import path from "node:path";
|
|
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
|
|
|
const name = "appearance/newTabBackground";
|
|
await runSmoke(name, async ({ browser }) => {
|
|
const output = await outputDir(name);
|
|
// The settings window changes the main window through the mock settings file and shared IndexedDB, so both pages need one context.
|
|
const context = await browser.newContext({ viewport: { width: 1200, height: 850 } });
|
|
await mockTauri(context, {
|
|
commands: test => ({
|
|
...test.workspace({ root: "C:\\new-tab-background", files: { "a.md": "# Note\n\nOriginal text." } }),
|
|
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
|
|
spelling_menu_install: () => null,
|
|
}),
|
|
});
|
|
const page = await openPage(context);
|
|
await page.goto(smokeUrl);
|
|
await page.locator('[data-tree-rel="a.md"]').waitFor();
|
|
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
|
|
await page.locator(".empty").waitFor();
|
|
const settings = await openPage(context);
|
|
await settings.goto(smokeUrl + "/?settingsWindow=true");
|
|
await settings.getByRole("button", { name: "Appearance", exact: true }).click();
|
|
const png = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jM1sAAAAASUVORK5CYII=", "base64");
|
|
// The image now lives on the work area layer behind the empty tab (src/lib/layout/Workbench.svelte:1258, :1543-1549).
|
|
const layer = ".workarea-background";
|
|
await settings.getByLabel("Background image file", { exact: true }).setInputFiles({ name: "test.png", mimeType: "image/png", buffer: png });
|
|
await page.waitForFunction(layer => getComputedStyle(document.querySelector(layer)).backgroundImage.includes("blob:"), layer);
|
|
await page.reload();
|
|
await page.locator(".empty").waitFor();
|
|
assert.ok(await page.locator(layer).evaluate(node => getComputedStyle(node).backgroundImage.includes("blob:")), "Background survives restart");
|
|
await settings.getByRole("button", { name: "Remove image", exact: true }).click();
|
|
await page.waitForFunction(layer => getComputedStyle(document.querySelector(layer)).backgroundImage === "none", layer);
|
|
for (const mode of ["light", "dark"]) {
|
|
await settings.evaluate(async mode => {
|
|
const { saveAppearance, readAppearance } = await import("/src/lib/theme/appearance.ts");
|
|
saveAppearance({ ...readAppearance(), theme: "default", mode });
|
|
window.dispatchEvent(new Event("focus"));
|
|
}, mode);
|
|
await settings.setViewportSize({ width: 650, height: 760 });
|
|
await settings.screenshot({ path: path.join(output, `appearance-${mode}-narrow.png`) });
|
|
}
|
|
assert.equal(await settings.getByRole("button", { name: "Reset background", exact: true }).isDisabled(), true);
|
|
await page.waitForFunction(() => !window.__TEST__.settings("appearance").newTabBackground);
|
|
assert.deepEqual([...page.errors, ...settings.errors], []);
|
|
console.log("PASS: background image applies, survives a reload, and is removed; Reset background is disabled");
|
|
});
|