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..fed8a00409 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,
@@ -746,26 +748,40 @@ test("self-closing ReleaseNoteHeader does NOT swallow the page body", () => {
assertNotContains(markdown, "ReleaseNoteHeader");
});
+// 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);
+ return entries.find(([, type]) => type !== "publicPreview") ?? entries[0];
+}
+
test("self-closing ReleaseNoteHeader resolves label from featureName", () => {
- const input = `\n\nCommand reference content.`;
+ const [featureName, mappedType] = pickMappedFeature();
+ 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");
});
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, "> ****");
});
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]}**`);
});
// ---------------------------------------------------------------------------