Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 84 lines 3.4 KB
Raw
1 import { expect, test } from 'bun:test';
2 import { rollChangelog } from './update-changelog';
3
4 const header = '# @composio/cli\n\n## Unreleased\n';
5 const history = '\n## 0.5.0\n\n- Earlier release.\n';
6 const repository = 'ComposioHQ/composio';
7
8 test('files each note under the stable release that shipped it', () => {
9 const baseline = {
10 tag: '@composio/cli@0.5.0',
11 markdown: header + history,
12 };
13 const first = {
14 tag: '@composio/cli@0.6.0',
15 markdown: header + '\n### Minor Changes\n\n- A feature.\n With more detail.\n' + history,
16 };
17 const second = {
18 tag: '@composio/cli@0.6.1',
19 markdown: first.markdown.replace(
20 '### Minor Changes',
21 '### Patch Changes\n\n- A fix.\n\n### Minor Changes'
22 ),
23 };
24 const current = second.markdown.replace(
25 '### Patch Changes',
26 '### Patch Changes\n\n- Pending fix.'
27 );
28 const updated = rollChangelog(current, [baseline, first, second], repository);
29
30 expect(updated).toStartWith(header + '\n### Patch Changes\n\n- Pending fix.\n\n## 0.6.1\n');
31 expect(updated).toContain('## 0.6.1\n\n### Patch Changes\n\n- A fix.\n');
32 expect(updated).toContain('## 0.6.0\n\n### Minor Changes\n\n- A feature.\n With more detail.\n');
33 expect(updated.match(/- A feature\./g)).toHaveLength(1);
34 expect(updated).toEndWith(history);
35 expect(rollChangelog(updated, [second], repository)).toBe(updated);
36 });
37
38 test('uses released notes even after the prior release was rolled on next', () => {
39 const first = {
40 tag: '@composio/cli@0.6.0',
41 markdown: header + '\n- Previously shipped.\n' + history,
42 };
43 const current = header + '\n- Pending fix.\n\n## 0.6.0\n\n- Previously shipped.\n' + history;
44 const second = {
45 tag: '@composio/cli@0.6.1',
46 // A release branch can carry a note that has not landed on next.
47 markdown:
48 header +
49 '\n- A fix from the release branch.\n\n## 0.6.0\n\n- Previously shipped.\n' +
50 history,
51 };
52 const updated = rollChangelog(current, [first, second], repository);
53
54 expect(updated).toStartWith(
55 header + '\n- Pending fix.\n\n## 0.6.1\n\n- A fix from the release branch.\n'
56 );
57 expect(updated.match(/- Previously shipped\./g)).toHaveLength(1);
58 });
59
60 test('files only new notes when a stable release comes from a stale branch', () => {
61 const firstNote = '- First fix.\n More detail.';
62 const secondNote = '- Second fix.';
63 const thirdNote = '- Third fix.';
64 const firstHistory = `\n## 0.6.0\n\n${firstNote}\n\n[Compare with 0.5.0](https://example.com/compare)\n${history}`;
65 const first = { tag: '@composio/cli@0.6.0', markdown: `${header}\n${firstNote}\n${history}` };
66 const second = {
67 tag: '@composio/cli@0.6.1',
68 markdown: `${header}\n${secondNote}\n${firstHistory}`,
69 };
70 const third = {
71 tag: '@composio/cli@0.6.2',
72 markdown: `${header}\n${thirdNote}\n\n${secondNote}\n\n${firstNote}\n${history}`,
73 };
74 const current = `${header}\n- Still pending.\n\n${thirdNote}\n\n${secondNote}\n\n${firstNote}\n${firstHistory}`;
75 const rolledThroughSecond = rollChangelog(current, [first, second], repository);
76 const updated = rollChangelog(rolledThroughSecond, [second, third], repository);
77
78 expect(updated).toStartWith(
79 header + '\n- Still pending.\n\n## 0.6.2\n\n' + thirdNote + '\n\n[Compare'
80 );
81 expect(updated.match(/- First fix\./g)).toHaveLength(1);
82 expect(updated.match(/- Second fix\./g)).toHaveLength(1);
83 expect(rollChangelog(current, [first, second, third], repository)).toBe(updated);
84 });