From 24820b914c390586cda1ef425d911735ac9c3641 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Wed, 19 Nov 2025 12:15:18 +0800 Subject: [PATCH] chore(e2e): add tests for tree --- apps/server-e2e/src/layout/tree.spec.ts | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 apps/server-e2e/src/layout/tree.spec.ts diff --git a/apps/server-e2e/src/layout/tree.spec.ts b/apps/server-e2e/src/layout/tree.spec.ts new file mode 100644 index 000000000..ba244a9d3 --- /dev/null +++ b/apps/server-e2e/src/layout/tree.spec.ts @@ -0,0 +1,38 @@ +import { test, expect } from "@playwright/test"; +import App from "../support/app"; + +const OPTIONS_TITLE = "Options"; +const NOTE_TITLE = "Tree Operations" + +test("Hoist note remains expanded when opening Options and clicking child note", async ({ page, context }) => { + const app = new App(page, context); + await app.goto(); + await app.closeAllTabs(); + + await app.goToSettings(); + + // Activate it when opening Options + await expect(app.noteTreeActiveNote).toContainText(OPTIONS_TITLE); + + // Clicking a hoist’s child note does not collapse the hoist note + await app.clickNoteOnNoteTreeByTitle("Appearance"); + const node = app.page.locator(".fancytree-node.fancytree-submatch:has(.bx-cog)"); + await expect(node).toHaveClass(/fancytree-expanded/); +}); + +test("Activate it when hoisting a note", async ({ page, context }) => { + const app = new App(page, context); + await app.goto(); + await app.closeAllTabs(); + + const treeNode = app.noteTree.getByText(NOTE_TITLE); + await treeNode.click({ button: "right" }); + const hoistMenuItem = page.locator( + '#context-menu-container .dropdown-item span', + { hasText: "Hoist note" } + ); + await hoistMenuItem.click(); + await expect(app.noteTreeActiveNote).toContainText(NOTE_TITLE); + await app.page.locator(".unhoist-button").click(); + await expect(app.noteTreeActiveNote).toContainText(NOTE_TITLE); +});