From 2fc27c1ec7d9b96d39daac97ca3e3d286f6608d7 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 27 Apr 2022 13:04:16 -0500 Subject: [PATCH] Update rewrite destination for flakey rewrite tests (#36519) * Update rewrite destination for flakey rewrite tests * update other test --- test/integration/custom-routes/next.config.js | 2 +- test/integration/custom-routes/test/index.test.js | 6 +++--- .../middleware/core/pages/rewrites/_middleware.js | 6 ++++-- test/integration/middleware/core/test/index.test.js | 9 +++------ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/test/integration/custom-routes/next.config.js b/test/integration/custom-routes/next.config.js index 70814483c17e..c4bf06f3e0fc 100644 --- a/test/integration/custom-routes/next.config.js +++ b/test/integration/custom-routes/next.config.js @@ -222,7 +222,7 @@ module.exports = { }, { source: '/overridden', - destination: 'https://vercel.com', + destination: 'https://example.vercel.sh', }, { source: '/nfl/:path*', diff --git a/test/integration/custom-routes/test/index.test.js b/test/integration/custom-routes/test/index.test.js index ae28cee1f731..a20ee0ab2297 100644 --- a/test/integration/custom-routes/test/index.test.js +++ b/test/integration/custom-routes/test/index.test.js @@ -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/ ) }) @@ -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', }, diff --git a/test/integration/middleware/core/pages/rewrites/_middleware.js b/test/integration/middleware/core/pages/rewrites/_middleware.js index 2d6b154dc86d..f4018868045f 100644 --- a/test/integration/middleware/core/pages/rewrites/_middleware.js +++ b/test/integration/middleware/core/pages/rewrites/_middleware.js @@ -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) ) } @@ -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') { diff --git a/test/integration/middleware/core/test/index.test.js b/test/integration/middleware/core/test/index.test.js index 5e0ba76d9c90..80e86207e633 100644 --- a/test/integration/middleware/core/test/index.test.js +++ b/test/integration/middleware/core/test/index.test.js @@ -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'), @@ -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 () => {