From 2069b93bd4746047ca2f476e1ab2726bc9129140 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 3 Sep 2020 13:03:57 -0500 Subject: [PATCH] remove tests for original PR --- .../dynamic-routing/pages/d/[id].js | 9 ----- .../dynamic-routing/pages/index.js | 12 ------ .../dynamic-routing/test/index.test.js | 33 --------------- .../pages/gsp-blog/[post].js | 6 ++- .../test/index.test.js | 40 +++++++++++++++++++ 5 files changed, 45 insertions(+), 55 deletions(-) delete mode 100644 test/integration/dynamic-routing/pages/d/[id].js diff --git a/test/integration/dynamic-routing/pages/d/[id].js b/test/integration/dynamic-routing/pages/d/[id].js deleted file mode 100644 index b17ed24dd8220..0000000000000 --- a/test/integration/dynamic-routing/pages/d/[id].js +++ /dev/null @@ -1,9 +0,0 @@ -import { useRouter } from 'next/router' - -const Page = () => { - const router = useRouter() - const { query } = router - return

This is {query.id}

-} - -export default Page diff --git a/test/integration/dynamic-routing/pages/index.js b/test/integration/dynamic-routing/pages/index.js index c6bf5d0c59eb6..bf9583e84609c 100644 --- a/test/integration/dynamic-routing/pages/index.js +++ b/test/integration/dynamic-routing/pages/index.js @@ -1,15 +1,6 @@ import Link from 'next/link' import { useRouter } from 'next/router' -if (typeof window !== 'undefined') { - window.caughtWarns = [] - const origWarn = window.console.warn - window.console.warn = function (...args) { - window.caughtWarns.push(args) - origWarn(...args) - } -} - const Page = () => { return (
@@ -137,9 +128,6 @@ const Page = () => { Nested Catch-all route (multi)
- - Dynamic route no as -

{JSON.stringify(Object.keys(useRouter().query))}

) diff --git a/test/integration/dynamic-routing/test/index.test.js b/test/integration/dynamic-routing/test/index.test.js index 5427e53c2403b..a4ec4616e4c91 100644 --- a/test/integration/dynamic-routing/test/index.test.js +++ b/test/integration/dynamic-routing/test/index.test.js @@ -84,31 +84,6 @@ function runTests(dev) { expect(url).toBe('?fromHome=true') }) - if (dev) { - it('should not have any console warnings on initial load', async () => { - const browser = await webdriver(appPort, '/') - expect(await browser.eval('window.caughtWarns')).toEqual([]) - }) - - it('should not have any console warnings when navigating to dynamic route', async () => { - let browser - try { - browser = await webdriver(appPort, '/') - await browser.eval('window.beforeNav = 1') - await browser.elementByCss('#dynamic-route-no-as').click() - await browser.waitForElementByCss('#asdf') - - expect(await browser.eval('window.beforeNav')).toBe(1) - - const text = await browser.elementByCss('#asdf').text() - expect(text).toMatch(/this is.*?dynamic-1/i) - expect(await browser.eval('window.caughtWarns')).toEqual([]) - } finally { - if (browser) await browser.close() - } - }) - } - it('should navigate to a dynamic page successfully', async () => { let browser try { @@ -918,14 +893,6 @@ function runTests(dev) { helloworld: 'hello-world', }, }, - { - namedRegex: '^/d/(?[^/]+?)(?:/)?$', - page: '/d/[id]', - regex: normalizeRegEx('^\\/d\\/([^\\/]+?)(?:\\/)?$'), - routeKeys: { - id: 'id', - }, - }, { namedRegex: '^/dash/(?[^/]+?)(?:/)?$', page: '/dash/[hello-world]', diff --git a/test/integration/gssp-ssr-change-reloading/pages/gsp-blog/[post].js b/test/integration/gssp-ssr-change-reloading/pages/gsp-blog/[post].js index 187308da75654..2077feda1dcef 100644 --- a/test/integration/gssp-ssr-change-reloading/pages/gsp-blog/[post].js +++ b/test/integration/gssp-ssr-change-reloading/pages/gsp-blog/[post].js @@ -13,9 +13,13 @@ export default function Gsp(props) { ) } -export const getStaticProps = ({ params }) => { +export const getStaticProps = async ({ params }) => { const count = 1 + if (params.post === 'second') { + await new Promise((resolve) => setTimeout(resolve, 2000)) + } + return { props: { count, diff --git a/test/integration/gssp-ssr-change-reloading/test/index.test.js b/test/integration/gssp-ssr-change-reloading/test/index.test.js index c6bfb6e58b4b9..1701a47de9e15 100644 --- a/test/integration/gssp-ssr-change-reloading/test/index.test.js +++ b/test/integration/gssp-ssr-change-reloading/test/index.test.js @@ -10,6 +10,19 @@ const appDir = join(__dirname, '..') let appPort let app +const installCheckVisible = (browser) => { + return browser.eval(`(function() { + window.checkInterval = setInterval(function() { + let watcherDiv = document.querySelector('#__next-build-watcher') + watcherDiv = watcherDiv.shadowRoot || watcherDiv + window.showedBuilder = window.showedBuilder || ( + watcherDiv.querySelector('div').className.indexOf('visible') > -1 + ) + if (window.showedBuilder) clearInterval(window.checkInterval) + }, 50) + })()`) +} + describe('GS(S)P Server-Side Change Reloading', () => { beforeAll(async () => { appPort = await findPort() @@ -62,6 +75,33 @@ describe('GS(S)P Server-Side Change Reloading', () => { ) }) + it('should show indicator when re-fetching data', async () => { + const browser = await webdriver(appPort, '/gsp-blog/second') + await installCheckVisible(browser) + await browser.eval(() => (window.beforeChange = 'hi')) + + const props = JSON.parse(await browser.elementByCss('#props').text()) + expect(props.count).toBe(1) + + const page = new File(join(appDir, 'pages/gsp-blog/[post].js')) + page.replace('count = 1', 'count = 2') + + await check( + async () => + JSON.parse(await browser.elementByCss('#props').text()).count + '', + '2' + ) + expect(await browser.eval(() => window.beforeChange)).toBe('hi') + expect(await browser.eval(() => window.showedBuilder)).toBe(true) + page.restore() + + await check( + async () => + JSON.parse(await browser.elementByCss('#props').text()).count + '', + '1' + ) + }) + it('should update page when getStaticPaths is changed only', async () => { const browser = await webdriver(appPort, '/gsp-blog/first') await browser.eval(() => (window.beforeChange = 'hi'))