Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/canary' into fix/runtime-confi…
Browse files Browse the repository at this point in the history
…g-serverless
  • Loading branch information
ijjk committed Feb 1, 2020
2 parents 29ae178 + e63d822 commit 64aa4a6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -49,6 +49,10 @@ jobs:
with:
path: '.'
key: ${{ github.sha }}

# TODO: remove after we fix watchpack watching too much
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- run: node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3

testsPass:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test_react_next.yml
Expand Up @@ -47,4 +47,7 @@ jobs:

- run: yarn upgrade react@next react-dom@next -W --dev

# TODO: remove after we fix watchpack watching too much
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- run: node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3
2 changes: 1 addition & 1 deletion examples/with-firebase-hosting/package.json
Expand Up @@ -10,7 +10,7 @@
"preserve": "npm run build-public && npm run build-funcs && npm run build-app && npm run copy-deps && npm run install-deps",
"serve": "cross-env NODE_ENV=production firebase serve",
"predeploy": "npm run build-public && npm run build-funcs && npm run build-app && npm run copy-deps",
"deploy": "firebase deploy",
"deploy": "NODE_ENV=production firebase deploy",
"clean": "rimraf \"dist/functions/**\" && rimraf \"dist/public\"",
"build-public": "cpx \"src/public/**/*.*\" \"dist/public\" -C",
"build-funcs": "babel \"src/functions\" --out-dir \"dist/functions\"",
Expand Down
5 changes: 3 additions & 2 deletions packages/next/client/index.js
Expand Up @@ -99,9 +99,10 @@ class Container extends React.Component {
// If page was exported and has a querystring
// If it's a dynamic route or has a querystring
if (
(data.nextExport &&
router.isSsr &&
((data.nextExport &&
(isDynamicRoute(router.pathname) || location.search)) ||
(Component && Component.__N_SSG && location.search)
(Component && Component.__N_SSG && location.search))
) {
// update query on mount for exported pages
router.replace(
Expand Down
14 changes: 14 additions & 0 deletions test/integration/dynamic-routing/pages/[name]/on-mount-redir.js
@@ -0,0 +1,14 @@
import React from 'react'
import Router from 'next/router'

class Page extends React.Component {
componentDidMount() {
Router.push('/')
}

render() {
return <p>redirecting..</p>
}
}

export default Page
20 changes: 19 additions & 1 deletion test/integration/dynamic-routing/test/index.test.js
Expand Up @@ -83,6 +83,12 @@ function runTests(dev) {
}
})

it('should allow calling Router.push on mount successfully', async () => {
const browser = await webdriver(appPort, '/post-1/on-mount-redir')
waitFor(2000)
expect(await browser.elementByCss('h3').text()).toBe('My blog')
})

// it('should navigate optional dynamic page', async () => {
// let browser
// try {
Expand Down Expand Up @@ -456,6 +462,12 @@ function runTests(dev) {
page: '/[name]/comments',
regex: normalizeRegEx('^\\/([^\\/]+?)\\/comments(?:\\/)?$'),
},
{
page: '/[name]/on-mount-redir',
regex: normalizeRegEx(
'^\\/([^\\/]+?)\\/on\\-mount\\-redir(?:\\/)?$'
),
},
{
page: '/[name]/[comment]',
regex: normalizeRegEx('^\\/([^\\/]+?)\\/([^\\/]+?)(?:\\/)?$'),
Expand Down Expand Up @@ -507,7 +519,10 @@ describe('Dynamic Routing', () => {
})

describe('serverless mode', () => {
let origNextConfig

beforeAll(async () => {
origNextConfig = await fs.readFile(nextConfig, 'utf8')
await fs.writeFile(
nextConfig,
`
Expand All @@ -526,7 +541,10 @@ describe('Dynamic Routing', () => {
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
afterAll(async () => {
await fs.writeFile(nextConfig, origNextConfig)
await killApp(app)
})
runTests()
})
})

0 comments on commit 64aa4a6

Please sign in to comment.