KarlBoosterBär
KarlBoosterBär
FFilament
Created by KarlBoosterBär on 9/17/2024 in #❓┊help
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.
5 replies