Skip to content

Commit 08ef1db

Browse files
committed
unskip middleware deploy test
1 parent 979fedb commit 08ef1db

File tree

4 files changed

+36
-43
lines changed

4 files changed

+36
-43
lines changed

test/e2e/app-dir/app-middleware/app-middleware.test.ts

+11-22
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ import { nextTestSetup, FileRef } from 'e2e-utils'
66
import type { Response } from 'node-fetch'
77

88
describe('app-dir with middleware', () => {
9-
const { next, skipped } = nextTestSetup({
9+
const { next } = nextTestSetup({
1010
files: __dirname,
11-
skipDeployment: true,
1211
})
1312

14-
if (skipped) {
15-
return
16-
}
17-
1813
it('should filter correctly after middleware rewrite', async () => {
1914
const browser = await next.browser('/start')
2015

@@ -179,8 +174,10 @@ describe('app-dir with middleware', () => {
179174

180175
await browser.elementById('submit-server-action').click()
181176

182-
await retry(() => {
183-
expect(next.cliOutput).toMatch(/\[Cookie From Action\]: \d+\.\d+/)
177+
await retry(async () => {
178+
expect(await browser.elementById('action-result').text()).toMatch(
179+
/Action Result: \d+\.\d+/
180+
)
184181
})
185182

186183
// ensure that we still can't read the secure cookie
@@ -210,16 +207,18 @@ describe('app-dir with middleware', () => {
210207

211208
await browser.elementById('submit-server-action').click()
212209

213-
await retry(() => {
214-
expect(next.cliOutput).toMatch(/\[Cookie From Action\]: \d+\.\d+/)
210+
await retry(async () => {
211+
expect(await browser.elementById('action-result').text()).toMatch(
212+
/Action Result: \d+\.\d+/
213+
)
215214
})
216215

217216
await browser.deleteCookies()
218217
})
219218
})
220219

221220
describe('app dir - middleware without pages dir', () => {
222-
const { next, skipped } = nextTestSetup({
221+
const { next } = nextTestSetup({
223222
files: {
224223
app: new FileRef(path.join(__dirname, 'app')),
225224
'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
@@ -235,13 +234,8 @@ describe('app dir - middleware without pages dir', () => {
235234
}
236235
`,
237236
},
238-
skipDeployment: true,
239237
})
240238

241-
if (skipped) {
242-
return
243-
}
244-
245239
// eslint-disable-next-line jest/no-identical-title
246240
it('Updates headers', async () => {
247241
const html = await next.render('/headers')
@@ -251,7 +245,7 @@ describe('app dir - middleware without pages dir', () => {
251245
})
252246

253247
describe('app dir - middleware with middleware in src dir', () => {
254-
const { next, skipped } = nextTestSetup({
248+
const { next } = nextTestSetup({
255249
files: {
256250
'src/app': new FileRef(path.join(__dirname, 'app')),
257251
'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
@@ -265,13 +259,8 @@ describe('app dir - middleware with middleware in src dir', () => {
265259
}
266260
`,
267261
},
268-
skipDeployment: true,
269262
})
270263

271-
if (skipped) {
272-
return
273-
}
274-
275264
it('works without crashing when using requestAsyncStorage', async () => {
276265
const browser = await next.browser('/')
277266
await browser.addCookie({
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
import { cookies } from 'next/headers'
22
import Link from 'next/link'
3+
import { Form } from '../form'
34

45
export default function Page() {
56
return (
67
<div>
78
<p id="total-cookies">Total Cookie Length: {cookies().size}</p>
89
<Link href="/rsc-cookies-delete">To Delete Cookies Route</Link>
910

10-
<form
11+
<Form
1112
action={async () => {
1213
'use server'
13-
console.log(
14-
'[Cookie From Action]:',
15-
cookies().get('rsc-secure-cookie').value
16-
)
14+
return cookies().get('rsc-secure-cookie').value
1715
}}
18-
>
19-
<button type="submit" id="submit-server-action">
20-
server action
21-
</button>
22-
</form>
16+
/>
2317
</div>
2418
)
2519
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use client'
2+
3+
import { useActionState } from 'react'
4+
5+
export function Form({ action }) {
6+
const [state, formAction] = useActionState(action, null)
7+
8+
return (
9+
<form action={formAction}>
10+
<div id="action-result">Action Result: {state}</div>
11+
<button type="submit" id="submit-server-action">
12+
server action
13+
</button>
14+
</form>
15+
)
16+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { cookies } from 'next/headers'
22
import Link from 'next/link'
3+
import { Form } from './form'
34

45
export default function Page() {
56
const rscCookie1 = cookies().get('rsc-cookie-value-1')?.value
@@ -11,20 +12,13 @@ export default function Page() {
1112
<p id="rsc-cookie-2">Cookie 2: {rscCookie2}</p>
1213
<p id="total-cookies">Total Cookie Length: {cookies().size}</p>
1314
<Link href="/rsc-cookies-delete">To Delete Cookies Route</Link>
14-
15-
<form
15+
<Form
1616
action={async () => {
1717
'use server'
18-
console.log(
19-
'[Cookie From Action]:',
20-
cookies().get('rsc-cookie-value-1').value
21-
)
18+
19+
return cookies().get('rsc-cookie-value-1')?.value
2220
}}
23-
>
24-
<button type="submit" id="submit-server-action">
25-
server action
26-
</button>
27-
</form>
21+
/>
2822
</div>
2923
)
3024
}

0 commit comments

Comments
 (0)