diff --git a/scripts/__tests__/verify-qa-build.test.ts b/scripts/__tests__/verify-qa-build.test.ts index ae1180aba..baa5b1ab9 100644 --- a/scripts/__tests__/verify-qa-build.test.ts +++ b/scripts/__tests__/verify-qa-build.test.ts @@ -88,11 +88,21 @@ describe('checkPrereleaseIndex', () => { expect(checkPrereleaseIndex(goodPrereleaseHtml)).toEqual([]); }); - it('(e) returns a problem when #browse-data all array is empty', () => { + it('(e) ALLOWS an empty #browse-data all array (prerelease has zero cards until a tutorial is ROLE_GATED, #3168)', () => { const html = `
${PRERELEASE_NAVIGATOR}${BROWSE_SCRIPT_EMPTY}`; + expect(checkPrereleaseIndex(html)).toEqual([]); + }); + + it('(e2) still flags a missing #browse-data script tag (empty is OK, absent is not)', () => { + const html = `${PRERELEASE_NAVIGATOR}`; const problems = checkPrereleaseIndex(html); - expect(problems.length).toBeGreaterThan(0); - expect(problems.some(p => /grid|browse/i.test(p))).toBe(true); + expect(problems.some(p => /browse-data|grid/i.test(p))).toBe(true); + }); + + it('(e3) still flags a malformed #browse-data with no "all" array', () => { + const html = `${PRERELEASE_NAVIGATOR}`; + const problems = checkPrereleaseIndex(html); + expect(problems.some(p => /malformed|all/i.test(p))).toBe(true); }); it('(f) a valid QA index fails checkPrereleaseIndex (different markers)', () => { diff --git a/scripts/verify-qa-build.ts b/scripts/verify-qa-build.ts index 0313ffd3c..1d748ebae 100644 --- a/scripts/verify-qa-build.ts +++ b/scripts/verify-qa-build.ts @@ -107,9 +107,18 @@ export function findUnhashedIslandRefs(html: string, islands: string[]): string[ }); } -// Shared helper: verify #browse-data script tag is present and non-empty. -// Returns problem strings (empty = OK). Used by both QA and prerelease checks. -function checkBrowseDataTag(html: string, channelLabel: string): string[] { +// Shared helper: verify #browse-data script tag is present and (unless +// allowEmpty) non-empty. Returns problem strings (empty = OK). Used by both +// QA and prerelease checks. +// +// allowEmpty (prerelease, #3168): a prerelease channel legitimately has ZERO +// cards until an author marks a tutorial visibility=ROLE_GATED, so an empty +// `all` array is a valid steady state — the gated navigator simply renders an +// empty grid. The script tag must still be present with parseable JSON carrying +// an `all` ARRAY (a missing tag / malformed JSON / non-array `all` is still a +// real build break — browse.json never emitted). QA keeps allowEmpty=false: +// an empty QA grid means the contribution fetch failed and is a hard error. +function checkBrowseDataTag(html: string, channelLabel: string, allowEmpty = false): string[] { const problems: string[] = []; const browseMatch = html.match(/