Files
mylibrary/src/test/resources/features/review.feature
2025-06-13 23:44:08 +02:00

76 lines
4.0 KiB
Gherkin

# language: en
Feature: Manage reviews
Background:
Given the review system has the following review customers:
| id | firstName | lastName | phoneNumber | loyaltyPoints |
| 33333333-3333-3333-3333-333333333333 | Carol | White | 0600000003 | 50 |
And the review system has the following review books:
| isbn | title | author | publisher | publicationDate | price | quantity | language |
| 978333333 | Book B | Author B | PubB | 2020-01-01 | 18.0 | 5 | EN |
| 978444444 | Book C | Author C | PubC | 2021-06-15 | 22.0 | 3 | FR |
And the review system has the following reviews:
| reviewId | bookId | customerName | comment | rating |
| rev-1 | 978333333 | Carol White | Great book! | 5 |
Scenario: Submit a new review
When I submit a new review with the following information:
| customerId | isbn | rating | comment |
| 33333333-3333-3333-3333-333333333333 | 978444444 | 4 | Enjoyed a lot! |
Then the review is created successfully
And the review system now has 2 reviews
Scenario: Get reviews by customer
When I request all reviews by customer "33333333-3333-3333-3333-333333333333"
Then I receive the following reviews:
| reviewId | bookId | customerName | comment | rating |
| rev-1 | 978333333 | Carol White | Great book! | 5 |
Scenario: Attempt to submit a review for a book not purchased
When I try to submit a new review with the following information:
| customerId | isbn | rating | comment |
| 33333333-3333-3333-3333-333333333333 | 978333333 | 5 | Not purchased |
Then the review submission fails
And I receive a review error message containing "customer hasn't purchased the book"
And the review system still has 1 review
Scenario: Attempt to submit a review with invalid details
When I try to submit a new review with the following information:
| customerId | isbn | rating | comment |
| | | | |
Then the review submission fails
And I receive a review error message containing "Invalid review details"
And the review system still has 1 review
Scenario: Attempt to submit a review for unknown book or customer
When I try to submit a new review with the following information:
| customerId | isbn | rating | comment |
| 99999999-9999-9999-9999-999999999999 | 999999999 | 5 | Unknown book |
Then the review submission fails
And I receive a review error message containing "Book or customer not found"
And the review system still has 1 review
Scenario: Attempt to submit a duplicate review
When I try to submit a new review with the following information:
| customerId | isbn | rating | comment |
| 33333333-3333-3333-3333-333333333333 | 978333333 | 5 | Another review |
Then the review submission fails
And I receive a review error message containing "Review already exists"
And the review system still has 1 review
Scenario: Attempt to get reviews by unknown customer
When I request all reviews by customer "99999999-9999-9999-9999-999999999999"
Then the review request fails
And I receive a review error message containing "Book or customer not found"
Scenario: Attempt to get reviews by unknown book
When I request all reviews for book "999999999"
Then the review request fails
And I receive a review error message containing "Book or customer not found"
Scenario: Attempt to delete a review with unknown ID
When I try to delete the review with id "unknown-review-id"
Then the review deletion fails
And I receive a review error message containing "Review not found"