Files
tutti/tools/scripts/desktop-release-changelog.test.mjs
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

78 lines
2.1 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import {
parseExistingChangelog,
schemaVersion,
upsertChangelogEntry
} from "../../apps/desktop/scripts/upsert-release-changelog.mjs";
function createSummary(version, generatedAt) {
return {
tag: `v${version}`,
version,
channel: "stable",
prerelease: false,
generatedAt,
targetCommit: "537327a1",
compare: { from: `v${version}-previous`, to: "HEAD", range: "test" },
zh: {
headline: "本次版本聚焦发布链路稳定性。",
sections: [{ title: "发布与下载", items: ["稳定包入口只指向正式版。"] }],
qaFocus: ["验证下载入口。"]
},
en: {
headline: "This release focuses on release stability.",
sections: [
{
title: "Release and Downloads",
items: ["Stable downloads only point to official releases."]
}
],
qaFocus: ["Verify the download entry."]
}
};
}
test("desktop release changelog treats missing existing json as empty", () => {
const changelog = parseExistingChangelog("");
assert.equal(changelog.schemaVersion, schemaVersion);
assert.deepEqual(changelog.entries, []);
});
test("desktop release changelog rejects invalid existing json", () => {
assert.throws(
() => parseExistingChangelog("not json"),
/Existing changelog is not valid JSON/
);
assert.throws(
() => parseExistingChangelog('{"entries":[]}'),
/Existing changelog must use schema/
);
});
test("desktop release changelog upserts versions and keeps newest first", () => {
const first = upsertChangelogEntry(
"",
createSummary("1.2.3", "2026-07-03T12:00:00.000Z")
);
const second = upsertChangelogEntry(
first,
createSummary("1.2.4", "2026-07-04T12:00:00.000Z")
);
const replaced = upsertChangelogEntry(
second,
createSummary("1.2.3", "2026-07-05T12:00:00.000Z")
);
assert.deepEqual(
replaced.entries.map((entry) => entry.version),
["1.2.3", "1.2.4"]
);
assert.equal(
replaced.entries[0]?.zh.headline,
"本次版本聚焦发布链路稳定性。"
);
});