diff --git a/components/breadcrumb/__tests__/image.test.ts b/components/breadcrumb/__tests__/image.test.ts index 1c86b595a0..feec0ba1ba 100644 --- a/components/breadcrumb/__tests__/image.test.ts +++ b/components/breadcrumb/__tests__/image.test.ts @@ -1,5 +1,5 @@ import { imageDemoTest } from '../../../tests/shared/imageTest'; describe('Breadcrumb image', () => { - imageDemoTest('breadcrumb', { skip: ['react-router.tsx'] }); + imageDemoTest('breadcrumb'); }); diff --git a/components/button/__tests__/visual-diff.config.ts b/components/button/__tests__/visual-diff.config.ts index 2dc149c8fa..c0c86e9ca5 100644 --- a/components/button/__tests__/visual-diff.config.ts +++ b/components/button/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'button', skip: ['loading.tsx'] }; +export default { id: 'button', skip: ['loading'] }; diff --git a/components/config-provider/__tests__/visual-diff.config.ts b/components/config-provider/__tests__/visual-diff.config.ts index 166002be2e..ca44d279bf 100644 --- a/components/config-provider/__tests__/visual-diff.config.ts +++ b/components/config-provider/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'config-provider', skip: ['direction.tsx', 'theme.tsx'] }; +export default { id: 'config-provider', skip: ['direction', 'theme'] }; diff --git a/components/dropdown/__tests__/visual-diff.config.ts b/components/dropdown/__tests__/visual-diff.config.ts index b30180071b..72a4a598d0 100644 --- a/components/dropdown/__tests__/visual-diff.config.ts +++ b/components/dropdown/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'dropdown', skip: ['dropdown-button.tsx'] }; +export default { id: 'dropdown', skip: ['dropdown-button'] }; diff --git a/components/float-button/__tests__/image.test.ts b/components/float-button/__tests__/image.test.ts index 7b5d460db7..15cbef314d 100644 --- a/components/float-button/__tests__/image.test.ts +++ b/components/float-button/__tests__/image.test.ts @@ -1,5 +1,5 @@ import { imageDemoTest } from '../../../tests/shared/imageTest'; describe('float-button image', () => { - imageDemoTest('float-button', { onlyViewport: ['back-top.tsx'] }); + imageDemoTest('float-button', { onlyViewport: ['back-top'] }); }); diff --git a/components/float-button/__tests__/visual-diff.config.ts b/components/float-button/__tests__/visual-diff.config.ts index b857a27b39..401eb5191b 100644 --- a/components/float-button/__tests__/visual-diff.config.ts +++ b/components/float-button/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'float-button', onlyViewport: ['back-top.tsx'] }; +export default { id: 'float-button', onlyViewport: ['back-top'] }; diff --git a/components/form/__tests__/visual-diff.config.ts b/components/form/__tests__/visual-diff.config.ts index 56fbecc705..9493aecc35 100644 --- a/components/form/__tests__/visual-diff.config.ts +++ b/components/form/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'form', skip: ['complex-form-control.tsx'] }; +export default { id: 'form', skip: ['complex-form-control'] }; diff --git a/components/icon/__tests__/visual-diff.config.ts b/components/icon/__tests__/visual-diff.config.ts index a5bb8b27a8..563d0c2afc 100644 --- a/components/icon/__tests__/visual-diff.config.ts +++ b/components/icon/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'icon', skip: ['basic.tsx'] }; +export default { id: 'icon', skip: ['basic'] }; diff --git a/components/input/__tests__/visual-diff.config.ts b/components/input/__tests__/visual-diff.config.ts index 6528a08ea9..3052cda6c7 100644 --- a/components/input/__tests__/visual-diff.config.ts +++ b/components/input/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'input', skip: ['search-input-loading.tsx'] }; +export default { id: 'input', skip: ['search-input-loading'] }; diff --git a/components/layout/__tests__/visual-diff.config.ts b/components/layout/__tests__/visual-diff.config.ts index b57618ea73..eef790c537 100644 --- a/components/layout/__tests__/visual-diff.config.ts +++ b/components/layout/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'layout', skip: ['fixed-sider.tsx'] }; +export default { id: 'layout', skip: ['fixed-sider'] }; diff --git a/components/list/__tests__/visual-diff.config.ts b/components/list/__tests__/visual-diff.config.ts index 77253bb3e7..a28de256ed 100644 --- a/components/list/__tests__/visual-diff.config.ts +++ b/components/list/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'list', skip: ['loadmore.tsx'] }; +export default { id: 'list', skip: ['loadmore'] }; diff --git a/components/popconfirm/__tests__/visual-diff.config.ts b/components/popconfirm/__tests__/visual-diff.config.ts index 4474b1f987..525ce7ad57 100644 --- a/components/popconfirm/__tests__/visual-diff.config.ts +++ b/components/popconfirm/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'popconfirm' }; +export default { id: 'popconfirm', onlyViewport: ['shift'] }; diff --git a/components/popover/__tests__/visual-diff.config.ts b/components/popover/__tests__/visual-diff.config.ts index 629f59d573..d2d1db2217 100644 --- a/components/popover/__tests__/visual-diff.config.ts +++ b/components/popover/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'popover' }; +export default { id: 'popover', onlyViewport: ['shift'] }; diff --git a/components/switch/__tests__/visual-diff.config.ts b/components/switch/__tests__/visual-diff.config.ts index 00adac832b..85b7df7175 100644 --- a/components/switch/__tests__/visual-diff.config.ts +++ b/components/switch/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'switch', skip: ['loading.tsx'] }; +export default { id: 'switch', skip: ['loading'] }; diff --git a/components/table/__tests__/visual-diff.config.ts b/components/table/__tests__/visual-diff.config.ts index c19cec4151..0c6e75340d 100644 --- a/components/table/__tests__/visual-diff.config.ts +++ b/components/table/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'table', skip: ['virtual-list.tsx'] }; +export default { id: 'table', skip: ['virtual-list'] }; diff --git a/components/tag/__tests__/visual-diff.config.ts b/components/tag/__tests__/visual-diff.config.ts index edf2e548e3..da3c485637 100644 --- a/components/tag/__tests__/visual-diff.config.ts +++ b/components/tag/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'tag', skip: ['status.tsx'] }; +export default { id: 'tag', skip: ['status'] }; diff --git a/components/timeline/__tests__/visual-diff.config.ts b/components/timeline/__tests__/visual-diff.config.ts index 0e734e6d27..26b790ac28 100644 --- a/components/timeline/__tests__/visual-diff.config.ts +++ b/components/timeline/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'timeline', skip: ['pending.tsx'] }; +export default { id: 'timeline', skip: ['pending'] }; diff --git a/components/tooltip/__tests__/visual-diff.config.ts b/components/tooltip/__tests__/visual-diff.config.ts index 6aee151e65..325cc26462 100644 --- a/components/tooltip/__tests__/visual-diff.config.ts +++ b/components/tooltip/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'tooltip', onlyViewport: ['shift.tsx'] }; +export default { id: 'tooltip', onlyViewport: ['shift'] }; diff --git a/components/tree/__tests__/visual-diff.config.ts b/components/tree/__tests__/visual-diff.config.ts index 4ab7120efa..ef1a3d0758 100644 --- a/components/tree/__tests__/visual-diff.config.ts +++ b/components/tree/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'tree', skip: ['virtual-scroll.tsx', 'big-data.tsx'] }; +export default { id: 'tree', skip: ['virtual-scroll', 'big-data'] }; diff --git a/components/upload/__tests__/visual-diff.config.ts b/components/upload/__tests__/visual-diff.config.ts index 3b33b5d53d..b56c1070de 100644 --- a/components/upload/__tests__/visual-diff.config.ts +++ b/components/upload/__tests__/visual-diff.config.ts @@ -1 +1 @@ -export default { id: 'upload', skip: ['crop-image.tsx'] }; +export default { id: 'upload', skip: ['crop-image'] }; diff --git a/scripts/visual-diff-capture.ts b/scripts/visual-diff-capture.ts index 37825715ae..75c0127c1d 100644 --- a/scripts/visual-diff-capture.ts +++ b/scripts/visual-diff-capture.ts @@ -15,7 +15,9 @@ import type { LogLevelNames } from 'loglevel'; interface VisualDiffConfig { id: string; - onlyViewport?: boolean; + skip?: boolean | string[]; + onlyViewport?: boolean | string[]; + /** Open Trigger to check the popup render */ openTriggerClassName?: string; } @@ -120,6 +122,14 @@ class BrowserAuto { const demoUrl = await retrieveDemoUrl(mdPath); const options = await retrieveConfig(mdPath); + const skip = + Array.isArray(options.skip) && + options.skip.some((c) => path.basename(mdPath, '.md').endsWith(c)); + if (skip) { + loglevel.info('Skip for: %s', mdPath); + return; + } + const query = new URLSearchParams(); query.set('theme', theme); if (enableCssVar) { @@ -140,7 +150,18 @@ class BrowserAuto { await page.waitForSelector('.dumi-antd-demo-layout'); - if (!options.onlyViewport) { + const onlyViewport = + options.onlyViewport === true || + (Array.isArray(options.onlyViewport) && + options.onlyViewport.some((c) => path.basename(mdPath, '.md').endsWith(c))); + + loglevel.info( + 'visit: %s, onlyViewport: %s, openTriggerClassName: %s', + pageUrl, + onlyViewport, + options.openTriggerClassName, + ); + if (!onlyViewport) { // Get scroll height of the rendered page and set viewport const bodyHeight = await page.evaluate(() => document.body.scrollHeight); await page.setViewportSize({ width: 800, height: bodyHeight }); @@ -252,8 +273,8 @@ function parseArgs(): { // 增加并发 await pAll( visitConfigs.map((visitConfig, i) => async () => { - console.log( - `处理 ${i + 1}/${mdPaths.length}: ${visitConfig.mdPath}-${visitConfig.theme}-${visitConfig.enableCssVar}`, + loglevel.info( + `处理 ${i + 1}/${visitConfigs.length}: ${visitConfig.mdPath} / ${visitConfig.theme} / ${visitConfig.enableCssVar}`, ); return task(visitConfig); }),