forked from pierront/mylibrary-template
		
	
		
			
	
	
		
			74 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Gherkin
		
	
	
	
	
	
		
		
			
		
	
	
			74 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Gherkin
		
	
	
	
	
	
| 
								 | 
							
								# language: en
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Feature: Manage reviews
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  Background:
							 | 
						||
| 
								 | 
							
								    Given the system has the following customers:
							 | 
						||
| 
								 | 
							
								      | id                                   | firstName | lastName | phoneNumber | loyaltyPoints |
							 | 
						||
| 
								 | 
							
								      | 33333333-3333-3333-3333-333333333333 | Carol     | White    | 0600000003  | 50            |
							 | 
						||
| 
								 | 
							
								    And the system has the following books:
							 | 
						||
| 
								 | 
							
								      | isbn      | title         | author      | publisher | publicationDate | price | quantity | language |
							 | 
						||
| 
								 | 
							
								      | 978333333 | Book B        | Author B    | PubB      | 2020-01-01      | 18.0  | 5        | EN       |
							 | 
						||
| 
								 | 
							
								    And the 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   | 978333333 | 4      | Enjoyed a lot! |
							 | 
						||
| 
								 | 
							
								    Then the review is created successfully
							 | 
						||
| 
								 | 
							
								    And the 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 submission fails
							 | 
						||
| 
								 | 
							
								    And I receive an error message containing "customer hasn't purchased the book"
							 | 
						||
| 
								 | 
							
								    And the 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 submission fails
							 | 
						||
| 
								 | 
							
								    And I receive an error message containing "Invalid review details"
							 | 
						||
| 
								 | 
							
								    And the 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 submission fails
							 | 
						||
| 
								 | 
							
								    And I receive an error message containing "Book or customer not found"
							 | 
						||
| 
								 | 
							
								    And the 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 submission fails
							 | 
						||
| 
								 | 
							
								    And I receive an error message containing "Review already exists"
							 | 
						||
| 
								 | 
							
								    And the 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 request fails
							 | 
						||
| 
								 | 
							
								    And I receive an 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 request fails
							 | 
						||
| 
								 | 
							
								    And I receive an 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 deletion fails
							 | 
						||
| 
								 | 
							
								    And I receive an error message containing "Review not found"
							 |