FilamentF
Filament3y ago
Hugo

[Testing] How to mount a table header action and make sure that the event was dispatched?

Im testing my application and currently testing a relation manager, but I'm having problems testing a table header action that creates a new record for that relation manager. It says that the event wasn't fired.
it('shows the create form for a new contract', function(): void {
    $client = Client::query()->first();

    livewire(ContractsRelationManager::class, [
        'ownerRecord' => $client,
        'pageClass' => EditClient::class,
    ])->assertSuccessful()
    ->assertTableHeaderActionsExistInOrder(['create'])
    ->mountAction('create')
    ->assertDispatched('open-modal');
});


until the mountAction('create') the test run's fine but it then says it failed to assert that the event 'open-modal' was fired. Is there a way to test table header actions?
Was this page helpful?