FilamentF
Filament13mo ago
sohail

`assertnotified` not working in table action

Hi i a writing a test for table actions and i do see the notification in browser but in test it failed and send notficiation was not send

Code
Action::make('toggle_admin_access')
            ->requiresConfirmation()
            ->form(ActionForms::confirmationForm())
            ->successNotificationTitle(fn(User $record) => $record->is_admin ? 'Admin Access Removed Successfully' : 'Admin Access Granted Successfully')
            ->action(function (User $record, Action $action) {
                $record->toggleAdminAccess();
                $action->sendSuccessNotification();
            });


Test
it('can grant admin access to user', function () {
    $user = User::factory()->create([
        'is_admin' => false,
    ]);
    signin('admin');

    livewire(Index::class)
        ->callTableAction('toggle_admin_access', $user, ['confirmations' => 'Confirm'])
        ->assertHasNoTableActionErrors()
        ->assertNotified('Admin Access Granted Successfully');

    expect($user->fresh())->is_admin->toBeTrue();
});


Error
A notification was not sent
Failed asserting that null is not null.
at vendor/filament/notifications/src/Notification.php:259
at vendor/filament/notifications/src/Testing/TestsNotifications.php:20
at vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:126
at vendor/livewire/livewire/src/Features/SupportTesting/Testable.php:293
Was this page helpful?