feat(KAN-22): rebuild password confirmation flows
This commit is contained in:
@@ -11,7 +11,7 @@ class PasswordConfirmationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_confirm_password_screen_can_be_rendered()
|
||||
public function test_confirm_password_screen_can_be_rendered(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
@@ -24,10 +24,32 @@ class PasswordConfirmationTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_password_confirmation_requires_authentication()
|
||||
public function test_password_confirmation_requires_authentication(): void
|
||||
{
|
||||
$response = $this->get(route('password.confirm'));
|
||||
|
||||
$response->assertRedirect(route('login'));
|
||||
}
|
||||
|
||||
public function test_password_can_be_confirmed(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post(route('password.confirm'), ['password' => 'password'])
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertNotNull(session('auth.password_confirmed_at'));
|
||||
}
|
||||
|
||||
public function test_password_confirmation_rejects_an_invalid_password(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post(route('password.confirm'), ['password' => 'incorrect'])
|
||||
->assertSessionHasErrors('password');
|
||||
|
||||
$this->assertNull(session('auth.password_confirmed_at'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\User;
|
||||
use Illuminate\Auth\Notifications\ResetPassword;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Laravel\Fortify\Features;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -20,11 +21,16 @@ class PasswordResetTest extends TestCase
|
||||
$this->skipUnlessFortifyFeature(Features::resetPasswords());
|
||||
}
|
||||
|
||||
public function test_reset_password_link_screen_can_be_rendered()
|
||||
public function test_reset_password_link_screen_can_be_rendered(): void
|
||||
{
|
||||
$response = $this->get(route('password.request'));
|
||||
|
||||
$response->assertOk();
|
||||
$response
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('auth/ForgotPassword')
|
||||
->where('status', null),
|
||||
);
|
||||
}
|
||||
|
||||
public function test_reset_password_link_can_be_requested()
|
||||
@@ -38,7 +44,7 @@ class PasswordResetTest extends TestCase
|
||||
Notification::assertSentTo($user, ResetPassword::class);
|
||||
}
|
||||
|
||||
public function test_reset_password_screen_can_be_rendered()
|
||||
public function test_reset_password_screen_can_be_rendered(): void
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
@@ -46,10 +52,19 @@ class PasswordResetTest extends TestCase
|
||||
|
||||
$this->post(route('password.email'), ['email' => $user->email]);
|
||||
|
||||
Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
|
||||
$response = $this->get(route('password.reset', $notification->token));
|
||||
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
|
||||
$response = $this->get(route('password.reset', [
|
||||
'token' => $notification->token,
|
||||
'email' => $user->email,
|
||||
]));
|
||||
|
||||
$response->assertOk();
|
||||
$response
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('auth/ResetPassword')
|
||||
->where('email', $user->email)
|
||||
->where('token', $notification->token),
|
||||
);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user