mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-28 10:32:27 +08:00
fix(test): help buttons ID check after change in structure
This commit is contained in:
parent
2cd69cc57a
commit
3c88e3c12c
@ -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.`);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user