Files
fusion/scripts/__tests__/extract-version-notes.test.mjs
Fusion ed940520b9 feat(FN-3311): add version notes extractor for GitHub releases
Merges FN-3311 work into the release pipeline: adds a version notes extractor with tests and integrates GitHub release creation into the release script, plus a minor CSS design token consistency fix in the dashboard.

Fusion-Task-Id: FN-3311
2026-05-04 14:35:23 -07:00

72 lines
1.9 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { extractVersionNotes } from "../lib/extract-version-notes.mjs";
const changelog = `# Fusion changelog
## 1.2.0
### @runfusion/fusion
#### Patch Changes
- Added release integration.
## 1.1.0
### @runfusion/fusion
#### Patch Changes
- Fixed parser bug.
## 1.0.0
### @runfusion/fusion
#### Patch Changes
- Initial release.
`;
test("extracts correct section for known version", () => {
const notes = extractVersionNotes(changelog, "1.1.0");
assert.match(notes, /Fixed parser bug\./);
assert.doesNotMatch(notes, /Added release integration\./);
});
test("returns full multiline body including sub-headings", () => {
const notes = extractVersionNotes(changelog, "1.2.0");
assert.match(notes, /^### @runfusion\/fusion/m);
assert.match(notes, /^#### Patch Changes/m);
assert.match(notes, /- Added release integration\./);
});
test("returns fallback when version not found", () => {
const notes = extractVersionNotes(changelog, "9.9.9");
assert.equal(notes, "Release v9.9.9");
});
test("returns fallback when changelog content is empty", () => {
const notes = extractVersionNotes("", "1.2.0");
assert.equal(notes, "Release v1.2.0");
});
test("handles version as last section with no trailing heading", () => {
const notes = extractVersionNotes(changelog, "1.0.0");
assert.match(notes, /Initial release\./);
});
test("handles single-version changelog", () => {
const single = `# Changelog\n\n## 2.0.0\n\n### pkg\n\n#### Patch Changes\n\n- Solo entry.\n`;
const notes = extractVersionNotes(single, "2.0.0");
assert.match(notes, /Solo entry\./);
});
test("does not bleed into adjacent version sections", () => {
const notes = extractVersionNotes(changelog, "1.1.0");
assert.doesNotMatch(notes, /Initial release\./);
assert.doesNotMatch(notes, /Added release integration\./);
});