(curCtx)
| 218 | |
| 219 | describe('with trailingSlash: true', () => { |
| 220 | const runSlashTests = (curCtx) => { |
| 221 | if (!curCtx.isDev) { |
| 222 | it('should preload all locales data correctly', async () => { |
| 223 | const browser = await webdriver( |
| 224 | curCtx.appPort, |
| 225 | `${curCtx.basePath}/mixed` |
| 226 | ) |
| 227 | |
| 228 | await browser.eval(`(function() { |
| 229 | document.querySelector('#to-gsp-en-us').scrollIntoView() |
| 230 | document.querySelector('#to-gsp-nl-nl').scrollIntoView() |
| 231 | document.querySelector('#to-gsp-fr').scrollIntoView() |
| 232 | })()`) |
| 233 | |
| 234 | await check(async () => { |
| 235 | const hrefs = await browser.eval( |
| 236 | `Object.keys(window.next.router.sdc)` |
| 237 | ) |
| 238 | hrefs.sort() |
| 239 | |
| 240 | const baseURL = await browser.url() |
| 241 | assert.deepEqual( |
| 242 | hrefs.map((href) => |
| 243 | new URL(href, baseURL).pathname |
| 244 | .replace(ctx.basePath, '') |
| 245 | .replace(/^\/_next\/data\/[^/]+/, '') |
| 246 | ), |
| 247 | ['/en-US/gsp.json', '/fr.json', '/fr/gsp.json', '/nl-NL/gsp.json'] |
| 248 | ) |
| 249 | return 'yes' |
| 250 | }, 'yes') |
| 251 | }) |
| 252 | |
| 253 | it('should have correct locale domain hrefs', async () => { |
| 254 | const res = await fetchViaHTTP( |
| 255 | curCtx.appPort, |
| 256 | '/do-BE/frank/', |
| 257 | undefined, |
| 258 | { |
| 259 | redirect: 'manual', |
| 260 | } |
| 261 | ) |
| 262 | expect(res.status).toBe(200) |
| 263 | |
| 264 | const html = await res.text() |
| 265 | const $ = cheerio.load(html) |
| 266 | |
| 267 | expect($('#to-fallback-hello')[0].attribs.href).toBe( |
| 268 | 'http://example.do/do-BE/gsp/fallback/hello/' |
| 269 | ) |
| 270 | expect($('#to-no-fallback-first')[0].attribs.href).toBe( |
| 271 | 'http://example.do/do-BE/gsp/no-fallback/first/' |
| 272 | ) |
| 273 | }) |
| 274 | } |
| 275 | |
| 276 | it('should redirect correctly', async () => { |
| 277 | for (const locale of nonDomainLocales) { |
no test coverage detected