diff --git a/src/public/app/widgets/floating_buttons/help_button.spec.ts b/src/public/app/widgets/floating_buttons/help_button.spec.ts new file mode 100644 index 000000000..b59d3b50d --- /dev/null +++ b/src/public/app/widgets/floating_buttons/help_button.spec.ts @@ -0,0 +1,37 @@ +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"; + +describe("Help button", () => { + it("All help notes are accessible", () => { + function getNoteIds(item: NoteMeta | NoteMetaFile): string[] { + const items = []; + + if ("noteId" in item && item.noteId) { + items.push(item.noteId); + } + + const children = "files" in item ? item.files : item.children; + for (const child of children ?? []) { + items.push(getNoteIds(child)); + } + return items.flat(); + } + + const allHelpNotes = [ + ...Object.values(byNoteType), + ...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 allNoteIds = new Set(getNoteIds(meta)); + + for (const helpNote of allHelpNotes) { + if (!allNoteIds.has(helpNote)) { + expect.fail(`Help note with ID ${helpNote} does not exist in the in-app help.`); + } + } + }); +}); diff --git a/src/public/app/widgets/floating_buttons/help_button.ts b/src/public/app/widgets/floating_buttons/help_button.ts index be860f276..b14bfb7b7 100644 --- a/src/public/app/widgets/floating_buttons/help_button.ts +++ b/src/public/app/widgets/floating_buttons/help_button.ts @@ -12,13 +12,13 @@ const TPL = ` `; -const byNoteType: Record, string | null> = { +export const byNoteType: Record, string | null> = { canvas: null, code: null, contentWidget: null, doc: null, file: null, - geoMap: "foPEtsL51pD2", + geoMap: "81SGnPGMk7Xc", image: null, launcher: null, mermaid: null, @@ -31,10 +31,10 @@ const byNoteType: Record, string | null> = { webView: null }; -const byBookType: Record = { +export const byBookType: Record = { list: null, grid: null, - calendar: "fDGg7QcJg3Xm" + calendar: "xWbu3jpNWapp" }; export default class ContextualHelpButton extends NoteContextAwareWidget {