diff --git a/tests/e2e/cncf-project-card.spec.js b/tests/e2e/cncf-project-card.spec.js index 827820e8..40313108 100644 --- a/tests/e2e/cncf-project-card.spec.js +++ b/tests/e2e/cncf-project-card.spec.js @@ -21,6 +21,20 @@ // both, which is the shape the real pages already cover. The fixture card is // named so that neither its name nor its description contains the substring // "Since", or the negative assertion could never hold. +// +// The fixture page carries a second card, with `since` and no `version`, and +// the pairing is what makes the `||` in that guard measurable rather than a +// second copy of a shape the architecture pages already render. Docusaurus +// gives each docs page its own chunk, so the browser reports one set of V8 +// ranges per page, and V8 emits a range for the `version` operand only when +// its count differs from the count of the surrounding render. Every production +// page is uniform -- adobe.md, zeiss.md, allianz.md, flipkart-chaos- +// engineering.md and both swisscom pages give every card a `since`, so +// `version` is never evaluated and the operand is reported zero; +// cern-scientific-computing.md and colopl.md give no card a `since`, so +// `version` is always evaluated and no range is emitted for it at all. Only a +// page that renders both shapes evaluates the operand for one card and not the +// other, which is what reports it as reached. import { test, expect } from '../tools/e2e-coverage.cjs'; const FIXTURE_ROUTE = '/e2e-coverage-fixtures/cncf-project-card'; @@ -41,4 +55,31 @@ describeCoverage('CNCFProjectCard meta row', () => { await expect(card).toContainText('v1.2.3'); await expect(card).not.toContainText('Since'); }); + + test('renders an adoption year with no version', async ({ page }) => { + const response = await page.goto(FIXTURE_ROUTE); + expect(response?.status()).toBe(200); + + const card = page.getByRole('link', { name: /Adopted Fixture Project/ }); + await expect(card).toHaveCount(1); + + await expect(card).toContainText('Since 2021'); + // The version-only card's value is the one string that would show this + // card had picked up the wrong props, so it is the useful negative. + await expect(card).not.toContainText('v1.2.3'); + }); + + test('the two cards render different halves of the meta row', async ({ + page, + }) => { + await page.goto(FIXTURE_ROUTE); + + // Both cards must be on the one page: the `||` operand is only reported as + // reached when a single chunk renders a card that evaluates `version` and + // a card that short-circuits before it. Splitting them across two fixture + // pages would restore the uniform shape every production page already has. + await expect( + page.locator('article a[href*="cncf.io/projects/"]'), + ).toHaveCount(2); + }); }); diff --git a/tests/e2e/fixtures/docs/cncf-project-card.mdx b/tests/e2e/fixtures/docs/cncf-project-card.mdx index 9ba8a699..6c207988 100644 --- a/tests/e2e/fixtures/docs/cncf-project-card.mdx +++ b/tests/e2e/fixtures/docs/cncf-project-card.mdx @@ -14,7 +14,18 @@ architecture pages under `docs/architectures/` render `` with `since` and `version`, with `since` alone, or with neither — never with `version` alone — so the right-hand operand of the meta guard `(since || version)` is the one arm of the component no production page reaches. -The card below supplies that shape. +The first card below supplies that shape. + +The second card is what makes the `||` itself measurable. Docusaurus gives each +docs page its own bundle chunk, so the browser reports one set of V8 ranges per +page, and V8 only emits a range for `version` when its count differs from the +count of the surrounding render. Every production page is uniform: on +`adobe.md`, `zeiss.md` and the rest every card carries `since`, so `version` is +never evaluated and the range is reported zero; on +`cern-scientific-computing.md` and `colopl.md` no card carries `since`, so +`version` is always evaluated and no range is emitted at all. A page that mixes +the two shapes evaluates `version` for one card and not the other, which is the +only arrangement that reports the operand as reached. + +