-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy patherror-pages.e2e.ts
56 lines (46 loc) · 2.32 KB
/
error-pages.e2e.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* Copyright Oxide Computer Company
*/
import { expect, test } from '@playwright/test'
import { getPageAsUser } from './utils'
test('Shows 404 page when a resource is not found', async ({ page }) => {
await page.goto('/nonexistent')
await expect(page.locator('text=Page not found')).toBeVisible()
await page.goto('/projects/nonexistent')
await expect(page.locator('text=Page not found')).toBeVisible()
await expect(page.getByRole('button', { name: 'Sign out' })).toBeVisible()
})
test('Shows something went wrong page on other errors', async ({ page, browserName }) => {
const messages: string[] = []
page.on('console', (e) => messages.push(e.text()))
await page.goto('/projects/error-503') // specially handled in mock server
await expect(page.getByText('Something went wrong')).toBeVisible()
// Invariant failed doesn't show up in the page...
await expect(page.getByText('Invariant failed')).toBeHidden()
// But we do see it in the browser console. Skip Firefox because it handles
// these errors differently and it's hard to get the error text out.
// eslint-disable-next-line playwright/no-conditional-in-test
if (browserName !== 'firefox') {
const error =
'Expected query to be prefetched.\nKey: ["projectView",{"path":{"project":"error-503"}}]'
// eslint-disable-next-line playwright/no-conditional-expect
expect(messages.some((m) => m.includes(error))).toBeTruthy()
}
// test clicking sign out
await page.getByRole('button', { name: 'Sign out' }).click()
// login route doesn't actually work in the mock setup (in production this
// is handled by nexus, and it's hard to get Vite to do the right thing here
// without getting elaborate with middleware), so this is a 404, but we do end
// up at the right URL
await expect(page).toHaveURL('/login')
})
test('error page for user with no groups or silo role', async ({ browser }) => {
const page = await getPageAsUser(browser, 'Jacob Klein')
await page.goto('/projects')
await expect(page.getByText('Something went wrong')).toBeVisible()
await expect(page.getByText('identity provider is not set up correctly')).toBeVisible()
})