1
1
import { createTest , type TestConfig } from 'e2e-shared/create-test'
2
- import { getShallowUrl } from 'e2e-shared/specs/shallow.defs '
2
+ import { getOptionsUrl } from 'e2e-shared/lib/options '
3
3
4
- function testMultiTenant ( options : TestConfig ) {
4
+ function testMultiTenant (
5
+ options : TestConfig & {
6
+ expectedPathname : string
7
+ }
8
+ ) {
5
9
const factory = createTest ( 'Multitenant' , ( { path } ) => {
6
10
for ( const shallow of [ true , false ] ) {
7
11
for ( const history of [ 'replace' , 'push' ] as const ) {
8
12
it ( `Updates with ({ shallow: ${ shallow } , history: ${ history } })` , ( ) => {
9
- cy . visit ( getShallowUrl ( path , { shallow, history } ) )
13
+ cy . visit ( getOptionsUrl ( path , { shallow, history } ) )
10
14
cy . contains ( '#hydration-marker' , 'hydrated' ) . should ( 'be.hidden' )
11
15
cy . get ( '#client-state' ) . should ( 'be.empty' )
12
16
cy . get ( '#server-state' ) . should ( 'be.empty' )
13
17
cy . get ( '#client-tenant' ) . should ( 'have.text' , 'david' )
14
18
cy . get ( '#server-tenant' ) . should ( 'have.text' , 'david' )
15
19
cy . get ( '#router-pathname' ) . should (
16
20
'have.text' ,
17
- options . nextJsRouter === 'pages'
18
- ? '/pages/multitenant/[tenant]'
19
- : '/app/multitenant'
21
+ options . expectedPathname
20
22
)
21
23
cy . get ( 'button' ) . click ( )
22
24
cy . get ( '#client-state' ) . should ( 'have.text' , 'pass' )
23
25
cy . get ( '#client-tenant' ) . should ( 'have.text' , 'david' )
24
26
cy . get ( '#server-tenant' ) . should ( 'have.text' , 'david' )
25
27
cy . get ( '#router-pathname' ) . should (
26
28
'have.text' ,
27
- options . nextJsRouter === 'pages'
28
- ? '/pages/multitenant/[tenant]'
29
- : '/app/multitenant'
29
+ options . expectedPathname
30
30
)
31
31
if ( shallow === false ) {
32
32
cy . get ( '#server-state' ) . should ( 'have.text' , 'pass' )
@@ -43,9 +43,7 @@ function testMultiTenant(options: TestConfig) {
43
43
cy . get ( '#server-state' ) . should ( 'be.empty' )
44
44
cy . get ( '#router-pathname' ) . should (
45
45
'have.text' ,
46
- options . nextJsRouter === 'pages'
47
- ? '/pages/multitenant/[tenant]'
48
- : '/app/multitenant'
46
+ options . expectedPathname
49
47
)
50
48
} )
51
49
}
@@ -57,10 +55,14 @@ function testMultiTenant(options: TestConfig) {
57
55
58
56
testMultiTenant ( {
59
57
path : '/app/multitenant' ,
60
- nextJsRouter : 'app'
58
+ nextJsRouter : 'app' ,
59
+ description : 'Dynamic route' ,
60
+ expectedPathname : '/app/multitenant'
61
61
} )
62
62
63
63
testMultiTenant ( {
64
64
path : '/pages/multitenant' ,
65
- nextJsRouter : 'pages'
65
+ nextJsRouter : 'pages' ,
66
+ description : 'Dynamic route' ,
67
+ expectedPathname : '/pages/multitenant/[tenant]'
66
68
} )
0 commit comments