feat: locale
This commit is contained in:
@@ -21,6 +21,7 @@ it('sends a verification email when a user registers', function () {
|
||||
'name' => 'Leon',
|
||||
'email' => 'leon@example.com',
|
||||
'password' => 'password',
|
||||
'locale' => 'fr-FR',
|
||||
'physicalActivityLevel' => PhysicalActivityLevel::LIGHTLY_ACTIVE->value,
|
||||
'weightGoal' => WeightGoal::MAINTAIN_WEIGHT->value,
|
||||
'pacePreference' => PacePreference::NORMAL->value,
|
||||
@@ -29,6 +30,7 @@ it('sends a verification email when a user registers', function () {
|
||||
])
|
||||
->assertCreated()
|
||||
->assertJsonPath('user.email', 'leon@example.com')
|
||||
->assertJsonPath('user.locale', 'fr')
|
||||
->assertJsonPath('user.emailVerified', false)
|
||||
->assertJsonPath('user.physicalActivityLevel', PhysicalActivityLevel::LIGHTLY_ACTIVE->value)
|
||||
->assertJsonPath('user.weightGoal', WeightGoal::MAINTAIN_WEIGHT->value)
|
||||
@@ -42,6 +44,7 @@ it('sends a verification email when a user registers', function () {
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'id' => $user->id,
|
||||
'locale' => 'fr',
|
||||
'physical_activity_level' => PhysicalActivityLevel::LIGHTLY_ACTIVE->value,
|
||||
'weight_goal' => WeightGoal::MAINTAIN_WEIGHT->value,
|
||||
'pace_preference' => PacePreference::NORMAL->value,
|
||||
@@ -54,7 +57,9 @@ it('sends a verification email when a user registers', function () {
|
||||
});
|
||||
|
||||
it('uses the custom account verification mailable', function () {
|
||||
$user = User::factory()->unverified()->create();
|
||||
$user = User::factory()->unverified()->create([
|
||||
'locale' => 'fr',
|
||||
]);
|
||||
|
||||
$mailable = (new VerifyEmail)->toMail($user);
|
||||
|
||||
@@ -65,6 +70,21 @@ it('uses the custom account verification mailable', function () {
|
||||
->assertSeeInHtml($user->name);
|
||||
});
|
||||
|
||||
it('uses the user locale for account verification emails', function () {
|
||||
$user = User::factory()->unverified()->create([
|
||||
'locale' => 'en',
|
||||
]);
|
||||
|
||||
$mailable = (new VerifyEmail)->toMail($user);
|
||||
|
||||
expect($mailable)->toBeInstanceOf(VerifyAccount::class);
|
||||
|
||||
$mailable
|
||||
->assertSeeInHtml('Verify my account')
|
||||
->assertSeeInHtml('Confirm your email address')
|
||||
->assertDontSeeInHtml('Vérifier mon compte');
|
||||
});
|
||||
|
||||
it('generates verification links with a relative signature', function () {
|
||||
$user = User::factory()->unverified()->create();
|
||||
|
||||
@@ -132,17 +152,22 @@ it('blocks login for unverified users', function () {
|
||||
|
||||
it('allows login for verified users', function () {
|
||||
$user = User::factory()->create([
|
||||
'locale' => 'en',
|
||||
'password' => 'password',
|
||||
]);
|
||||
|
||||
$this->postJson('/api/auth/login', [
|
||||
'email' => $user->email,
|
||||
'locale' => 'fr-FR',
|
||||
'password' => 'password',
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('user.email', $user->email)
|
||||
->assertJsonPath('user.locale', 'fr')
|
||||
->assertJsonPath('user.emailVerified', true)
|
||||
->assertCookie('token');
|
||||
|
||||
expect($user->fresh()->locale)->toBe('fr');
|
||||
});
|
||||
|
||||
it('resends a verification email for an unverified user without authentication', function () {
|
||||
|
||||
Reference in New Issue
Block a user