From d5e7f752aaa9e2151fff83bafa0839af7449f039 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Wed, 27 Mar 2019 20:24:34 +0100 Subject: [PATCH] test: add scenario to handle 404 page --- src/webui/components/NotFound/index.js | 6 +++++- test/e2e/e2e.spec.js | 7 +++++++ test/e2e/setup.js | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/webui/components/NotFound/index.js b/src/webui/components/NotFound/index.js index 2d7b82ade..39bf39542 100644 --- a/src/webui/components/NotFound/index.js +++ b/src/webui/components/NotFound/index.js @@ -10,6 +10,8 @@ import Typography from '@material-ui/core/Typography/index'; import { Wrapper, Inner, EmptyPackage, Heading, Card, List } from './styles'; import PackageImg from './img/package.svg'; +export const NOT_FOUND_TEXT = "Sorry, we couldn't find it..."; + // eslint-disable-next-line react/prop-types const NotFound = ({ history, width }) => { const handleGoTo = to => () => { @@ -42,7 +44,9 @@ const NotFound = ({ history, width }) => { - {"Sorry, we couldn't find it..."} + + {NOT_FOUND_TEXT} + {renderSubTitle()} {renderList()} diff --git a/test/e2e/e2e.spec.js b/test/e2e/e2e.spec.js index 13b07286b..6a39dc08c 100644 --- a/test/e2e/e2e.spec.js +++ b/test/e2e/e2e.spec.js @@ -152,4 +152,11 @@ describe('/ (Verdaccio Page)', () => { const text = await page.evaluate(() => document.querySelector('#help-card__title').textContent); expect(text).toMatch('No Package Published Yet'); }); + + test('should go to 404 page', async () => { + await page.goto('http://0.0.0.0:55552/-/web/detail/@verdaccio/not-found'); + await page.waitFor(500); + const text = await page.evaluate(() => document.querySelector('.not-found-text').textContent); + expect(text).toMatch("Sorry, we couldn't find it..."); + }); }); diff --git a/test/e2e/setup.js b/test/e2e/setup.js index 9a56bcf99..452fddacc 100644 --- a/test/e2e/setup.js +++ b/test/e2e/setup.js @@ -9,7 +9,7 @@ const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup'); module.exports = async function() { console.log(chalk.green('Setup Puppeteer')); - const browser = await puppeteer.launch({headless: true}); + const browser = await puppeteer.launch({headless: true, /* slowMo: 300 */ }); global.__BROWSER__ = browser; mkdirp.sync(DIR); fs.writeFileSync(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint());