diff --git a/Makefile b/Makefile index 53bc797..0f2b527 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/features/products.feature b/features/products.feature index 2aac404..d01dd6d 100644 --- a/features/products.feature +++ b/features/products.feature @@ -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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/features/steps/web_steps.py b/features/steps/web_steps.py index 9c5dad8..6aa2e69 100644 --- a/features/steps/web_steps.py +++ b/features/steps/web_steps.py @@ -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() diff --git a/service/routes.py b/service/routes.py index b5c354b..e9b6004 100644 --- a/service/routes.py +++ b/service/routes.py @@ -234,7 +234,6 @@ def change_product_availability(product_id): return jsonify(message), status.HTTP_200_OK - ###################################################################### # get product categories ###################################################################### diff --git a/service/static/index.html b/service/static/index.html index bdbaaa7..7362e08 100644 --- a/service/static/index.html +++ b/service/static/index.html @@ -103,7 +103,7 @@

Create, Retrieve, Update, and Delete a Product:

- + diff --git a/service/static/js/rest_api.js b/service/static/js/rest_api.js index 9453add..d4d9f7a 100644 --- a/service/static/js/rest_api.js +++ b/service/static/js/rest_api.js @@ -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();