Unverified Commit 9fe8a0c7 authored by Janka Uryga's avatar Janka Uryga Committed by GitHub

fix: broken deploy test from #77898 (#78692)

i messed up a deployment test thing in
https://github.com/vercel/next.js/pull/77898, had the fix locally but
forgot to push before merging. the test tries to wait for some initial
stuff to happen stuff after the deployment finishes, but we should only
to do that once, it won't work in the second test of the `it.each`, so
the test fails.
parent c784c6f0
...@@ -740,12 +740,33 @@ describe('use-cache', () => { ...@@ -740,12 +740,33 @@ describe('use-cache', () => {
expect(text).toBe('This page could not be found.') expect(text).toBe('This page could not be found.')
}) })
it.each([ describe('should not read nor write cached data when draft mode is enabled', () => {
{ description: 'js enabled', disableJavaScript: false }, if (isNextDeploy) {
{ description: 'js disabled', disableJavaScript: true }, // Wait for the background revalidation after the deployment to settle.
])( beforeAll(async () => {
'should not read nor write cached data when draft mode is enabled: $description', const browser = await next.browser('/draft-mode')
async ({ disableJavaScript }) => { try {
const initialTopLevelValue = await browser
.elementById('top-level')
.text()
await retry(async () => {
await browser.refresh()
expect(await browser.elementById('top-level').text()).not.toBe(
initialTopLevelValue
)
})
} finally {
// we're not in a test, so the browser won't get cleaned up automatically.
await browser.close()
}
})
}
it.each([
{ description: 'js enabled', disableJavaScript: false },
{ description: 'js disabled', disableJavaScript: true },
])('$description', async ({ disableJavaScript }) => {
const browser = await next.browser('/draft-mode', { const browser = await next.browser('/draft-mode', {
// This test relies on a server action to set draft mode. // This test relies on a server action to set draft mode.
// To ensure that it works for both fetch actions and MPA actions, // To ensure that it works for both fetch actions and MPA actions,
...@@ -769,20 +790,7 @@ describe('use-cache', () => { ...@@ -769,20 +790,7 @@ describe('use-cache', () => {
'Enable Draft Mode' 'Enable Draft Mode'
) )
let initialTopLevelValue = await browser.elementById('top-level').text() const initialTopLevelValue = await browser.elementById('top-level').text()
if (isNextDeploy) {
await retry(async () => {
// Wait for the background revalidation after the deployment to settle.
await browser.refresh()
expect(await browser.elementById('top-level').text()).not.toBe(
initialTopLevelValue
)
})
initialTopLevelValue = await browser.elementById('top-level').text()
}
// Draft mode is disabled, cached data should be returned on refresh. // Draft mode is disabled, cached data should be returned on refresh.
...@@ -853,8 +861,8 @@ describe('use-cache', () => { ...@@ -853,8 +861,8 @@ describe('use-cache', () => {
expect(await browser.elementById('closure').text()).toBe( expect(await browser.elementById('closure').text()).toBe(
initialClosureValue initialClosureValue
) )
} })
) })
if (isNextDev) { if (isNextDev) {
it('should not have unhandled rejection of Request data promises when use cache is enabled without dynamicIO', async () => { it('should not have unhandled rejection of Request data promises when use cache is enabled without dynamicIO', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment