feat: report reviews etc ...

This commit is contained in:
2026-05-23 12:15:11 +02:00
parent 49419c1e7b
commit 4af28f3828
15 changed files with 146 additions and 0 deletions
@@ -156,6 +156,41 @@ it('lists reviews for a single meal post', function () {
->assertJsonMissing(['id' => $otherReview->id]);
});
it('shows the authenticated users review for a meal post', function () {
$user = User::factory()->create();
$mealPost = MealPosts::factory()->create();
$review = PostReviews::query()->create([
'meal_post_id' => $mealPost->id,
'user_id' => $user->id,
'rating' => 4,
'comment' => 'Mon avis.',
]);
PostReviews::query()->create([
'meal_post_id' => $mealPost->id,
'user_id' => User::factory()->create()->id,
'rating' => 5,
'comment' => 'Un autre avis.',
]);
Sanctum::actingAs($user);
$this->getJson("/api/meal-posts/{$mealPost->id}/my-review")
->assertOk()
->assertJsonPath('data.id', $review->id)
->assertJsonPath('data.user_id', $user->id);
});
it('returns null when the authenticated user has not reviewed a meal post', function () {
$user = User::factory()->create();
$mealPost = MealPosts::factory()->create();
Sanctum::actingAs($user);
$this->getJson("/api/meal-posts/{$mealPost->id}/my-review")
->assertOk()
->assertJsonPath('data', null);
});
it('lets the review author update and delete their review', function () {
$user = User::factory()->create();
$review = PostReviews::query()->create([