diff --git a/.github/workflows/ui-upload.yml b/.github/workflows/ui-upload.yml deleted file mode 100644 index f2470f4dc4..0000000000 --- a/.github/workflows/ui-upload.yml +++ /dev/null @@ -1,63 +0,0 @@ -# Upload 📷 UI snapshots to argos server, help visual regression testing. -name: 📷 UI Upload - -on: - workflow_run: - workflows: ["📷 UI"] - types: - - completed - -permissions: - contents: read - -jobs: - upload-ui: - permissions: - actions: read # for dawidd6/action-download-artifact to query and download artifacts - pull-requests: read # for dawidd6/action-download-artifact to query commit hash - name: deploy preview - runs-on: ubuntu-latest - if: > - github.event.workflow_run.conclusion == 'success' - steps: - - name: checkout - uses: actions/checkout@v3 - - - name: Download commit artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: commit - - - name: Save commit id - id: commit - run: echo "::set-output name=id::$( ./commit.txt - - - name: Save commit - if: github.event_name == 'push' - run: echo ${{ github.sha }} > ./commit.txt - - - name: Upload commit - if: ${{ always() }} - uses: actions/upload-artifact@v3 - with: - name: commit - path: ./commit.txt - - - name: Save branch - if: github.event_name == 'pull_request' && github.base_ref == 'master' - run: echo pull/${{ github.event.pull_request.number }}/merge > ./branch.txt - - - name: Save branch - if: github.event_name == 'push' - run: echo ${GITHUB_REF##*/} > ./branch.txt - - - name: Upload branch - if: ${{ always() }} - uses: actions/upload-artifact@v3 - with: - name: branch - path: ./branch.txt + - name: Upload on Argos + id: deploy + run: npm run argos + env: + ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }} + ARGOS_PARALLEL_NONCE: ${{ github.run_id }} diff --git a/.jest.js b/.jest.js index 1e96c6f9ab..b9434c048d 100644 --- a/.jest.js +++ b/.jest.js @@ -44,6 +44,7 @@ module.exports = { '!components/*/__tests__/type.test.tsx', '!components/**/*/interface.{ts,tsx}', '!components/*/__tests__/image.test.{ts,tsx}', + '!components/__tests__/node.test.tsx', ], transformIgnorePatterns, snapshotSerializers: ['enzyme-to-json/serializer'], diff --git a/.jest.node.js b/.jest.node.js index 4e79459c59..341226e400 100644 --- a/.jest.node.js +++ b/.jest.node.js @@ -12,8 +12,7 @@ module.exports = { '\\.md$': './node_modules/@ant-design/tools/lib/jest/demoPreprocessor', '\\.(jpg|png|gif|svg)$': './node_modules/@ant-design/tools/lib/jest/imagePreprocessor', }, - testRegex: 'demo\\.test\\.(j|t)s$', + testRegex: 'node\\.test\\.(j|t)sx$', testEnvironment: 'node', transformIgnorePatterns, - snapshotSerializers: ['enzyme-to-json/serializer'], }; diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 021c86cd6a..74eff9a2fe 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -15,6 +15,16 @@ timeline: true --- +## 4.23.1 + +`2022-09-09` + +- 🐞 Fix unable to close modal when using visible in `Modal.confirm().update`. [#37471](https://github.com/ant-design/ant-design/pull/37471) [@Aaron674092290](https://github.com/Aaron674092290) +- 🐞 Fix esbuild strict mode call `No matching export theme` error. [#37462](https://github.com/ant-design/ant-design/pull/37462) +- 🐞 Fix Switch background flush issue by reverting [#35103](https://github.com/ant-design/ant-design/pull/35103). [#37458](https://github.com/ant-design/ant-design/pull/37458) +- TypeScript + - 🤖 InputNumber `value` add null type. [#37421](https://github.com/ant-design/ant-design/pull/37421) [@li-jia-nan](https://github.com/li-jia-nan) + ## 4.23.0 `2022-09-04` @@ -44,8 +54,6 @@ timeline: true - 🌐 Add missing translations for filterCheckall in ru_RU. [#37311](https://github.com/ant-design/ant-design/pull/37311) [@HelLuv](https://github.com/HelLuv) - 🌐 Add missing translations in `cs_CZ`. [#37388](https://github.com/ant-design/ant-design/pull/37388) [@ZdenekKrcal](https://github.com/ZdenekKrcal) ---- - ## 4.22.8 `2022-08-26` diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index b08e8c4384..a961783d71 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -15,6 +15,16 @@ timeline: true --- +## 4.23.1 + +`2022-09-09` + +- 🐞 修复 `Modal.confirm().update({visible: true})` 导致无法关闭 modal 的问题。[#37471](https://github.com/ant-design/ant-design/pull/37471) [@Aaron674092290](https://github.com/Aaron674092290) +- 🐞 兜底修复 esbuild 严格模式构建时报 `No matching export theme` 错误。[#37462](https://github.com/ant-design/ant-design/pull/37462) +- 🐞 回滚 [#35103](https://github.com/ant-design/ant-design/pull/35103) 以修复 Switch 切换时背景闪烁的问题。[#37458](https://github.com/ant-design/ant-design/pull/37458) +- TypeScript + - 🤖 InputNumber `value` 新增类型 null。[#37421](https://github.com/ant-design/ant-design/pull/37421) [@li-jia-nan](https://github.com/li-jia-nan) + ## 4.23.0 `2022-09-04` @@ -44,8 +54,6 @@ timeline: true - 🌐 补全 `ru_RU` 中 `filterCheckall` 的翻译。[#37311](https://github.com/ant-design/ant-design/pull/37311) [@HelLuv](https://github.com/HelLuv) - 🌐 补全 `cs_CZ` 的翻译。[#37388](https://github.com/ant-design/ant-design/pull/37388) [@ZdenekKrcal](https://github.com/ZdenekKrcal) ---- - ## 4.22.8 `2022-08-26` diff --git a/components/__tests__/node.test.tsx b/components/__tests__/node.test.tsx new file mode 100644 index 0000000000..ff197dec83 --- /dev/null +++ b/components/__tests__/node.test.tsx @@ -0,0 +1,48 @@ +import glob from 'glob'; +import * as React from 'react'; +import { renderToString } from 'react-dom/server'; +import type { Options } from '../../tests/shared/demoTest'; + +(global as any).testConfig = {}; + +jest.mock('../../tests/shared/demoTest', () => { + function fakeDemoTest(name: string, option: Options = {}) { + (global as any).testConfig[name] = option; + } + + return fakeDemoTest; +}); + +describe('node', () => { + beforeAll(() => { + jest.useFakeTimers().setSystemTime(new Date('2016-11-22')); + }); + + // Find the component exist demo test file + const files = glob.sync(`./components/*/__tests__/demo.test.@(j|t)s?(x)`); + + files.forEach(componentTestFile => { + const componentName = componentTestFile.match(/components\/([^/]*)\//)![1]; + + // Test for ssr + describe(componentName, () => { + const demoList = glob.sync(`./components/${componentName}/demo/*.md`); + + // Use mock to get config + require(`../../${componentTestFile}`); // eslint-disable-line global-require, import/no-dynamic-require + const option = (global as any).testConfig?.[componentName]; + + demoList.forEach(demoFile => { + const skip: string[] = option?.skip || []; + const test = skip.some(skipMarkdown => demoFile.includes(skipMarkdown)) ? it.skip : it; + + test(demoFile, () => { + const Demo = require(`../../${demoFile}`).default; // eslint-disable-line global-require, import/no-dynamic-require + expect(() => { + renderToString(); + }).not.toThrow(); + }); + }); + }); + }); +}); diff --git a/components/_util/reactNode.ts b/components/_util/reactNode.ts index 759fd7a6c2..1fc075b619 100644 --- a/components/_util/reactNode.ts +++ b/components/_util/reactNode.ts @@ -6,17 +6,18 @@ export function isFragment(child: React.ReactElement): boolean { return child && child.type === React.Fragment; } -type AnyObject = Record; +type AnyObject = Record; -type RenderProps = undefined | AnyObject | ((originProps: AnyObject) => AnyObject | undefined); +type RenderProps = AnyObject | ((originProps: AnyObject) => AnyObject | void); export function replaceElement( element: React.ReactNode, replacement: React.ReactNode, - props: RenderProps, + props?: RenderProps, ): React.ReactNode { - if (!isValidElement(element)) return replacement; - + if (!isValidElement(element)) { + return replacement; + } return React.cloneElement( element, typeof props === 'function' ? props(element.props || {}) : props, diff --git a/components/affix/__tests__/Affix.test.tsx b/components/affix/__tests__/Affix.test.tsx index 47e4ee4794..b65684f8a6 100644 --- a/components/affix/__tests__/Affix.test.tsx +++ b/components/affix/__tests__/Affix.test.tsx @@ -65,6 +65,11 @@ describe('Affix Render', () => { } as DOMRect, }; + beforeEach(() => { + const entities = getObserverEntities(); + entities.splice(0, entities.length); + }); + beforeAll(() => { domMock.mockImplementation(function fn(this: HTMLElement) { return ( @@ -171,22 +176,20 @@ describe('Affix Render', () => { }); it('instance change', async () => { - const getObserverLength = () => Object.keys(getObserverEntities()).length; - const container = document.createElement('div'); document.body.appendChild(container); let target: HTMLDivElement | null = container; - const originLength = getObserverLength(); const getTarget = () => target; const { rerender } = render({null}); await sleep(100); + expect(getObserverEntities()).toHaveLength(1); + expect(getObserverEntities()[0].target).toBe(container); - expect(getObserverLength()).toBe(originLength + 1); target = null; rerender({null}); - await sleep(100); - expect(getObserverLength()).toBe(originLength); + expect(getObserverEntities()).toHaveLength(1); + expect(getObserverEntities()[0].target).toBe(window); }); }); diff --git a/components/affix/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/affix/__tests__/__snapshots__/demo-extend.test.ts.snap index a77adba253..2edf5200fb 100644 --- a/components/affix/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/affix/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -36,7 +36,7 @@ Array [ exports[`renders ./components/affix/demo/debug.md extend context correctly 1`] = `
Top @@ -46,7 +46,7 @@ exports[`renders ./components/affix/demo/debug.md extend context correctly 1`] = class="" >
`; diff --git a/components/alert/__tests__/__snapshots__/demo.test.ts.snap b/components/alert/__tests__/__snapshots__/demo.test.ts.snap index 89375f5f50..e6e5349da3 100644 --- a/components/alert/__tests__/__snapshots__/demo.test.ts.snap +++ b/components/alert/__tests__/__snapshots__/demo.test.ts.snap @@ -211,7 +211,7 @@ Array [ >
`; diff --git a/components/alert/__tests__/demo-extend.test.ts b/components/alert/__tests__/demo-extend.test.ts index 5751215777..f0592bac09 100644 --- a/components/alert/__tests__/demo-extend.test.ts +++ b/components/alert/__tests__/demo-extend.test.ts @@ -1,3 +1,3 @@ import { extendTest } from '../../../tests/shared/demoTest'; -extendTest('alert'); +extendTest('alert', { skip: ['loop-banner.md'] }); diff --git a/components/alert/__tests__/demo.test.ts b/components/alert/__tests__/demo.test.ts index 0810864015..86318266b3 100644 --- a/components/alert/__tests__/demo.test.ts +++ b/components/alert/__tests__/demo.test.ts @@ -1,3 +1,3 @@ import demoTest from '../../../tests/shared/demoTest'; -demoTest('alert'); +demoTest('alert', { skip: ['loop-banner.md'] }); diff --git a/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap index 3d65031817..2f4ff9307d 100644 --- a/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -7,7 +7,7 @@ exports[`renders ./components/anchor/demo/basic.md extend context correctly 1`] >