forked from heygen-com/hyperframes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangelog-weekly.test.ts
More file actions
117 lines (104 loc) · 3.78 KB
/
Copy pathchangelog-weekly.test.ts
File metadata and controls
117 lines (104 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { createWeeklyDraft, parseWeeklyOptions, weeklyPacketPaths } from "./changelog-weekly.ts";
import { parseCommit, type RawCommit } from "./draft-changelog.ts";
function commit(subject: string) {
const raw: RawCommit = {
sha: "1234567890abcdef1234567890abcdef12345678",
shortSha: "1234567",
author: "Test Author",
subject,
};
return {
...parseCommit(raw),
date: "2026-06-03",
};
}
describe("weekly changelog arguments", () => {
it("parses date range and write flags", () => {
assert.deepEqual(
parseWeeklyOptions(["--from", "2026-06-01", "--to=2026-06-07", "--write", "--force"]),
{
from: "2026-06-01",
to: "2026-06-07",
write: true,
force: true,
},
);
});
});
describe("weekly changelog rendering", () => {
it("creates docs, source, Discord, and X drafts", () => {
const draft = createWeeklyDraft(
{
from: "2026-06-01",
to: "2026-06-07",
write: false,
force: false,
},
[commit("feat(cli): add render hints (#42)"), commit("fix: repair playback")],
);
assert.match(draft.docsUpdate, /label="Week of June 1, 2026"/);
assert.match(draft.weeklyNotes, /HyperFrames weekly digest - June 1, 2026 - June 7, 2026/);
assert.match(draft.discordDraft, /This week's highlights:/);
assert.match(draft.xDraft, /Full update: TODO add docs link/);
});
it("keeps internal and editorial-only changes out of top highlights", () => {
const draft = createWeeklyDraft(
{
from: "2026-06-01",
to: "2026-06-07",
write: false,
force: false,
},
[
commit("feat(docs): add changelog release workflow (#41)"),
commit("fix(cli): validate cloud render input (#42)"),
commit("chore: update generated baselines (#43)"),
],
);
assert.match(draft.discordDraft, /CLI: Validate cloud render input/);
assert.doesNotMatch(draft.discordDraft, /Docs: Add changelog release workflow/);
assert.doesNotMatch(draft.docsUpdate, /Update generated baselines/);
});
it("terminates generated bullets so consecutive items are not read as one sentence", () => {
const draft = createWeeklyDraft(
{
from: "2026-06-01",
to: "2026-06-07",
write: false,
force: false,
},
[commit("feat(cli): add render hints (#42)"), commit("fix: repair playback")],
);
const bullets = draft.docsUpdate.split("\n").filter((line) => line.startsWith("- "));
assert.ok(bullets.length > 0);
// Every bullet ends a sentence, so a reader (or an RSS feed) does not run
// consecutive list items together into one giant run-on sentence.
bullets.forEach((bullet) => assert.ok(bullet.endsWith("."), `unterminated bullet: ${bullet}`));
const commitBullets = bullets.filter((bullet) => bullet.includes("/commit/"));
assert.ok(commitBullets.length > 0);
commitBullets.forEach((bullet) => assert.ok(bullet.endsWith(").")));
});
it("stamps the writing bar into drafts that a human has to rewrite", () => {
const draft = createWeeklyDraft(
{
from: "2026-06-01",
to: "2026-06-07",
write: false,
force: false,
},
[commit("fix: repair playback")],
);
for (const text of [draft.docsUpdate, draft.weeklyNotes, draft.discordDraft, draft.xDraft]) {
assert.match(text, /Style bar: keep sentences under 25 words/);
}
});
it("uses predictable packet paths from the week ending date", () => {
assert.deepEqual(weeklyPacketPaths("2026-06-07"), {
weeklyNotes: "updates/weekly/2026-06-07.md",
discordDraft: "updates/social/2026-06-07.discord.md",
xDraft: "updates/social/2026-06-07.x.md",
});
});
});