feat(react/floating_buttons): port in-app help button

This commit is contained in:
Elian Doran
2025-08-28 00:23:00 +03:00
parent cabe240e7e
commit f51d944bb3
5 changed files with 65 additions and 83 deletions

View File

@@ -0,0 +1,38 @@
import { describe, expect, it } from "vitest";
import { byBookType, byNoteType } from "./in_app_help.js";
import fs from "fs";
import type { HiddenSubtreeItem } from "@triliumnext/commons";
import path from "path";
describe("Help button", () => {
it("All help notes are accessible", () => {
function getNoteIds(item: HiddenSubtreeItem | HiddenSubtreeItem[]): string[] {
const items: (string | string[])[] = [];
if ("id" in item && item.id) {
items.push(item.id);
}
const subitems = (Array.isArray(item) ? item : item.children);
for (const child of subitems ?? []) {
items.push(getNoteIds(child as (HiddenSubtreeItem | HiddenSubtreeItem[])));
}
return items.flat();
}
const allHelpNotes = [
...Object.values(byNoteType),
...Object.values(byBookType)
].filter((noteId) => noteId) as string[];
const metaPath = path.resolve(path.join(__dirname, "../../../server/src/assets/doc_notes/en/User Guide/!!!meta.json"));
const meta: HiddenSubtreeItem[] = JSON.parse(fs.readFileSync(metaPath, "utf-8"));
const allNoteIds = new Set(getNoteIds(meta));
for (const helpNote of allHelpNotes) {
if (!allNoteIds.has(`_help_${helpNote}`)) {
expect.fail(`Help note with ID ${helpNote} does not exist in the in-app help.`);
}
}
});
});