Use compact accessible SVG actions for selected blocks
This commit is contained in:
1 parent
eb1875f0bc
commit
640dadaa75
3 files changed
+46
-7
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { Window } from "happy-dom";
|
||||
import { showBuilderBlockActions } from "../src/live-canvas.ts";
|
||||
|
||||
test("compact selection actions retain accessible names and callbacks without interpreting labels", () => {
|
||||
const window = new Window(), document = window.document;
|
||||
document.body.innerHTML = '<div data-block-id="text">Content</div>';
|
||||
let calls = 0;
|
||||
showBuilderBlockActions(document as unknown as Document, "text", "Text — <script>example</script>", { Edit: () => calls++, Delete: () => calls++ });
|
||||
const toolbar = document.querySelector('[role="toolbar"]')!;
|
||||
expect(toolbar.getAttribute("aria-label")).toBe("Text — <script>example</script> actions");
|
||||
expect(toolbar.querySelector("strong")?.textContent).toBe("Text");
|
||||
expect(toolbar.querySelector("script")).toBeNull();
|
||||
const edit = toolbar.querySelector('[aria-label="Edit"]') as any;
|
||||
expect(edit.title).toBe("Edit");
|
||||
expect(edit.querySelector("svg")).not.toBeNull();
|
||||
edit.click();
|
||||
expect(calls).toBe(1);
|
||||
showBuilderBlockActions(document as unknown as Document, "text", "Text", { Edit: () => calls++ });
|
||||
expect(document.querySelectorAll('[role="toolbar"]')).toHaveLength(1);
|
||||
window.happyDOM.abort();
|
||||
});
|
||||
Reference in new issue
Block a user