@@ -85,24 +85,15 @@ async function runChoiceAndWaitForFile(
8585
8686async function waitForFrontmatter (
8787 file : string ,
88- predicate : ( frontmatter : Record < string , unknown > | null ) => boolean ,
88+ predicate : ( frontmatter : { authors : string [ ] } ) => boolean ,
8989) {
90- const filePath = sandbox . path ( file ) ;
91- return obsidian . waitFor ( async ( ) => {
92- const rawFrontmatter = await obsidian . dev . eval (
93- `(() => {
94- const file = app.vault.getFileByPath(${ JSON . stringify ( filePath ) } );
95- if (!file) return null;
96- return app.metadataCache.getFileCache(file)?.frontmatter ?? null;
97- })()` ,
98- ) ;
99- const frontmatter =
100- rawFrontmatter && typeof rawFrontmatter === "object"
101- ? ( rawFrontmatter as Record < string , unknown > )
102- : null ;
103-
104- return predicate ( frontmatter ) ? frontmatter : undefined ;
105- } , WAIT_OPTS ) ;
90+ return await obsidian . metadata . waitForFrontmatter < {
91+ authors : string [ ] ;
92+ } > (
93+ sandbox . path ( file ) ,
94+ predicate ,
95+ WAIT_OPTS ,
96+ ) ;
10697}
10798
10899async function runTeardownStep (
@@ -211,7 +202,7 @@ describe("issue 1140: list properties with links", () => {
211202 const frontmatter = await waitForFrontmatter (
212203 "qa-1140-single-link.md" ,
213204 ( value ) =>
214- Array . isArray ( value ? .authors ) && value . authors . length === 1 ,
205+ Array . isArray ( value . authors ) && value . authors . length === 1 ,
215206 ) ;
216207
217208 expect ( frontmatter ) . toMatchObject ( {
@@ -228,7 +219,7 @@ describe("issue 1140: list properties with links", () => {
228219 const frontmatter = await waitForFrontmatter (
229220 "qa-1140-multi-link.md" ,
230221 ( value ) =>
231- Array . isArray ( value ? .authors ) && value . authors . length === 2 ,
222+ Array . isArray ( value . authors ) && value . authors . length === 2 ,
232223 ) ;
233224
234225 expect ( frontmatter ) . toMatchObject ( {
0 commit comments