From 1de5d78fda2f396fc89d91f9d2e6060c3cb8e0da Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 28 Dec 2020 14:41:08 -0600 Subject: [PATCH] Update i18n test (#20548) This tweaks the new i18n query history test to address intermittent failures in CI x-ref: https://github.com/vercel/next.js/pull/19197#issuecomment-751845314 x-ref: https://github.com/vercel/next.js/pull/19135#issuecomment-751822153 x-ref: https://github.com/vercel/next.js/pull/20379#issuecomment-751821500 --- test/integration/i18n-support/test/shared.js | 26 ++++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/test/integration/i18n-support/test/shared.js b/test/integration/i18n-support/test/shared.js index 2e4bd25a4a..c1227fa400 100644 --- a/test/integration/i18n-support/test/shared.js +++ b/test/integration/i18n-support/test/shared.js @@ -37,20 +37,29 @@ export function runTests(ctx) { window.next.router.asPath, { locale: 'nl' } ) + })()`) + + await check(() => browser.elementByCss('#router-locale').text(), 'nl') + expect(await browser.eval('window.beforeNav')).toBe(1) + + await browser.eval(`(function() { window.next.router.push( '/gssp?page=1' ) })()`) - await browser.waitForElementByCss('#gssp') + await check(async () => { + const html = await browser.eval('document.documentElement.innerHTML') + const props = JSON.parse(cheerio.load(html)('#props').text()) - const props = JSON.parse(await browser.elementByCss('#props').text()) - expect(props).toEqual({ - locale: 'nl', - locales, - defaultLocale: 'en-US', - query: { page: '1' }, - }) + assert.deepEqual(props, { + locale: 'nl', + locales, + defaultLocale: 'en-US', + query: { page: '1' }, + }) + return 'success' + }, 'success') await browser .back() @@ -65,6 +74,7 @@ export function runTests(ctx) { defaultLocale: 'en-US', query: { page: '1' }, }) + expect(await browser.eval('window.beforeNav')).toBe(1) }) if (!ctx.isDev) { -- GitLab