Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix actions-navigation deploy test #66850

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/deploy-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use server'

export async function addToCart() {
console.log('addToCart')
return 'Added to cart!'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import { useFormStatus } from 'react-dom'
import { useFormStatus, useFormState } from 'react-dom'
import { addToCart } from './actions'

function SubmitButton() {
Expand All @@ -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>
</>
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/app-dir/actions-navigation/index.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -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