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/modularizeimports/modularizeimports.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/options-request/options-request.test.ts",
|
||||
"test/e2e/app-dir/revalidate-dynamic/revalidate-dynamic.test.ts",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
'use server'
|
||||
|
||||
export async function addToCart() {
|
||||
console.log('addToCart')
|
||||
return 'Added to cart!'
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
'use client'
|
||||
import { useFormStatus } from 'react-dom'
|
||||
import { useFormStatus, useFormState } from 'react-dom'
|
||||
import { addToCart } from './actions'
|
||||
|
||||
function SubmitButton() {
|
||||
|
@ -13,10 +13,12 @@ function SubmitButton() {
|
|||
}
|
||||
|
||||
export default function Page() {
|
||||
const [state, formAction] = useFormState(addToCart)
|
||||
return (
|
||||
<>
|
||||
<h1>Add to cart</h1>
|
||||
<form action={addToCart}>
|
||||
{state && <div id="result">{state}</div>}
|
||||
<form action={formAction}>
|
||||
<SubmitButton />
|
||||
</form>
|
||||
</>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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', () => {
|
||||
const { next } = nextTestSetup({
|
||||
|
@ -40,8 +40,8 @@ describe('app-dir action handling', () => {
|
|||
|
||||
await browser.elementByCss('button').click()
|
||||
|
||||
await check(() => {
|
||||
return (next.cliOutput.match(/addToCart/g) || []).length
|
||||
}, 1)
|
||||
await retry(async () => {
|
||||
expect(await browser.elementById('result').text()).toBe('Added to cart!')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue