test('password can be reset with valid token', function () {
Notification::fake();
$user = User::factory()->create();
$user->save();
$response = $this
->get(route('filament.app.auth.password-reset.request'));
$response->assertStatus(200);
// Assert we see the email field
$response->assertSee([
'input',
'id="data.email"'
], false);
Livewire::test(RequestPasswordReset::class)
->set('data.email', $user->email)
->call('request')
->assertHasNoErrors();
Notification::assertSentTo($user, ResetPasswordNotification::class, function ($notification) use ($user) {
// Now that we've requested a password reset, we can test the reset password screen with the token received
$this->assertNotNull($notification->token);
$this->get($notification->url)
->assertStatus(200);
$newPassword = 'new-password-x';
Livewire::test(ResetPassword::class)
->set('password', $newPassword)
->set('passwordConfirmation', $newPassword)
->call('resetPassword')
->assertHasNoErrors();
$hashResult = Hash::check($newPassword, $user->refresh()->password);
// Assert that the password has been updated
$this->assertTrue($hashResult);
return true;
});
});