F
Filament11mo ago
gizmojo

Test form component's action

Is there a way of interacting with individual form components inside a form? E.g how to call add action on a repeater? mountFormComponentAction('data.categories', 'add') Or testing a select's createOptionForm mountFormComponentAction('data.categories.record-183.language_id', 'editOption') In v2 you could
livewire(EditProduct::class, [
'record' => $product->getKey(),
])
->call(
'dispatchFormEvent',
'repeater::createItem',
'data.categories',
)
livewire(EditProduct::class, [
'record' => $product->getKey(),
])
->call(
'dispatchFormEvent',
'repeater::createItem',
'data.categories',
)
Also is there a way of asserting that an action was called or is there a way to test notifications for an action. How do test the replicate action redirects to the newly created product in assertRedirect?
livewire(EditProduct::class, [
'record' => $product->id,
])
->callAction('replicate', data: [
'name' => $name = $this->faker->unique()->realText(),
])
->assertHasNoActionErrors()
->assertNotified('Replicated')
->assertRedirect();
livewire(EditProduct::class, [
'record' => $product->id,
])
->callAction('replicate', data: [
'name' => $name = $this->faker->unique()->realText(),
])
->assertHasNoActionErrors()
->assertNotified('Replicated')
->assertRedirect();
This shows 'A notification was not sent'
Solution:
GitHub
How to test select createOptionUsing · filamentphp filament · Discu...
I searched the docs for how to test select createOptionUsing modal but i couldn't find any Forms\Components\Select::make('owner_id') ->relationship('owner', 'name') -...
Jump to solution
3 Replies
Solution
LeandroFerreira
LeandroFerreira11mo ago
GitHub
How to test select createOptionUsing · filamentphp filament · Discu...
I searched the docs for how to test select createOptionUsing modal but i couldn't find any Forms\Components\Select::make('owner_id') ->relationship('owner', 'name') -...
gizmojo
gizmojoOP11mo ago
Cheers @Leandro Ferreira that's exactly what I needed. Any ideas how to test the replicate action was successfully called and redirects?
LeandroFerreira
LeandroFerreira11mo ago
Hum, possible but I need to try it
Want results from more Discord servers?
Add your server