Skip to content

Commit

Permalink
Merge pull request #125 from NYU-DevOps-Spring2018-Orders/clickable
Browse files Browse the repository at this point in the history
Clickable
  • Loading branch information
andyd0 authored May 2, 2018
2 parents f3ed88b + 648e3a7 commit 6218406
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 30 deletions.
32 changes: 11 additions & 21 deletions features/orders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -77,67 +77,57 @@ Scenario: Delete an order
When I visit the "Home Page"
And I set the "order_customer_id" to "11"
And I press the "search" order Button
And I press the "retrieve" item button
And I press the "delete" order button
Then I should see the message "Order has been Deleted!"

Scenario: Update an item
When I visit the "Home Page"
And I set the "item_name" to "laptop"
And I press the "search" item button
And I press the "Retrieve" item button
And I press the "retrieve" item button
Then I should see "1" in the "item_quantity" field
When I change "item_quantity" to "3"
And I press the "Update" item button
And I press the "update" item button
Then I should see the message "Success"
When I press the "Clear" item button
And I set the "item_name" to "laptop"
And I press the "search" item button
And I press the "Retrieve" item button
Then I should see "3" in the "item_quantity" field

Scenario: Update an order
When I visit the "Home Page"
And I set the "order_customer_id" to "11"
And I press the "search" order Button
And I press the "Retrieve" order button
Then I should see "processing" in the "order_status" field
When I change "order_status" to "shipped"
And I press the "Update" order button
When I change "order_customer_id" to "12"
And I press the "update" order button
Then I should see the message "Success"
When I press the "Clear" order button
And I set the "order_customer_id" to "11"
And I press the "search" order Button
And I press the "Retrieve" order button
Then I should see "shipped" in the "order_status" field

Scenario: Create a order
When I visit the "Home Page"
And I set the "item_product_id" to "214"
And I set the "item_name" to "banana"
And I set the "item_quantity" to "10"
And I set the "item_price" to "20.34"
When I press the "Create" item button
When I press the "create" item button
And I set the "item_product_id" to "78"
And I set the "item_name" to "laptop"
And I set the "item_quantity" to "1"
And I set the "item_price" to "642.34"
When I press the "Create" item button
When I press the "create" item button
And I set the "item_product_id" to "28"
And I set the "item_name" to "apple"
And I set the "item_quantity" to "100"
And I set the "item_price" to "60.24"
When I press the "Create" item button
When I press the "create" item button
And I set the "order_customer_id" to "123"
And I set the time "order_date" to "2018-02-27T19:35"
And I set the "order_status" to "processing"
When I press the "Create" order button
When I press the "create" order button
Then I should see the message "Success"
And I should not see "404 Not Found"

Scenario: Cancel a order
When I visit the "Home Page"
And I set the "order_customer_id" to "11"
And I press the "search" order Button
And I press the "Cancel" order button
And I press the "retrieve" order button
And I press the "cancel" order button
Then I should see "cancelled" in the "order_status" field
And I should see the message "Order has been Canceled!"
44 changes: 35 additions & 9 deletions features/steps/order_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from app import server
import time

WAIT_SECONDS = 30
WAIT_SECONDS = 120
BASE_URL = getenv('BASE_URL', 'http://localhost:5000/')

@given(u'the following orders')
Expand Down Expand Up @@ -78,11 +79,23 @@ def step_impl(context, element_name, text_string):
# id='clear-btn'. That allows us to lowercase the name and add '-btn'
# to get the element id of any button
##################################################################

@when(u'I press the "{button}" order button')
def step_impl(context, button):
button_id = button.lower() + '-btn'
context.driver.find_element_by_id(button_id).click()
button_id = button.lower() + '-btn'

if button == "retrieve":
time.sleep(5)
element = context.driver.find_element_by_id('order_id').text

found = WebDriverWait(context.driver, WAIT_SECONDS).until(
expected_conditions.text_to_be_present_in_element(
(By.ID, 'order_id'), element
)
)
expect(found).to_be(True)
context.driver.find_element_by_id(button_id).click()
else:
context.driver.find_element_by_id(button_id).click()

@then(u'I should see "{name}" in the order results')
def step_impl(context, name):
Expand All @@ -98,9 +111,9 @@ def step_impl(context, name):

@then(u'I should not see "{name}" in the order results')
def step_impl(context, name):
element = context.driver.find_element_by_id('order_results')
error_msg = "I should not see '%s' in '%s'" % (name, element.text)
ensure(name in element.text, False, error_msg)
element = context.driver.find_element_by_id('order_results')
error_msg = "I should not see '%s' in '%s'" % (name, element.text)
ensure(name in element.text, False, error_msg)

@then(u'I should see the message "{message}"')
def step_impl(context, message):
Expand All @@ -116,8 +129,21 @@ def step_impl(context, message):

@when(u'I press the "{button}" item button')
def step_impl(context, button):
button_id = button.lower() + '-btn-item'
context.driver.find_element_by_id(button_id).click()
button_id = button.lower() + '-btn-item'

if button == "retrieve":
time.sleep(5)
element = context.driver.find_element_by_id('item_id').text

found = WebDriverWait(context.driver, WAIT_SECONDS).until(
expected_conditions.text_to_be_present_in_element(
(By.ID, 'item_id'), element
)
)
expect(found).to_be(True)
context.driver.find_element_by_id(button_id).click()
else:
context.driver.find_element_by_id(button_id).click()

@then(u'I should see "{name}" in the item results')
def step_impl(context, name):
Expand Down

2 comments on commit 6218406

@andyd0
Copy link

@andyd0 andyd0 commented on 6218406 May 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IBM Cloud toolchain: Delivery Pipeline deployed orders to dev, including this commit

@andyd0
Copy link

@andyd0 andyd0 commented on 6218406 May 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IBM Cloud toolchain: Delivery Pipeline deployed orders to prod, including this commit

Please sign in to comment.