@@ -67,7 +67,9 @@ export function runTests(ctx) {
67
67
} )
68
68
} )
69
69
70
- it ( 'should redirect to locale domain correctly client-side' , async ( ) => {
70
+ // this test can not currently be tested in browser without modifying the
71
+ // host resolution since it needs a domain to test locale domains behavior
72
+ it . skip ( 'should redirect to locale domain correctly client-side' , async ( ) => {
71
73
const browser = await webdriver ( ctx . appPort , `${ ctx . basePath || '/' } ` )
72
74
73
75
await browser . eval ( `(function() {
@@ -104,7 +106,9 @@ export function runTests(ctx) {
104
106
)
105
107
} )
106
108
107
- it ( 'should render the correct href for locale domain' , async ( ) => {
109
+ // this test can not currently be tested in browser without modifying the
110
+ // host resolution since it needs a domain to test locale domains behavior
111
+ it . skip ( 'should render the correct href for locale domain' , async ( ) => {
108
112
let browser = await webdriver (
109
113
ctx . appPort ,
110
114
`${ ctx . basePath || '' } /links?nextLocale=go`
@@ -142,6 +146,46 @@ export function runTests(ctx) {
142
146
}
143
147
} )
144
148
149
+ it ( 'should render the correct href with locale domains but not on a locale domain' , async ( ) => {
150
+ let browser = await webdriver (
151
+ ctx . appPort ,
152
+ `${ ctx . basePath || '' } /links?nextLocale=go`
153
+ )
154
+
155
+ for ( const [ element , pathname ] of [
156
+ [ '#to-another' , '/another' ] ,
157
+ [ '#to-gsp' , '/gsp' ] ,
158
+ [ '#to-fallback-first' , '/gsp/fallback/first' ] ,
159
+ [ '#to-fallback-hello' , '/gsp/fallback/hello' ] ,
160
+ [ '#to-gssp' , '/gssp' ] ,
161
+ [ '#to-gssp-slug' , '/gssp/first' ] ,
162
+ ] ) {
163
+ const href = await browser . elementByCss ( element ) . getAttribute ( 'href' )
164
+ const { hostname, pathname : hrefPathname } = url . parse ( href )
165
+ expect ( hostname ) . not . toBe ( 'example.com' )
166
+ expect ( hrefPathname ) . toBe ( `${ ctx . basePath || '' } /go${ pathname } ` )
167
+ }
168
+
169
+ browser = await webdriver (
170
+ ctx . appPort ,
171
+ `${ ctx . basePath || '' } /links?nextLocale=go-BE`
172
+ )
173
+
174
+ for ( const [ element , pathname ] of [
175
+ [ '#to-another' , '/another' ] ,
176
+ [ '#to-gsp' , '/gsp' ] ,
177
+ [ '#to-fallback-first' , '/gsp/fallback/first' ] ,
178
+ [ '#to-fallback-hello' , '/gsp/fallback/hello' ] ,
179
+ [ '#to-gssp' , '/gssp' ] ,
180
+ [ '#to-gssp-slug' , '/gssp/first' ] ,
181
+ ] ) {
182
+ const href = await browser . elementByCss ( element ) . getAttribute ( 'href' )
183
+ const { hostname, pathname : hrefPathname } = url . parse ( href )
184
+ expect ( hostname ) . not . toBe ( 'example.com' )
185
+ expect ( hrefPathname ) . toBe ( `${ ctx . basePath || '' } /go-BE${ pathname } ` )
186
+ }
187
+ } )
188
+
145
189
it ( 'should navigate through history with query correctly' , async ( ) => {
146
190
const browser = await webdriver ( ctx . appPort , `${ ctx . basePath || '/' } ` )
147
191
0 commit comments