🎮Days🕹
🎮Days🕹
FFilament
Created by 🎮Days🕹 on 4/12/2024 in #❓┊help
Testing action error
Hello and thanks for anyone that helps me. So I have a list page were i have a custom action
Action::make('import-historical-orders')
->label('Import Historical Orders')
->before(function (Action $action) {
if (Gate::denies('import-historical-orders')) {
$action->failure();
$action->halt();
}
})
->action(fn () => ImportUserHistoricalOrders::dispatch(auth()->user()))
->successNotification($this->importHistoricalOrdersSuccessNotification())
->failureNotification($this->importHistoricalOrdersFailureNotification());
Action::make('import-historical-orders')
->label('Import Historical Orders')
->before(function (Action $action) {
if (Gate::denies('import-historical-orders')) {
$action->failure();
$action->halt();
}
})
->action(fn () => ImportUserHistoricalOrders::dispatch(auth()->user()))
->successNotification($this->importHistoricalOrdersSuccessNotification())
->failureNotification($this->importHistoricalOrdersFailureNotification());
When testing this action i'm getting the error
Failed asserting that an event [open-modal] was fired with parameters: {"id":"oUPpTeYPcvmKfIXk0WEo-action"}
Failed asserting that an event [open-modal] was fired with parameters: {"id":"oUPpTeYPcvmKfIXk0WEo-action"}
The test is the following one
livewire(ListHistoricalOrders::class)
->callAction('import-historical-orders')
->assertActionHalted('import-historical-orders')
livewire(ListHistoricalOrders::class)
->callAction('import-historical-orders')
->assertActionHalted('import-historical-orders')
If i remove the Action $action parameter from the closure on the before method from the action the error doesn't appear anymore. So how can i test an action that have a closure with the action itself?
7 replies