From f3ea9c91f3c43eb29bc13182248ea5d5469fd82e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Jul 2026 15:22:47 +0000 Subject: [PATCH] tests: fix vacuous-pass bugs in verify.ts Verifier audit findings, each verified against the source: - ensurePptxMaxSlides passed 'true' into the rels slot instead of isSlideMax, so the slide{N+1}-must-not-exist assertion never ran - the verifier could only fail when the deck had FEWER slides than the max, the inverse of its purpose. Two live regression tests (9681, 11896: no extra blank slides) were neutered by this. - ensureHtmlElementContents skipped selectors that matched nothing - all content assertions silently vacuous when the selector is absent (e.g. jupyter display-error tests pass if error output disappears entirely). Now asserts the selector matched. - verifyYamlFile resolved successfully when the yaml file was missing or empty; now fails loudly before running the predicate. - ensurePptxRegexMatches MOVED the pptx into its temp dir (destroying it for any later verifier in the same test); now copies like withPptxContent does. Like the previous commit, these assertions were dead until now and may surface genuine regressions on their first live CI run. Co-Authored-By: Claude Fable 5 --- tests/verify.ts | 59 +++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/tests/verify.ts b/tests/verify.ts index a59761dfb36..d9b57dc9a6c 100644 --- a/tests/verify.ts +++ b/tests/verify.ts @@ -429,23 +429,26 @@ export const ensureHtmlElementContents = ( const doc = new DOMParser().parseFromString(htmlInput, "text/html")!; options.selectors.forEach((sel) => { const el = doc.querySelector(sel); - if (el !== null) { - const contents = el.innerText; - options.matches.forEach((regex) => { - assert( - asRegexp(regex).test(contents), - `Required match ${String(regex)} is missing from selector ${sel} content: ${contents}.`, - ); - }); + // a selector matching nothing must fail, not skip - otherwise the + // content assertions are silently vacuous + assert( + el !== null, + `Selector ${sel} matched no element in ${file}.`, + ); + const contents = el.innerText; + options.matches.forEach((regex) => { + assert( + asRegexp(regex).test(contents), + `Required match ${String(regex)} is missing from selector ${sel} content: ${contents}.`, + ); + }); - options.noMatches?.forEach((regex) => { - assert( - !asRegexp(regex).test(contents), - `Unexpected match ${String(regex)} is present from selector ${sel} content: ${contents}.`, - ); - }); - - } + options.noMatches?.forEach((regex) => { + assert( + !asRegexp(regex).test(contents), + `Unexpected match ${String(regex)} is present from selector ${sel} content: ${contents}.`, + ); + }); }); }, }; @@ -1061,7 +1064,9 @@ export const ensurePptxMaxSlides = ( // callback won't be used here () => Promise.resolve(), `Checking Pptx for maximum ${slideNumberMax} slides`, - )(file, slideNumberMax, true); + // positional args: rels=false, isSlideMax=true - passing true in the + // rels slot silently disabled the max-slides check entirely + )(file, slideNumberMax, false, true); }; export const ensureDocxRegexMatches = ( @@ -1173,9 +1178,10 @@ export const ensurePptxRegexMatches = ( const [_dir, stem] = dirAndStem(file); const temp = await Deno.makeTempDir(); try { - // Move the docx to a temp dir and unzip it + // Copy (not move - later verifiers may still need the pptx) to a + // temp dir and unzip it const zipFile = join(temp, stem + ".zip"); - await Deno.rename(file, zipFile); + await Deno.copyFile(file, zipFile); await unzip(zipFile); // Open the core xml document and match the matches @@ -1247,14 +1253,13 @@ export const verifyYamlFile = ( return { name: "Project Yaml is Valid", verify: async (_output: ExecuteOutput[]) => { - if (existsSync(file)) { - const raw = await Deno.readTextFile(file); - if (raw) { - const yaml = readYamlFromString(raw); - const isValid = func(yaml); - assert(isValid, "Project Metadata isn't valid"); - } - } + // missing or empty yaml must fail, not skip the predicate + assert(existsSync(file), `Yaml file ${file} doesn't exist`); + const raw = await Deno.readTextFile(file); + assert(raw.trim().length > 0, `Yaml file ${file} is empty`); + const yaml = readYamlFromString(raw); + const isValid = func(yaml); + assert(isValid, "Project Metadata isn't valid"); }, }; };