ci: better naming for test-image snapshot filename (#46369)

This commit is contained in:
vagusX 2023-12-10 19:58:23 +08:00 committed by GitHub
parent b05641dd2d
commit 48d430dff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -136,8 +136,8 @@ function generateReportMd(badCases: IBadCase[], targetBranch: string, targetRef:
reportMdStr += [
badCase.filename,
`![master: ref](${publicPath}/visualRegressionReport/images/base/${filename})`,
`⛔️`,
`🚨`,
`⛔️⛔️⛔️ Missing ⛔️⛔️⛔️`,
`🚨🚨🚨 Removed 🚨🚨🚨`,
].join(' | ');
reportMdStr += ' |\n';
}

View File

@ -35,7 +35,7 @@ export default function imageTest(
identifier: string,
options: ImageTestOptions,
) {
function test(name: string, themedComponent: React.ReactElement) {
function test(name: string, suffix: string, themedComponent: React.ReactElement) {
it(name, async () => {
await jestPuppeteer.resetPage();
await page.setRequestInterception(true);
@ -86,7 +86,7 @@ export default function imageTest(
});
expect(image).toMatchImageSnapshot({
customSnapshotIdentifier: `${identifier}-${name.replace(/\s/g, '-')}`,
customSnapshotIdentifier: `${identifier}${suffix}`,
});
MockDate.reset();
@ -98,12 +98,14 @@ export default function imageTest(
Object.entries(themes).forEach(([key, algorithm]) => {
test(
`component image screenshot should correct ${key}`,
`-${key}`,
<div style={{ background: key === 'dark' ? '#000' : '', padding: `24px 12px` }} key={key}>
<ConfigProvider theme={{ algorithm }}>{component}</ConfigProvider>
</div>,
);
test(
`component image screenshot should correct ${key}.css-var`,
`[CSS Var] component image screenshot should correct ${key}`,
`-${key}.css-var`,
<div style={{ background: key === 'dark' ? '#000' : '', padding: `24px 12px` }} key={key}>
<div>CSS Var</div>
<ConfigProvider theme={{ algorithm, cssVar: true }}>{component}</ConfigProvider>
@ -113,6 +115,7 @@ export default function imageTest(
} else {
test(
`component image screenshot should correct`,
'',
<>
{Object.entries(themes).map(([key, algorithm]) => (
<div style={{ background: key === 'dark' ? '#000' : '', padding: `24px 12px` }} key={key}>
@ -122,7 +125,8 @@ export default function imageTest(
</>,
);
test(
`component image screenshot should correct.css-var`,
`[CSS Var] component image screenshot should correct`,
'.css-var',
<>
<div>CSS Var</div>
{Object.entries(themes).map(([key, algorithm]) => (