From 5b4c35dd54080eb516d71c5aa18f43353df7b901 Mon Sep 17 00:00:00 2001 From: Duncan Mackenzie Date: Mon, 5 Oct 2026 11:53:21 -0700 Subject: [PATCH 1/2] Derive ReleaseNoteHeader featureName tests from the feature map Two ReleaseNoteHeader tests hard-coded a feature's release stage (serverlessWorkersCloudRun as Pre-release, cloudCli as Public Preview), so they broke whenever a feature changed stage. #5383 moved serverlessWorkersCloudRun to Public Preview and the override test started failing. Both tests now pick a feature from FEATURE_RELEASE_TYPES and read the expected label from RELEASE_NOTE_LABELS, which mdx-to-md.mjs now exports. The override test sets an explicit type that always differs from the mapped one. The self-closing test prefers a feature whose stage differs from the publicPreview default, so a broken lookup can't pass by falling through to the default. --- scripts/mdx-to-md.mjs | 2 +- tests/test-mdx-to-md.mjs | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/mdx-to-md.mjs b/scripts/mdx-to-md.mjs index feee343b1c..0fc0a3064e 100644 --- a/scripts/mdx-to-md.mjs +++ b/scripts/mdx-to-md.mjs @@ -141,7 +141,7 @@ const EVENT_HISTORY_DEMO_COMPONENTS = COMPONENTS_BY_STRATEGY("event-history-demo // Availability labels for ReleaseNoteHeader resolved `type` values. // Mirrors ReleaseNoteHeader.BASE_RELEASE_STAGES labels in the React component. -const RELEASE_NOTE_LABELS = { +export const RELEASE_NOTE_LABELS = { prerelease: "Pre-release", publicPreview: "Public Preview", publicpreview: "Public Preview", diff --git a/tests/test-mdx-to-md.mjs b/tests/test-mdx-to-md.mjs index faeeb4ca0f..d34771d268 100644 --- a/tests/test-mdx-to-md.mjs +++ b/tests/test-mdx-to-md.mjs @@ -21,7 +21,9 @@ import { dedent, scanMarkdownImports, COMPONENT_REGISTRY, + RELEASE_NOTE_LABELS, } from "../scripts/mdx-to-md.mjs"; +import { FEATURE_RELEASE_TYPES } from "../src/constants/featureReleaseTypes.js"; import { jsonToMarkdownTable } from "../scripts/component-handlers/data-tables.mjs"; import { selectIntegrations, @@ -747,9 +749,15 @@ test("self-closing ReleaseNoteHeader does NOT swallow the page body", () => { }); test("self-closing ReleaseNoteHeader resolves label from featureName", () => { - const input = `\n\nCommand reference content.`; + // Derived from the feature map so the test survives release-stage changes. + // Prefer a feature whose stage differs from the publicPreview default, so a + // broken lookup can't pass by falling through to the default. + const entries = Object.entries(FEATURE_RELEASE_TYPES); + const [featureName, mappedType] = + entries.find(([, type]) => type !== "publicPreview") ?? entries[0]; + const input = `\n\nCommand reference content.`; const { markdown } = transformMdx(input); - assertContains(markdown, "> **Public Preview**"); + assertContains(markdown, `> **${RELEASE_NOTE_LABELS[mappedType]}**`); assertContains(markdown, "Command reference content."); assertNotContains(markdown, "ReleaseNoteHeader"); }); @@ -763,9 +771,13 @@ test("ReleaseNoteHeader resolves label from featureName in paired form", () => { }); test("ReleaseNoteHeader featureName overrides explicit type when mapped", () => { - const input = `\nBody.\n`; + // Derived from the feature map so the test survives release-stage changes. + const [featureName, mappedType] = Object.entries(FEATURE_RELEASE_TYPES)[0]; + const explicitType = mappedType === "prerelease" ? "publicPreview" : "prerelease"; + const input = `\nBody.\n`; const { markdown } = transformMdx(input); - assertContains(markdown, "> **Pre-release**"); + assertContains(markdown, `> **${RELEASE_NOTE_LABELS[mappedType]}**`); + assertNotContains(markdown, `> **${RELEASE_NOTE_LABELS[explicitType]}**`); }); // --------------------------------------------------------------------------- From 0753067972ceb4700dd814439555452910affa6f Mon Sep 17 00:00:00 2001 From: Duncan Mackenzie Date: Mon, 5 Oct 2026 11:58:44 -0700 Subject: [PATCH 2/2] Derive paired-form ReleaseNoteHeader test from the feature map The paired-form featureName test used standaloneActivity, which #5290 removed from FEATURE_RELEASE_TYPES at GA. Since then the test has only exercised the publicPreview default, not the featureName lookup. It now shares a pickMappedFeature() helper with the self-closing test, which prefers a feature whose stage differs from the default. --- tests/test-mdx-to-md.mjs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/test-mdx-to-md.mjs b/tests/test-mdx-to-md.mjs index d34771d268..fed8a00409 100644 --- a/tests/test-mdx-to-md.mjs +++ b/tests/test-mdx-to-md.mjs @@ -748,13 +748,16 @@ test("self-closing ReleaseNoteHeader does NOT swallow the page body", () => { assertNotContains(markdown, "ReleaseNoteHeader"); }); -test("self-closing ReleaseNoteHeader resolves label from featureName", () => { - // Derived from the feature map so the test survives release-stage changes. - // Prefer a feature whose stage differs from the publicPreview default, so a - // broken lookup can't pass by falling through to the default. +// Picks a feature from the feature map so the featureName tests survive +// release-stage changes. Prefers a stage other than the publicPreview default, +// so a broken lookup can't pass by falling through to the default. +function pickMappedFeature() { const entries = Object.entries(FEATURE_RELEASE_TYPES); - const [featureName, mappedType] = - entries.find(([, type]) => type !== "publicPreview") ?? entries[0]; + return entries.find(([, type]) => type !== "publicPreview") ?? entries[0]; +} + +test("self-closing ReleaseNoteHeader resolves label from featureName", () => { + const [featureName, mappedType] = pickMappedFeature(); const input = `\n\nCommand reference content.`; const { markdown } = transformMdx(input); assertContains(markdown, `> **${RELEASE_NOTE_LABELS[mappedType]}**`); @@ -763,9 +766,10 @@ test("self-closing ReleaseNoteHeader resolves label from featureName", () => { }); test("ReleaseNoteHeader resolves label from featureName in paired form", () => { - const input = `\nAvailable in preview.\n`; + const [featureName, mappedType] = pickMappedFeature(); + const input = `\nAvailable in preview.\n`; const { markdown } = transformMdx(input); - assertContains(markdown, "> **Public Preview**"); + assertContains(markdown, `> **${RELEASE_NOTE_LABELS[mappedType]}**`); assertContains(markdown, "Available in preview."); assertNotContains(markdown, "> ****"); });