Skip to content

Commit

Permalink
Fix failing tests from upstream server
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 8, 2022
1 parent a7d3e84 commit 8b9cc24
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/integration/custom-routes/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ module.exports = {
},
{
source: '/overridden',
destination: 'https://example.com',
destination: 'https://vercel.com',
},
],
}
Expand Down
6 changes: 3 additions & 3 deletions test/integration/custom-routes/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ const runTests = (isDev = false) => {
console.error('Invalid response', html)
}
expect(res.status).toBe(200)
expect(html).toContain('Example Domain')
expect(html).toContain('Vercel')

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

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

Expand Down
10 changes: 6 additions & 4 deletions test/integration/middleware/core/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,20 @@ function rewriteTests(log, locale = '') {
)

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

const browser = await webdriver(context.appPort, `${locale}/rewrites`)
await browser.elementByCss('#override-with-external-rewrite').click()
await check(
() => browser.eval('document.documentElement.innerHTML'),
/Example Domain/
/Vercel/
)
expect(await browser.eval('window.location.pathname')).toBe(
await check(
() => browser.eval('window.location.pathname'),
`${locale || ''}/rewrites/about`
)
expect(await browser.eval('window.location.search')).toBe(
await check(
() => browser.eval('window.location.search'),
'?override=external'
)
})
Expand Down

0 comments on commit 8b9cc24

Please sign in to comment.