Unverified Commit 02de2079 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

fix actions-navigation deploy test (#66850)

Switches to reading action result from state rather than runtime logs.
parent 4dd26753
......@@ -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",
......
'use server'
export async function addToCart() {
console.log('addToCart')
return 'Added to cart!'
}
'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>
</>
......
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!')
})
})
})
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