userLayout.e2e.js 816 Bytes
Newer Older
1 2 3
import config from '../config/config';

const RouterConfig = config.routes;
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
4

5 6
const BASE_URL = `http://localhost:${process.env.PORT || 8000}`;

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
7 8 9 10 11 12 13 14 15 16
function formatter(data) {
  return data
    .reduce((pre, item) => {
      pre.push(item.path);
      return pre;
    }, [])
    .filter(item => item);
}

describe('Homepage', () => {
afc163's avatar
afc163 committed
17
  const testPage = path => async () => {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
18 19 20 21
    await page.goto(`${BASE_URL}${path}`);
    await page.waitForSelector('footer', {
      timeout: 2000,
    });
afc163's avatar
afc163 committed
22 23 24 25 26
    const haveFooter = await page.evaluate(
      () => document.getElementsByTagName('footer').length > 0
    );
    expect(haveFooter).toBeTruthy();
  };
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
27 28

  beforeAll(async () => {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
29
    jest.setTimeout(1000000);
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
30
  });
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
31
  formatter(RouterConfig[0].routes).forEach(route => {
32
    it(`test pages ${route}`, testPage(route));
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
33 34
  });
});