diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 97db4c35a1..16bb7253a7 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -2,7 +2,7 @@ name: Preview Build -on: +on: pull_request: types: [opened, synchronize, reopened] @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: cache package-lock.json uses: actions/cache@v2 @@ -22,7 +22,7 @@ jobs: key: lock-${{ github.sha }} - name: create package-lock.json - run: npm i --package-lock-only + run: npm i --package-lock-only --ignore-scripts - name: hack for single file run: | @@ -47,7 +47,7 @@ jobs: needs: setup steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml index 8e858fefb9..0d4b713e9b 100644 --- a/.github/workflows/rebase.yml +++ b/.github/workflows/rebase.yml @@ -1,6 +1,6 @@ name: Automatic Rebase -on: +on: issue_comment: types: [created] @@ -10,7 +10,7 @@ jobs: if: github.event.issue.pull_request != '' && (contains(github.event.comment.body, '/rebase') || contains(github.event.comment.body, '\rebase')) runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2 with: fetch-depth: 0 - name: Automatic Rebase diff --git a/.github/workflows/site-deploy.yml b/.github/workflows/site-deploy.yml index 3dcb975168..77008b5bf5 100644 --- a/.github/workflows/site-deploy.yml +++ b/.github/workflows/site-deploy.yml @@ -10,7 +10,7 @@ jobs: if: github.event.ref_type == 'tag' && (contains(github.event.ref, '-') == false) steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: cache package-lock.json uses: actions/cache@v2 @@ -19,7 +19,7 @@ jobs: key: lock-${{ github.sha }} - name: create package-lock.json - run: npm i --package-lock-only + run: npm i --package-lock-only --ignore-scripts - name: hack for single file run: | @@ -43,7 +43,7 @@ jobs: needs: setup steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8e8438486..3b2abedf11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: cache package-lock.json uses: actions/cache@v2 @@ -18,7 +18,7 @@ jobs: key: lock-${{ github.sha }} - name: create package-lock.json - run: npm i --package-lock-only + run: npm i --package-lock-only --ignore-scripts - name: hack for single file run: | @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -78,7 +78,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -100,7 +100,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -122,7 +122,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -145,7 +145,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -171,7 +171,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -194,7 +194,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -225,7 +225,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -256,7 +256,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -296,7 +296,7 @@ jobs: REACT: 16 steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -324,7 +324,7 @@ jobs: REACT: 16 steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -352,7 +352,7 @@ jobs: REACT: 16 steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -388,7 +388,7 @@ jobs: REACT: 16 steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -424,7 +424,7 @@ jobs: REACT: 16 steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -460,7 +460,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - name: restore cache from package-lock.json uses: actions/cache@v2 @@ -496,4 +496,4 @@ jobs: - name: lessc mixins run: npx lessc --js ./es/style/mixins/index.less - needs: setup \ No newline at end of file + needs: setup diff --git a/.github/workflows/ui.yml b/.github/workflows/ui.yml index 21b5d6085b..daace2e28e 100644 --- a/.github/workflows/ui.yml +++ b/.github/workflows/ui.yml @@ -12,10 +12,33 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@master + uses: actions/checkout@v2 + + - name: cache package-lock.json + uses: actions/cache@v2 + with: + path: package-temp-dir + key: lock-${{ github.sha }} + + - name: create package-lock.json + run: npm i --package-lock-only --ignore-scripts + + - name: hack for single file + run: | + if [ ! -d "package-temp-dir" ]; then + mkdir package-temp-dir + fi + cp package-lock.json package-temp-dir + - name: cache node_modules + id: node_modules_cache_id + uses: actions/cache@v2 + with: + path: node_modules + key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} - name: install - run: npm install + if: steps.node_modules_cache_id.outputs.cache-hit != 'true' + run: npm ci - name: test run: npm run test-image diff --git a/README-pt_BR.md b/README-pt_BR.md index bffdc4bec2..4a206306c6 100644 --- a/README-pt_BR.md +++ b/README-pt_BR.md @@ -42,7 +42,7 @@ Uma solução empresarial de design e biblioteca UI para React. [bundlesize-css-image]: https://img.badgesize.io/https:/unpkg.com/antd/dist/antd.min.css?label=antd.min.css&compression=gzip&style=flat-square [unpkg-js-url]: https://unpkg.com/browse/antd/dist/antd.min.js [unpkg-css-url]: https://unpkg.com/browse/antd/dist/antd.min.css -[issues-helper-image]: https://img.shields.io/badge/Issues%20Manage%20By-issues--helper-orange?style=flat-square +[issues-helper-image]: https://img.shields.io/badge/using-issues--helper-orange?style=flat-square [issues-helper-url]: https://github.com/actions-cool/issues-helper diff --git a/README-uk_UA.md b/README-uk_UA.md index 1e6370aec9..43ad56dc4b 100644 --- a/README-uk_UA.md +++ b/README-uk_UA.md @@ -42,7 +42,7 @@ [bundlesize-css-image]: https://img.badgesize.io/https:/unpkg.com/antd/dist/antd.min.css?label=antd.min.css&compression=gzip&style=flat-square [unpkg-js-url]: https://unpkg.com/browse/antd/dist/antd.min.js [unpkg-css-url]: https://unpkg.com/browse/antd/dist/antd.min.css -[issues-helper-image]: https://img.shields.io/badge/Issues%20Manage%20By-issues--helper-orange?style=flat-square +[issues-helper-image]: https://img.shields.io/badge/using-issues--helper-orange?style=flat-square [issues-helper-url]: https://github.com/actions-cool/issues-helper diff --git a/README-zh_CN.md b/README-zh_CN.md index 763c385758..10337257d8 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -42,7 +42,7 @@ [bundlesize-css-image]: https://img.badgesize.io/https:/unpkg.com/antd/dist/antd.min.css?label=antd.min.css&compression=gzip&style=flat-square [unpkg-js-url]: https://unpkg.com/browse/antd/dist/antd.min.js [unpkg-css-url]: https://unpkg.com/browse/antd/dist/antd.min.css -[issues-helper-image]: https://img.shields.io/badge/Issues%20Manage%20By-issues--helper-orange?style=flat-square +[issues-helper-image]: https://img.shields.io/badge/using-issues--helper-orange?style=flat-square [issues-helper-url]: https://github.com/actions-cool/issues-helper diff --git a/components/affix/__tests__/Affix.test.tsx b/components/affix/__tests__/Affix.test.tsx index 1bf2283757..e67833cbbb 100644 --- a/components/affix/__tests__/Affix.test.tsx +++ b/components/affix/__tests__/Affix.test.tsx @@ -4,6 +4,7 @@ import Affix, { AffixProps, AffixState } from '..'; import { getObserverEntities } from '../utils'; import Button from '../../button'; import rtlTest from '../../../tests/shared/rtlTest'; +import accessibilityTest from '../../../tests/shared/accessibilityTest'; import { sleep } from '../../../tests/utils'; const events: Partial) => void>> = {}; @@ -53,6 +54,7 @@ class AffixMounter extends React.Component<{ describe('Affix Render', () => { rtlTest(Affix); + accessibilityTest(Affix); const domMock = jest.spyOn(HTMLElement.prototype, 'getBoundingClientRect'); let affixMounterWrapper: ReactWrapper; diff --git a/components/affix/index.tsx b/components/affix/index.tsx index 8efae73988..c39d282b2f 100644 --- a/components/affix/index.tsx +++ b/components/affix/index.tsx @@ -92,10 +92,7 @@ class Affix extends React.Component { componentDidUpdate(prevProps: AffixProps) { const { prevTarget } = this.state; const targetFunc = this.getTargetFunc(); - let newTarget = null; - if (targetFunc) { - newTarget = targetFunc() || null; - } + const newTarget = targetFunc?.() || null; if (prevTarget !== newTarget) { removeObserveTarget(this); @@ -128,12 +125,8 @@ class Affix extends React.Component { } getOffsetTop = () => { - const { offsetBottom } = this.props; - let { offsetTop } = this.props; - if (offsetBottom === undefined && offsetTop === undefined) { - offsetTop = 0; - } - return offsetTop; + const { offsetBottom, offsetTop } = this.props; + return (offsetBottom === undefined && offsetTop === undefined) ? 0 : offsetTop; }; getOffsetBottom = () => this.props.offsetBottom; diff --git a/components/alert/__tests__/__snapshots__/index.test.tsx.snap b/components/alert/__tests__/__snapshots__/index.test.tsx.snap index 0ece9e15eb..4465c8d244 100644 --- a/components/alert/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/alert/__tests__/__snapshots__/index.test.tsx.snap @@ -1,77 +1,238 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Alert action of Alert custom action 1`] = ` - + + + + + + + + + +
+
+ Success Tips +
+
+
+ + +
+ + + + + `; exports[`Alert could accept none react element icon 1`] = ` diff --git a/components/alert/__tests__/index.test.tsx b/components/alert/__tests__/index.test.tsx index 6529a13450..d3ae3968d3 100644 --- a/components/alert/__tests__/index.test.tsx +++ b/components/alert/__tests__/index.test.tsx @@ -1,16 +1,19 @@ import React from 'react'; -import { mount, render } from 'enzyme'; +import { mount } from 'enzyme'; +import { act } from 'react-dom/test-utils'; import Alert from '..'; import Button from '../../button'; import Tooltip from '../../tooltip'; import Popconfirm from '../../popconfirm'; import rtlTest from '../../../tests/shared/rtlTest'; +import accessibilityTest from '../../../tests/shared/accessibilityTest'; import { sleep } from '../../../tests/utils'; const { ErrorBoundary } = Alert; describe('Alert', () => { rtlTest(Alert); + accessibilityTest(Alert); beforeAll(() => { jest.useFakeTimers(); @@ -30,14 +33,18 @@ describe('Alert', () => { onClose={onClose} />, ); - wrapper.find('.ant-alert-close-icon').simulate('click'); - jest.runAllTimers(); + act(() => { + jest.useFakeTimers(); + wrapper.find('.ant-alert-close-icon').simulate('click'); + jest.runAllTimers(); + jest.useRealTimers(); + }); expect(onClose).toHaveBeenCalled(); }); describe('action of Alert', () => { it('custom action', () => { - const wrapper = render( + const wrapper = mount( { it('could accept none react element icon', () => { const wrapper = mount(); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); it('should not render message div when no message', () => { diff --git a/components/anchor/Anchor.tsx b/components/anchor/Anchor.tsx index 792251bb3e..82b871267c 100644 --- a/components/anchor/Anchor.tsx +++ b/components/anchor/Anchor.tsx @@ -291,7 +291,7 @@ export default class Anchor extends React.Component
key @@ -50,20 +51,20 @@ exports[`AutoComplete legacy dataSource should accept react element option 1`] =
@@ -99,13 +100,14 @@ exports[`AutoComplete rtl render component should be rendered correctly in RTL d class="ant-select-selection-search" > { it('legacy dataSource should accept react element option', () => { const wrapper = mount(ReactNode]} />); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); it('legacy AutoComplete.Option should be compatiable', () => { diff --git a/components/avatar/__tests__/Avatar.test.js b/components/avatar/__tests__/Avatar.test.js index aa066fdf7a..a65782dba0 100644 --- a/components/avatar/__tests__/Avatar.test.js +++ b/components/avatar/__tests__/Avatar.test.js @@ -155,7 +155,7 @@ describe('Avatar Render', () => { it('support size is number', () => { const wrapper = mount(TestString); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); Object.entries(sizes).forEach(([key, value]) => { @@ -189,7 +189,7 @@ describe('Avatar Render', () => { ); wrapper.find('img').simulate('error'); wrapper.update(); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); wrapper.detach(); global.document.body.removeChild(div); }); diff --git a/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap b/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap index 66ab85ed28..8d66c5c98f 100644 --- a/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap +++ b/components/avatar/__tests__/__snapshots__/Avatar.test.js.snap @@ -86,11 +86,14 @@ exports[`Avatar Render adjusts component size to 100 when window size is xxl 1`] exports[`Avatar Render fallback 1`] = ` - + + A + `; @@ -100,7 +103,7 @@ exports[`Avatar Render rtl render component should be rendered correctly in RTL > `; @@ -229,11 +232,11 @@ exports[`Avatar Render should show image on success after a failure state 2`] = exports[`Avatar Render support size is number 1`] = ` TestString diff --git a/components/badge/__tests__/__snapshots__/index.test.js.snap b/components/badge/__tests__/__snapshots__/index.test.js.snap index d9155ad6c4..d21432a4c6 100644 --- a/components/badge/__tests__/__snapshots__/index.test.js.snap +++ b/components/badge/__tests__/__snapshots__/index.test.js.snap @@ -173,12 +173,12 @@ exports[`Badge rtl render component should be rendered correctly in RTL directio - - - - - 按钮 - - + `; exports[`Button renders Chinese characters correctly 4`] = ` - + 按钮 + `; exports[`Button renders Chinese characters correctly 5`] = ` @@ -169,10 +124,11 @@ exports[`Button renders Chinese characters correctly 6`] = ` > { rtlTest(() => ); it('renders correctly', () => { - expect().toMatchRenderedSnapshot(); + expect(mount().render()).toMatchSnapshot(); }); it('mount correctly', () => { @@ -47,33 +47,37 @@ describe('Button', () => { }); it('renders Chinese characters correctly', () => { - expect().toMatchRenderedSnapshot(); + expect(mount().render()).toMatchSnapshot(); // should not insert space when there is icon - expect(}>按钮).toMatchRenderedSnapshot(); + expect(mount(}>按钮).render()).toMatchSnapshot(); // should not insert space when there is icon expect( , - ).toMatchRenderedSnapshot(); + ).toMatchSnapshot(); // should not insert space when there is icon - expect(}>按钮).toMatchRenderedSnapshot(); + expect(}>按钮).toMatchSnapshot(); // should not insert space when there is icon while loading expect( - } loading> - 按钮 - , - ).toMatchRenderedSnapshot(); + mount( + } loading> + 按钮 + , + ).render(), + ).toMatchSnapshot(); // should insert space while loading - expect().toMatchRenderedSnapshot(); + expect(mount().render()).toMatchSnapshot(); // should insert space while only one nested element expect( - 按钮 - , - ).toMatchRenderedSnapshot(); + mount( + , + ).render(), + ).toMatchSnapshot(); }); it('renders Chinese characters correctly in HOC', () => { @@ -206,9 +210,9 @@ describe('Button', () => { }); it('fixbug renders {0} , 0 and {false}', () => { - expect().toMatchRenderedSnapshot(); - expect().toMatchRenderedSnapshot(); - expect().toMatchRenderedSnapshot(); + expect(mount().render()).toMatchSnapshot(); + expect(mount().render()).toMatchSnapshot(); + expect(mount().render()).toMatchSnapshot(); }); it('should not render as link button when href is undefined', async () => { @@ -320,6 +324,6 @@ describe('Button', () => { <>text , ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); }); diff --git a/components/calendar/__tests__/__snapshots__/index.test.js.snap b/components/calendar/__tests__/__snapshots__/index.test.js.snap index 3cb53bd857..3182f3e41c 100644 --- a/components/calendar/__tests__/__snapshots__/index.test.js.snap +++ b/components/calendar/__tests__/__snapshots__/index.test.js.snap @@ -1905,16 +1905,17 @@ exports[`Calendar rtl render component should be rendered correctly in RTL direc class="ant-select-selection-search" >
diff --git a/components/cascader/__tests__/__snapshots__/index.test.js.snap b/components/cascader/__tests__/__snapshots__/index.test.js.snap index 4385c69659..87bf5ca963 100644 --- a/components/cascader/__tests__/__snapshots__/index.test.js.snap +++ b/components/cascader/__tests__/__snapshots__/index.test.js.snap @@ -1264,16 +1264,17 @@ exports[`Cascader rtl render component should be rendered correctly in RTL direc class="ant-select-selection-search" > { datetime="YYYY-MM-DD HH:mm:ss" />, ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); }); diff --git a/components/config-provider/__tests__/form.test.js b/components/config-provider/__tests__/form.test.js index 76ba1b872b..d8a6c4216d 100644 --- a/components/config-provider/__tests__/form.test.js +++ b/components/config-provider/__tests__/form.test.js @@ -88,7 +88,7 @@ describe('ConfigProvider.Form', () => { , ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); }); diff --git a/components/config-provider/__tests__/index.test.js b/components/config-provider/__tests__/index.test.js index 83f93d9aca..4b11c42a30 100644 --- a/components/config-provider/__tests__/index.test.js +++ b/components/config-provider/__tests__/index.test.js @@ -113,6 +113,6 @@ describe('ConfigProvider', () => { , ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); }); diff --git a/components/date-picker/__tests__/RangePicker.test.js b/components/date-picker/__tests__/RangePicker.test.js index bd890d5e5e..26a347abef 100644 --- a/components/date-picker/__tests__/RangePicker.test.js +++ b/components/date-picker/__tests__/RangePicker.test.js @@ -87,7 +87,7 @@ describe('RangePicker', () => { open />, ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); }); diff --git a/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap b/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap index 23e2cc902b..250e9bbec6 100644 --- a/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap @@ -118,7 +118,7 @@ Array [
,
,
menu @@ -31,8 +31,8 @@ Array [ ,
string diff --git a/components/dropdown/__tests__/index.test.js b/components/dropdown/__tests__/index.test.js index bb991dfd85..06631ea92a 100644 --- a/components/dropdown/__tests__/index.test.js +++ b/components/dropdown/__tests__/index.test.js @@ -25,7 +25,7 @@ describe('Dropdown', () => { , ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); it('overlay is string', () => { @@ -34,7 +34,7 @@ describe('Dropdown', () => { , ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); it('support Menu expandIcon', async () => { diff --git a/components/form/__tests__/index.test.js b/components/form/__tests__/index.test.js index 11e9a63370..bb1eb6848d 100644 --- a/components/form/__tests__/index.test.js +++ b/components/form/__tests__/index.test.js @@ -796,7 +796,7 @@ describe('Form', () => { , ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); it('noStyle should not work when hidden', () => { @@ -807,7 +807,7 @@ describe('Form', () => { , ); - expect(wrapper).toMatchRenderedSnapshot(); + expect(wrapper.render()).toMatchSnapshot(); }); }); diff --git a/components/layout/__tests__/__snapshots__/index.test.js.snap b/components/layout/__tests__/__snapshots__/index.test.js.snap index c449351cd4..80c2074bd1 100644 --- a/components/layout/__tests__/__snapshots__/index.test.js.snap +++ b/components/layout/__tests__/__snapshots__/index.test.js.snap @@ -28,7 +28,7 @@ exports[`Layout rtl render component should be rendered correctly in RTL directi exports[`Layout rtl render component should be rendered correctly in RTL direction 3`] = `