feat: locale
This commit is contained in:
@@ -22,6 +22,7 @@ it('sends a password reset email with a clickable api web url', function () {
|
||||
|
||||
$user = User::factory()->create([
|
||||
'email' => 'leon@example.com',
|
||||
'locale' => 'fr',
|
||||
]);
|
||||
|
||||
$this
|
||||
@@ -58,6 +59,38 @@ it('sends a password reset email with a clickable api web url', function () {
|
||||
);
|
||||
});
|
||||
|
||||
it('uses the user locale for password reset emails', function () {
|
||||
Notification::fake();
|
||||
|
||||
$user = User::factory()->create([
|
||||
'email' => 'leon@example.com',
|
||||
'locale' => 'en',
|
||||
]);
|
||||
|
||||
$this
|
||||
->postJson('/api/auth/forgot-password', [
|
||||
'email' => $user->email,
|
||||
])
|
||||
->assertOk();
|
||||
|
||||
Notification::assertSentTo(
|
||||
$user,
|
||||
ResetPassword::class,
|
||||
function (ResetPassword $notification) use ($user): bool {
|
||||
$mail = $notification->toMail($user);
|
||||
|
||||
expect($mail)->toBeInstanceOf(ResetPasswordMail::class);
|
||||
|
||||
$mail
|
||||
->assertSeeInHtml('Reset your password')
|
||||
->assertSeeInHtml('Choose a new password')
|
||||
->assertDontSeeInHtml('Réinitialise ton mot de passe');
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('does not reveal whether a reset email can be sent', function () {
|
||||
Notification::fake();
|
||||
|
||||
@@ -100,6 +133,7 @@ it('resets the password and invalidates existing api tokens', function () {
|
||||
it('shows the api password reset form from the email link', function () {
|
||||
$user = User::factory()->create([
|
||||
'email' => 'leon@example.com',
|
||||
'locale' => 'fr',
|
||||
]);
|
||||
$token = Password::broker()->createToken($user);
|
||||
|
||||
@@ -114,9 +148,29 @@ it('shows the api password reset form from the email link', function () {
|
||||
->assertSee($user->email);
|
||||
});
|
||||
|
||||
it('shows the api password reset form in the user locale', function () {
|
||||
$user = User::factory()->create([
|
||||
'email' => 'leon@example.com',
|
||||
'locale' => 'en',
|
||||
]);
|
||||
$token = Password::broker()->createToken($user);
|
||||
|
||||
$this
|
||||
->get(route('password.reset', [
|
||||
'email' => $user->email,
|
||||
'token' => $token,
|
||||
], absolute: false))
|
||||
->assertOk()
|
||||
->assertViewIs('auth.reset-password')
|
||||
->assertSee('New password')
|
||||
->assertSee('Update password')
|
||||
->assertDontSee('Nouveau mot de passe');
|
||||
});
|
||||
|
||||
it('resets the password from the api web form', function () {
|
||||
$user = User::factory()->create([
|
||||
'email' => 'leon@example.com',
|
||||
'locale' => 'fr',
|
||||
'password' => 'old-password',
|
||||
]);
|
||||
$token = Password::broker()->createToken($user);
|
||||
|
||||
Reference in New Issue
Block a user