@@ -62,13 +62,26 @@ describe('scanDocsFolder', () => {
6262 expect ( pages [ 2 ] . file ) . toBe ( 'advanced.md' ) ;
6363 } ) ;
6464
65- it ( 'should not include headings in page objects' , async ( ) => {
65+ it ( 'should extract h2/h3 headings into page objects' , async ( ) => {
6666 const result = await scanDocsFolder ( testDocsPath ) ;
6767
68- const pages = result . manifest . pages ;
69- for ( const page of pages ) {
70- expect ( page ) . not . toHaveProperty ( 'headings' ) ;
71- }
68+ const configPage = result . manifest . pages . find ( ( p : Page ) => p . slug === 'config' ) ;
69+ const settingsPage = configPage ?. children ?. find ( ( p : Page ) => p . slug === 'config/settings' ) ;
70+
71+ expect ( settingsPage ?. headings ) . toEqual ( [
72+ { level : 2 , text : 'General Settings' , id : 'general-settings' } ,
73+ { level : 3 , text : 'Display Name' , id : 'display-name' } ,
74+ { level : 2 , text : 'Advanced Settings' , id : 'advanced-settings' } ,
75+ ] ) ;
76+ } ) ;
77+
78+ it ( 'should omit headings on pages without h2/h3 content' , async ( ) => {
79+ const result = await scanDocsFolder ( testDocsPath ) ;
80+
81+ // home.md has only an h1, no h2/h3 — field should be omitted
82+ const homePage = result . manifest . pages . find ( ( p : Page ) => p . slug === 'home' ) ;
83+ expect ( homePage ) . toBeDefined ( ) ;
84+ expect ( homePage ) . not . toHaveProperty ( 'headings' ) ;
7285 } ) ;
7386
7487 it ( 'should throw error when no valid markdown files found' , async ( ) => {
0 commit comments