feat: report reviews etc ...
This commit is contained in:
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user