Unverified Commit 89242ec1 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

unskip middleware deploy test (#70264)

This whole test suite was disabled but only 2 tests rely on runtime
logs, so this refactors the test to remove the runtime log dependency in
favor of returning the output from the action and reading from the DOM.
parent 1e2493e0
......@@ -6,15 +6,10 @@ import { nextTestSetup, FileRef } from 'e2e-utils'
import type { Response } from 'node-fetch'
describe('app-dir with middleware', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should filter correctly after middleware rewrite', async () => {
const browser = await next.browser('/start')
......@@ -179,8 +174,10 @@ describe('app-dir with middleware', () => {
await browser.elementById('submit-server-action').click()
await retry(() => {
expect(next.cliOutput).toMatch(/\[Cookie From Action\]: \d+\.\d+/)
await retry(async () => {
expect(await browser.elementById('action-result').text()).toMatch(
/Action Result: \d+\.\d+/
)
})
// ensure that we still can't read the secure cookie
......@@ -210,8 +207,10 @@ describe('app-dir with middleware', () => {
await browser.elementById('submit-server-action').click()
await retry(() => {
expect(next.cliOutput).toMatch(/\[Cookie From Action\]: \d+\.\d+/)
await retry(async () => {
expect(await browser.elementById('action-result').text()).toMatch(
/Action Result: \d+\.\d+/
)
})
await browser.deleteCookies()
......@@ -219,7 +218,7 @@ describe('app-dir with middleware', () => {
})
describe('app dir - middleware without pages dir', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: {
app: new FileRef(path.join(__dirname, 'app')),
'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
......@@ -235,13 +234,8 @@ describe('app dir - middleware without pages dir', () => {
}
`,
},
skipDeployment: true,
})
if (skipped) {
return
}
// eslint-disable-next-line jest/no-identical-title
it('Updates headers', async () => {
const html = await next.render('/headers')
......@@ -251,7 +245,7 @@ describe('app dir - middleware without pages dir', () => {
})
describe('app dir - middleware with middleware in src dir', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: {
'src/app': new FileRef(path.join(__dirname, 'app')),
'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
......@@ -265,13 +259,8 @@ describe('app dir - middleware with middleware in src dir', () => {
}
`,
},
skipDeployment: true,
})
if (skipped) {
return
}
it('works without crashing when using requestAsyncStorage', async () => {
const browser = await next.browser('/')
await browser.addCookie({
......
import { cookies } from 'next/headers'
import Link from 'next/link'
import { Form } from '../form'
export default function Page() {
return (
......@@ -7,19 +8,12 @@ export default function Page() {
<p id="total-cookies">Total Cookie Length: {cookies().size}</p>
<Link href="/rsc-cookies-delete">To Delete Cookies Route</Link>
<form
<Form
action={async () => {
'use server'
console.log(
'[Cookie From Action]:',
cookies().get('rsc-secure-cookie').value
)
return cookies().get('rsc-secure-cookie').value
}}
>
<button type="submit" id="submit-server-action">
server action
</button>
</form>
/>
</div>
)
}
'use client'
import { useActionState } from 'react'
export function Form({ action }) {
const [state, formAction] = useActionState(action, null)
return (
<form action={formAction}>
<div id="action-result">Action Result: {state}</div>
<button type="submit" id="submit-server-action">
server action
</button>
</form>
)
}
import { cookies } from 'next/headers'
import Link from 'next/link'
import { Form } from './form'
export default function Page() {
const rscCookie1 = cookies().get('rsc-cookie-value-1')?.value
......@@ -11,20 +12,13 @@ export default function Page() {
<p id="rsc-cookie-2">Cookie 2: {rscCookie2}</p>
<p id="total-cookies">Total Cookie Length: {cookies().size}</p>
<Link href="/rsc-cookies-delete">To Delete Cookies Route</Link>
<form
<Form
action={async () => {
'use server'
console.log(
'[Cookie From Action]:',
cookies().get('rsc-cookie-value-1').value
)
return cookies().get('rsc-cookie-value-1')?.value
}}
>
<button type="submit" id="submit-server-action">
server action
</button>
</form>
/>
</div>
)
}
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