-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathssr-catch-error.spec.ts
55 lines (47 loc) · 1.86 KB
/
ssr-catch-error.spec.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
import { expect } from '@playwright/test';
import { test, prepareStandaloneSetup } from './utils.js';
const startApp = prepareStandaloneSetup('ssr-catch-error');
for (const mode of ['DEV', 'PRD'] as const) {
test.describe(`ssr-catch-error: ${mode}`, () => {
let port: number;
let stopApp: () => Promise<void>;
test.beforeAll(async () => {
({ port, stopApp } = await startApp(mode));
});
test.afterAll(async () => {
await stopApp();
});
test('access top page', async ({ page }) => {
await page.goto(`http://localhost:${port}/`);
await expect(page.getByText('Home Page')).toBeVisible();
await expect(page.getByText('Something went wrong')).toBeVisible();
});
test('access dynamic server page', async ({ page }) => {
await page.goto(`http://localhost:${port}/dynamic`);
await expect(page.getByText('Home Page')).toBeVisible();
await expect(page.getByText('Something went wrong')).toBeVisible();
});
test('access invalid page through client router', async ({ page }) => {
await page.goto(`http://localhost:${port}/`);
await page.getByText('Invalid page').click();
await expect(
page.getByText('Unexpected error in client fallback'),
).toBeVisible();
});
test('access invalid page directly', async ({ page }) => {
await page.goto(`http://localhost:${port}/invalid`);
await expect(page.getByText('Unauthorized')).toBeVisible();
});
test('navigate back after invalid page through client router', async ({
page,
}) => {
await page.goto(`http://localhost:${port}/`);
await page.getByText('Invalid page').click();
await expect(
page.getByText('Unexpected error in client fallback'),
).toBeVisible();
await page.goBack();
await expect(page.getByText('Home Page')).toBeVisible();
});
});
}