-
-
Notifications
You must be signed in to change notification settings - Fork 448
/
error-modal.spec.ts
35 lines (31 loc) · 1.55 KB
/
error-modal.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
import { expect, test } from '@playwright/test'
import { pageLoads } from './support'
test.beforeEach(async ({ page }) => {
pageLoads.watch(page)
await page.goto('/error-modal')
})
test('displays the modal containing the response as HTML when an invalid Inertia response comes back', async ({
page,
}) => {
await page.getByText('Invalid Visit', { exact: true }).click()
await expect(page.frameLocator('iframe').getByText('This is a page that does not')).toBeVisible()
await expect(page.frameLocator('iframe').locator('body')).toContainText(
'This is a page that does not have the Inertia app loaded.',
)
})
test('displays the modal with a helpful message when a regular JSON response comes back instead of an Inertia response', async ({
page,
}) => {
await page.getByText('Invalid Visit (JSON response)').click()
await expect(page.frameLocator('iframe').locator('body')).toContainText(
'All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.',
)
await page.frameLocator('iframe').getByText('All Inertia requests must').click()
await expect(page.frameLocator('iframe').locator('body')).toContainText('{"foo":"bar"}')
})
test('can close the modal using the escape key', async ({ page }) => {
await page.getByText('Invalid Visit', { exact: true }).click()
await expect(page.frameLocator('iframe').getByText('This is a page that does not')).toBeVisible()
await page.locator('body').press('Escape')
await expect(page.frameLocator('iframe').getByText('This is a page that does not')).toBeHidden()
})