Keep an open context menu when its items change
The file pane menu took its items from live state: the template list, the selection, and the clipboard. A template reload while the menu was open rebuilt the menu and closed its open submenu. The workspace/manageTemplates smoke test failed in about half of its runs because of this race. ContextMenu.svelte now reads the items once when the menu opens. It builds the menu again only when its position or label changes. manageTemplates has a new check: a template reload keeps the open submenu. The check fails without the fix. With the fix, the test passed 6 of 6 runs. The tree, plugins, menus, and workspace smoke groups pass (23 of 23), and pnpm check passes.
This commit is contained in:
@@ -33,6 +33,13 @@ await runSmoke(name, async ({ page }) => {
|
||||
await row("a.md").waitFor();
|
||||
await page.getByRole("navigation", { name: "Workspace files" }).click({ button: "right", position: { x: 90, y: 360 } });
|
||||
await item("New note").hover();
|
||||
// A template reload behind the open menu keeps the menu and its open submenu (src/lib/layout/ContextMenu.svelte).
|
||||
const submenu = page.getByRole("menu", { name: "New note", exact: true });
|
||||
await submenu.waitFor();
|
||||
await submenu.evaluate(node => { node.dataset.smokeMark = "open"; });
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("runestone-templates-changed")));
|
||||
await page.waitForTimeout(300);
|
||||
assert.equal(await page.locator('[data-smoke-mark="open"]:popover-open').count(), 1, "A template reload keeps the open submenu");
|
||||
await item("Daily").click();
|
||||
await row("Daily.md").waitFor();
|
||||
assert.equal(await file("Daily.md"), "# Daily\n\n## Tasks");
|
||||
|
||||
Reference in New Issue
Block a user