Password reset request notification test failing

I'm writing a test for the password reset to check if a password reset link can be requested but it's failing. I'm faking notifications and I'm pretty sure I have the correct component and notification but I'm not sure why it's saying the notification hasn't been sent. User implements CanResetPasswords and FilamentUser, and has the Notifiable trait
<?php

namespace Tests\Feature\Nexus\Auth;

use App\Models\User;
use Filament\Notifications\Auth\ResetPassword as ResetPasswordNotification;
use Filament\Pages\Auth\PasswordReset\RequestPasswordReset;
use Illuminate\Support\Facades\Notification;

use function Pest\Livewire\livewire;

test('a nexus password reset link can be requested', function () {
Notification::fake();

$user = User::factory()->create();

$component = livewire(RequestPasswordReset::class)
->fillForm([
'email' => $user->email,
])
->call('request');

$component->assertHasNoErrors();

Notification::assertSentTo($user, ResetPasswordNotification::class);
});
<?php

namespace Tests\Feature\Nexus\Auth;

use App\Models\User;
use Filament\Notifications\Auth\ResetPassword as ResetPasswordNotification;
use Filament\Pages\Auth\PasswordReset\RequestPasswordReset;
use Illuminate\Support\Facades\Notification;

use function Pest\Livewire\livewire;

test('a nexus password reset link can be requested', function () {
Notification::fake();

$user = User::factory()->create();

$component = livewire(RequestPasswordReset::class)
->fillForm([
'email' => $user->email,
])
->call('request');

$component->assertHasNoErrors();

Notification::assertSentTo($user, ResetPasswordNotification::class);
});
No description
1 Reply
Aethyrion
AethyrionOP3d ago
Sorted it. I have a two types of users: customers and users (for Filament). I just needed to set $panel->authPasswordBroker('users') in my admin panel provider. As I have the default password broker to "customers" it wasn't finding the user based off the credentials provided

Did you find this page helpful?