11import { assertPageVisits } from "../utils/assert-page-visits"
22import { applyTrailingSlashOption } from "../../utils"
33
4- Cypress . on ( "uncaught:exception" , ( err ) => {
4+ Cypress . on ( "uncaught:exception" , err => {
55 if ( err . message . includes ( "Minified React error" ) ) {
66 return false
77 }
@@ -12,38 +12,62 @@ const TRAILING_SLASH = Cypress.env(`TRAILING_SLASH`) || `never`
1212describe ( "trailingSlash" , ( ) => {
1313 describe ( TRAILING_SLASH , ( ) => {
1414 it ( "should work when using Gatsby Link (without slash)" , ( ) => {
15- cy . visit ( '/' ) . waitForRouteChange ( )
15+ cy . visit ( "/" ) . waitForRouteChange ( )
1616
17- cy . get ( `[data-testid="static-without-slash"]` ) . click ( ) . waitForRouteChange ( ) . assertRoute ( applyTrailingSlashOption ( `/routes/static` , TRAILING_SLASH ) )
17+ cy . get ( `[data-testid="static-without-slash"]` )
18+ . click ( )
19+ . waitForRouteChange ( )
20+ . assertRoute (
21+ applyTrailingSlashOption ( `/routes/ssg/static` , TRAILING_SLASH )
22+ )
1823 } )
1924 it ( "should work when using Gatsby Link (with slash)" , ( ) => {
20- cy . visit ( '/' ) . waitForRouteChange ( )
25+ cy . visit ( "/" ) . waitForRouteChange ( )
2126
22- cy . get ( `[data-testid="static-with-slash"]` ) . click ( ) . waitForRouteChange ( ) . assertRoute ( applyTrailingSlashOption ( `/routes/static` , TRAILING_SLASH ) )
27+ cy . get ( `[data-testid="static-with-slash"]` )
28+ . click ( )
29+ . waitForRouteChange ( )
30+ . assertRoute (
31+ applyTrailingSlashOption ( `/routes/ssg/static` , TRAILING_SLASH )
32+ )
2333 } )
2434 it ( "should work on direct visit (with other setting)" , ( ) => {
25- const destination = applyTrailingSlashOption ( "/routes/static" , TRAILING_SLASH )
26- const inverse = TRAILING_SLASH === `always` ? "/routes/static" : "/routes/static/"
35+ const destination = applyTrailingSlashOption (
36+ "/routes/ssg/static" ,
37+ TRAILING_SLASH
38+ )
39+ const inverse =
40+ TRAILING_SLASH === `always`
41+ ? "/routes/ssg/static"
42+ : "/routes/ssg/static/"
2743
2844 assertPageVisits ( [
2945 {
3046 path : destination ,
3147 status : 200 ,
3248 } ,
33- { path : inverse , status : 301 , destinationPath : destination }
49+ { path : inverse , status : 301 , destinationPath : destination } ,
3450 ] )
3551
36- cy . visit ( inverse ) . waitForRouteChange ( ) . assertRoute ( applyTrailingSlashOption ( `/routes/static` , TRAILING_SLASH ) )
52+ cy . visit ( inverse )
53+ . waitForRouteChange ( )
54+ . assertRoute (
55+ applyTrailingSlashOption ( `/routes/ssg/static` , TRAILING_SLASH )
56+ )
3757 } )
3858 it ( "should work on direct visit (with current setting)" , ( ) => {
3959 assertPageVisits ( [
4060 {
41- path : applyTrailingSlashOption ( "/routes/static" , TRAILING_SLASH ) ,
61+ path : applyTrailingSlashOption ( "/routes/ssg/ static" , TRAILING_SLASH ) ,
4262 status : 200 ,
4363 } ,
4464 ] )
4565
46- cy . visit ( applyTrailingSlashOption ( "/routes/static" , TRAILING_SLASH ) ) . waitForRouteChange ( ) . assertRoute ( applyTrailingSlashOption ( `/routes/static` , TRAILING_SLASH ) )
66+ cy . visit ( applyTrailingSlashOption ( "/routes/ssg/static" , TRAILING_SLASH ) )
67+ . waitForRouteChange ( )
68+ . assertRoute (
69+ applyTrailingSlashOption ( `/routes/ssg/static` , TRAILING_SLASH )
70+ )
4771 } )
4872 } )
4973} )
0 commit comments