Skip to content

Commit 45ff8f7

Browse files
AyoubElkairhorns
authored andcommitted
add test that makes sure the imperative component is included in the route table
1 parent 8d7045f commit 45ff8f7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Page } from 'playwright-chromium'
2-
import { newTestPage, rootURL } from '../../helpers'
2+
import { newTestPage, reactReady, rootURL } from '../../helpers'
33

44
// For these tests, we don't use reactReady because the page is rendered server side so we don't need to wait on the client side
55
describe('imperative rendering', () => {
@@ -9,25 +9,29 @@ describe('imperative rendering', () => {
99
page = await newTestPage()
1010
})
1111

12-
test('the route should not fetch props and hydrate on the client side', async () => {
13-
page.on('request', (request) => {
14-
if (request.headers().accept === 'application/json') {
15-
throw new Error(
16-
`Expecting request to only be rendered server side, props request made: ${request.method()} ${request.url()}`
17-
)
12+
test('the route table should include the imperative route', async () => {
13+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
14+
page.on('response', async (response) => {
15+
if (response.url().includes('@fstr!route-table.js')) {
16+
const responseBody = await response.text()
17+
expect(responseBody).toBeDefined()
18+
expect(responseBody.includes('/imperative/true')).toBe(true)
1819
}
1920
})
2021

21-
await page.goto(`${rootURL}/imperative-true`)
22+
await page.goto(`${rootURL}/imperative/true`)
23+
await reactReady(page)
2224
})
2325

2426
test('the route handler should redirect to a 404 page', async () => {
2527
await page.goto(`${rootURL}/imperative/false`)
28+
await reactReady(page)
2629
expect(await page.isVisible("text='Not Found'")).toBe(true)
2730
})
2831

2932
test('the route handler should render the component', async () => {
3033
await page.goto(`${rootURL}/imperative/true`)
34+
await reactReady(page)
3135
expect(await page.isVisible("text='Imperatively renderable page'")).toBe(true)
3236
})
3337
})

0 commit comments

Comments
 (0)