mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This may or may not help with the [flakiness](https://app.datadoghq.com/ci/test-runs?query=test_level%3Atest%20env%3Aci%20%40git.repository.id%3Agithub.com%2Fvercel%2Fnext.js%20%40test.service%3Anextjs%20%40test.suite%3A%22tsconfig-path-reloading%22%20%40test.status%3Afail&agg_m=count&agg_m_source=base&agg_t=count¤tTab=overview&eventStack=&fromUser=false&index=citest&start=1713291659981&end=1721067659981&paused=false) of the `tsconfig-path-reloading` test with turbopack. I also found a race condition bug in `packages/next/src/server/lib/router-utils/setup-dev-bundler.ts` after removing an artificial delay of 200ms in the `jsconfig-path-reloading` test.
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { check, retry } from 'next-test-utils'
|
|
import { join } from 'path'
|
|
|
|
describe('custom-app-server-action-redirect', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: join(__dirname, 'custom-server'),
|
|
skipDeployment: true,
|
|
startCommand: 'node server.js',
|
|
serverReadyPattern: /Next mode: (production|development)/,
|
|
dependencies: {
|
|
'get-port': '5.1.1',
|
|
},
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
it('redirects with basepath properly when server action handler uses `redirect`', async () => {
|
|
const browser = await next.browser('/base')
|
|
const getCount = async () => browser.elementByCss('#current-count').text()
|
|
|
|
// Increase count to track if the page reloaded
|
|
await browser.elementByCss('#increase-count').click().click()
|
|
await retry(async () => {
|
|
expect(await getCount()).toBe('Count: 2')
|
|
})
|
|
|
|
await browser.elementById('submit-server-action-redirect').click()
|
|
|
|
expect(await browser.waitForElementByCss('#another').text()).toBe(
|
|
'Another Page'
|
|
)
|
|
expect(await browser.url()).toBe(
|
|
`http://localhost:${next.appPort}/base/another`
|
|
)
|
|
|
|
// Count should still be 2 as the browser should not have reloaded the page.
|
|
expect(await getCount()).toBe('Count: 2')
|
|
})
|
|
|
|
it('redirects with proper cookies set from both redirect response and post respose', async () => {
|
|
const browser = await next.browser('/base')
|
|
|
|
await browser.elementById('submit-server-action-redirect').click()
|
|
|
|
expect(await browser.waitForElementByCss('#another').text()).toBe(
|
|
'Another Page'
|
|
)
|
|
expect(await browser.url()).toBe(
|
|
`http://localhost:${next.appPort}/base/another`
|
|
)
|
|
await check(
|
|
() => browser.eval('document.cookie'),
|
|
/custom-server-test-cookie/
|
|
)
|
|
await check(
|
|
() => browser.eval('document.cookie'),
|
|
/custom-server-action-test-cookie/
|
|
)
|
|
})
|
|
})
|