mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
fix(hidden_subtree): visible launchers broken due to branch enforcement
This commit is contained in:
parent
115e9e0202
commit
bb9e7b1c6e
34
apps/server/src/services/hidden_subtree.spec.ts
Normal file
34
apps/server/src/services/hidden_subtree.spec.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { describe, it } from "vitest";
|
||||||
|
import cls from "./cls.js";
|
||||||
|
import hiddenSubtreeService from "./hidden_subtree.js";
|
||||||
|
import sql_init from "./sql_init.js";
|
||||||
|
import branches from "./branches.js";
|
||||||
|
import becca from "../becca/becca.js";
|
||||||
|
|
||||||
|
describe("Hidden Subtree", () => {
|
||||||
|
describe("Launcher movement persistence", () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
sql_init.initializeDb();
|
||||||
|
await sql_init.dbReady;
|
||||||
|
cls.init(() => hiddenSubtreeService.checkHiddenSubtree());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should persist launcher movement between visible and available after integrity check", async () => {
|
||||||
|
// Move backend log to visible launchers.
|
||||||
|
const backendLogBranch = becca.getBranchFromChildAndParent("_lbBackendLog", "_lbAvailableLaunchers");
|
||||||
|
expect(backendLogBranch).toBeDefined();
|
||||||
|
|
||||||
|
// Move launcher to visible launchers.
|
||||||
|
cls.init(() => {
|
||||||
|
branches.moveBranchToNote(backendLogBranch!, "_lbVisibleLaunchers");
|
||||||
|
hiddenSubtreeService.checkHiddenSubtree();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure the launcher is still in visible launchers.
|
||||||
|
const childBranches = backendLogBranch?.childNote.getParentBranches()
|
||||||
|
.filter((b) => !b.isDeleted);
|
||||||
|
expect(childBranches).toBeDefined();
|
||||||
|
expect(childBranches![0].parentNoteId).toStrictEqual("_lbVisibleLaunchers");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -369,6 +369,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
|
|||||||
|
|
||||||
// Clean up any branches that shouldn't exist according to the meta definition
|
// Clean up any branches that shouldn't exist according to the meta definition
|
||||||
// For hidden subtree notes, we want to ensure they only exist in their designated locations
|
// For hidden subtree notes, we want to ensure they only exist in their designated locations
|
||||||
|
if (item.enforceBranches) {
|
||||||
const expectedParents = getExpectedParentIds(item.id, hiddenSubtreeDefinition);
|
const expectedParents = getExpectedParentIds(item.id, hiddenSubtreeDefinition);
|
||||||
const currentBranches = note.getParentBranches();
|
const currentBranches = note.getParentBranches();
|
||||||
|
|
||||||
@ -382,6 +383,7 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const attrs = [...(item.attributes || [])];
|
const attrs = [...(item.attributes || [])];
|
||||||
|
|
||||||
|
@ -43,4 +43,10 @@ export interface HiddenSubtreeItem {
|
|||||||
| "quickSearch"
|
| "quickSearch"
|
||||||
| "aiChatLauncher";
|
| "aiChatLauncher";
|
||||||
command?: keyof typeof Command;
|
command?: keyof typeof Command;
|
||||||
|
/**
|
||||||
|
* If set to true, then branches will be enforced to be in the correct place.
|
||||||
|
* This is useful for ensuring that the launcher is always in the correct place, even if
|
||||||
|
* the user moves it around.
|
||||||
|
*/
|
||||||
|
enforceBranches?: boolean;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user