diff --git a/src/components/GlobalFooter/index.js b/src/components/GlobalFooter/index.js index 01e526e832f321984ec0240d7a9232f1ee7a6e0e..1c2fb74efec05e82c1a19992cdbe09784d3bb7a8 100644 --- a/src/components/GlobalFooter/index.js +++ b/src/components/GlobalFooter/index.js @@ -5,7 +5,7 @@ import styles from './index.less'; const GlobalFooter = ({ className, links, copyright }) => { const clsString = classNames(styles.globalFooter, className); return ( -
+
+ ); }; diff --git a/src/e2e/layout.e2e.js b/src/e2e/layout.e2e.js new file mode 100644 index 0000000000000000000000000000000000000000..af1d2b33ea9aa0fe8ed565737b106fa720fe7f65 --- /dev/null +++ b/src/e2e/layout.e2e.js @@ -0,0 +1,61 @@ +import puppeteer from 'puppeteer'; +import RouterConfig from '../../config/router.config'; + +function formatter(data) { + return data + .reduce((pre, item) => { + if (item.routes) { + return pre.concat(formatter(item.routes)); + } + pre.push(item.path); + return pre; + }, []) + .filter(item => item); +} + +describe('Homepage', () => { + let browser; + let page; + + const testAllPage = async layout => + new Promise(async (resolve, reject) => { + const loadPage = async index => { + const path = layout[index]; + try { + await page.goto(`http://localhost:8000${path}`, { waitUntil: 'networkidle2' }); + const haveFooter = await page.evaluate( + () => document.getElementsByTagName('footer').length > 0 + ); + + expect(haveFooter).toBeTruthy(); + + if (index < layout.length - 1) { + loadPage(index + 1); + } else { + resolve('ok'); + } + } catch (error) { + reject(error); + } + }; + loadPage(0); + }); + + beforeAll(async () => { + browser = await puppeteer.launch({ args: ['--no-sandbox'] }); + page = await browser.newPage(); + jest.setTimeout(1000000); + }); + + it('test user layout', async () => { + const userLayout = formatter(RouterConfig[0].routes); + await testAllPage(userLayout); + }); + + it('test base layout', async () => { + const baseLayout = formatter(RouterConfig[1].routes); + await testAllPage(baseLayout); + }); + + afterAll(() => browser.close()); +});