@mui/internal-code-infra 0.0.4-canary.73 → 0.0.4-canary.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -3
- package/src/cli/cmdPublish.mjs +32 -3
- package/src/brokenLinksChecker/__fixtures__/static-site/broken-links.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/broken-targets.html +0 -22
- package/src/brokenLinksChecker/__fixtures__/static-site/example.md +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/external-links.html +0 -21
- package/src/brokenLinksChecker/__fixtures__/static-site/ignored-page.html +0 -17
- package/src/brokenLinksChecker/__fixtures__/static-site/index.html +0 -29
- package/src/brokenLinksChecker/__fixtures__/static-site/invalid-html.html +0 -15
- package/src/brokenLinksChecker/__fixtures__/static-site/known-targets.json +0 -5
- package/src/brokenLinksChecker/__fixtures__/static-site/nested/page.html +0 -21
- package/src/brokenLinksChecker/__fixtures__/static-site/orphaned-page.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-api-links.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-custom-targets.html +0 -24
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-ignored-content.html +0 -28
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-known-target-links.html +0 -19
- package/src/brokenLinksChecker/__fixtures__/static-site/unclosed-tags.html +0 -1
- package/src/brokenLinksChecker/__fixtures__/static-site/valid.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/with-anchors.html +0 -31
- package/src/brokenLinksChecker/index.test.ts +0 -301
- package/src/changelog/categorizeCommits.test.ts +0 -319
- package/src/changelog/filterCommits.test.ts +0 -363
- package/src/changelog/parseCommitLabels.test.ts +0 -509
- package/src/changelog/renderChangelog.test.ts +0 -378
- package/src/changelog/sortSections.test.ts +0 -199
- package/src/cli/cmdVale.test.mjs +0 -644
- package/src/eslint/mui/rules/add-undef-to-optional.test.mjs +0 -361
- package/src/eslint/mui/rules/consistent-production-guard.test.mjs +0 -162
- package/src/eslint/mui/rules/disallow-active-elements-as-key-event-target.test.mjs +0 -66
- package/src/eslint/mui/rules/disallow-react-api-in-server-components.test.mjs +0 -305
- package/src/eslint/mui/rules/docgen-ignore-before-comment.test.mjs +0 -52
- package/src/eslint/mui/rules/flatten-parentheses.test.mjs +0 -245
- package/src/eslint/mui/rules/mui-name-matches-component-name.test.mjs +0 -247
- package/src/eslint/mui/rules/no-empty-box.test.mjs +0 -40
- package/src/eslint/mui/rules/no-floating-cleanup.test.mjs +0 -141
- package/src/eslint/mui/rules/no-guarded-throw.test.mjs +0 -206
- package/src/eslint/mui/rules/no-presentation-role.test.mjs +0 -33
- package/src/eslint/mui/rules/no-styled-box.test.mjs +0 -73
- package/src/eslint/mui/rules/require-dev-wrapper.test.mjs +0 -265
- package/src/eslint/mui/rules/rules-of-use-theme-variants.test.mjs +0 -149
- package/src/eslint/mui/rules/straight-quotes.test.mjs +0 -67
- package/src/remark/firstBlockHeading.test.mjs +0 -107
- package/src/remark/gitDiff.test.mjs +0 -45
- package/src/remark/noSpaceInLinks.test.mjs +0 -22
- package/src/remark/straightQuotes.test.mjs +0 -25
- package/src/remark/tableAlignment.test.mjs +0 -28
- package/src/remark/terminalLanguage.test.mjs +0 -17
- package/src/utils/build.test.mjs +0 -1263
- package/src/utils/pnpm.test.mjs +0 -731
- package/src/utils/template.test.mjs +0 -133
- package/src/utils/typescript.test.mjs +0 -341
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
-
// eslint-disable-next-line import/extensions
|
|
4
|
-
import { renderChangelog } from './renderChangelog.mjs';
|
|
5
|
-
import type { ChangelogSection, CategorizedCommit, ChangelogConfig } from './types';
|
|
6
|
-
|
|
7
|
-
function createCommit(
|
|
8
|
-
prNumber: number,
|
|
9
|
-
message: string,
|
|
10
|
-
mergedAt?: string | null,
|
|
11
|
-
author?: string,
|
|
12
|
-
): CategorizedCommit {
|
|
13
|
-
return {
|
|
14
|
-
sha: `sha-${prNumber}`,
|
|
15
|
-
message,
|
|
16
|
-
labels: [],
|
|
17
|
-
prNumber,
|
|
18
|
-
html_url: `https://github.com/mui/mui-x/pull/${prNumber}`,
|
|
19
|
-
author: author ? { login: author, association: 'team' } : null,
|
|
20
|
-
createdAt: null,
|
|
21
|
-
mergedAt: mergedAt || null,
|
|
22
|
-
parsed: {
|
|
23
|
-
scopes: [],
|
|
24
|
-
components: [],
|
|
25
|
-
flags: [],
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function createSection(commits: CategorizedCommit[]): ChangelogSection {
|
|
31
|
-
return {
|
|
32
|
-
key: 'features',
|
|
33
|
-
level: 3,
|
|
34
|
-
commits,
|
|
35
|
-
pkgInfo: null,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const baseConfig: ChangelogConfig = {
|
|
40
|
-
format: {
|
|
41
|
-
version: 'v{{version}}',
|
|
42
|
-
dateFormat: '_MMM DD, YYYY_',
|
|
43
|
-
changelogMessage: '{{flagPrefix}}{{message}} (#{{prNumber}})',
|
|
44
|
-
},
|
|
45
|
-
categorization: {
|
|
46
|
-
strategy: 'component',
|
|
47
|
-
sections: {
|
|
48
|
-
fallbackSection: 'Other',
|
|
49
|
-
titles: {},
|
|
50
|
-
},
|
|
51
|
-
labels: {
|
|
52
|
-
plan: {
|
|
53
|
-
values: [],
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
describe('renderChangelog - commit sorting by tags', () => {
|
|
60
|
-
describe('sorting commits with tags', () => {
|
|
61
|
-
it('should group commits by their starting tags', () => {
|
|
62
|
-
const commits = [
|
|
63
|
-
createCommit(
|
|
64
|
-
1,
|
|
65
|
-
'[internal] Remove local Claude settings from the repo',
|
|
66
|
-
'2025-01-10T00:00:00Z',
|
|
67
|
-
'cherniavskii',
|
|
68
|
-
),
|
|
69
|
-
createCommit(2, '[code-infra] Update codeowners', '2025-01-01T00:00:00Z', 'JCQuintas'),
|
|
70
|
-
createCommit(
|
|
71
|
-
3,
|
|
72
|
-
'[code-infra] Fix `material-ui/disallow-react-api-in-server-components`',
|
|
73
|
-
'2025-01-05T00:00:00Z',
|
|
74
|
-
'JCQuintas',
|
|
75
|
-
),
|
|
76
|
-
createCommit(4, '[code-infra] Prepare for v9', '2025-01-02T00:00:00Z', 'JCQuintas'),
|
|
77
|
-
createCommit(5, '[docs-infra] Fix two broken links', '2025-01-08T00:00:00Z', 'Janpot'),
|
|
78
|
-
createCommit(
|
|
79
|
-
6,
|
|
80
|
-
'[docs-infra] Fix missing slots section on API page',
|
|
81
|
-
'2025-01-09T00:00:00Z',
|
|
82
|
-
'Janpot',
|
|
83
|
-
),
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
const section = createSection(commits);
|
|
87
|
-
const result = renderChangelog(
|
|
88
|
-
[section],
|
|
89
|
-
baseConfig,
|
|
90
|
-
{
|
|
91
|
-
version: '1.0.0',
|
|
92
|
-
lastRelease: 'v0.1.0',
|
|
93
|
-
release: 'v1.0.0',
|
|
94
|
-
date: new Date('2025-01-15'),
|
|
95
|
-
},
|
|
96
|
-
{ team: [], community: [], all: [] },
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
// Extract the commit messages from the rendered output
|
|
100
|
-
const lines = result.split('\n').filter((line) => line.startsWith('- '));
|
|
101
|
-
|
|
102
|
-
// All code-infra commits should come first (sorted by tag), then docs-infra, then internal
|
|
103
|
-
expect(lines[0]).toContain('Update codeowners');
|
|
104
|
-
expect(lines[1]).toContain('Prepare for v9');
|
|
105
|
-
expect(lines[2]).toContain('Fix `material-ui/disallow-react-api-in-server-components`');
|
|
106
|
-
expect(lines[3]).toContain('Fix two broken links');
|
|
107
|
-
expect(lines[4]).toContain('Fix missing slots section on API page');
|
|
108
|
-
expect(lines[5]).toContain('Remove local Claude settings from the repo');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should sort commits with same tags by merge time', () => {
|
|
112
|
-
const commits = [
|
|
113
|
-
createCommit(1, '[code-infra] Commit 1', '2025-01-10T00:00:00Z'),
|
|
114
|
-
createCommit(2, '[code-infra] Commit 2', '2025-01-05T00:00:00Z'),
|
|
115
|
-
createCommit(3, '[code-infra] Commit 3', '2025-01-08T00:00:00Z'),
|
|
116
|
-
];
|
|
117
|
-
|
|
118
|
-
const section = createSection(commits);
|
|
119
|
-
const result = renderChangelog(
|
|
120
|
-
[section],
|
|
121
|
-
baseConfig,
|
|
122
|
-
{
|
|
123
|
-
version: '1.0.0',
|
|
124
|
-
lastRelease: 'v0.1.0',
|
|
125
|
-
release: 'v1.0.0',
|
|
126
|
-
date: new Date('2025-01-15'),
|
|
127
|
-
},
|
|
128
|
-
{ team: [], community: [], all: [] },
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
const lines = result.split('\n').filter((line) => line.startsWith('- '));
|
|
132
|
-
|
|
133
|
-
expect(lines[0]).toContain('Commit 2');
|
|
134
|
-
expect(lines[1]).toContain('Commit 3');
|
|
135
|
-
expect(lines[2]).toContain('Commit 1');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('should handle commits with multiple tags', () => {
|
|
139
|
-
const commits = [
|
|
140
|
-
createCommit(1, '[code-infra] Update codeowners', '2025-01-01T00:00:00Z', 'JCQuintas'),
|
|
141
|
-
createCommit(
|
|
142
|
-
2,
|
|
143
|
-
'[code-infra][docs] V9 charts migration doc kickoff',
|
|
144
|
-
'2025-01-11T00:00:00Z',
|
|
145
|
-
'JCQuintas',
|
|
146
|
-
),
|
|
147
|
-
createCommit(3, '[docs-infra] Fix two broken links', '2025-01-08T00:00:00Z', 'Janpot'),
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
const section = createSection(commits);
|
|
151
|
-
const result = renderChangelog(
|
|
152
|
-
[section],
|
|
153
|
-
baseConfig,
|
|
154
|
-
{
|
|
155
|
-
version: '1.0.0',
|
|
156
|
-
lastRelease: 'v0.1.0',
|
|
157
|
-
release: 'v1.0.0',
|
|
158
|
-
date: new Date('2025-01-15'),
|
|
159
|
-
},
|
|
160
|
-
{ team: [], community: [], all: [] },
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
const lines = result.split('\n').filter((line) => line.startsWith('- '));
|
|
164
|
-
|
|
165
|
-
// [code-infra] should come before [code-infra][docs]
|
|
166
|
-
expect(lines[0]).toContain('Update codeowners');
|
|
167
|
-
expect(lines[1]).toContain('V9 charts migration doc kickoff');
|
|
168
|
-
expect(lines[2]).toContain('Fix two broken links');
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('should handle commits without tags', () => {
|
|
172
|
-
const commits = [
|
|
173
|
-
createCommit(1, '[code-infra] Update codeowners', '2025-01-05T00:00:00Z'),
|
|
174
|
-
createCommit(2, 'No tag commit', '2025-01-01T00:00:00Z'),
|
|
175
|
-
createCommit(3, 'Another no tag commit', '2025-01-02T00:00:00Z'),
|
|
176
|
-
];
|
|
177
|
-
|
|
178
|
-
const section = createSection(commits);
|
|
179
|
-
const result = renderChangelog(
|
|
180
|
-
[section],
|
|
181
|
-
baseConfig,
|
|
182
|
-
{
|
|
183
|
-
version: '1.0.0',
|
|
184
|
-
lastRelease: 'v0.1.0',
|
|
185
|
-
release: 'v1.0.0',
|
|
186
|
-
date: new Date('2025-01-15'),
|
|
187
|
-
},
|
|
188
|
-
{ team: [], community: [], all: [] },
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
const lines = result.split('\n').filter((line) => line.startsWith('- '));
|
|
192
|
-
|
|
193
|
-
// Tagged commits should come before untagged
|
|
194
|
-
expect(lines[0]).toContain('Update codeowners');
|
|
195
|
-
expect(lines[1]).toContain('No tag commit');
|
|
196
|
-
expect(lines[2]).toContain('Another no tag commit');
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it('should match the user-provided example output order', () => {
|
|
200
|
-
const commits = [
|
|
201
|
-
createCommit(
|
|
202
|
-
20853,
|
|
203
|
-
'[internal] Remove local Claude settings from the repo',
|
|
204
|
-
'2025-01-01T00:00:00Z',
|
|
205
|
-
'cherniavskii',
|
|
206
|
-
),
|
|
207
|
-
createCommit(20886, '[code-infra] Update codeowners', '2025-01-02T00:00:00Z', 'JCQuintas'),
|
|
208
|
-
createCommit(
|
|
209
|
-
20909,
|
|
210
|
-
'[code-infra] Fix `material-ui/disallow-react-api-in-server-components`',
|
|
211
|
-
'2025-01-03T00:00:00Z',
|
|
212
|
-
'JCQuintas',
|
|
213
|
-
),
|
|
214
|
-
createCommit(20860, '[code-infra] Prepare for v9', '2025-01-04T00:00:00Z', 'JCQuintas'),
|
|
215
|
-
createCommit(20914, '[docs-infra] Fix two broken links', '2025-01-05T00:00:00Z', 'Janpot'),
|
|
216
|
-
createCommit(
|
|
217
|
-
20915,
|
|
218
|
-
'[docs-infra] Fix missing slots section on API page',
|
|
219
|
-
'2025-01-06T00:00:00Z',
|
|
220
|
-
'Janpot',
|
|
221
|
-
),
|
|
222
|
-
createCommit(
|
|
223
|
-
20922,
|
|
224
|
-
'[code-infra] Github action to sync title and label',
|
|
225
|
-
'2025-01-07T00:00:00Z',
|
|
226
|
-
'brijeshb42',
|
|
227
|
-
),
|
|
228
|
-
createCommit(
|
|
229
|
-
20934,
|
|
230
|
-
'[code-infra] Fix the label comparison to use lower case',
|
|
231
|
-
'2025-01-08T00:00:00Z',
|
|
232
|
-
'brijeshb42',
|
|
233
|
-
),
|
|
234
|
-
createCommit(
|
|
235
|
-
20973,
|
|
236
|
-
'[code-infra][docs] V9 charts migration doc kickoff',
|
|
237
|
-
'2025-01-09T00:00:00Z',
|
|
238
|
-
'JCQuintas',
|
|
239
|
-
),
|
|
240
|
-
createCommit(
|
|
241
|
-
20932,
|
|
242
|
-
'[internal] Set up shared instructions for coding agents',
|
|
243
|
-
'2025-01-10T00:00:00Z',
|
|
244
|
-
'cherniavskii',
|
|
245
|
-
),
|
|
246
|
-
createCommit(20928, '[code-infra] V9 preparation', '2025-01-11T00:00:00Z', 'JCQuintas'),
|
|
247
|
-
createCommit(
|
|
248
|
-
20977,
|
|
249
|
-
'[code-infra] Fix `renameImports` codemod not preserving comments',
|
|
250
|
-
'2025-01-12T00:00:00Z',
|
|
251
|
-
'JCQuintas',
|
|
252
|
-
),
|
|
253
|
-
createCommit(
|
|
254
|
-
20982,
|
|
255
|
-
'[code-infra] Ignore scheduler demo with random data',
|
|
256
|
-
'2025-01-13T00:00:00Z',
|
|
257
|
-
'JCQuintas',
|
|
258
|
-
),
|
|
259
|
-
];
|
|
260
|
-
|
|
261
|
-
const section = createSection(commits);
|
|
262
|
-
const result = renderChangelog(
|
|
263
|
-
[section],
|
|
264
|
-
baseConfig,
|
|
265
|
-
{
|
|
266
|
-
version: '1.0.0',
|
|
267
|
-
lastRelease: 'v0.1.0',
|
|
268
|
-
release: 'v1.0.0',
|
|
269
|
-
date: new Date('2025-01-15'),
|
|
270
|
-
},
|
|
271
|
-
{ team: [], community: [], all: [] },
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
const lines = result.split('\n').filter((line) => line.startsWith('- '));
|
|
275
|
-
|
|
276
|
-
// Expected order: all [code-infra] commits sorted by merge time (chronological),
|
|
277
|
-
// then [code-infra][docs] (which has code-infra as first tag, followed by docs),
|
|
278
|
-
// then [docs-infra], then [internal]
|
|
279
|
-
expect(lines[0]).toContain('20886'); // [code-infra] 2025-01-02
|
|
280
|
-
expect(lines[1]).toContain('20909'); // [code-infra] 2025-01-03
|
|
281
|
-
expect(lines[2]).toContain('20860'); // [code-infra] 2025-01-04
|
|
282
|
-
expect(lines[3]).toContain('20922'); // [code-infra] 2025-01-07
|
|
283
|
-
expect(lines[4]).toContain('20934'); // [code-infra] 2025-01-08
|
|
284
|
-
expect(lines[5]).toContain('20928'); // [code-infra] 2025-01-11
|
|
285
|
-
expect(lines[6]).toContain('20977'); // [code-infra] 2025-01-12
|
|
286
|
-
expect(lines[7]).toContain('20982'); // [code-infra] 2025-01-13
|
|
287
|
-
expect(lines[8]).toContain('20973'); // [code-infra][docs] 2025-01-09
|
|
288
|
-
expect(lines[9]).toContain('20914'); // [docs-infra] 2025-01-05
|
|
289
|
-
expect(lines[10]).toContain('20915'); // [docs-infra] 2025-01-06
|
|
290
|
-
expect(lines[11]).toContain('20853'); // [internal] 2025-01-01
|
|
291
|
-
expect(lines[12]).toContain('20932'); // [internal] 2025-01-10
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('should handle tags with spaces and hyphens', () => {
|
|
295
|
-
const commits = [
|
|
296
|
-
createCommit(1, '[my-scope] Commit 1', '2025-01-05T00:00:00Z'),
|
|
297
|
-
createCommit(2, '[my scope] Commit 2', '2025-01-01T00:00:00Z'),
|
|
298
|
-
createCommit(3, '[my-scope] Commit 3', '2025-01-02T00:00:00Z'),
|
|
299
|
-
];
|
|
300
|
-
|
|
301
|
-
const section = createSection(commits);
|
|
302
|
-
const result = renderChangelog(
|
|
303
|
-
[section],
|
|
304
|
-
baseConfig,
|
|
305
|
-
{
|
|
306
|
-
version: '1.0.0',
|
|
307
|
-
lastRelease: 'v0.1.0',
|
|
308
|
-
release: 'v1.0.0',
|
|
309
|
-
date: new Date('2025-01-15'),
|
|
310
|
-
},
|
|
311
|
-
{ team: [], community: [], all: [] },
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
const lines = result.split('\n').filter((line) => line.startsWith('- '));
|
|
315
|
-
|
|
316
|
-
// All commits with same tag should be together
|
|
317
|
-
expect(lines[0]).toContain('Commit 2');
|
|
318
|
-
expect(lines[1]).toContain('Commit 3');
|
|
319
|
-
expect(lines[2]).toContain('Commit 1');
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('should handle case-insensitive tag matching', () => {
|
|
323
|
-
const commits = [
|
|
324
|
-
createCommit(1, '[CODE-INFRA] Uppercase tag', '2025-01-01T00:00:00Z'),
|
|
325
|
-
createCommit(2, '[code-infra] Lowercase tag', '2025-01-02T00:00:00Z'),
|
|
326
|
-
createCommit(3, '[Code-Infra] Mixed case tag', '2025-01-03T00:00:00Z'),
|
|
327
|
-
];
|
|
328
|
-
|
|
329
|
-
const section = createSection(commits);
|
|
330
|
-
const result = renderChangelog(
|
|
331
|
-
[section],
|
|
332
|
-
baseConfig,
|
|
333
|
-
{
|
|
334
|
-
version: '1.0.0',
|
|
335
|
-
lastRelease: 'v0.1.0',
|
|
336
|
-
release: 'v1.0.0',
|
|
337
|
-
date: new Date('2025-01-15'),
|
|
338
|
-
},
|
|
339
|
-
{ team: [], community: [], all: [] },
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
const lines = result.split('\n').filter((line) => line.startsWith('- '));
|
|
343
|
-
|
|
344
|
-
// All should be treated as the same tag and sorted by merge time
|
|
345
|
-
expect(lines[0]).toContain('Uppercase tag');
|
|
346
|
-
expect(lines[1]).toContain('Lowercase tag');
|
|
347
|
-
expect(lines[2]).toContain('Mixed case tag');
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('should sort commits with merge time fallback to prNumber', () => {
|
|
351
|
-
const commits = [
|
|
352
|
-
createCommit(1, '[code-infra] Commit with mergedAt', null),
|
|
353
|
-
createCommit(3, '[code-infra] Commit 3', null),
|
|
354
|
-
createCommit(2, '[code-infra] Commit 2', null),
|
|
355
|
-
];
|
|
356
|
-
|
|
357
|
-
const section = createSection(commits);
|
|
358
|
-
const result = renderChangelog(
|
|
359
|
-
[section],
|
|
360
|
-
baseConfig,
|
|
361
|
-
{
|
|
362
|
-
version: '1.0.0',
|
|
363
|
-
lastRelease: 'v0.1.0',
|
|
364
|
-
release: 'v1.0.0',
|
|
365
|
-
date: new Date('2025-01-15'),
|
|
366
|
-
},
|
|
367
|
-
{ team: [], community: [], all: [] },
|
|
368
|
-
);
|
|
369
|
-
|
|
370
|
-
const lines = result.split('\n').filter((line) => line.startsWith('- '));
|
|
371
|
-
|
|
372
|
-
// Should be sorted by prNumber when mergedAt is null
|
|
373
|
-
expect(lines[0]).toContain('Commit with mergedAt');
|
|
374
|
-
expect(lines[1]).toContain('Commit 2');
|
|
375
|
-
expect(lines[2]).toContain('Commit 3');
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
});
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
// eslint-disable-next-line import/extensions
|
|
3
|
-
import { sortSections } from './sortSections.mjs';
|
|
4
|
-
import type { ChangelogSection, CategorizationConfig, LabelConfig } from './types';
|
|
5
|
-
|
|
6
|
-
const baseLabelConfig: LabelConfig = {
|
|
7
|
-
plan: {
|
|
8
|
-
values: ['pro', 'premium'],
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function createSection(key: string, commits: number = 1): ChangelogSection {
|
|
13
|
-
return {
|
|
14
|
-
key,
|
|
15
|
-
level: 3,
|
|
16
|
-
commits: Array(commits).fill({
|
|
17
|
-
sha: 'abc123',
|
|
18
|
-
message: 'test commit',
|
|
19
|
-
labels: [],
|
|
20
|
-
prNumber: 1,
|
|
21
|
-
html_url: 'https://github.com/test/repo/pull/1',
|
|
22
|
-
author: null,
|
|
23
|
-
createdAt: null,
|
|
24
|
-
mergedAt: null,
|
|
25
|
-
parsed: { scopes: [], components: [], flags: [] },
|
|
26
|
-
}),
|
|
27
|
-
pkgInfo: null,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe('sortSections', () => {
|
|
32
|
-
describe('default ordering', () => {
|
|
33
|
-
const config: CategorizationConfig = {
|
|
34
|
-
strategy: 'component',
|
|
35
|
-
labels: baseLabelConfig,
|
|
36
|
-
sections: {
|
|
37
|
-
fallbackSection: 'Other',
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
it('should sort sections alphabetically by key when no order is specified', () => {
|
|
42
|
-
const sections = [createSection('Zebra'), createSection('Apple'), createSection('Mango')];
|
|
43
|
-
|
|
44
|
-
const result = sortSections(sections, config);
|
|
45
|
-
|
|
46
|
-
expect(result.map((s) => s.key)).toEqual(['Apple', 'Mango', 'Zebra']);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should return empty array for empty input', () => {
|
|
50
|
-
const result = sortSections([], config);
|
|
51
|
-
|
|
52
|
-
expect(result).toEqual([]);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('priority ordering', () => {
|
|
57
|
-
it('should sort sections by order index (lower values first)', () => {
|
|
58
|
-
const config: CategorizationConfig = {
|
|
59
|
-
strategy: 'component',
|
|
60
|
-
labels: baseLabelConfig,
|
|
61
|
-
sections: {
|
|
62
|
-
order: {
|
|
63
|
-
Zebra: -1,
|
|
64
|
-
Apple: 1,
|
|
65
|
-
Mango: 0,
|
|
66
|
-
},
|
|
67
|
-
fallbackSection: 'Other',
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const sections = [createSection('Apple'), createSection('Zebra'), createSection('Mango')];
|
|
72
|
-
|
|
73
|
-
const result = sortSections(sections, config);
|
|
74
|
-
|
|
75
|
-
expect(result.map((s) => s.key)).toEqual(['Zebra', 'Mango', 'Apple']);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should sort alphabetically when order index is the same', () => {
|
|
79
|
-
const config: CategorizationConfig = {
|
|
80
|
-
strategy: 'component',
|
|
81
|
-
labels: baseLabelConfig,
|
|
82
|
-
sections: {
|
|
83
|
-
order: {
|
|
84
|
-
Zebra: 0,
|
|
85
|
-
Apple: 0,
|
|
86
|
-
Mango: 0,
|
|
87
|
-
},
|
|
88
|
-
fallbackSection: 'Other',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const sections = [createSection('Zebra'), createSection('Apple'), createSection('Mango')];
|
|
93
|
-
|
|
94
|
-
const result = sortSections(sections, config);
|
|
95
|
-
|
|
96
|
-
expect(result.map((s) => s.key)).toEqual(['Apple', 'Mango', 'Zebra']);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should use default order index of 0 for sections not in order config', () => {
|
|
100
|
-
const config: CategorizationConfig = {
|
|
101
|
-
strategy: 'component',
|
|
102
|
-
labels: baseLabelConfig,
|
|
103
|
-
sections: {
|
|
104
|
-
order: {
|
|
105
|
-
Zebra: -1,
|
|
106
|
-
Apple: 1,
|
|
107
|
-
},
|
|
108
|
-
fallbackSection: 'Other',
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const sections = [
|
|
113
|
-
createSection('Apple'),
|
|
114
|
-
createSection('Zebra'),
|
|
115
|
-
createSection('Mango'), // Not in order config, defaults to 0
|
|
116
|
-
];
|
|
117
|
-
|
|
118
|
-
const result = sortSections(sections, config);
|
|
119
|
-
|
|
120
|
-
// Zebra (-1) < Mango (0) < Apple (1)
|
|
121
|
-
expect(result.map((s) => s.key)).toEqual(['Zebra', 'Mango', 'Apple']);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should handle negative order indices', () => {
|
|
125
|
-
const config: CategorizationConfig = {
|
|
126
|
-
strategy: 'component',
|
|
127
|
-
labels: baseLabelConfig,
|
|
128
|
-
sections: {
|
|
129
|
-
order: {
|
|
130
|
-
First: -100,
|
|
131
|
-
Second: -50,
|
|
132
|
-
Third: 0,
|
|
133
|
-
Last: 100,
|
|
134
|
-
},
|
|
135
|
-
fallbackSection: 'Other',
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const sections = [
|
|
140
|
-
createSection('Last'),
|
|
141
|
-
createSection('Third'),
|
|
142
|
-
createSection('First'),
|
|
143
|
-
createSection('Second'),
|
|
144
|
-
];
|
|
145
|
-
|
|
146
|
-
const result = sortSections(sections, config);
|
|
147
|
-
|
|
148
|
-
expect(result.map((s) => s.key)).toEqual(['First', 'Second', 'Third', 'Last']);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('should not mutate the original array', () => {
|
|
152
|
-
const config: CategorizationConfig = {
|
|
153
|
-
strategy: 'component',
|
|
154
|
-
labels: baseLabelConfig,
|
|
155
|
-
sections: {
|
|
156
|
-
order: {
|
|
157
|
-
Zebra: -1,
|
|
158
|
-
},
|
|
159
|
-
fallbackSection: 'Other',
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const sections = [createSection('Apple'), createSection('Zebra')];
|
|
164
|
-
const originalOrder = sections.map((s) => s.key);
|
|
165
|
-
|
|
166
|
-
sortSections(sections, config);
|
|
167
|
-
|
|
168
|
-
expect(sections.map((s) => s.key)).toEqual(originalOrder);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('package strategy', () => {
|
|
173
|
-
it('should sort package sections by order index', () => {
|
|
174
|
-
const config: CategorizationConfig = {
|
|
175
|
-
strategy: 'package',
|
|
176
|
-
labels: baseLabelConfig,
|
|
177
|
-
packageNaming: {
|
|
178
|
-
mappings: {
|
|
179
|
-
'data grid': '@mui/x-data-grid',
|
|
180
|
-
charts: '@mui/x-charts',
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
sections: {
|
|
184
|
-
order: {
|
|
185
|
-
'@mui/x-charts': -1,
|
|
186
|
-
'@mui/x-data-grid': 1,
|
|
187
|
-
},
|
|
188
|
-
fallbackSection: 'Other',
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const sections = [createSection('@mui/x-data-grid'), createSection('@mui/x-charts')];
|
|
193
|
-
|
|
194
|
-
const result = sortSections(sections, config);
|
|
195
|
-
|
|
196
|
-
expect(result.map((s) => s.key)).toEqual(['@mui/x-charts', '@mui/x-data-grid']);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
});
|