feat: accept terms
CI / 🧪 Tests Laravel (push) Successful in 2m7s
CI / 🐳 Build & Push Image (push) Successful in 38s

This commit is contained in:
2026-08-07 16:10:25 +02:00
parent 68560655f3
commit 6b757c37be
5 changed files with 62 additions and 1 deletions
+30 -1
View File
@@ -27,6 +27,7 @@ it('sends a verification email when a user registers', function () {
'pacePreference' => PacePreference::NORMAL->value,
'sex' => UserSex::WOMAN->value,
'dateOfBirth' => '2003-04-24',
'termsAccepted' => true,
])
->assertCreated()
->assertJsonPath('user.email', 'leon@example.com')
@@ -45,7 +46,8 @@ it('sends a verification email when a user registers', function () {
expect($user->hasVerifiedEmail())->toBeFalse()
->and($user->trial_ends_at)->not->toBeNull()
->and($user->trial_ends_at->isFuture())->toBeTrue();
->and($user->trial_ends_at->isFuture())->toBeTrue()
->and($user->terms_accepted_at)->not->toBeNull();
$this->assertDatabaseHas('users', [
'id' => $user->id,
@@ -71,6 +73,7 @@ it('returns a temporary error when the verification email cannot be sent during
'email' => 'leon@example.com',
'password' => 'Motsdfdepasse123*',
'locale' => 'fr-FR',
'termsAccepted' => true,
])
->assertServiceUnavailable()
->assertJsonPath('message', __('api.auth.verification_email_failed'));
@@ -94,6 +97,7 @@ it('registers mobile users with a bearer token', function () {
'pacePreference' => PacePreference::NORMAL->value,
'sex' => UserSex::MAN->value,
'dateOfBirth' => '2003-04-24',
'termsAccepted' => true,
])
->assertCreated()
->assertJsonPath('user.email', 'mobile.leon@example.com')
@@ -111,6 +115,31 @@ it('registers mobile users with a bearer token', function () {
Notification::assertSentTo($user, VerifyEmail::class);
});
it('requires users to accept the terms during registration', function () {
Notification::fake();
$registrationData = [
'name' => 'TermsLeon',
'email' => 'terms.leon@example.com',
'password' => 'Motsdfdepasse123*',
'termsAccepted' => false,
];
$this->postJson('/api/auth/mobile/register', $registrationData)
->assertUnprocessable()
->assertJsonValidationErrors('termsAccepted');
unset($registrationData['termsAccepted']);
$this->postJson('/api/auth/mobile/register', $registrationData)
->assertUnprocessable()
->assertJsonValidationErrors('termsAccepted');
$this->assertDatabaseMissing('users', [
'email' => 'terms.leon@example.com',
]);
});
it('uses the custom account verification mailable', function () {
$user = User::factory()->unverified()->create([
'locale' => 'fr',