Browse Source
feat: win add test script (#3845)
* feat: win add test script
* bugfix: fix test error
* use new config
pull/3881/head
陈帅
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
17 additions and
11 deletions
-
azure-pipelines.yml
-
jest-puppeteer.config.js
-
src/e2e/baseLayout.e2e.js
-
src/e2e/topMenu.e2e.js
-
src/pages/Result/Success.test.js
-
src/utils/authority.js
|
|
@ -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 = { |
|
|
'--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}`; |
|
|
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', () => { |
|
|
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}`); |
|
|
|
|
|
@ -1,9 +0,0 @@ |
|
|
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'); |
|
|
|
|
|
}); |
|
|
|
|
|
@ -1,4 +1,6 @@ |
|
|
// 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) { |
|
|
if (typeof authority === 'string') { |
|
|
if (typeof authority === 'string') { |
|
|
return [authority]; |
|
|
return [authority]; |
|
|
} |
|
|
} |
|
|
|
|
|
if (!authority && NODE_ENV !== 'production') { |
|
|
|
|
|
return ['admin']; |
|
|
|
|
|
} |
|
|
return authority; |
|
|
return authority; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|