@mui/internal-code-infra 0.0.4-canary.8 → 0.0.4-canary.81
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/LICENSE +1 -1
- package/README.md +19 -8
- package/build/babel-config.d.mts +5 -1
- package/build/brokenLinksChecker/crawlWorker.d.mts +1 -0
- package/build/brokenLinksChecker/index.d.mts +45 -2
- package/build/changelog/types.d.ts +1 -1
- package/build/cli/cmdArgosPush.d.mts +2 -2
- package/build/cli/cmdBuild.d.mts +3 -2
- package/build/cli/cmdCopyFiles.d.mts +2 -2
- package/build/cli/cmdExtractErrorCodes.d.mts +2 -2
- package/build/cli/cmdGenerateChangelog.d.mts +2 -2
- package/build/cli/cmdGithubAuth.d.mts +2 -2
- package/build/cli/cmdListWorkspaces.d.mts +6 -4
- package/build/cli/cmdNetlifyIgnore.d.mts +3 -2
- package/build/cli/cmdPublish.d.mts +4 -2
- package/build/cli/cmdPublishCanary.d.mts +3 -3
- package/build/cli/cmdPublishNewPackage.d.mts +4 -2
- package/build/cli/cmdSetVersionOverrides.d.mts +2 -2
- package/build/cli/cmdVale.d.mts +46 -0
- package/build/cli/cmdValidateBuiltTypes.d.mts +2 -2
- package/build/eslint/baseConfig.d.mts +3 -1
- package/build/eslint/mui/rules/disallow-react-api-in-server-components.d.mts +2 -2
- package/build/eslint/mui/rules/docgen-ignore-before-comment.d.mts +2 -2
- package/build/eslint/mui/rules/no-floating-cleanup.d.mts +5 -0
- package/build/eslint/mui/rules/no-guarded-throw.d.mts +31 -0
- package/build/eslint/mui/rules/no-presentation-role.d.mts +5 -0
- package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +2 -2
- package/build/eslint/mui/rules/nodeEnvUtils.d.mts +18 -0
- package/build/remark/config.d.mts +43 -0
- package/build/remark/createLintTester.d.mts +10 -0
- package/build/remark/firstBlockHeading.d.mts +4 -0
- package/build/remark/gitDiff.d.mts +2 -0
- package/build/remark/noSpaceInLinks.d.mts +2 -0
- package/build/remark/straightQuotes.d.mts +2 -0
- package/build/remark/tableAlignment.d.mts +2 -0
- package/build/remark/terminalLanguage.d.mts +2 -0
- package/build/utils/babel.d.mts +1 -1
- package/build/utils/build.d.mts +56 -37
- package/build/utils/git.d.mts +7 -0
- package/build/utils/github.d.mts +1 -1
- package/build/utils/pnpm.d.mts +81 -2
- package/build/utils/testUtils.d.mts +7 -0
- package/build/utils/typescript.d.mts +6 -16
- package/package.json +66 -42
- package/src/babel-config.mjs +3 -1
- package/src/brokenLinksChecker/crawlWorker.mjs +240 -0
- package/src/brokenLinksChecker/index.mjs +263 -188
- package/src/changelog/fetchChangelogs.mjs +6 -2
- package/src/changelog/renderChangelog.mjs +1 -1
- package/src/changelog/types.ts +1 -1
- package/src/cli/cmdBuild.mjs +51 -85
- package/src/cli/cmdListWorkspaces.mjs +12 -27
- package/src/cli/cmdNetlifyIgnore.mjs +34 -93
- package/src/cli/cmdPublish.mjs +95 -20
- package/src/cli/cmdPublishCanary.mjs +128 -132
- package/src/cli/cmdPublishNewPackage.mjs +27 -6
- package/src/cli/cmdSetVersionOverrides.mjs +8 -9
- package/src/cli/cmdVale.mjs +513 -0
- package/src/cli/index.mjs +2 -0
- package/src/cli/packageJson.d.ts +1 -1
- package/src/eslint/baseConfig.mjs +51 -19
- package/src/eslint/docsConfig.mjs +2 -1
- package/src/eslint/mui/config.mjs +24 -4
- package/src/eslint/mui/index.mjs +6 -0
- package/src/eslint/mui/rules/no-floating-cleanup.mjs +187 -0
- package/src/eslint/mui/rules/no-guarded-throw.mjs +115 -0
- package/src/eslint/mui/rules/no-presentation-role.mjs +60 -0
- package/src/eslint/mui/rules/nodeEnvUtils.mjs +52 -0
- package/src/eslint/mui/rules/require-dev-wrapper.mjs +25 -40
- package/src/estree-typescript.d.ts +1 -1
- package/src/remark/config.mjs +157 -0
- package/src/remark/createLintTester.mjs +19 -0
- package/src/remark/firstBlockHeading.mjs +87 -0
- package/src/remark/gitDiff.mjs +43 -0
- package/src/remark/noSpaceInLinks.mjs +42 -0
- package/src/remark/straightQuotes.mjs +31 -0
- package/src/remark/tableAlignment.mjs +23 -0
- package/src/remark/terminalLanguage.mjs +19 -0
- package/src/untyped-plugins.d.ts +11 -11
- package/src/utils/build.mjs +604 -270
- package/src/utils/git.mjs +27 -7
- package/src/utils/pnpm.mjs +277 -10
- package/src/utils/testUtils.mjs +18 -0
- package/src/utils/typescript.mjs +23 -42
- package/vale/.vale.ini +1 -0
- package/vale/styles/MUI/CorrectReferenceAllCases.yml +42 -0
- package/vale/styles/MUI/CorrectRererenceCased.yml +14 -0
- package/vale/styles/MUI/GoogleLatin.yml +11 -0
- package/vale/styles/MUI/MuiBrandName.yml +22 -0
- package/vale/styles/MUI/NoBritish.yml +112 -0
- package/vale/styles/MUI/NoCompanyName.yml +17 -0
- package/build/markdownlint/duplicate-h1.d.mts +0 -56
- package/build/markdownlint/git-diff.d.mts +0 -11
- package/build/markdownlint/index.d.mts +0 -52
- package/build/markdownlint/straight-quotes.d.mts +0 -11
- package/build/markdownlint/table-alignment.d.mts +0 -11
- package/build/markdownlint/terminal-language.d.mts +0 -11
- 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 -28
- 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 -261
- 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/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-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/markdownlint/duplicate-h1.mjs +0 -69
- package/src/markdownlint/git-diff.mjs +0 -31
- package/src/markdownlint/index.mjs +0 -62
- package/src/markdownlint/straight-quotes.mjs +0 -26
- package/src/markdownlint/table-alignment.mjs +0 -42
- package/src/markdownlint/terminal-language.mjs +0 -19
- package/src/utils/build.test.mjs +0 -705
- package/src/utils/template.test.mjs +0 -133
- package/src/utils/typescript.test.mjs +0 -380
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import getPort from 'get-port';
|
|
3
|
-
import { describe, expect, it } from 'vitest';
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line import/extensions
|
|
6
|
-
import { crawl, Issue, Link } from './index.mjs';
|
|
7
|
-
|
|
8
|
-
type ExpectedIssue = Omit<Partial<Issue>, 'link'> & { link?: Partial<Link> };
|
|
9
|
-
|
|
10
|
-
function objectMatchingIssue(expectedIssue: ExpectedIssue) {
|
|
11
|
-
return expect.objectContaining({
|
|
12
|
-
...expectedIssue,
|
|
13
|
-
...(expectedIssue.link ? { link: expect.objectContaining(expectedIssue.link) } : {}),
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Helper to assert that an issue with matching properties exists in the issues array
|
|
19
|
-
*/
|
|
20
|
-
function expectIssue(issues: Issue[], expectedIssue: ExpectedIssue) {
|
|
21
|
-
expect(issues).toEqual(expect.arrayContaining([objectMatchingIssue(expectedIssue)]));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Helper to assert that no issue with matching properties exists in the issues array
|
|
26
|
-
*/
|
|
27
|
-
function expectNotIssue(issues: Issue[], notExpectedIssue: ExpectedIssue) {
|
|
28
|
-
expect(issues).not.toEqual(expect.arrayContaining([objectMatchingIssue(notExpectedIssue)]));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe('Broken Links Checker', () => {
|
|
32
|
-
const fixtureDir = path.join(import.meta.dirname, '__fixtures__', 'static-site');
|
|
33
|
-
const servePath = path.join(import.meta.dirname, '..', '..', 'node_modules', '.bin', 'serve');
|
|
34
|
-
|
|
35
|
-
it('should detect all broken links and targets across the entire site', async () => {
|
|
36
|
-
const port = await getPort();
|
|
37
|
-
const host = `http://localhost:${port}`;
|
|
38
|
-
|
|
39
|
-
const result = await crawl({
|
|
40
|
-
startCommand: `${servePath} ${fixtureDir} -p ${port}`,
|
|
41
|
-
host,
|
|
42
|
-
ignoredPaths: [/ignored-page\.html$/],
|
|
43
|
-
ignoredContent: ['.sidebar'],
|
|
44
|
-
ignoredTargets: new Set(['__should-be-ignored']),
|
|
45
|
-
knownTargets: new Map([['/external-page.html', new Set(['#valid-target'])]]),
|
|
46
|
-
knownTargetsDownloadUrl: [`${host}/known-targets.json`],
|
|
47
|
-
seedUrls: ['/', '/orphaned-page.html'],
|
|
48
|
-
// Test ignores with new array syntax and various property combinations
|
|
49
|
-
ignores: [
|
|
50
|
-
// Backward compatible: single values still work
|
|
51
|
-
{ path: '/broken-links.html', href: '/does-not-exist.html' },
|
|
52
|
-
// Test array syntax: multiple hrefs in one rule (OR logic within property)
|
|
53
|
-
{ path: '/broken-links.html', href: [/another-missing/, '../broken-relative-html.html'] },
|
|
54
|
-
// Test contentType: ignore broken links from markdown files
|
|
55
|
-
{ contentType: 'text/markdown', href: '/broken-from-markdown.html' },
|
|
56
|
-
// Test href-only rule (matches from any page) - note: matches the actual href value
|
|
57
|
-
{ href: 'broken-relative.html' },
|
|
58
|
-
],
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(result.links).toHaveLength(66);
|
|
62
|
-
// Issue count: original 11, minus ignored ones (broken-from-markdown via contentType,
|
|
63
|
-
// broken-relative via href-only rule)
|
|
64
|
-
expect(result.issues).toHaveLength(9);
|
|
65
|
-
|
|
66
|
-
// Test ignores: these broken links should be ignored (not in issues)
|
|
67
|
-
expectNotIssue(result.issues, {
|
|
68
|
-
type: 'broken-link',
|
|
69
|
-
link: {
|
|
70
|
-
src: '/broken-links.html',
|
|
71
|
-
href: '/does-not-exist.html',
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
expectNotIssue(result.issues, {
|
|
76
|
-
type: 'broken-link',
|
|
77
|
-
link: {
|
|
78
|
-
src: '/broken-links.html',
|
|
79
|
-
href: '/another-missing-page.html',
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Check broken-target type issues
|
|
84
|
-
expectIssue(result.issues, {
|
|
85
|
-
type: 'broken-target',
|
|
86
|
-
link: {
|
|
87
|
-
src: '/broken-targets.html',
|
|
88
|
-
href: '/with-anchors.html#nonexistent',
|
|
89
|
-
text: 'Non-existent anchor',
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
expectIssue(result.issues, {
|
|
94
|
-
type: 'broken-target',
|
|
95
|
-
link: {
|
|
96
|
-
src: '/broken-targets.html',
|
|
97
|
-
href: '/valid.html#missing-target',
|
|
98
|
-
text: 'Valid page, missing target',
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
expectIssue(result.issues, {
|
|
103
|
-
type: 'broken-target',
|
|
104
|
-
link: {
|
|
105
|
-
src: '/broken-targets.html',
|
|
106
|
-
href: '/with-anchors.html#also-missing',
|
|
107
|
-
text: 'Also missing',
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Verify that valid links are not reported
|
|
112
|
-
expectNotIssue(result.issues, { link: { href: '/' } });
|
|
113
|
-
expectNotIssue(result.issues, { link: { href: '/valid.html' } });
|
|
114
|
-
expectNotIssue(result.issues, { link: { href: '/with-anchors.html' } });
|
|
115
|
-
expectNotIssue(result.issues, { link: { href: '/with-anchors.html#section1' } });
|
|
116
|
-
expectNotIssue(result.issues, { link: { href: '/with-anchors.html#section2' } });
|
|
117
|
-
expectNotIssue(result.issues, { link: { href: '/with-anchors.html#section3' } });
|
|
118
|
-
expectNotIssue(result.issues, { link: { href: '/nested/page.html' } });
|
|
119
|
-
|
|
120
|
-
// Verify that external links are not reported
|
|
121
|
-
expectNotIssue(result.issues, { link: { href: 'https://example.com' } });
|
|
122
|
-
expectNotIssue(result.issues, { link: { href: 'https://github.com/mui' } });
|
|
123
|
-
|
|
124
|
-
// Test ignoredPaths: ignored-page.html should not be crawled
|
|
125
|
-
expectNotIssue(result.issues, { link: { src: '/ignored-page.html' } });
|
|
126
|
-
expectNotIssue(result.issues, { link: { href: '/this-link-should-not-be-checked.html' } });
|
|
127
|
-
|
|
128
|
-
// Test ignoredContent: links in .sidebar should be ignored
|
|
129
|
-
expectNotIssue(result.issues, { link: { href: '/sidebar-broken-link.html' } });
|
|
130
|
-
|
|
131
|
-
// Test ignoredTargets: IDs that shouldn't be tracked as valid link destinations
|
|
132
|
-
// (e.g., framework-specific IDs like '__next'). Links to these should be reported as broken.
|
|
133
|
-
expectIssue(result.issues, {
|
|
134
|
-
type: 'broken-target',
|
|
135
|
-
link: {
|
|
136
|
-
src: '/page-with-custom-targets.html',
|
|
137
|
-
href: '#__should-be-ignored',
|
|
138
|
-
text: 'Link to ignored ID',
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// Test that non-ignored custom target is valid
|
|
143
|
-
expectNotIssue(result.issues, { link: { href: '/page-with-custom-targets.html#custom-id' } });
|
|
144
|
-
|
|
145
|
-
// Test knownTargets: valid-target is known and should not cause issues
|
|
146
|
-
expectNotIssue(result.issues, { link: { href: '/external-page.html#valid-target' } });
|
|
147
|
-
|
|
148
|
-
// Test knownTargets: invalid-target is not in knownTargets and should cause an issue
|
|
149
|
-
expectIssue(result.issues, {
|
|
150
|
-
type: 'broken-target',
|
|
151
|
-
link: {
|
|
152
|
-
src: '/page-with-known-target-links.html',
|
|
153
|
-
href: '/external-page.html#invalid-target',
|
|
154
|
-
text: 'Invalid external target',
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// Test knownTargetsDownloadUrl: method1 and method2 are in downloaded known targets
|
|
159
|
-
expectNotIssue(result.issues, { link: { href: '/api-page.html#method1' } });
|
|
160
|
-
expectNotIssue(result.issues, { link: { href: '/api-page.html#method2' } });
|
|
161
|
-
|
|
162
|
-
// Test knownTargetsDownloadUrl: unknown-method is not in downloaded known targets and should cause an issue
|
|
163
|
-
expectIssue(result.issues, {
|
|
164
|
-
type: 'broken-target',
|
|
165
|
-
link: {
|
|
166
|
-
src: '/page-with-api-links.html',
|
|
167
|
-
href: '/api-page.html#unknown-method',
|
|
168
|
-
text: 'Unknown API method',
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// Test seedUrls: orphaned-page.html should be crawled even though it's not linked from anywhere
|
|
173
|
-
expect(result.pages.has('/orphaned-page.html')).toBe(true);
|
|
174
|
-
|
|
175
|
-
// Test seedUrls: broken link from orphaned page should be detected
|
|
176
|
-
expectIssue(result.issues, {
|
|
177
|
-
type: 'broken-link',
|
|
178
|
-
link: {
|
|
179
|
-
src: '/orphaned-page.html',
|
|
180
|
-
href: '/orphaned-broken-link.html',
|
|
181
|
-
text: 'Broken link from orphaned page',
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// Test trailing slash normalization: /valid.html and /valid.html/ should be treated as the same page
|
|
186
|
-
// The orphaned page has both links, but they should not cause duplicate page crawls
|
|
187
|
-
expectNotIssue(result.issues, { link: { href: '/valid.html/' } });
|
|
188
|
-
|
|
189
|
-
// Test contentType ignores: broken link from markdown should be ignored via contentType rule
|
|
190
|
-
expectNotIssue(result.issues, {
|
|
191
|
-
type: 'broken-link',
|
|
192
|
-
link: {
|
|
193
|
-
src: '/example.md',
|
|
194
|
-
href: '/broken-from-markdown.html',
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Valid links from markdown should not cause issues
|
|
199
|
-
expectNotIssue(result.issues, { link: { href: '/valid.html', src: '/example.md' } });
|
|
200
|
-
expectNotIssue(result.issues, {
|
|
201
|
-
link: { href: '/with-anchors.html#section1', src: '/example.md' },
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// Links inside code blocks should NOT be extracted (they're text, not <a> tags)
|
|
205
|
-
expectNotIssue(result.issues, { link: { href: '/this-should-not-be-checked.html' } });
|
|
206
|
-
|
|
207
|
-
// Markdown file itself should be crawlable without issues
|
|
208
|
-
expectNotIssue(result.issues, { link: { href: '/example.md' } });
|
|
209
|
-
|
|
210
|
-
// Test that markdown heading anchors are discovered (rehype-slug)
|
|
211
|
-
expect(result.pages.get('/example.md')?.targets.has('#example-markdown-file')).toBe(true);
|
|
212
|
-
expect(result.pages.get('/example.md')?.targets.has('#markdown-section')).toBe(true);
|
|
213
|
-
|
|
214
|
-
// Test href-only ignores: broken-relative.html should be ignored from any page via href-only rule
|
|
215
|
-
expectNotIssue(result.issues, {
|
|
216
|
-
type: 'broken-link',
|
|
217
|
-
link: {
|
|
218
|
-
href: 'broken-relative.html',
|
|
219
|
-
},
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// Valid relative links from markdown should not cause issues
|
|
223
|
-
expectNotIssue(result.issues, { link: { href: 'valid.html', src: '/example.md' } });
|
|
224
|
-
expectNotIssue(result.issues, { link: { href: './with-anchors.html', src: '/example.md' } });
|
|
225
|
-
|
|
226
|
-
// Test relative links in HTML
|
|
227
|
-
// Also verifies that the ignore pattern { path: /^\/broken-links\.html$/, href: '../broken-relative-html.html' }
|
|
228
|
-
// does NOT match this link since the path regex doesn't match /nested/page.html
|
|
229
|
-
expectIssue(result.issues, {
|
|
230
|
-
type: 'broken-link',
|
|
231
|
-
link: {
|
|
232
|
-
src: '/nested/page.html',
|
|
233
|
-
href: '../broken-relative-html.html',
|
|
234
|
-
text: 'Relative broken link from HTML',
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
// Valid relative links from HTML should not cause issues
|
|
239
|
-
expectNotIssue(result.issues, { link: { href: '../valid.html', src: '/nested/page.html' } });
|
|
240
|
-
|
|
241
|
-
// Test unclosed tags: links inside unclosed <main> tags should still be detected
|
|
242
|
-
// (regression test for node-html-parser parseNoneClosedTags option)
|
|
243
|
-
expectIssue(result.issues, {
|
|
244
|
-
type: 'broken-link',
|
|
245
|
-
link: {
|
|
246
|
-
src: '/unclosed-tags.html',
|
|
247
|
-
href: '/broken-inside-unclosed-main.html',
|
|
248
|
-
text: 'Broken link inside unclosed main',
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
// Valid links inside unclosed tags should not cause issues
|
|
253
|
-
expectNotIssue(result.issues, {
|
|
254
|
-
link: { href: '/valid.html', src: '/unclosed-tags.html' },
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// Test contentType is stored on pageData
|
|
258
|
-
expect(result.pages.get('/example.md')?.contentType).toBe('text/markdown');
|
|
259
|
-
expect(result.pages.get('/')?.contentType).toBe('text/html');
|
|
260
|
-
}, 30000);
|
|
261
|
-
});
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
// eslint-disable-next-line import/extensions
|
|
3
|
-
import { categorizeCommits } from './categorizeCommits.mjs';
|
|
4
|
-
import type { FetchedCommitDetails, CategorizationConfig, LabelConfig } from './types';
|
|
5
|
-
|
|
6
|
-
const baseLabelConfig: LabelConfig = {
|
|
7
|
-
plan: {
|
|
8
|
-
values: ['pro', 'premium'],
|
|
9
|
-
},
|
|
10
|
-
flags: {
|
|
11
|
-
'breaking change': { name: 'breaking change' },
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function createCommit(
|
|
16
|
-
prNumber: number,
|
|
17
|
-
labels: string[],
|
|
18
|
-
overrides?: Partial<FetchedCommitDetails>,
|
|
19
|
-
): FetchedCommitDetails {
|
|
20
|
-
return {
|
|
21
|
-
sha: `sha-${prNumber}`,
|
|
22
|
-
message: `feat: feature for PR #${prNumber}`,
|
|
23
|
-
labels,
|
|
24
|
-
prNumber,
|
|
25
|
-
html_url: `https://github.com/mui/mui-x/pull/${prNumber}`,
|
|
26
|
-
author: { login: 'dev', association: 'team' },
|
|
27
|
-
createdAt: null,
|
|
28
|
-
mergedAt: null,
|
|
29
|
-
...overrides,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
describe('categorizeCommits', () => {
|
|
34
|
-
describe('component strategy', () => {
|
|
35
|
-
const componentConfig: CategorizationConfig = {
|
|
36
|
-
strategy: 'component',
|
|
37
|
-
labels: baseLabelConfig,
|
|
38
|
-
sections: {
|
|
39
|
-
fallbackSection: 'Other',
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
it('should categorize commits by component label', () => {
|
|
44
|
-
const commits = [
|
|
45
|
-
createCommit(1, ['component: Button']),
|
|
46
|
-
createCommit(2, ['component: Checkbox']),
|
|
47
|
-
createCommit(3, ['component: Button']),
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
const result = categorizeCommits(commits, componentConfig);
|
|
51
|
-
|
|
52
|
-
expect(result.size).toBe(2);
|
|
53
|
-
// Component labels are normalized to lowercase by parseCommitLabels
|
|
54
|
-
expect(result.get('Button')).toHaveLength(2);
|
|
55
|
-
expect(result.get('Checkbox')).toHaveLength(1);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should place commits without component labels in fallback section', () => {
|
|
59
|
-
const commits = [createCommit(1, []), createCommit(2, ['breaking change'])];
|
|
60
|
-
|
|
61
|
-
const result = categorizeCommits(commits, componentConfig);
|
|
62
|
-
|
|
63
|
-
expect(result.size).toBe(1);
|
|
64
|
-
expect(result.get('Other')).toHaveLength(2);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should place commits with multiple component labels in multiple sections', () => {
|
|
68
|
-
const commits = [createCommit(1, ['component: Button', 'component: Checkbox'])];
|
|
69
|
-
|
|
70
|
-
const result = categorizeCommits(commits, componentConfig);
|
|
71
|
-
|
|
72
|
-
expect(result.size).toBe(2);
|
|
73
|
-
// Component labels are normalized to lowercase by parseCommitLabels
|
|
74
|
-
expect(result.get('Button')).toHaveLength(1);
|
|
75
|
-
expect(result.get('Checkbox')).toHaveLength(1);
|
|
76
|
-
// Same commit object in both categories
|
|
77
|
-
expect(result.get('Button')?.[0].prNumber).toBe(1);
|
|
78
|
-
expect(result.get('Checkbox')?.[0].prNumber).toBe(1);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should use categoryOverride when present', () => {
|
|
82
|
-
const configWithOverrides: CategorizationConfig = {
|
|
83
|
-
...componentConfig,
|
|
84
|
-
labels: {
|
|
85
|
-
...baseLabelConfig,
|
|
86
|
-
categoryOverrides: {
|
|
87
|
-
'all components': 'General changes',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const commits = [
|
|
93
|
-
createCommit(1, ['component: Button', 'all components']),
|
|
94
|
-
createCommit(2, ['component: Checkbox']),
|
|
95
|
-
createCommit(3, ['component: Button', 'all components']),
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
const result = categorizeCommits(commits, configWithOverrides);
|
|
99
|
-
|
|
100
|
-
expect(result.size).toBe(2);
|
|
101
|
-
expect(result.get('General changes')).toHaveLength(2);
|
|
102
|
-
expect(result.get('General changes')?.[0].prNumber).toBe(1);
|
|
103
|
-
expect(result.get('General changes')?.[1].prNumber).toBe(3);
|
|
104
|
-
// Component labels are normalized to lowercase by parseCommitLabels
|
|
105
|
-
expect(result.get('Checkbox')).toHaveLength(1);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('package strategy', () => {
|
|
110
|
-
const packageConfig: CategorizationConfig = {
|
|
111
|
-
strategy: 'package',
|
|
112
|
-
labels: baseLabelConfig,
|
|
113
|
-
packageNaming: {
|
|
114
|
-
mappings: {
|
|
115
|
-
'data grid': '@mui/x-data-grid',
|
|
116
|
-
charts: '@mui/x-charts',
|
|
117
|
-
pickers: '@mui/x-date-pickers',
|
|
118
|
-
},
|
|
119
|
-
genericScopes: ['docs', 'code-infra'],
|
|
120
|
-
plans: {
|
|
121
|
-
pro: {
|
|
122
|
-
'@mui/x-data-grid': '@mui/x-data-grid-pro',
|
|
123
|
-
'@mui/x-charts': '@mui/x-charts-pro',
|
|
124
|
-
'@mui/x-date-pickers': '@mui/x-date-pickers-pro',
|
|
125
|
-
},
|
|
126
|
-
premium: {
|
|
127
|
-
'@mui/x-data-grid': '@mui/x-data-grid-premium',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
sections: {
|
|
132
|
-
fallbackSection: 'Other',
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
it('should categorize commits by scope to package mapping', () => {
|
|
137
|
-
const commits = [
|
|
138
|
-
createCommit(1, ['scope: data grid']),
|
|
139
|
-
createCommit(2, ['scope: charts']),
|
|
140
|
-
createCommit(3, ['scope: data grid']),
|
|
141
|
-
];
|
|
142
|
-
|
|
143
|
-
const result = categorizeCommits(commits, packageConfig);
|
|
144
|
-
|
|
145
|
-
expect(result.size).toBe(2);
|
|
146
|
-
expect(result.get('@mui/x-data-grid')).toHaveLength(2);
|
|
147
|
-
expect(result.get('@mui/x-charts')).toHaveLength(1);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('should place commits without scope in fallback section', () => {
|
|
151
|
-
const commits = [createCommit(1, []), createCommit(2, ['breaking change'])];
|
|
152
|
-
|
|
153
|
-
const result = categorizeCommits(commits, packageConfig);
|
|
154
|
-
|
|
155
|
-
expect(result.size).toBe(1);
|
|
156
|
-
expect(result.get('Other')).toHaveLength(2);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('should place commits with multiple scope labels in multiple sections', () => {
|
|
160
|
-
const commits = [createCommit(1, ['scope: data grid', 'scope: charts'])];
|
|
161
|
-
|
|
162
|
-
const result = categorizeCommits(commits, packageConfig);
|
|
163
|
-
|
|
164
|
-
expect(result.size).toBe(2);
|
|
165
|
-
expect(result.get('@mui/x-data-grid')).toHaveLength(1);
|
|
166
|
-
expect(result.get('@mui/x-charts')).toHaveLength(1);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should use generic scopes directly as section names', () => {
|
|
170
|
-
const commits = [createCommit(1, ['scope: docs']), createCommit(2, ['scope: code-infra'])];
|
|
171
|
-
|
|
172
|
-
const result = categorizeCommits(commits, packageConfig);
|
|
173
|
-
|
|
174
|
-
expect(result.size).toBe(2);
|
|
175
|
-
expect(result.get('docs')).toHaveLength(1);
|
|
176
|
-
expect(result.get('code-infra')).toHaveLength(1);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should apply plan to package name when plan label is present', () => {
|
|
180
|
-
const commits = [
|
|
181
|
-
createCommit(1, ['scope: data grid', 'plan: pro']),
|
|
182
|
-
createCommit(2, ['scope: data grid', 'plan: premium']),
|
|
183
|
-
createCommit(3, ['scope: data grid']),
|
|
184
|
-
];
|
|
185
|
-
|
|
186
|
-
const result = categorizeCommits(commits, packageConfig);
|
|
187
|
-
|
|
188
|
-
expect(result.size).toBe(3);
|
|
189
|
-
expect(result.get('@mui/x-data-grid-pro')).toHaveLength(1);
|
|
190
|
-
expect(result.get('@mui/x-data-grid-premium')).toHaveLength(1);
|
|
191
|
-
expect(result.get('@mui/x-data-grid')).toHaveLength(1);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('should throw error when scope mapping is not found', () => {
|
|
195
|
-
const commits = [createCommit(42, ['scope: unknown-package'])];
|
|
196
|
-
|
|
197
|
-
expect(() => categorizeCommits(commits, packageConfig)).toThrow(
|
|
198
|
-
'No package mapping found for scope "unknown-package" in commit #42',
|
|
199
|
-
);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('should throw error when plan mapping is not found for package', () => {
|
|
203
|
-
const commits = [createCommit(42, ['scope: charts', 'plan: premium'])];
|
|
204
|
-
|
|
205
|
-
expect(() => categorizeCommits(commits, packageConfig)).toThrow(
|
|
206
|
-
'No premium plan package mapping found for base package "@mui/x-charts" in commit #42',
|
|
207
|
-
);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('should throw error when package naming config is missing', () => {
|
|
211
|
-
const configWithoutNaming: CategorizationConfig = {
|
|
212
|
-
strategy: 'package',
|
|
213
|
-
labels: baseLabelConfig,
|
|
214
|
-
sections: {
|
|
215
|
-
fallbackSection: 'Other',
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const commits = [createCommit(1, ['scope: data grid'])];
|
|
220
|
-
|
|
221
|
-
expect(() => categorizeCommits(commits, configWithoutNaming)).toThrow(
|
|
222
|
-
'Package naming configuration is required for package-first strategy',
|
|
223
|
-
);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('should use categoryOverride when present', () => {
|
|
227
|
-
const configWithOverrides: CategorizationConfig = {
|
|
228
|
-
...packageConfig,
|
|
229
|
-
labels: {
|
|
230
|
-
...baseLabelConfig,
|
|
231
|
-
categoryOverrides: {
|
|
232
|
-
'all packages': 'General changes',
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
const commits = [
|
|
238
|
-
createCommit(1, ['scope: data grid', 'all packages']),
|
|
239
|
-
createCommit(2, ['scope: charts']),
|
|
240
|
-
];
|
|
241
|
-
|
|
242
|
-
const result = categorizeCommits(commits, configWithOverrides);
|
|
243
|
-
|
|
244
|
-
expect(result.size).toBe(2);
|
|
245
|
-
expect(result.get('General changes')).toHaveLength(1);
|
|
246
|
-
expect(result.get('@mui/x-charts')).toHaveLength(1);
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
describe('unknown strategy', () => {
|
|
251
|
-
it('should throw error for unknown strategy', () => {
|
|
252
|
-
const invalidConfig = {
|
|
253
|
-
strategy: 'invalid' as 'component',
|
|
254
|
-
labels: baseLabelConfig,
|
|
255
|
-
sections: {
|
|
256
|
-
fallbackSection: 'Other',
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
const commits = [createCommit(1, [])];
|
|
261
|
-
|
|
262
|
-
expect(() => categorizeCommits(commits, invalidConfig)).toThrow(
|
|
263
|
-
'Unknown categorization strategy: invalid',
|
|
264
|
-
);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
describe('parsed labels', () => {
|
|
269
|
-
const config: CategorizationConfig = {
|
|
270
|
-
strategy: 'component',
|
|
271
|
-
labels: {
|
|
272
|
-
...baseLabelConfig,
|
|
273
|
-
flags: {
|
|
274
|
-
'breaking change': { name: 'breaking change' },
|
|
275
|
-
enhancement: { name: 'enhancement' },
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
sections: {
|
|
279
|
-
fallbackSection: 'Other',
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
it('should include parsed labels in categorized commits', () => {
|
|
284
|
-
const commits = [createCommit(1, ['component: Button', 'breaking change', 'enhancement'])];
|
|
285
|
-
|
|
286
|
-
const result = categorizeCommits(commits, config);
|
|
287
|
-
|
|
288
|
-
const categorizedCommit = result.get('Button')?.[0];
|
|
289
|
-
expect(categorizedCommit?.parsed.components).toEqual(['Button']);
|
|
290
|
-
expect(categorizedCommit?.parsed.flags).toEqual(['breaking change', 'enhancement']);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it('should include plan in parsed labels', () => {
|
|
294
|
-
const commits = [createCommit(1, ['component: Button', 'plan: pro'])];
|
|
295
|
-
|
|
296
|
-
const result = categorizeCommits(commits, config);
|
|
297
|
-
|
|
298
|
-
// Component labels are normalized to lowercase by parseCommitLabels
|
|
299
|
-
const categorizedCommit = result.get('Button')?.[0];
|
|
300
|
-
expect(categorizedCommit?.parsed.plan).toBe('pro');
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
describe('empty input', () => {
|
|
305
|
-
const config: CategorizationConfig = {
|
|
306
|
-
strategy: 'component',
|
|
307
|
-
labels: baseLabelConfig,
|
|
308
|
-
sections: {
|
|
309
|
-
fallbackSection: 'Other',
|
|
310
|
-
},
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
it('should return empty map for empty commits array', () => {
|
|
314
|
-
const result = categorizeCommits([], config);
|
|
315
|
-
|
|
316
|
-
expect(result.size).toBe(0);
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
});
|