1
1
import { Page } from 'playwright-chromium'
2
- import { newTestPage , rootURL } from '../../helpers'
2
+ import { newTestPage , reactReady , rootURL } from '../../helpers'
3
3
4
4
// 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
5
5
describe ( 'imperative rendering' , ( ) => {
@@ -9,25 +9,29 @@ describe('imperative rendering', () => {
9
9
page = await newTestPage ( )
10
10
} )
11
11
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 )
18
19
}
19
20
} )
20
21
21
- await page . goto ( `${ rootURL } /imperative-true` )
22
+ await page . goto ( `${ rootURL } /imperative/true` )
23
+ await reactReady ( page )
22
24
} )
23
25
24
26
test ( 'the route handler should redirect to a 404 page' , async ( ) => {
25
27
await page . goto ( `${ rootURL } /imperative/false` )
28
+ await reactReady ( page )
26
29
expect ( await page . isVisible ( "text='Not Found'" ) ) . toBe ( true )
27
30
} )
28
31
29
32
test ( 'the route handler should render the component' , async ( ) => {
30
33
await page . goto ( `${ rootURL } /imperative/true` )
34
+ await reactReady ( page )
31
35
expect ( await page . isVisible ( "text='Imperatively renderable page'" ) ) . toBe ( true )
32
36
} )
33
37
} )
0 commit comments