diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9c4c97e1ad91a23e84b499ffdae0eac65a9cb579..2df685a5dd6c44538cf54537cd2ff99ffa7b99ba 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -52,6 +52,10 @@ jobs: displayName: install - script: npm run lint displayName: lint + - script: npm run test:all + env: + PROGRESS: none + displayName: test - script: npm run build env: PROGRESS: none diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js index 090687a34f3770a7b4617bc7390c19bc0575d26e..2494ca09ccc1d00c14039df86fa25817a50e583a 100644 --- a/jest-puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -6,6 +6,7 @@ module.exports = { '--disable-dev-shm-usage', '--no-first-run', '--no-zygote', + '--no-sandbox' ], }, }; diff --git a/src/e2e/baseLayout.e2e.js b/src/e2e/baseLayout.e2e.js index 74938719d5a2c071fba3f1e407ca18af1c36720e..70bb984df31a07311ef8a8f49df3554b56917400 100644 --- a/src/e2e/baseLayout.e2e.js +++ b/src/e2e/baseLayout.e2e.js @@ -5,13 +5,17 @@ const BASE_URL = `http://localhost:${process.env.PORT || 8000}`; function formatter(data) { return data .reduce((pre, item) => { - pre.push(item.path); + if (item.routes) { + pre.push(item.routes[0].path); + } else { + pre.push(item.path); + } return pre; }, []) .filter(item => item); } -describe('Homepage', async () => { +describe('Homepage', () => { const testPage = path => async () => { await page.goto(`${BASE_URL}${path}`); await page.waitForSelector('footer', { diff --git a/src/e2e/topMenu.e2e.js b/src/e2e/topMenu.e2e.js index 51ff9f35c632e3c6471b153b45f76b40e9a11cc9..d90983b9fef9d63ab2a64ce3c36ee7aed66622f5 100644 --- a/src/e2e/topMenu.e2e.js +++ b/src/e2e/topMenu.e2e.js @@ -4,6 +4,7 @@ describe('Homepage', () => { beforeAll(async () => { jest.setTimeout(1000000); }); + it('topmenu should have footer', async () => { const params = '/form/basic-form?navTheme=light&layout=topmenu'; await page.goto(`${BASE_URL}${params}`); diff --git a/src/pages/Result/Success.test.js b/src/pages/Result/Success.test.js deleted file mode 100644 index 9bc9b8dffdc39e5db8dbfd5b2c9e5203a4845e26..0000000000000000000000000000000000000000 --- a/src/pages/Result/Success.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import Success from './Success'; - -it('renders with Result', () => { - const wrapper = shallow(); - expect(wrapper.find('Result').length).toBe(1); - expect(wrapper.find('Result').prop('type')).toBe('success'); -}); diff --git a/src/utils/authority.js b/src/utils/authority.js index dea309fe116107cf2c23ffb61f483eb140854e26..288c1e68adc9381a821ba1032cb068791e0184ee 100644 --- a/src/utils/authority.js +++ b/src/utils/authority.js @@ -1,4 +1,6 @@ // use localStorage to store the authority info, which might be sent from server in actual project. +const { NODE_ENV } = process.env; + export function getAuthority(str) { // return localStorage.getItem('antd-pro-authority') || ['admin', 'user']; const authorityString = @@ -13,6 +15,9 @@ export function getAuthority(str) { if (typeof authority === 'string') { return [authority]; } + if (!authority && NODE_ENV !== 'production') { + return ['admin']; + } return authority; }