Skip to content

Commit

Permalink
remove tests for original PR
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Sep 3, 2020
1 parent 477a81a commit 2069b93
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 55 deletions.
9 changes: 0 additions & 9 deletions test/integration/dynamic-routing/pages/d/[id].js

This file was deleted.

12 changes: 0 additions & 12 deletions test/integration/dynamic-routing/pages/index.js
Original file line number Diff line number Diff line change
@@ -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 (
<div>
Expand Down Expand Up @@ -137,9 +128,6 @@ const Page = () => {
<a id="nested-ssg-catch-all-multi">Nested Catch-all route (multi)</a>
</Link>
<br />
<Link href="/d/dynamic-1">
<a id="dynamic-route-no-as">Dynamic route no as</a>
</Link>
<p id="query">{JSON.stringify(Object.keys(useRouter().query))}</p>
</div>
)
Expand Down
33 changes: 0 additions & 33 deletions test/integration/dynamic-routing/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -918,14 +893,6 @@ function runTests(dev) {
helloworld: 'hello-world',
},
},
{
namedRegex: '^/d/(?<id>[^/]+?)(?:/)?$',
page: '/d/[id]',
regex: normalizeRegEx('^\\/d\\/([^\\/]+?)(?:\\/)?$'),
routeKeys: {
id: 'id',
},
},
{
namedRegex: '^/dash/(?<helloworld>[^/]+?)(?:/)?$',
page: '/dash/[hello-world]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
40 changes: 40 additions & 0 deletions test/integration/gssp-ssr-change-reloading/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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'))
Expand Down

0 comments on commit 2069b93

Please sign in to comment.