From e1ebd5235dd0f3620c2cb4a574d149ca0090c3b9 Mon Sep 17 00:00:00 2001 From: dario-piotrowicz Date: Sun, 5 Feb 2023 22:39:30 +0000 Subject: [PATCH] add e2e tests for 404 pages --- ui-e2e-tests/page-not-found.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ui-e2e-tests/page-not-found.spec.ts diff --git a/ui-e2e-tests/page-not-found.spec.ts b/ui-e2e-tests/page-not-found.spec.ts new file mode 100644 index 0000000..2b7b64c --- /dev/null +++ b/ui-e2e-tests/page-not-found.spec.ts @@ -0,0 +1,20 @@ +import { test, expect, type Page } from '@playwright/test' + +async function test404Page(page: Page, url: string) { + const response = await page.goto(url) + expect(response?.status()).toEqual(404) + const NotFoundTextLocator = page.getByText("The page you are looking for isn't here.") + await expect(NotFoundTextLocator).toBeVisible() +} + +test('Trying to access a non existent page should result in a 404 page', async ({ page }) => { + await test404Page(page, 'http://127.0.0.1:8788/gibberish_fytr75235dfhhlplo') +}) + +test('Trying to access a non existent sub-page should result in a 404 page', async ({ page }) => { + await test404Page(page, 'http://127.0.0.1:8788/explore/gibberish_fytr75235dfhhlplo') +}) + +test('Trying to access a non existent sub-sub-page should result in a 404 page', async ({ page }) => { + await test404Page(page, 'http://127.0.0.1:8788/explore/gibberish/fytr75235dfhhlplo') +})