Skip to content

Commit

Permalink
validate form with js disabled works
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamMikacich committed Oct 31, 2024
1 parent 213b0e7 commit 282de59
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/tests/src/app/useAction/success-form-js-disabled/page.tsx
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>
);
}
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('');
});

0 comments on commit 282de59

Please sign in to comment.