Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/mdx-to-md.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 22 additions & 6 deletions tests/test-mdx-to-md.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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];
Comment on lines +754 to +756
}

test("self-closing ReleaseNoteHeader resolves label from featureName", () => {
const input = `<ReleaseNoteHeader featureName="cloudCli" />\n\nCommand reference content.`;
const [featureName, mappedType] = pickMappedFeature();
Comment on lines +754 to +760
const input = `<ReleaseNoteHeader featureName="${featureName}" />\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 = `<ReleaseNoteHeader featureName="standaloneActivity">\nAvailable in preview.\n</ReleaseNoteHeader>`;
const [featureName, mappedType] = pickMappedFeature();
const input = `<ReleaseNoteHeader featureName="${featureName}">\nAvailable in preview.\n</ReleaseNoteHeader>`;
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 = `<ReleaseNoteHeader featureName="serverlessWorkersCloudRun" type="publicPreview">\nBody.\n</ReleaseNoteHeader>`;
// 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 = `<ReleaseNoteHeader featureName="${featureName}" type="${explicitType}">\nBody.\n</ReleaseNoteHeader>`;
const { markdown } = transformMdx(input);
assertContains(markdown, "> **Pre-release**");
assertContains(markdown, `> **${RELEASE_NOTE_LABELS[mappedType]}**`);
assertNotContains(markdown, `> **${RELEASE_NOTE_LABELS[explicitType]}**`);
});

// ---------------------------------------------------------------------------
Expand Down
Loading