Skip to content

Build your personal knowledge base with Trilium Notes

fix(test): help buttons ID check after change in structure

Elian Doran3c88e3c12c0b
diff --git a/src/public/app/widgets/floating_buttons/help_button.spec.ts b/src/public/app/widgets/floating_buttons/help_button.spec.ts
index b59d3b50d2..bc954f27d9 100644
--- a/src/public/app/widgets/floating_buttons/help_button.spec.ts
+++ b/src/public/app/widgets/floating_buttons/help_button.spec.ts
@@ -1,21 +1,20 @@
import { describe, expect, it } from "vitest";
import { byBookType, byNoteType } from "./help_button.js";
import fs from "fs";
-import type { NoteMetaFile } from "../../../../services/meta/note_meta.js";
-import type NoteMeta from "../../../../services/meta/note_meta.js";
+import type { HiddenSubtreeItem } from "../../../../services/hidden_subtree.js";
describe("Help button", () => {
it("All help notes are accessible", () => {
- function getNoteIds(item: NoteMeta | NoteMetaFile): string[] {
- const items = [];
+ function getNoteIds(item: HiddenSubtreeItem | HiddenSubtreeItem[]): string[] {
+ const items: (string | string[])[] = [];
- if ("noteId" in item && item.noteId) {
- items.push(item.noteId);
+ if ("id" in item && item.id) {
+ items.push(item.id);
}
- const children = "files" in item ? item.files : item.children;
- for (const child of children ?? []) {
- items.push(getNoteIds(child));
+ const subitems = (Array.isArray(item) ? item : item.children);
+ for (const child of subitems ?? []) {
+ items.push(getNoteIds(child as (HiddenSubtreeItem | HiddenSubtreeItem[])));
}
return items.flat();
}
@@ -25,11 +24,11 @@ describe("Help button", () => {
...Object.values(byBookType)
].filter((noteId) => noteId) as string[];
- const meta: NoteMetaFile = JSON.parse(fs.readFileSync("src/public/app/doc_notes/en/User Guide/!!!meta.json", "utf-8"));
+ const meta: HiddenSubtreeItem[] = JSON.parse(fs.readFileSync("src/public/app/doc_notes/en/User Guide/!!!meta.json", "utf-8"));
const allNoteIds = new Set(getNoteIds(meta));
for (const helpNote of allHelpNotes) {
- if (!allNoteIds.has(helpNote)) {
+ if (!allNoteIds.has(`_help_${helpNote}`)) {
expect.fail(`Help note with ID ${helpNote} does not exist in the in-app help.`);
}
}