Skip to content

Commit

Permalink
add scenario for Action
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzSteven-Wang committed Dec 1, 2023
1 parent 2026b21 commit d7015d3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ lint: ## Run the linter
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
pylint service tests --max-line-length=127

.PHONY: tests
.PHONY: test
test: ## Run the unit tests
$(info Running tests...)
green -vvv --processes=1 --run-coverage --termcolor --minimum-coverage=95
Expand Down
24 changes: 23 additions & 1 deletion features/products.feature
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,26 @@ Scenario: Query a Product by Available
And I select "False" in the "Available" dropdown
And I press the "Search" button
Then I should see the message "Success"
And I should see "iPhone 16" in the results
And I should see "iPhone 16" in the results

Scenario: Action Change the Availability of a Product
When I visit the "Home Page"
And I press the "Search" button
Then I should see the message "Success"
When I copy the "Id" field
And I press the "Clear" button
Then the "Id" field should be empty
And the "Name" field should be empty
And the "Category" field should be empty
And the "Description" field should be empty
And the "Price" field should be empty
And the "image_url" field should be empty
When I paste the "Id" field
And I press the "Change Availability" button
Then I should see the message "Product availability changed to False"
And I should see "iPhone 15" in the "name" field
And I should see "Best iphone for now" in the "description" field
And I should see "999" in the "price" field
And I should see "False" in the "available" dropdown
And I should see "sample.url" in the "image_url" field
And I should see "ELECTRONICS" in the "category" field
2 changes: 1 addition & 1 deletion features/steps/web_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def step_impl(context, element_name):

@when('I press the "{button}" button')
def step_impl(context, button):
button_id = button.lower() + "-btn"
button_id = button.lower().replace(" ", "_") + "-btn"
context.driver.find_element(By.ID, button_id).click()


Expand Down
1 change: 0 additions & 1 deletion service/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def change_product_availability(product_id):
return jsonify(message), status.HTTP_200_OK



######################################################################
# get product categories
######################################################################
Expand Down
2 changes: 1 addition & 1 deletion service/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ <h3>Create, Retrieve, Update, and Delete a Product:</h3>
<button type="submit" class="btn btn-primary" id="clear-btn">Clear</button>
<button type="submit" class="btn btn-success" id="create-btn">Create</button>
<button type="submit" class="btn btn-warning" id="update-btn">Update</button>
<button type="submit" class="btn btn-warning" id="availability-btn">Change Availability</button>
<button type="submit" class="btn btn-warning" id="change_availability-btn">Change Availability</button>
</div>
</div>
</div> <!-- form horizontal -->
Expand Down
2 changes: 1 addition & 1 deletion service/static/js/rest_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ $(function () {
// Change Availability
// ****************************************

$("#availability-btn").click(function () {
$("#change_availability-btn").click(function () {
let product_id = $("#product_id").val();

$("#flash_message").empty();
Expand Down

0 comments on commit d7015d3

Please sign in to comment.