-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate form with js disabled works
- Loading branch information
1 parent
213b0e7
commit 282de59
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/tests/src/app/useAction/success-form-js-disabled/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use client'; | ||
|
||
import { successFormAction } from '@/app/actions'; | ||
import { useAction } from '@vergestack/api-react'; | ||
|
||
export default function Home() { | ||
const { data, handlers, errors } = useAction(successFormAction); | ||
|
||
return ( | ||
<form {...handlers}> | ||
<p id="data">{!data ? 'No data' : data}</p> | ||
<p id="error">{JSON.stringify(errors)}</p> | ||
<input type="text" name="name" /> | ||
<button type="submit">Execute</button> | ||
</form> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/tests/src/app/useAction/success-form-js-disabled/tests.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { expect, test } from '@playwright/test'; | ||
test.use({ javaScriptEnabled: false }); | ||
|
||
test('useAction success form', async ({ page }) => { | ||
await page.goto('/useAction/success-form-js-disabled'); | ||
|
||
await page.fill('input[name="name"]', 'world'); | ||
|
||
await page.waitForSelector('button'); | ||
|
||
await page.click('button'); | ||
|
||
// Wait for navigation/form submission to complete | ||
await page.waitForLoadState('networkidle'); | ||
|
||
// Check that input field is cleared after submission | ||
const inputValue = await page.inputValue('input[name="name"]'); | ||
expect(inputValue).toBe(''); | ||
}); |