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