Skip to content

Commit

Permalink
Update rewrite destination for flakey rewrite tests (#36519)
Browse files Browse the repository at this point in the history
* Update rewrite destination for flakey rewrite tests

* update other test
  • Loading branch information
ijjk committed Apr 27, 2022
1 parent 842e4ec commit 2fc27c1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/integration/custom-routes/next.config.js
Expand Up @@ -222,7 +222,7 @@ module.exports = {
},
{
source: '/overridden',
destination: 'https://vercel.com',
destination: 'https://example.vercel.sh',
},
{
source: '/nfl/:path*',
Expand Down
6 changes: 3 additions & 3 deletions test/integration/custom-routes/test/index.test.js
Expand Up @@ -89,13 +89,13 @@ const runTests = (isDev = false) => {
console.error('Invalid response', html)
}
expect(res.status).toBe(200)
expect(html).toContain('Vercel')
expect(html).toContain('Example Domain')

const browser = await webdriver(appPort, '/nav')
await browser.elementByCss('#to-before-files-overridden').click()
await check(
() => browser.eval('document.documentElement.innerHTML'),
/Vercel/
/Example Domain/
)
})

Expand Down Expand Up @@ -1768,7 +1768,7 @@ const runTests = (isDev = false) => {
source: '/old-blog/:path*',
},
{
destination: 'https://vercel.com',
destination: 'https://example.vercel.sh',
regex: normalizeRegEx('^\\/overridden(?:\\/)?$'),
source: '/overridden',
},
Expand Down
Expand Up @@ -12,7 +12,9 @@ export async function middleware(request) {
) {
const isExternal = url.searchParams.get('override') === 'external'
return NextResponse.rewrite(
isExternal ? 'https://vercel.com' : new URL('/rewrites/a', request.url)
isExternal
? 'https://example.vercel.sh'
: new URL('/rewrites/a', request.url)
)
}

Expand Down Expand Up @@ -52,7 +54,7 @@ export async function middleware(request) {
}

if (url.pathname === '/rewrites/rewrite-me-to-vercel') {
return NextResponse.rewrite('https://vercel.com')
return NextResponse.rewrite('https://example.vercel.sh')
}

if (url.pathname === '/rewrites/clear-query-params') {
Expand Down
9 changes: 3 additions & 6 deletions test/integration/middleware/core/test/index.test.js
Expand Up @@ -260,13 +260,13 @@ function rewriteTests(log, locale = '') {
)

expect(res.status).toBe(200)
expect(await res.text()).toContain('Vercel')
expect(await res.text()).toContain('Example Domain')

const browser = await webdriver(context.appPort, `${locale}/rewrites`)
await browser.elementByCss('#override-with-external-rewrite').click()
await check(
() => browser.eval('document.documentElement.innerHTML'),
/Vercel/
/Example Domain/
)
await check(
() => browser.eval('window.location.pathname'),
Expand Down Expand Up @@ -474,12 +474,9 @@ function rewriteTests(log, locale = '') {
`${locale}/rewrites/rewrite-me-to-vercel`
)
const html = await res.text()
const $ = cheerio.load(html)
// const browser = await webdriver(context.appPort, '/rewrite-me-to-vercel')
// TODO: running this to chech the window.location.pathname hangs for some reason;
expect($('head > title').text()).toBe(
'Develop. Preview. Ship. For the best frontend teams – Vercel'
)
expect(html).toContain('Example Domain')
})

it(`${locale} should rewrite without hard navigation`, async () => {
Expand Down

0 comments on commit 2fc27c1

Please sign in to comment.