refactor and move to selenium
This commit is contained in:
@@ -54,6 +54,7 @@ Feature: Supplier main board
|
||||
Given there is an active list and order
|
||||
And there is another section with table
|
||||
And I am signed in as supplier
|
||||
When I visit the supplier root path
|
||||
And a new order on a table in another section is created
|
||||
Then I should see the list and the new list
|
||||
And I should see the order and the new order
|
||||
@@ -69,7 +70,8 @@ Feature: Supplier main board
|
||||
Scenario: Selecting a specific section and jumping towards section view
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
When I select the section in the supplier dashboard
|
||||
When I visit the supplier root path
|
||||
And I select the section in the supplier dashboard
|
||||
And I click on the section main board section jumper
|
||||
Then I should be redirected to the supplier section view
|
||||
|
||||
@@ -78,6 +80,7 @@ Feature: Supplier main board
|
||||
Given there is an active list and order
|
||||
And there is another section with table
|
||||
And I am signed in as supplier
|
||||
When I visit the supplier root path
|
||||
# wait until page is fully loaded, could be a pure ruby command inside a within :selector statement since the browser will wait for the selector to be present and then the lists are loaded
|
||||
And I wait 4 seconds
|
||||
When the active list changes to another table in another section
|
||||
@@ -89,7 +92,8 @@ Feature: Supplier main board
|
||||
Scenario: Remove an order
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
When the supplier marks the order as wrong in the main board view
|
||||
When I visit the supplier root path
|
||||
And the supplier marks the order as wrong in the main board view
|
||||
Then the supplier main board order should not be visible anymore
|
||||
And the supplier main board list total should be updated
|
||||
And the supplier placed orders counter should be reduced
|
||||
@@ -98,7 +102,8 @@ Feature: Supplier main board
|
||||
Scenario: Closing list with active orders updates supplier counters
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
When I click on the close list button in the supplier dashboard
|
||||
When I visit the supplier root path
|
||||
And I click on the close list button in the supplier dashboard
|
||||
And confirm the supplier close list modal
|
||||
Then the supplier placed orders counter should be reduced
|
||||
|
||||
@@ -107,7 +112,8 @@ Feature: Supplier main board
|
||||
Given there is an active list and order
|
||||
And there is another section with table
|
||||
And I am signed in as supplier
|
||||
When a new order on a table in another section is created
|
||||
When I visit the supplier root path
|
||||
And a new order on a table in another section is created
|
||||
Then I should see the list and the new list
|
||||
And I should see the order and the new order
|
||||
When I select the section in the supplier dashboard
|
||||
|
||||
@@ -5,8 +5,8 @@ Feature: Adding product category
|
||||
Given there is a confirmed and open supplier
|
||||
And I am signed in as supplier
|
||||
#And there are 2 supplier products
|
||||
And the supplier visits the menu page
|
||||
When the supplier clicks on the new product category button
|
||||
When the supplier visits the menu page
|
||||
And the supplier clicks on the new product category button
|
||||
And the supplier fills in the new product category form selecting not available on tuesdays
|
||||
And the supplier submits the product category form
|
||||
Then then new product category with proper properties should have been created
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
step "I am signed in as supplier" do
|
||||
step 'visit the supplier sign in path'
|
||||
find('#supplier_email').set @supplier.email
|
||||
find('#supplier_password').set @supplier_password
|
||||
click_on 'Inloggen'
|
||||
|
||||
visit test_login_admin_suppliers_path(email: @supplier.email)
|
||||
#step 'visit the supplier sign in path'
|
||||
#find('#supplier_email').set @supplier.email
|
||||
#find('#supplier_password').set @supplier_password
|
||||
#click_on 'Inloggen'
|
||||
end
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
step "the section table should be positioned in the section" do
|
||||
table = page.find(".section-table-#{@table.id}")
|
||||
left = table['style'].to_s.match(/left:(\d+)/)
|
||||
left.should be_present
|
||||
left[1].to_i.should > 10
|
||||
top = table['style'].to_s.match(/top:(\d+)/)
|
||||
top.should be_present
|
||||
top[1].to_i.should > 10
|
||||
page.find(".section-table-#{@table.id}") # wait for table presence
|
||||
|
||||
left = page.evaluate_script("$('.section-table-#{@table.id}').position().left")
|
||||
left.to_i.should > 0
|
||||
|
||||
top = page.evaluate_script("$('.section-table-#{@table.id}').position().top")
|
||||
top.to_i.should > 0
|
||||
end
|
||||
|
||||
step "the section table should be marked as having an active order" do
|
||||
table = page.find(".section-table-#{@table.id}")
|
||||
table['class'].should include 'active_order'
|
||||
assert_element_class ".section-table-#{@table.id}", 'active_order'
|
||||
end
|
||||
|
||||
step "the section table should still be marked as having an active order" do
|
||||
step "the section table should be marked as having an active order"
|
||||
end
|
||||
|
||||
step "the section table should be marked as occupied" do
|
||||
table = page.find(".section-table-#{@table.id}")
|
||||
table['class'].should include 'occupied'
|
||||
assert_element_class ".section-table-#{@table.id}", 'occupied'
|
||||
end
|
||||
|
||||
step "the section table should be marked as in need of help" do
|
||||
table = page.find(".section-table-#{@table.id}")
|
||||
table['class'].should include 'needs_help'
|
||||
assert_element_class ".section-table-#{@table.id}", 'needs_help'
|
||||
end
|
||||
|
||||
step "the section table should not be marked as in need of help" do
|
||||
@@ -97,9 +95,9 @@ step "I click the supplier section normal mode button" do
|
||||
end
|
||||
|
||||
step "I fill in the supplier edit section form with new values" do
|
||||
find('.section-edit-title-field').set 'RenamedSection'
|
||||
find('.section-edit-width-field').set '40'
|
||||
find('.section-edit-height-field').set '52.7'
|
||||
js_set_field '.section-edit-title-field', 'RenamedSection'
|
||||
js_set_field '.section-edit-width-field', 40
|
||||
js_set_field '.section-edit-height-field', 52.7
|
||||
end
|
||||
|
||||
step "the last section tab header should have the newly filled in name" do
|
||||
|
||||
@@ -66,6 +66,7 @@ step "the user order :product_name should be in the order list with price" do |p
|
||||
concerning_product = Product.find_by_name(product_name)
|
||||
#ember_order = ember_store['product_orders'].find{|po| po['product_id'] == concerning_product.id}
|
||||
#ember_order = ember_find('product_order', concerning_product.id)
|
||||
sleep 0.1
|
||||
ember_order = ember_all('product_order').find{|po| po['product_id'] == concerning_product.id }
|
||||
quantity = ember_order['quantity']
|
||||
order_price = quantity * concerning_product.price
|
||||
|
||||
+2
-1
@@ -19,7 +19,8 @@ Dir.glob("spec/acceptance_steps/**/*steps.rb") { |f| load f, true }
|
||||
|
||||
I18n.locale =I18n.default_locale
|
||||
Devise.stretches = 1
|
||||
Capybara.javascript_driver = :webkit
|
||||
#Capybara.javascript_driver = :webkit
|
||||
Capybara.javascript_driver = :selenium
|
||||
Capybara.default_wait_time = 4 # ember needs more time than the default of 2
|
||||
Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }
|
||||
WebMock.disable_net_connect!(allow_localhost: true)
|
||||
|
||||
@@ -15,18 +15,31 @@ module SpecEmberHelpers
|
||||
JSON.parse(h)
|
||||
end
|
||||
|
||||
def assert_element_class(selector, class_name)
|
||||
find selector # capybara wait for element
|
||||
time = 0
|
||||
classes = page.evaluate_script("$('#{selector}').attr('class')")
|
||||
while !classes.include?(class_name) and time < 10
|
||||
sleep 0.1
|
||||
classes = page.evaluate_script("$('#{selector}').attr('class')")
|
||||
time += 1
|
||||
end
|
||||
classes.should include class_name
|
||||
end
|
||||
|
||||
def js_set_field(selector, value)
|
||||
page.execute_script("$('#{selector}').val('#{value}').trigger('change')")
|
||||
end
|
||||
|
||||
def ember_find(typeKey, id)
|
||||
h = page.evaluate_script <<-SCRIPT
|
||||
$s = App.__container__.lookup('store:main');
|
||||
record = $s.all('#{typeKey}').findBy('id', '#{id}');
|
||||
record ? record.serialize() : null
|
||||
App.__container__.lookup('store:main').all('#{typeKey}').findBy('id', '#{id}').serialize()
|
||||
SCRIPT
|
||||
end
|
||||
|
||||
def ember_all(typeKey)
|
||||
h = page.evaluate_script <<-SCRIPT
|
||||
$s = App.__container__.lookup('store:main');
|
||||
$s.all('#{typeKey}').invoke('serialize')
|
||||
App.__container__.lookup('store:main').all('#{typeKey}').invoke('serialize')
|
||||
SCRIPT
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user