Add the command palette, Write formatting keys, and platform labels
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.
This commit is contained in:
@@ -95,7 +95,8 @@ export function settle(page) {
|
||||
*/
|
||||
export function mockTauri(target, { label = "main", state = {}, commands, strict = true } = {}) {
|
||||
const options = JSON.stringify({ label, state, strict });
|
||||
return target.addInitScript(`(${installMock})(${options}, ${commands ? commands.toString() : "undefined"});`);
|
||||
// Tests find module URLs in the resource entries. The default buffer of 250 entries is too small for the app.
|
||||
return target.addInitScript(`performance.setResourceTimingBufferSize(5000); (${installMock})(${options}, ${commands ? commands.toString() : "undefined"});`);
|
||||
}
|
||||
|
||||
// This function runs in the page. Keep it self-contained.
|
||||
|
||||
@@ -123,9 +123,10 @@ await runSmoke('appearance/backgroundImages', async ({ browser }) => {
|
||||
await main.setViewportSize({ width: 600, height: 700 });
|
||||
await main.keyboard.press('F1');
|
||||
await main.getByRole('dialog', { name: 'Help and about' }).waitFor();
|
||||
assert.equal(await main.locator('.help-card details[open]').count(), 0);
|
||||
await main.locator('.help-card summary').first().focus(); await main.keyboard.press('Enter');
|
||||
// The shortcut list is open by default (src/lib/layout/SettingsDialog.svelte).
|
||||
assert.equal(await main.locator('.help-card details[open]').count(), 1);
|
||||
await main.locator('.help-card summary').first().focus(); await main.keyboard.press('Enter');
|
||||
assert.equal(await main.locator('.help-card details[open]').count(), 2);
|
||||
await main.keyboard.press('Enter');
|
||||
await main.screenshot({ path: `${output}/help-${theme}-narrow.png` });
|
||||
await main.getByRole('button', { name: 'Close help', exact: true }).click();
|
||||
|
||||
@@ -24,7 +24,7 @@ await runSmoke("appearance/colorThemeMenu", async ({ browser }) => {
|
||||
await settings.waitForFunction(() => document.documentElement.dataset.palette === "claude");
|
||||
assert.equal(await settings.evaluate(() => document.documentElement.dataset.palette), "claude");
|
||||
assert.equal(await settings.locator("input[type=color]").count(), 0);
|
||||
await page.getByRole("button", { name: "New tab (Ctrl T)", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
|
||||
await page.locator(".empty").waitFor();
|
||||
await page.waitForFunction(() => document.documentElement.dataset.palette === "claude");
|
||||
// The empty tab is transparent over the work area layer, which paints the theme background (src/lib/layout/Workbench.svelte:1258, :1548).
|
||||
|
||||
@@ -18,7 +18,7 @@ await runSmoke(name, async ({ browser }) => {
|
||||
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.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");
|
||||
|
||||
@@ -60,7 +60,7 @@ await runSmoke("appearance/tooltipsAndSelection", async ({ page }) => {
|
||||
assert.equal(colors.pluginBg.trim(), "transparent");
|
||||
console.log(mode, colors);
|
||||
await page.screenshot({ path: path.join(output, `${mode}-selection.png`) });
|
||||
await page.getByRole("button", { name: "New tab (Ctrl T)", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
|
||||
await page.locator(".empty").waitFor();
|
||||
await page.screenshot({ path: path.join(output, `${mode}-zero-background.png`) });
|
||||
await page.getByRole("tab", { name: /welcome\.md/ }).click();
|
||||
|
||||
@@ -35,14 +35,14 @@ await runSmoke("editor/emptyMenu", async ({ page }) => {
|
||||
await setSource('');
|
||||
await page.locator('.cm-line').first().click({button:'right'});
|
||||
await menu().waitFor();
|
||||
for (const label of ['Add link','Add external link','Format','Paragraph','Insert','Paste Ctrl+V','Paste as plain text','Select all Ctrl+A']) assert.equal(await menu().getByRole('menuitem', {name:label,exact:true}).count(),1,label);
|
||||
for (const label of ['Add link','Add external link Ctrl+K','Format','Paragraph','Insert','Paste Ctrl+V','Paste as plain text','Select all Ctrl+A']) assert.equal(await menu().getByRole('menuitem', {name:label,exact:true}).count(),1,label);
|
||||
assert.equal(await menu().getByRole('menuitem',{name:'Cut Ctrl+X',exact:true}).isDisabled(),true);
|
||||
assert.equal(await menu().getByRole('menuitem',{name:'Copy Ctrl+C',exact:true}).isDisabled(),true);
|
||||
await page.screenshot({path:`${output}/empty-${theme}.png`});
|
||||
await menu().getByRole('menuitem',{name:'Format',exact:true}).focus();
|
||||
await page.keyboard.press('ArrowRight');
|
||||
const format = page.getByRole('menu',{name:'Format',exact:true});
|
||||
for (const label of ['Bold','Italic','Strikethrough','Highlight','Code','Math','Comment','Clear formatting']) assert.equal(await format.getByRole('menuitem',{name:label,exact:true}).count(),1);
|
||||
for (const label of ['Bold Ctrl+B','Italic Ctrl+I','Strikethrough Ctrl+Shift+X','Highlight Ctrl+Shift+H','Code','Math','Comment','Clear formatting']) assert.equal(await format.getByRole('menuitem',{name:label,exact:true}).count(),1);
|
||||
await page.keyboard.press('End');
|
||||
assert.equal(await page.getByRole('menuitem',{name:'Comment',exact:true}).evaluate(el=>el===document.activeElement),true);
|
||||
await page.screenshot({path:`${output}/format-${theme}.png`});
|
||||
@@ -59,12 +59,12 @@ await runSmoke("editor/emptyMenu", async ({ page }) => {
|
||||
await page.getByRole('menu',{name:'Insert',exact:true}).getByRole('menuitem',{name:'Code block',exact:true}).click();
|
||||
assert.match(await source(),/^```\nCode\n```/);
|
||||
await setSource(''); await openKeyboard();
|
||||
await menu().getByRole('menuitem',{name:'Add external link',exact:true}).click();
|
||||
await menu().getByRole('menuitem',{name:'Add external link Ctrl+K',exact:true}).click();
|
||||
assert.equal(await source(),'[]()');
|
||||
assert.equal(await page.evaluate(()=>window.__CM__.state.selection.main.head),1);
|
||||
assert.equal(await page.getByRole('dialog').count(),0);
|
||||
await setSource('label',0,5); await openKeyboard();
|
||||
await menu().getByRole('menuitem',{name:'Add external link',exact:true}).click();
|
||||
await menu().getByRole('menuitem',{name:'Add external link Ctrl+K',exact:true}).click();
|
||||
assert.equal(await source(),'[label]()');
|
||||
assert.equal(await page.evaluate(()=>window.__CM__.state.selection.main.head),8);
|
||||
await setSource(''); await openKeyboard();
|
||||
@@ -101,7 +101,7 @@ await runSmoke("editor/emptyMenu", async ({ page }) => {
|
||||
await page.locator('.source-editor .cm-content').focus();
|
||||
await page.keyboard.press('Shift+F10');
|
||||
await menu().waitFor();
|
||||
await menu().getByRole('menuitem',{name:'Add external link',exact:true}).click();
|
||||
await menu().getByRole('menuitem',{name:'Add external link Ctrl+K',exact:true}).click();
|
||||
assert.equal(await page.getByRole('dialog').count(),0);
|
||||
await page.locator('.source-editor .cm-content').focus();
|
||||
await page.keyboard.press('Control+a');
|
||||
|
||||
@@ -52,7 +52,7 @@ await runSmoke("editor/markdownMenu", async ({ page }) => {
|
||||
await page.keyboard.press("Shift+F10");
|
||||
await menu.waitFor();
|
||||
await menu.getByRole("menuitem", { name: "Format", exact: true }).hover();
|
||||
await menu.getByRole("menuitem", { name: "Bold", exact: true }).click();
|
||||
await menu.getByRole("menuitem", { name: "Bold Ctrl+B", exact: true }).click();
|
||||
await waitForText("**First** paragraph.\n\nSecond paragraph.\n");
|
||||
await page.keyboard.press("Control+z"); await waitForText(source);
|
||||
await page.getByRole("tab", { selected: true }).click({ button: "right" });
|
||||
@@ -62,7 +62,7 @@ await runSmoke("editor/markdownMenu", async ({ page }) => {
|
||||
await page.keyboard.press("Control+Shift+ArrowRight");
|
||||
await page.keyboard.press("Shift+F10"); await menu.waitFor();
|
||||
await menu.getByRole("menuitem", { name: "Format", exact: true }).hover();
|
||||
await menu.getByRole("menuitem", { name: "Italic", exact: true }).click();
|
||||
await menu.getByRole("menuitem", { name: "Italic Ctrl+I", exact: true }).click();
|
||||
await page.keyboard.press("Control+s");
|
||||
await page.waitForFunction(() => window.__TEST__.files.get("notes/welcome.md") === "*First* paragraph.\n\nSecond paragraph.\n");
|
||||
await page.keyboard.press("Control+z");
|
||||
@@ -85,7 +85,7 @@ await runSmoke("editor/markdownMenu", async ({ page }) => {
|
||||
await page.locator(".cm-line").filter({ hasText: "First paragraph." }).click({ button: "right", position: { x: 12, y: 10 } });
|
||||
await menu.waitFor();
|
||||
await menu.getByRole("menuitem", { name: "Format", exact: true }).hover();
|
||||
await menu.getByRole("menuitem", { name: "Highlight", exact: true }).click();
|
||||
await menu.getByRole("menuitem", { name: "Highlight Ctrl+Shift+H", exact: true }).click();
|
||||
await page.keyboard.press("Control+s");
|
||||
await page.waitForFunction(() => window.__TEST__.files.get("notes/welcome.md").startsWith("==First== paragraph."));
|
||||
await page.keyboard.press("Control+End");
|
||||
@@ -113,7 +113,7 @@ await runSmoke("editor/markdownMenu", async ({ page }) => {
|
||||
await page.keyboard.press("Control+Home");
|
||||
await page.keyboard.press("Control+Shift+ArrowRight");
|
||||
await page.keyboard.press("Shift+F10");
|
||||
await menu.getByRole("menuitem", { name: "Add external link", exact: true }).click();
|
||||
await menu.getByRole("menuitem", { name: "Add external link Ctrl+K", exact: true }).click();
|
||||
// External links insert `[label]()` with the caret in the URL, without a dialog (src/lib/editor/markdownMenu.ts:57, src/lib/editor/linkCommands.ts:3-8).
|
||||
assert.equal(await page.getByRole("dialog").count(), 0);
|
||||
await page.keyboard.type("https://example.com/a");
|
||||
|
||||
@@ -49,7 +49,7 @@ await runSmoke("editor/surfaces", async ({ page }) => {
|
||||
await text.click({ button: 'right', position: { x: 20, y: 8 } });
|
||||
const writer = menu('Markdown text actions');
|
||||
assert.deepEqual(await styles(writer), reference);
|
||||
for (const name of ['Add link', 'Add external link', 'Format', 'Paragraph', 'Insert', 'Paste Ctrl+V', 'Select all Ctrl+A']) assert.equal(await item(name).count(), 1);
|
||||
for (const name of ['Add link', 'Add external link Ctrl+K', 'Format', 'Paragraph', 'Insert', 'Paste Ctrl+V', 'Select all Ctrl+A']) assert.equal(await item(name).count(), 1);
|
||||
await item('Corrected').waitFor();
|
||||
assert.equal(await item('Spelling').count(), 0, 'Corrections appear directly in the main menu');
|
||||
assert.equal(await writer.locator(':scope > button').first().textContent(), 'Corrected');
|
||||
@@ -78,7 +78,7 @@ await runSmoke("editor/surfaces", async ({ page }) => {
|
||||
await page.locator('.cm-content').click({ button: 'right', position: { x: 600, y: 150 } });
|
||||
assert.deepEqual(await styles(writer), reference, 'Blank space uses the same actions');
|
||||
await item('Format').focus(); await page.keyboard.press('ArrowRight');
|
||||
await item('Bold').click();
|
||||
await item('Bold Ctrl+B').click();
|
||||
await page.locator('.cm-content').click({ button: 'right', position: { x: 600, y: 150 } });
|
||||
await page.getByRole('menuitem', { name: 'Undo Ctrl+Z', exact: true }).click();
|
||||
assert.equal(await page.locator('.cm-content').textContent().then(s => s.includes('**')), false, 'Undo reverses the menu edit');
|
||||
|
||||
@@ -36,7 +36,7 @@ await runSmoke("editor/templatesAndTasks", async ({ page }) => {
|
||||
const { saveNoteTemplate } = await import('/src/lib/workspace/templates.ts');
|
||||
await saveNoteTemplate('To Do', '- [ ] \n'.repeat(10));
|
||||
});
|
||||
await page.getByRole('button', { name: 'New tab (Ctrl T)', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'New tab (Ctrl+T)', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'New note', exact: true }).last().click();
|
||||
await page.getByRole('menuitem', { name: 'To Do', exact: true }).click();
|
||||
const title = page.getByRole('textbox', { name: 'Note filename', exact: true });
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
// The command palette (Ctrl+Shift+P), the side pane on Ctrl+\, the generated shortcut list in Help, and the Write formatting shortcuts.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const name = "layout/commands";
|
||||
await runSmoke(name, async ({ page }) => {
|
||||
const output = await outputDir(name);
|
||||
await mockTauri(page, {
|
||||
commands: test => {
|
||||
const workspace = test.workspace({ root: "C:\\commands", files: { "a.md": "# Note\n\nalpha beta gamma delta epsilon\n" } });
|
||||
test.files = workspace.files;
|
||||
return { ...workspace, plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }), spelling_menu_install: () => null };
|
||||
},
|
||||
});
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await page.locator(".live-writer .cm-content").waitFor();
|
||||
|
||||
// The palette lists the app commands with their shortcuts and runs the chosen one.
|
||||
await page.keyboard.press("Control+Shift+P");
|
||||
const palette = page.getByRole("dialog", { name: "Commands", exact: true });
|
||||
await palette.waitFor();
|
||||
assert.equal(await palette.getByRole("button", { name: "Save the active file Ctrl+S", exact: true }).count(), 1);
|
||||
assert.match(await palette.locator("footer").textContent(), /\d+ commands/);
|
||||
await page.screenshot({ path: path.join(output, "palette.png") });
|
||||
await page.getByRole("textbox", { name: "Find a command", exact: true }).fill("side pane");
|
||||
assert.deepEqual((await palette.locator(".rs-picker-row").allTextContents()).map(text => text.replace(/\s+/g, " ").trim()), ["Show or hide the side pane Ctrl+\\"]);
|
||||
assert.equal(await page.locator("aside.left").count(), 1);
|
||||
await page.keyboard.press("Enter");
|
||||
await palette.waitFor({ state: "detached" });
|
||||
await page.locator("aside.left").waitFor({ state: "detached" });
|
||||
// Ctrl+\ shows the side pane again. Ctrl+B no longer toggles it.
|
||||
await page.keyboard.press("Control+Backslash");
|
||||
await page.locator("aside.left").waitFor();
|
||||
|
||||
// Write formatting shortcuts make the same edits as the Format menu.
|
||||
const select = word => page.evaluate(async word => {
|
||||
const { EditorView } = await import("/node_modules/@codemirror/view/dist/index.js");
|
||||
const view = EditorView.findFromDOM(document.querySelector(".live-writer .cm-content"));
|
||||
const from = view.state.doc.toString().indexOf(word);
|
||||
view.dispatch({ selection: { anchor: from, head: from + word.length } });
|
||||
view.focus();
|
||||
}, word);
|
||||
for (const [word, keys] of [["beta", "Control+b"], ["gamma", "Control+i"], ["delta", "Control+Shift+X"], ["epsilon", "Control+Shift+H"], ["alpha", "Control+k"]]) {
|
||||
await select(word);
|
||||
await page.keyboard.press(keys);
|
||||
}
|
||||
assert.equal(await page.locator("aside.left").count(), 1, "Ctrl+B in Write does not hide the side pane");
|
||||
await page.keyboard.press("Control+s");
|
||||
await page.waitForFunction(() => window.__TEST__.files.get("a.md").includes("==epsilon=="));
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.files.get("a.md")), "# Note\n\n[alpha]() **beta** *gamma* ~~delta~~ ==epsilon==\n");
|
||||
|
||||
// The Format menu shows the shortcuts.
|
||||
await page.locator(".live-writer .cm-line").filter({ hasText: "beta" }).click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "Format", exact: true }).hover();
|
||||
for (const label of ["Bold Ctrl+B", "Italic Ctrl+I", "Strikethrough Ctrl+Shift+X", "Highlight Ctrl+Shift+H"]) await page.getByRole("menuitem", { name: label, exact: true }).waitFor();
|
||||
assert.equal(await page.getByRole("menuitem", { name: "Add external link Ctrl+K", exact: true }).count(), 1);
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
// Help lists every shortcut, open, in groups.
|
||||
await page.keyboard.press("F1");
|
||||
const help = page.getByRole("dialog", { name: "Help and about", exact: true });
|
||||
await help.waitFor();
|
||||
const list = help.locator("details").filter({ hasText: "Keyboard shortcuts" });
|
||||
assert.equal(await list.getAttribute("open"), "");
|
||||
for (const heading of ["General", "Write", "Files"]) await list.getByRole("heading", { name: heading, exact: true }).waitFor();
|
||||
const rows = await list.locator("dl div").allTextContents();
|
||||
for (const row of ["Show all commandsCtrl+Shift+P", "Show or hide the side paneCtrl+\\", "BoldCtrl+B", "Delete permanentlyShift+Delete", "Help and aboutF1"]) assert(rows.includes(row), `Help lists ${row}`);
|
||||
await page.screenshot({ path: path.join(output, "help-shortcuts.png") });
|
||||
console.log("PASS: the command palette, Ctrl+\\ for the side pane, Write formatting shortcuts, menu shortcut labels, and the Help shortcut list");
|
||||
});
|
||||
@@ -69,7 +69,7 @@ await runSmoke("layout/outline", async ({ browser }) => {
|
||||
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+b");
|
||||
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);
|
||||
|
||||
@@ -144,7 +144,7 @@ await runSmoke("settings/general", async ({ browser }) => {
|
||||
await help.getByText(`Version ${version}`, { exact: false }).waitFor();
|
||||
await page.screenshot({ path: path.join(output, "help.png") });
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.press("Control+b");
|
||||
await page.keyboard.press("Control+Backslash");
|
||||
await showSettings(true);
|
||||
await settings.waitFor();
|
||||
await closeSettings();
|
||||
|
||||
@@ -130,7 +130,7 @@ await runSmoke("tabs/lastTabAndSiteIcons", async ({ browser }) => {
|
||||
const dimensions = await page.locator(".header").evaluate(header => {
|
||||
const bar = header.querySelector('[role="tablist"]');
|
||||
const rows = [...bar.querySelectorAll(".tab")];
|
||||
const plus = header.querySelector('[aria-label="New tab (Ctrl T)"]');
|
||||
const plus = header.querySelector('[aria-label="New tab (Ctrl+T)"]');
|
||||
const bounds = bar.getBoundingClientRect();
|
||||
return {
|
||||
overflow: bar.scrollWidth - bar.clientWidth,
|
||||
@@ -146,10 +146,10 @@ await runSmoke("tabs/lastTabAndSiteIcons", async ({ browser }) => {
|
||||
assert.ok(dimensions.tabWidth >= 96, JSON.stringify(dimensions));
|
||||
assert.ok(dimensions.gap >= 0 && dimensions.gap <= 8, JSON.stringify(dimensions));
|
||||
assert.ok(dimensions.fits);
|
||||
const plus = page.getByRole("button", { name: "New tab (Ctrl T)", exact: true });
|
||||
const plus = page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true });
|
||||
await plus.evaluate(button => button.blur());
|
||||
await plus.focus();
|
||||
await page.locator('[role="tooltip"]:popover-open').filter({ hasText: "New tab (Ctrl T)" }).waitFor();
|
||||
await page.locator('[role="tooltip"]:popover-open').filter({ hasText: "New tab (Ctrl+T)" }).waitFor();
|
||||
await page.keyboard.press("Escape");
|
||||
await page.locator(".header").screenshot({ path: path.join(output, `compact-tabs-${width}-${theme}.png`) });
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ await runSmoke("tabs/menus", async ({ page }) => {
|
||||
await tab("b.md").waitFor({ state: "detached" });
|
||||
// Closing the last tab leaves an empty tab (src/lib/layout/Workbench.svelte:291), so the plus button adds a second one.
|
||||
await tab("New tab").waitFor();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl T)", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
|
||||
const added = page.getByRole("tab", { name: "New tab", exact: true, selected: true });
|
||||
await page.waitForFunction(() => document.querySelectorAll('[role="tab"][data-path^="empty:"]').length === 2);
|
||||
await added.click({ button: "right" });
|
||||
|
||||
@@ -71,7 +71,7 @@ await runSmoke("tabs/order", async ({ page }) => {
|
||||
assert.equal(await page.getByRole("menu", { name: "Tab actions" }).count(), 0);
|
||||
console.log("PASS: pointer moves, cancellation, keyboard moves, and tab menus");
|
||||
|
||||
await page.getByRole("button", { name: "New tab (Ctrl T)", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
|
||||
await tab("New tab").press("Alt+Shift+Home");
|
||||
assert.match((await order())[0], /^empty:/);
|
||||
await page.getByRole("button", { name: "Close New tab", exact: true }).click();
|
||||
|
||||
@@ -90,7 +90,7 @@ await runSmoke("tabs/ribbonDrop", async ({ browser }) => {
|
||||
return page.locator(".header").evaluate((header, kind) => {
|
||||
const bounds = header.getBoundingClientRect();
|
||||
const bar = header.querySelector('[role="tablist"]').getBoundingClientRect();
|
||||
const plus = header.querySelector('[aria-label="New tab (Ctrl T)"]').getBoundingClientRect();
|
||||
const plus = header.querySelector('[aria-label="New tab (Ctrl+T)"]').getBoundingClientRect();
|
||||
const first = header.querySelector('.tab').getBoundingClientRect();
|
||||
if (kind === "near") return { x: first.left + first.width / 2, y: bounds.bottom + 18 };
|
||||
if (kind === "outside") return { x: first.left + first.width / 2, y: bounds.bottom + 80 };
|
||||
|
||||
@@ -43,7 +43,7 @@ await runSmoke('tree/navigation', async ({ browser }) => {
|
||||
const welcome = page.locator('.welcome-actions');
|
||||
await welcome.waitFor();
|
||||
await welcome.getByRole('button', { name: 'Open browser', exact: true }).waitFor();
|
||||
assert.deepEqual(await welcome.locator('button').allTextContents().then(values => values.map(value => value.replace(/Ctrl [NOP]/g, '').trim())), ['New file', 'New note', 'Find file', 'Open folder', 'Open browser']);
|
||||
assert.deepEqual(await welcome.locator('button').allTextContents().then(values => values.map(value => value.replace(/Ctrl\+[NOP]/g, '').trim())), ['New file', 'New note', 'Find file', 'Open folder', 'Open browser']);
|
||||
const firstRow = welcome.locator('.welcome-row').first();
|
||||
assert.equal(await firstRow.locator('button').count(), 3);
|
||||
const tops = await firstRow.locator('button').evaluateAll(nodes => nodes.map(node => node.getBoundingClientRect().top));
|
||||
@@ -103,7 +103,7 @@ await runSmoke('tree/navigation', async ({ browser }) => {
|
||||
await emptyPage.goto(smokeUrl);
|
||||
await emptyPage.locator('.welcome-actions').waitFor();
|
||||
await emptyPage.locator('.welcome-actions').getByRole('button', { name: 'Open browser', exact: true }).waitFor();
|
||||
assert.deepEqual(await emptyPage.locator('.welcome-actions button').allTextContents().then(values => values.map(value => value.replace(/Ctrl O/g, '').trim())), ['Open folder', 'Open browser']);
|
||||
assert.deepEqual(await emptyPage.locator('.welcome-actions button').allTextContents().then(values => values.map(value => value.replace(/Ctrl\+O/g, '').trim())), ['Open folder', 'Open browser']);
|
||||
await emptyPage.screenshot({ path: path.join(output, 'splash-no-workspace.png') });
|
||||
await emptyPage.close();
|
||||
const errors = [...page.errors, ...emptyPage.errors];
|
||||
|
||||
@@ -159,7 +159,7 @@ await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
assert.equal(await detached.getByRole('button', { name: 'Show outline', exact: true }).count(), 0);
|
||||
assert.equal(await detached.evaluate(() => localStorage.getItem('runestone.workbenchLayout')), saved);
|
||||
assert.equal(await detached.getByRole('button', { name: 'Files', exact: true }).count(), 0);
|
||||
await detached.keyboard.press('Control+b');
|
||||
await detached.keyboard.press('Control+Backslash');
|
||||
await detached.keyboard.press('Control+Shift+f');
|
||||
assert.equal(await detached.locator('aside.left,aside.right,.plugin-ribbon,.gutter-v').count(), 0);
|
||||
await detached.keyboard.press('Escape');
|
||||
|
||||
@@ -12,12 +12,12 @@ await runSmoke("workspace/dialogDismissal", async ({ page }) => {
|
||||
});
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="a.md"]').waitFor();
|
||||
await page.getByRole("button", { name: "New file Ctrl N" }).click();
|
||||
await page.getByRole("button", { name: "New file Ctrl+N" }).click();
|
||||
await page.getByRole("textbox", { name: "New file path relative to the workspace" }).waitFor();
|
||||
await page.mouse.click(5, 700);
|
||||
assert.equal(await page.locator("dialog").count(), 0, "Outside click dismisses new-file dialog");
|
||||
// The empty tab's button is now "Find file" (src/lib/layout/EditorPane.svelte:167).
|
||||
await page.getByRole("button", { name: "Find file Ctrl P" }).click();
|
||||
await page.getByRole("button", { name: "Find file Ctrl+P" }).click();
|
||||
await page.getByRole("textbox", { name: "Find a file" }).click();
|
||||
assert.equal(await page.locator("dialog").count(), 1, "Inside click keeps file search open");
|
||||
await page.mouse.click(5, 700);
|
||||
|
||||
@@ -128,7 +128,7 @@ await runSmoke("workspace/openAndCreate", async ({ page }) => {
|
||||
await page.evaluate(() => window.__TEST__.clear());
|
||||
await trigger.click();
|
||||
await menu.getByText("No recent workspaces yet.").waitFor();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl T)", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
|
||||
await menu.waitFor({ state: "hidden" });
|
||||
console.log("Workspace smoke passed: history, opening and creating in new windows, original workspace preserved, cancellation, errors, keyboard and empty state.");
|
||||
}, { viewport: { width: 1100, height: 800 }, timeout: 30000 });
|
||||
|
||||
@@ -25,7 +25,7 @@ await runSmoke("workspace/saveAsTemplate", async ({ page }) => {
|
||||
await page.getByRole("textbox", { name: "Template name" }).fill("Meeting");
|
||||
await page.getByRole("button", { name: "Continue", exact: true }).click();
|
||||
await page.waitForFunction(() => window.__TEST__.files.has(".runestone/templates/Meeting.md"));
|
||||
await page.getByRole("button", { name: "New tab (Ctrl T)", exact: true }).click();
|
||||
await page.getByRole("button", { name: "New tab (Ctrl+T)", exact: true }).click();
|
||||
// The file tree toolbar also has a "New note" button (src/lib/layout/FileTree.svelte:886); this one is in the empty tab (src/lib/layout/EditorPane.svelte:166).
|
||||
await page.getByRole("main").getByRole("button", { name: "New note", exact: true }).click();
|
||||
await menu("Meeting").click();
|
||||
|
||||
Reference in New Issue
Block a user