Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
test(mermaid): follow ELK's new node order and assert the layout actually differs
Elian Doraneff9322342fe
diff --git a/packages/trilium-e2e/src/note_types/mermaid.spec.ts b/packages/trilium-e2e/src/note_types/mermaid.spec.tsindex 22416d4a27..269d8c0076 100644--- a/packages/trilium-e2e/src/note_types/mermaid.spec.ts+++ b/packages/trilium-e2e/src/note_types/mermaid.spec.ts@@ -8,9 +8,6 @@ test("renders ELK flowchart", async ({ page, context }) => {noteTitle: "Flowchart ELK on",snapshot: `- document:- - paragraph: A- - paragraph: B- - paragraph: C- paragraph: Guarantee- paragraph: User attributes- paragraph: Master data@@ -21,11 +18,27 @@ test("renders ELK flowchart", async ({ page, context }) => {- paragraph: Customer- paragraph: Profit Centers- paragraph: Guarantee+ - paragraph: A+ - paragraph: B+ - paragraph: C- text: Interfaces for B`});});+// The aria snapshots above read label text in DOM order, which mermaid emits from the+// diagram source and is therefore the same under either layout. Node coordinates are what+// differ, so this is the assertion that `layout: elk` in a note's front matter still beats+// the `layout: dagre` the client pins in getMermaidConfig().+test("lays the ELK flowchart out differently from the dagre one", async ({ page, context }) => {+ const elk = await nodePositions(page, context, "Flowchart ELK on");+ const dagre = await nodePositions(page, context, "Flowchart ELK off");++ expect(elk.length).toBeGreaterThan(0);+ expect(elk.length).toBe(dagre.length);+ expect(elk).not.toEqual(dagre);+});+test("renders standard flowchart", async ({ page, context }) => {await testAriaSnapshot({page,@@ -161,3 +174,13 @@ function requireBoundingBox(box: Awaited<ReturnType<Locator["boundingBox"]>>, la}return box;}++async function nodePositions(page: Page, context: BrowserContext, noteTitle: string) {+ const app = new App(page, context);+ await app.goto();+ await app.goToNoteInNewTab(noteTitle);++ const nodes = app.currentNoteSplit.locator(".render-container svg .node");+ await expect(nodes.first()).toBeVisible();+ return await nodes.evaluateAll((els) => els.map((el) => el.getAttribute("transform") ?? ""));+}