File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ import { expect , test } from '@playwright/test' ;
2+ import type { Page } from 'playwright-core' ;
3+
4+ test . describe ( 'redirect to 404' , ( ) => {
5+ const testCases : {
6+ name : string ;
7+ invalidUrls : string [ ] ;
8+ wait ?: ( params : { page : Page } ) => Promise < void > ;
9+ } [ ] = [
10+ {
11+ name : 'astro-demo' ,
12+ invalidUrls : [
13+ 'https://nkzsw-gyaaa-aaaal-ada3a-cai.icp0.io/unknown' ,
14+ 'https://nkzsw-gyaaa-aaaal-ada3a-cai.icp0.io/unknown/unknown'
15+ ]
16+ } ,
17+ {
18+ name : 'juno-docs' ,
19+ invalidUrls : [
20+ 'https://juno.build/unknown' ,
21+ 'https://juno.build/unknown/unknown' ,
22+ 'https://juno.build/docs/unknown' ,
23+ 'https://juno.build/docs/examples/functions/unknown'
24+ ]
25+ } ,
26+ {
27+ name : 'juno-console' ,
28+ invalidUrls : [ 'https://console.juno.build/unknown' ] ,
29+ wait : async ( { page } ) => {
30+ const orderSent = page . locator ( '.container p[role="presentation"]' ) ;
31+ await orderSent . waitFor ( ) ;
32+ }
33+ }
34+ ] ;
35+
36+ testCases . forEach ( ( { invalidUrls, wait } ) => {
37+ invalidUrls . forEach ( ( invalidUrl ) => {
38+ test ( `should redirect ${ invalidUrl } to 404` , async ( { page } ) => {
39+ const response = await page . goto ( invalidUrl , { waitUntil : 'domcontentloaded' } ) ;
40+
41+ expect ( response ?. status ( ) ) . toBe ( 404 ) ;
42+
43+ await wait ?.( { page } ) ;
44+
45+ await expect ( page ) . toHaveScreenshot ( ) ;
46+ } ) ;
47+ } ) ;
48+ } ) ;
49+ } ) ;
You can’t perform that action at this time.
0 commit comments