1
1
import { assertPageVisits } from "../utils/assert-page-visits"
2
2
import { applyTrailingSlashOption } from "../../utils"
3
3
4
- Cypress . on ( "uncaught:exception" , ( err ) => {
4
+ Cypress . on ( "uncaught:exception" , err => {
5
5
if ( err . message . includes ( "Minified React error" ) ) {
6
6
return false
7
7
}
@@ -12,38 +12,62 @@ const TRAILING_SLASH = Cypress.env(`TRAILING_SLASH`) || `never`
12
12
describe ( "trailingSlash" , ( ) => {
13
13
describe ( TRAILING_SLASH , ( ) => {
14
14
it ( "should work when using Gatsby Link (without slash)" , ( ) => {
15
- cy . visit ( '/' ) . waitForRouteChange ( )
15
+ cy . visit ( "/" ) . waitForRouteChange ( )
16
16
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
+ )
18
23
} )
19
24
it ( "should work when using Gatsby Link (with slash)" , ( ) => {
20
- cy . visit ( '/' ) . waitForRouteChange ( )
25
+ cy . visit ( "/" ) . waitForRouteChange ( )
21
26
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
+ )
23
33
} )
24
34
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/"
27
43
28
44
assertPageVisits ( [
29
45
{
30
46
path : destination ,
31
47
status : 200 ,
32
48
} ,
33
- { path : inverse , status : 301 , destinationPath : destination }
49
+ { path : inverse , status : 301 , destinationPath : destination } ,
34
50
] )
35
51
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
+ )
37
57
} )
38
58
it ( "should work on direct visit (with current setting)" , ( ) => {
39
59
assertPageVisits ( [
40
60
{
41
- path : applyTrailingSlashOption ( "/routes/static" , TRAILING_SLASH ) ,
61
+ path : applyTrailingSlashOption ( "/routes/ssg/ static" , TRAILING_SLASH ) ,
42
62
status : 200 ,
43
63
} ,
44
64
] )
45
65
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
+ )
47
71
} )
48
72
} )
49
73
} )
0 commit comments