11import { describe , expect , it } from "vitest" ;
22import { byBookType , byNoteType } from "./help_button.js" ;
33import fs from "fs" ;
4- import type { NoteMetaFile } from "../../../../services/meta/note_meta.js" ;
5- import type NoteMeta from "../../../../services/meta/note_meta.js" ;
4+ import type { HiddenSubtreeItem } from "../../../../services/hidden_subtree.js" ;
65
76describe ( "Help button" , ( ) => {
87 it ( "All help notes are accessible" , ( ) => {
9- function getNoteIds ( item : NoteMeta | NoteMetaFile ) : string [ ] {
10- const items = [ ] ;
8+ function getNoteIds ( item : HiddenSubtreeItem | HiddenSubtreeItem [ ] ) : string [ ] {
9+ const items : ( string | string [ ] ) [ ] = [ ] ;
1110
12- if ( "noteId " in item && item . noteId ) {
13- items . push ( item . noteId ) ;
11+ if ( "id " in item && item . id ) {
12+ items . push ( item . id ) ;
1413 }
1514
16- const children = "files" in item ? item . files : item . children ;
17- for ( const child of children ?? [ ] ) {
18- items . push ( getNoteIds ( child ) ) ;
15+ const subitems = ( Array . isArray ( item ) ? item : item . children ) ;
16+ for ( const child of subitems ?? [ ] ) {
17+ items . push ( getNoteIds ( child as ( HiddenSubtreeItem | HiddenSubtreeItem [ ] ) ) ) ;
1918 }
2019 return items . flat ( ) ;
2120 }
@@ -25,11 +24,11 @@ describe("Help button", () => {
2524 ...Object . values ( byBookType )
2625 ] . filter ( ( noteId ) => noteId ) as string [ ] ;
2726
28- const meta : NoteMetaFile = JSON . parse ( fs . readFileSync ( "src/public/app/doc_notes/en/User Guide/!!!meta.json" , "utf-8" ) ) ;
27+ const meta : HiddenSubtreeItem [ ] = JSON . parse ( fs . readFileSync ( "src/public/app/doc_notes/en/User Guide/!!!meta.json" , "utf-8" ) ) ;
2928 const allNoteIds = new Set ( getNoteIds ( meta ) ) ;
3029
3130 for ( const helpNote of allHelpNotes ) {
32- if ( ! allNoteIds . has ( helpNote ) ) {
31+ if ( ! allNoteIds . has ( `_help_ ${ helpNote } ` ) ) {
3332 expect . fail ( `Help note with ID ${ helpNote } does not exist in the in-app help.` ) ;
3433 }
3534 }
0 commit comments