Unverified Commit b86048b4 authored by 陈帅's avatar 陈帅 Committed by GitHub

feat: win add test script (#3845)

* feat: win add test script

* bugfix: fix test error

* use new config
parent cc57c6a9
...@@ -52,6 +52,10 @@ jobs: ...@@ -52,6 +52,10 @@ jobs:
displayName: install displayName: install
- script: npm run lint - script: npm run lint
displayName: lint displayName: lint
- script: npm run test:all
env:
PROGRESS: none
displayName: test
- script: npm run build - script: npm run build
env: env:
PROGRESS: none PROGRESS: none
......
...@@ -6,6 +6,7 @@ module.exports = { ...@@ -6,6 +6,7 @@ module.exports = {
'--disable-dev-shm-usage', '--disable-dev-shm-usage',
'--no-first-run', '--no-first-run',
'--no-zygote', '--no-zygote',
'--no-sandbox'
], ],
}, },
}; };
...@@ -5,13 +5,17 @@ const BASE_URL = `http://localhost:${process.env.PORT || 8000}`; ...@@ -5,13 +5,17 @@ const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;
function formatter(data) { function formatter(data) {
return data return data
.reduce((pre, item) => { .reduce((pre, item) => {
if (item.routes) {
pre.push(item.routes[0].path);
} else {
pre.push(item.path); pre.push(item.path);
}
return pre; return pre;
}, []) }, [])
.filter(item => item); .filter(item => item);
} }
describe('Homepage', async () => { describe('Homepage', () => {
const testPage = path => async () => { const testPage = path => async () => {
await page.goto(`${BASE_URL}${path}`); await page.goto(`${BASE_URL}${path}`);
await page.waitForSelector('footer', { await page.waitForSelector('footer', {
......
...@@ -4,6 +4,7 @@ describe('Homepage', () => { ...@@ -4,6 +4,7 @@ describe('Homepage', () => {
beforeAll(async () => { beforeAll(async () => {
jest.setTimeout(1000000); jest.setTimeout(1000000);
}); });
it('topmenu should have footer', async () => { it('topmenu should have footer', async () => {
const params = '/form/basic-form?navTheme=light&layout=topmenu'; const params = '/form/basic-form?navTheme=light&layout=topmenu';
await page.goto(`${BASE_URL}${params}`); await page.goto(`${BASE_URL}${params}`);
......
import React from 'react';
import { shallow } from 'enzyme';
import Success from './Success';
it('renders with Result', () => {
const wrapper = shallow(<Success />);
expect(wrapper.find('Result').length).toBe(1);
expect(wrapper.find('Result').prop('type')).toBe('success');
});
// use localStorage to store the authority info, which might be sent from server in actual project. // 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) { export function getAuthority(str) {
// return localStorage.getItem('antd-pro-authority') || ['admin', 'user']; // return localStorage.getItem('antd-pro-authority') || ['admin', 'user'];
const authorityString = const authorityString =
...@@ -13,6 +15,9 @@ export function getAuthority(str) { ...@@ -13,6 +15,9 @@ export function getAuthority(str) {
if (typeof authority === 'string') { if (typeof authority === 'string') {
return [authority]; return [authority];
} }
if (!authority && NODE_ENV !== 'production') {
return ['admin'];
}
return authority; return authority;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment