fix actions-navigation deploy test (#66850)
Switches to reading action result from state rather than runtime logs.
This commit is contained in:
parent
4dd26753d9
commit
02de207967
4 changed files with 9 additions and 8 deletions
|
@ -36,7 +36,6 @@
|
||||||
"test/e2e/app-dir/mdx/mdx.test.ts",
|
"test/e2e/app-dir/mdx/mdx.test.ts",
|
||||||
"test/e2e/app-dir/modularizeimports/modularizeimports.test.ts",
|
"test/e2e/app-dir/modularizeimports/modularizeimports.test.ts",
|
||||||
"test/e2e/app-dir/third-parties/basic.test.ts",
|
"test/e2e/app-dir/third-parties/basic.test.ts",
|
||||||
"test/e2e/app-dir/actions-navigation/index.test.ts",
|
|
||||||
"test/e2e/app-dir/app-static/app-static-custom-handler.test.ts",
|
"test/e2e/app-dir/app-static/app-static-custom-handler.test.ts",
|
||||||
"test/e2e/app-dir/options-request/options-request.test.ts",
|
"test/e2e/app-dir/options-request/options-request.test.ts",
|
||||||
"test/e2e/app-dir/revalidate-dynamic/revalidate-dynamic.test.ts",
|
"test/e2e/app-dir/revalidate-dynamic/revalidate-dynamic.test.ts",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
'use server'
|
'use server'
|
||||||
|
|
||||||
export async function addToCart() {
|
export async function addToCart() {
|
||||||
console.log('addToCart')
|
return 'Added to cart!'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
'use client'
|
'use client'
|
||||||
import { useFormStatus } from 'react-dom'
|
import { useFormStatus, useFormState } from 'react-dom'
|
||||||
import { addToCart } from './actions'
|
import { addToCart } from './actions'
|
||||||
|
|
||||||
function SubmitButton() {
|
function SubmitButton() {
|
||||||
|
@ -13,10 +13,12 @@ function SubmitButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
|
const [state, formAction] = useFormState(addToCart)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h1>Add to cart</h1>
|
<h1>Add to cart</h1>
|
||||||
<form action={addToCart}>
|
{state && <div id="result">{state}</div>}
|
||||||
|
<form action={formAction}>
|
||||||
<SubmitButton />
|
<SubmitButton />
|
||||||
</form>
|
</form>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { nextTestSetup } from 'e2e-utils'
|
import { nextTestSetup } from 'e2e-utils'
|
||||||
import { check, waitFor } from 'next-test-utils'
|
import { check, waitFor, retry } from 'next-test-utils'
|
||||||
|
|
||||||
describe('app-dir action handling', () => {
|
describe('app-dir action handling', () => {
|
||||||
const { next } = nextTestSetup({
|
const { next } = nextTestSetup({
|
||||||
|
@ -40,8 +40,8 @@ describe('app-dir action handling', () => {
|
||||||
|
|
||||||
await browser.elementByCss('button').click()
|
await browser.elementByCss('button').click()
|
||||||
|
|
||||||
await check(() => {
|
await retry(async () => {
|
||||||
return (next.cliOutput.match(/addToCart/g) || []).length
|
expect(await browser.elementById('result').text()).toBe('Added to cart!')
|
||||||
}, 1)
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue