From 4462be55d186142aeba04780b82a48ee72d79348 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Wed, 21 Jan 2015 19:18:12 +0100 Subject: [PATCH] Fix all failing specs --- .../suppliers/product_category_generation.feature | 1 + spec/acceptance/suppliers/settings.feature | 4 ++-- .../suppliers/product_category_steps.rb | 10 +++++----- spec/acceptance_steps/suppliers/settings_steps.rb | 4 ++-- spec/acceptance_steps/suppliers/signup_steps.rb | 8 ++++---- spec/acceptance_steps/suppliers/table_steps.rb | 4 ++-- spec/acceptance_steps/users/authentication_steps.rb | 4 ++-- spec/acceptance_steps/users/changing_table_steps.rb | 6 +----- spec/acceptance_steps/users/feedback_steps.rb | 4 ++-- spec/acceptance_steps/users/side_menu_steps.rb | 6 ++---- spec/support/ember_helpers.rb | 6 ++++++ 11 files changed, 29 insertions(+), 28 deletions(-) diff --git a/spec/acceptance/suppliers/product_category_generation.feature b/spec/acceptance/suppliers/product_category_generation.feature index 18392c75..23dca832 100644 --- a/spec/acceptance/suppliers/product_category_generation.feature +++ b/spec/acceptance/suppliers/product_category_generation.feature @@ -8,6 +8,7 @@ Feature: Adding product category 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 I open the debugger And the supplier submits the product category form Then then new product category with proper properties should have been created When the supplier clicks on the add product button for the product category diff --git a/spec/acceptance/suppliers/settings.feature b/spec/acceptance/suppliers/settings.feature index 08261d70..05888211 100644 --- a/spec/acceptance/suppliers/settings.feature +++ b/spec/acceptance/suppliers/settings.feature @@ -4,8 +4,8 @@ Feature: Manage settings Scenario: Changing the name Given there is a confirmed and open supplier And I am signed in as supplier - And I visit the supplier settings path - When the supplier changes the name to "Test8" in the settings page + When I visit the supplier settings path + And the supplier changes the name to "Test8" in the settings page And the supplier submits the supplier settings form Then the supplier should be redirected to the root path When the supplier opens the side menu diff --git a/spec/acceptance_steps/suppliers/product_category_steps.rb b/spec/acceptance_steps/suppliers/product_category_steps.rb index 785fca62..c29bf2a5 100644 --- a/spec/acceptance_steps/suppliers/product_category_steps.rb +++ b/spec/acceptance_steps/suppliers/product_category_steps.rb @@ -6,8 +6,8 @@ end step "the supplier fills in the new product category form selecting not available on tuesdays" do # default all days on, so click on tuesday deactivates it within '.modal' do - find('.form-row.name input').set 'New product category' - find('.form-row.tuesday label').click + js_set_field '.form-row.name input', 'New product category' + find('.form-row.tuesday .switch').click end end @@ -32,9 +32,9 @@ end step "the supplier fills in the new product form and submits it" do within ('.menu-product-new') do - find('.name input').set "Delicious pie" - find('.price input').set "4.75" - find('.code input').set "P079" + js_set_field '.name input', "Delicious pie" + js_set_field '.price input', "4.75" + js_set_field '.code input', "P079" find('.save-product-action').click sleep 0.5 end diff --git a/spec/acceptance_steps/suppliers/settings_steps.rb b/spec/acceptance_steps/suppliers/settings_steps.rb index 6ef8b26d..274ce867 100644 --- a/spec/acceptance_steps/suppliers/settings_steps.rb +++ b/spec/acceptance_steps/suppliers/settings_steps.rb @@ -1,5 +1,5 @@ step "I provide a new supplier email address" do - find('.supplier-email').set 'new-supplier-mail@mozo.bar' + js_set_field '.supplier-email', 'new-supplier-mail@mozo.bar' end step "the supplier submits the supplier settings form" do @@ -28,7 +28,7 @@ step "an email should have been sent to the original supplier email with email c end step "the supplier changes the name to :name in the settings page" do |new_name| - page.find('input.supplier-name').set new_name + js_set_field 'input.supplier-name', new_name end step "the supplier clicks on the new email confirmation link" do diff --git a/spec/acceptance_steps/suppliers/signup_steps.rb b/spec/acceptance_steps/suppliers/signup_steps.rb index 539874f6..d076338d 100644 --- a/spec/acceptance_steps/suppliers/signup_steps.rb +++ b/spec/acceptance_steps/suppliers/signup_steps.rb @@ -4,10 +4,10 @@ step "I visit the supplier signup path" do end step "fill in the supplier signup form with new credentials" do - find('#supplier_name').set 'Signup Supplier' - find('#supplier_email').set 'signup_supplier@example.com' - find('#supplier_password').set 'SignupSupplier' - find('#supplier_password_confirmation').set 'SignupSupplier' + js_set_field '#supplier_name', 'Signup Supplier' + js_set_field '#supplier_email', 'signup_supplier@example.com' + js_set_field '#supplier_password', 'SignupSupplier' + js_set_field '#supplier_password_confirmation', 'SignupSupplier' end step "click on the supplier signup submit button" do diff --git a/spec/acceptance_steps/suppliers/table_steps.rb b/spec/acceptance_steps/suppliers/table_steps.rb index 6e925781..ad14ebb8 100644 --- a/spec/acceptance_steps/suppliers/table_steps.rb +++ b/spec/acceptance_steps/suppliers/table_steps.rb @@ -9,7 +9,7 @@ end step "the supplier fills in the new table form selecting the first section" do within '.modal' do - find('.number input').set '7' + js_set_field '.number input', 7 find('.section select').find(%|option[value="#{@sections.first.id}"]|).select_option end end @@ -33,7 +33,7 @@ end step "the supplier changes the table number to :number and section to the last section" do |number| within '.modal' do - find('.number input').set number + js_set_field '.number input', number find('.section select').find(%|option[value="#{@sections.last.id}"]|).select_option end end diff --git a/spec/acceptance_steps/users/authentication_steps.rb b/spec/acceptance_steps/users/authentication_steps.rb index fecc8341..b0d11ba7 100644 --- a/spec/acceptance_steps/users/authentication_steps.rb +++ b/spec/acceptance_steps/users/authentication_steps.rb @@ -2,8 +2,8 @@ step "there is no user information stored in the local storage" do visit '/' page.execute_script %|Qstorage = window.localStorage| - page.evaluate_script(%|Qstorage.getItem('user_id')|).should be_blank - page.evaluate_script(%|Qstorage.getItem('auth_token')|).should be_blank + page.execute_script(%|Qstorage.removeItem('user_id')|) + page.execute_script(%|Qstorage.removeItem('auth_token')|) end step "I visit the user obtain token path" do diff --git a/spec/acceptance_steps/users/changing_table_steps.rb b/spec/acceptance_steps/users/changing_table_steps.rb index 269b23b7..5f0bf9ba 100644 --- a/spec/acceptance_steps/users/changing_table_steps.rb +++ b/spec/acceptance_steps/users/changing_table_steps.rb @@ -33,11 +33,7 @@ step "there is another table with an active list of another user" do end step "the user scans a QR code of another not occupied table" do - r = page.evaluate_script %| - c = App.__container__.lookup('controller:select_qrcode'); - c.send('selectQr', {_id: "#{@other_table.id}"}); - c.toString() - | + page.execute_script %|App.__container__.lookup('controller:select_qrcode').send('selectQr', {_id: "#{@other_table.id}"})| #page.execute_script "Quser.actions_for_table({table_id: '#{@other_table.id}'})" end diff --git a/spec/acceptance_steps/users/feedback_steps.rb b/spec/acceptance_steps/users/feedback_steps.rb index ce8eaa81..ff030149 100644 --- a/spec/acceptance_steps/users/feedback_steps.rb +++ b/spec/acceptance_steps/users/feedback_steps.rb @@ -1,9 +1,9 @@ step "the user fills in the feedback field" do - find('.feedback-field').set "Nice app!" + js_set_field '.feedback-field', "Nice app!" end step "the user clicks on the submit feedback button" do - find(".submit-feedback-button").click + js_click ".submit-feedback-button" end step "the user should see the feedback submitted message" do diff --git a/spec/acceptance_steps/users/side_menu_steps.rb b/spec/acceptance_steps/users/side_menu_steps.rb index a7dd4d3e..5e99167f 100644 --- a/spec/acceptance_steps/users/side_menu_steps.rb +++ b/spec/acceptance_steps/users/side_menu_steps.rb @@ -1,6 +1,5 @@ step "the user opens the side menu" do - page.execute_script %|$('.toggle-side-menu').click()| - sleep 1 + js_click '.toggle-side-menu' end step "the user opens the side menu again" do @@ -8,8 +7,7 @@ step "the user opens the side menu again" do end step "the user clicks on the lists link in the side menu" do - page.execute_script %|$('.side-menu-lists').click()| - sleep 2 + js_click '.side-menu-lists' end step "the user clicks on the about link in the side menu" do diff --git a/spec/support/ember_helpers.rb b/spec/support/ember_helpers.rb index bdf8dec7..1aea9fa6 100644 --- a/spec/support/ember_helpers.rb +++ b/spec/support/ember_helpers.rb @@ -28,9 +28,15 @@ module SpecEmberHelpers end def js_set_field(selector, value) + find selector page.execute_script("$('#{selector}').val('#{value}').trigger('change')") end + def js_click(selector) + find selector + page.execute_script "$('#{selector}').click()" + end + def ember_find(typeKey, id) h = page.evaluate_script <<-SCRIPT App.__container__.lookup('store:main').all('#{typeKey}').findBy('id', '#{id}').serialize()