1- import { test , expect } from '@playwright/test' ;
1+ import { test } from '@playwright/test' ;
22
33test . setTimeout ( 35e3 ) ;
44
@@ -8,12 +8,7 @@ test('go to /', async ({ page }) => {
88 await page . waitForSelector ( `text=Starter` ) ;
99} ) ;
1010
11- test ( 'test 404' , async ( { page } ) => {
12- const res = await page . goto ( '/post/not-found' ) ;
13- expect ( res ?. status ( ) ) . toBe ( 404 ) ;
14- } ) ;
15-
16- test ( 'add a post' , async ( { page, browser } ) => {
11+ test ( 'add a post' , async ( { page } ) => {
1712 const nonce = `${ Math . random ( ) } ` ;
1813
1914 await page . goto ( '/' ) ;
@@ -23,32 +18,5 @@ test('add a post', async ({ page, browser }) => {
2318 await page . waitForLoadState ( 'networkidle' ) ;
2419 await page . reload ( ) ;
2520
26- expect ( await page . content ( ) ) . toContain ( nonce ) ;
27-
28- const ssrContext = await browser . newContext ( {
29- javaScriptEnabled : false ,
30- } ) ;
31- const ssrPage = await ssrContext . newPage ( ) ;
32- await ssrPage . goto ( '/' ) ;
33-
34- expect ( await ssrPage . content ( ) ) . toContain ( nonce ) ;
35- } ) ;
36-
37- test ( 'server-side rendering test' , async ( { page, browser } ) => {
38- // add a post
39- const nonce = `${ Math . random ( ) } ` ;
40-
41- await page . goto ( '/' ) ;
42- await page . fill ( `[name=title]` , nonce ) ;
43- await page . fill ( `[name=text]` , nonce ) ;
44- await page . click ( `form [type=submit]` ) ;
45- await page . waitForLoadState ( 'networkidle' ) ;
46-
47- // load the page without js
48- const ssrContext = await browser . newContext ( {
49- javaScriptEnabled : false ,
50- } ) ;
51- const ssrPage = await ssrContext . newPage ( ) ;
52- await ssrPage . goto ( '/' ) ;
53- expect ( await ssrPage . content ( ) ) . toContain ( nonce ) ;
21+ await page . waitForSelector ( `text="${ nonce } "` ) ;
5422} ) ;
0 commit comments