@@ -172,6 +172,64 @@ describe("compileMemoryWikiVault", () => {
172172 ) . resolves . not . toContain ( "syntheses/broken.md" ) ;
173173 } ) ;
174174
175+ it . each ( [
176+ {
177+ name : "root index with syntax-error frontmatter" ,
178+ relativePath : "index.md" ,
179+ frontmatterLines : [
180+ "pageType: report" ,
181+ "sourceIds:" ,
182+ ' - **MEMORY.md line 235**:"some quoted, value"' ,
183+ ] ,
184+ error : "Unexpected scalar" ,
185+ } ,
186+ {
187+ name : "root index with sequence-root frontmatter" ,
188+ relativePath : "index.md" ,
189+ frontmatterLines : [ "- pageType: report" ] ,
190+ error : "Wiki frontmatter must be a YAML mapping" ,
191+ } ,
192+ {
193+ name : "directory index with syntax-error frontmatter" ,
194+ relativePath : "sources/index.md" ,
195+ frontmatterLines : [
196+ "pageType: report" ,
197+ "sourceIds:" ,
198+ ' - **MEMORY.md line 235**:"some quoted, value"' ,
199+ ] ,
200+ error : "Unexpected scalar" ,
201+ } ,
202+ {
203+ name : "directory index with scalar-root frontmatter" ,
204+ relativePath : "sources/index.md" ,
205+ frontmatterLines : [ "report" ] ,
206+ error : "Wiki frontmatter must be a YAML mapping" ,
207+ } ,
208+ ] ) (
209+ "rejects $name without changing its bytes" ,
210+ async ( { relativePath, frontmatterLines, error } ) => {
211+ const { rootDir, config } = await createVault ( {
212+ rootDir : nextCaseRoot ( ) ,
213+ initialize : true ,
214+ config : { render : { createDashboards : false } } ,
215+ } ) ;
216+ const targetPath = path . join ( rootDir , relativePath ) ;
217+ const original = [
218+ "---" ,
219+ ...frontmatterLines ,
220+ "---" ,
221+ "" ,
222+ "# Existing Index" ,
223+ "" ,
224+ "Keep this body." ,
225+ ] . join ( "\n" ) ;
226+ await fs . writeFile ( targetPath , original , "utf8" ) ;
227+
228+ await expect ( compileMemoryWikiVault ( config ) ) . rejects . toThrow ( error ) ;
229+ await expect ( fs . readFile ( targetPath , "utf8" ) ) . resolves . toBe ( original ) ;
230+ } ,
231+ ) ;
232+
175233 it ( "discovers pages in nested subdirectories during compile" , async ( ) => {
176234 const { rootDir, config } = await createVault ( {
177235 rootDir : nextCaseRoot ( ) ,
0 commit comments