fix(tree): fix failure to auto-activate hoisted note (#7782)

This commit is contained in:
Elian Doran 2025-11-19 08:20:21 +02:00 committed by GitHub
commit 84b3d6db76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 1 deletions

View File

@ -89,7 +89,7 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
effectivePathSegments.reverse();
if (effectivePathSegments.includes(hoistedNoteId)) {
if (effectivePathSegments.includes(hoistedNoteId) && effectivePathSegments.includes('root')) {
return effectivePathSegments;
} else {
const noteId = getNoteIdFromUrl(notePath);

View File

@ -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 hoists 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);
});