feat: translation codes
This commit is contained in:
@@ -62,7 +62,7 @@ it('deletes the authenticated account and related data', function () {
|
||||
|
||||
$this->deleteJson('/api/auth/me')
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.auth.deleted'));
|
||||
->assertJsonPath('code', 'ACCOUNT_DELETED');
|
||||
|
||||
$this->assertDatabaseMissing('users', ['id' => $user->getKey()]);
|
||||
$this->assertDatabaseMissing('meal_posts', ['id' => $localMealPost->getKey()]);
|
||||
|
||||
@@ -70,7 +70,7 @@ it('prevents replacing a document while it is under review', function () {
|
||||
'document' => UploadedFile::fake()->image('identity.jpg'),
|
||||
])
|
||||
->assertConflict()
|
||||
->assertJsonPath('message', __('api.certification.already_pending'));
|
||||
->assertJsonPath('code', 'CERTIFICATION_ALREADY_PENDING');
|
||||
});
|
||||
|
||||
it('approves a certification and removes the reviewed identity document', function () {
|
||||
|
||||
@@ -131,7 +131,7 @@ it('fails closed when production moderation cannot be reached', function () {
|
||||
'comment' => 'Très bon repas.',
|
||||
])
|
||||
->assertServiceUnavailable()
|
||||
->assertJsonPath('message', __('api.moderation.unavailable'));
|
||||
->assertJsonPath('code', 'CONTENT_MODERATION_UNAVAILABLE');
|
||||
|
||||
$this->assertDatabaseCount('post_reviews', 0);
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ it('records a failed meal image analysis attempt', function () {
|
||||
'image' => fakeMealAnalysisImage(),
|
||||
])
|
||||
->assertStatus(502)
|
||||
->assertJsonPath('message', __('api.meal_image_analysis.failed'));
|
||||
->assertJsonPath('code', 'MEAL_ANALYSIS_FAILED');
|
||||
|
||||
Exceptions::assertReported(\RuntimeException::class);
|
||||
|
||||
@@ -172,7 +172,7 @@ it('requires an active subscription to analyze a meal image', function () {
|
||||
'image' => fakeMealAnalysisImage(),
|
||||
])
|
||||
->assertStatus(402)
|
||||
->assertJsonPath('message', __('api.meal_image_analysis.subscription_required'));
|
||||
->assertJsonPath('code', 'MEAL_ANALYSIS_SUBSCRIPTION_REQUIRED');
|
||||
|
||||
expect(AiUsage::query()->count())->toBe(0);
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ it('creates a report and a moderation case for a meal post', function () {
|
||||
'details' => 'Même image publiée en boucle.',
|
||||
])
|
||||
->assertCreated()
|
||||
->assertJsonPath('message', __('api.reports.created'))
|
||||
->assertJsonPath('code', 'REPORT_CREATED')
|
||||
->assertJsonPath('data.reason', ReportReason::SPAM->value)
|
||||
->assertJsonPath('data.reportableType', 'meal_post')
|
||||
->assertJsonPath('data.reportableId', $mealPost->id);
|
||||
@@ -58,7 +58,7 @@ it('prevents duplicate reports and reports on own content', function () {
|
||||
|
||||
$this->postJson("/api/meal-posts/{$mealPost->id}/reports", $payload)
|
||||
->assertConflict()
|
||||
->assertJsonPath('message', __('api.reports.already_exists'));
|
||||
->assertJsonPath('code', 'REPORT_ALREADY_EXISTS');
|
||||
|
||||
expect(Report::query()->count())->toBe(1);
|
||||
|
||||
@@ -66,7 +66,7 @@ it('prevents duplicate reports and reports on own content', function () {
|
||||
|
||||
$this->postJson("/api/meal-posts/{$mealPost->id}/reports", $payload)
|
||||
->assertUnprocessable()
|
||||
->assertJsonPath('message', __('api.reports.cannot_report_own_meal'));
|
||||
->assertJsonPath('code', 'CANNOT_REPORT_OWN_MEAL');
|
||||
});
|
||||
|
||||
it('reports users and prevents reporting own profile', function () {
|
||||
@@ -94,7 +94,7 @@ it('reports users and prevents reporting own profile', function () {
|
||||
'reason' => ReportReason::OTHER->value,
|
||||
])
|
||||
->assertUnprocessable()
|
||||
->assertJsonPath('message', __('api.reports.cannot_report_self'));
|
||||
->assertJsonPath('code', 'CANNOT_REPORT_SELF');
|
||||
});
|
||||
|
||||
it('reports post reviews and prevents reporting own review', function () {
|
||||
@@ -128,7 +128,7 @@ it('reports post reviews and prevents reporting own review', function () {
|
||||
'reason' => ReportReason::OTHER->value,
|
||||
])
|
||||
->assertUnprocessable()
|
||||
->assertJsonPath('message', __('api.reports.cannot_report_own_review'));
|
||||
->assertJsonPath('code', 'CANNOT_REPORT_OWN_REVIEW');
|
||||
});
|
||||
|
||||
it('notifies moderators once when a report threshold is reached', function () {
|
||||
|
||||
@@ -30,7 +30,7 @@ it('sends a password reset email with a clickable api web url', function () {
|
||||
'email' => 'LEON@example.com',
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.auth.password_reset_link_sent'));
|
||||
->assertJsonPath('code', 'PASSWORD_RESET_LINK_SENT');
|
||||
|
||||
Notification::assertSentTo(
|
||||
$user,
|
||||
@@ -99,7 +99,7 @@ it('does not reveal whether a reset email can be sent', function () {
|
||||
'email' => 'missing@example.com',
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.auth.password_reset_link_sent'));
|
||||
->assertJsonPath('code', 'PASSWORD_RESET_LINK_SENT');
|
||||
|
||||
Notification::assertNothingSent();
|
||||
});
|
||||
@@ -121,7 +121,7 @@ it('resets the password and invalidates existing api tokens', function () {
|
||||
'token' => $token,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.auth.password_reset'));
|
||||
->assertJsonPath('code', 'PASSWORD_RESET');
|
||||
|
||||
expect(Hash::check('new-password', $user->fresh()->password))->toBeTrue();
|
||||
|
||||
@@ -208,7 +208,7 @@ it('rejects an invalid password reset token', function () {
|
||||
'token' => 'invalid-token',
|
||||
])
|
||||
->assertUnprocessable()
|
||||
->assertJsonPath('message', __('passwords.token'));
|
||||
->assertJsonPath('code', 'PASSWORD_RESET_FAILED');
|
||||
|
||||
expect(Hash::check('new-password', $user->fresh()->password))->toBeFalse();
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ it('creates one review per user for a meal post', function () {
|
||||
'rating' => 4,
|
||||
])
|
||||
->assertConflict()
|
||||
->assertJsonPath('message', __('api.post_reviews.already_exists'));
|
||||
->assertJsonPath('code', 'MEAL_REVIEW_ALREADY_EXISTS');
|
||||
|
||||
expect(PostReviews::query()->count())->toBe(1);
|
||||
});
|
||||
|
||||
@@ -174,7 +174,7 @@ it('keeps the local strava connection when strava revocation fails temporarily',
|
||||
$this
|
||||
->deleteJson('/api/strava/connection')
|
||||
->assertStatus(502)
|
||||
->assertJsonPath('message', __('api.strava.disconnect_failed'));
|
||||
->assertJsonPath('code', 'STRAVA_DISCONNECT_FAILED');
|
||||
|
||||
expect($user->fresh()->stravaConnection)->not->toBeNull();
|
||||
});
|
||||
@@ -295,5 +295,5 @@ it('requires an activity read scope before syncing strava activities', function
|
||||
$this
|
||||
->postJson('/api/strava/sync')
|
||||
->assertUnprocessable()
|
||||
->assertJsonPath('message', __('api.strava.missing_activity_scope'));
|
||||
->assertJsonPath('code', 'STRAVA_ACTIVITY_SCOPE_MISSING');
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ it('updates the authenticated user password and keeps the current api token', fu
|
||||
'passwordConfirmation' => 'NewPassword123!',
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.auth.password_updated'));
|
||||
->assertJsonPath('code', 'PASSWORD_UPDATED');
|
||||
|
||||
expect(Hash::check('NewPassword123!', $user->fresh()->password))->toBeTrue();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ it('blocks a user idempotently, removes follows, lists the block, and unblocks',
|
||||
|
||||
$this->postJson("/api/users/{$blocked->id}/block")
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.blocks.blocked'));
|
||||
->assertJsonPath('code', 'USER_BLOCKED');
|
||||
|
||||
$this->postJson("/api/users/{$blocked->id}/block")->assertOk();
|
||||
|
||||
@@ -46,7 +46,7 @@ it('does not allow a user to block themselves', function () {
|
||||
|
||||
$this->postJson("/api/users/{$user->id}/block")
|
||||
->assertUnprocessable()
|
||||
->assertJsonPath('message', __('api.blocks.cannot_block_self'));
|
||||
->assertJsonPath('code', 'CANNOT_BLOCK_SELF');
|
||||
});
|
||||
|
||||
it('requires authentication to manage blocks', function () {
|
||||
|
||||
Reference in New Issue
Block a user