-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
Hi there,
First of all, thanks for all the great work on Inertia and its Rails integration.
When writing E2E tests with Rspec and Capybara, I noticed that submitting an Inertia powered form or clicking on an Inertia powered link always sends a get request to the server, ignoring the verb.
Example with a form:
Take the following client-side rendered component:
import React from 'react'
import { useForm } from '@inertiajs/inertia-react'
const MyForm = () => {
const { post, data, setData, processing, errors } = useForm({
name: '',
email: '',
});
const handleSubmit = (e) => {
e.preventDefault();
post('/my/endpoint');
};
return (
<form onSubmit={handleSubmit}>
<input type="text" name="name" value={data.name} onChange={e => setData('name', e.target.value)} />
<button type="submit">Submit</button>
</form>
)
}- β When submitting the form, a POST request is sent to the server.
- π΄ But when submitting the form in a Capybara test, it sends a GET request
Example with a link:
Take the following component:
import React from 'react'
import { Link } from '@inertiajs/inertia-react'
const MyLink = () => <Link href="/my/endpoint" method="post">My Link</Link>
export default MyLink;- β When clicking on the link, a POST request is sent to the server.
- π΄ But when clicking on the link in a Capybara test, it sends a GET request
I've been able to reproduce this issue in a Rails 7.1.3 app with Inertia 2.2.8
ershad and binary-koan
Metadata
Metadata
Assignees
Labels
No labels