© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
KarlBoosterBär

Test Form Component Action

I have a Custom Page which includes a header Action. The Action is a slide over, which shows a form to create a model. I want to test if the action executes as expected an create the record, as well as if the fields that are conditionally disabled are really disabled when they should be. My test looks like this :
it('can create tariff', function() {
    $tariff = Tariff::factory()->make();
    livewire(ListLocationTariffs::class, ['record' => $this->location->uuid])
        ->callAction('createTariff')
        ->setActionData($tariff->toArray())
        ->assertFormExists()
//        ->assertFormFieldExists('mountedActionsData.0.name')
        ->callMountedAction();

    $this->assertDatabaseHas('tariffs', [... $tariff->toArray(), 'location_id' => $this->location->id]);
});
it('can create tariff', function() {
    $tariff = Tariff::factory()->make();
    livewire(ListLocationTariffs::class, ['record' => $this->location->uuid])
        ->callAction('createTariff')
        ->setActionData($tariff->toArray())
        ->assertFormExists()
//        ->assertFormFieldExists('mountedActionsData.0.name')
        ->callMountedAction();

    $this->assertDatabaseHas('tariffs', [... $tariff->toArray(), 'location_id' => $this->location->id]);
});

and passes when executed.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Test form component's action
FilamentFFilament / ❓┊help
3y ago
Test create action form field
FilamentFFilament / ❓┊help
2y ago
action with form with livewire component inside
FilamentFFilament / ❓┊help
15mo ago
Form\Actions\Action call javascript?
FilamentFFilament / ❓┊help
3y ago