fixed some failing tests

This commit is contained in:
zmagod 2017-10-24 09:45:35 +02:00
parent f76dc29e61
commit cd70395717
5 changed files with 21 additions and 6 deletions

View file

@ -23,7 +23,7 @@ Scenario: Unsuccessful avatar image upload, file is too big
Given I'm on the profile page
Then I click on image within ".avatar-container" element
And I attach a "Moon.png" file to "user_avatar_input" field
Then I click "Update" button
Then I click "Upload" button
And I should see "Avatar file size must be less than 0.2 MB" error message under "user_avatar_input" field
@javascript
@ -31,7 +31,7 @@ Scenario: Unsuccessful avatar image upload, file is invalid
Given I'm on the profile page
Then I click on image within ".avatar-container" element
And I attach a "File.txt" file to "user_avatar_input" field
Then I click "Update" button
Then I click "Upload" button
And I should see "Avatar content type is invalid" error message under "user_avatar_input" field
@javascript
@ -39,7 +39,7 @@ Scenario: Successful upload avatar image
Given I'm on the profile page
Then I click on image within ".avatar-container" element
And I attach a "Star.png" file to "user_avatar_input" field
Then I click "Update" button
Then I click "Upload" button
And I should see "Your account has been updated successfully" flash message
@javascript
@ -69,11 +69,11 @@ Scenario: Successfully changes user initials
@javascript
Scenario: Successfully changes user email
Given I'm on the profile page
Then I click on Edit on "settings_page.new_email" input field
Then I click on Edit on "settings_page.email" input field
And I change "nonadmin@myorg.com" with "user@myorg.com" email
And I fill in "mypassword1234" in Current password field
Then I click "Update" button
And I should see "user@myorg.com" in "settings_page.new_email" input field
And I should see "user@myorg.com" in "settings_page.email" input field
@javascript
Scenario: Unsuccessful Password Change, password is too short

View file

@ -11,6 +11,7 @@ Then(/^I click on Browse button$/) do
end
Then(/^I change "([^"]*)" with "([^"]*)" email$/) do |prev_email, new_email|
wait_for_ajax
find(:xpath, "//input[@value='#{prev_email}']").set(new_email)
end

View file

@ -51,6 +51,7 @@ Then(/^I attach a "([^"]*)" file to "([^"]*)" field$/) do |file, field_id|
end
Then(/^I should see "([^"]*)" error message under "([^"]*)" field$/) do |message, field_id|
wait_for_ajax
parent = find_by_id(field_id).first(:xpath, './/..')
expect(parent).to have_content(message)
end

View file

@ -4,6 +4,8 @@
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
ENV['CUCUMBER'] = 'cucumber'
require 'cucumber/rails'
require 'capybara/cucumber'
require 'capybara-webkit'
@ -32,7 +34,7 @@ end
Capybara.javascript_driver = :webkit
Capybara.default_max_wait_time = 30
Capybara.asset_host = 'http://localhost:3000'
# Precompile webpacker to avoid render bugs in capybara webkit
# global hook throws an error :( https://github.com/cucumber/cucumber/wiki/Hooks
Before('@compile') do

11
features/support/wait.rb Normal file
View file

@ -0,0 +1,11 @@
# @TODO make this funtion work!
def wait_for_ajax
counter = 0
while page.evaluate_script('axios.interceptors.response.use(function(response) { return 1 })').to_i > 0
counter += 1
sleep(0.1)
if (0.1 * counter) >= Capybara.default_max_wait_time
raise "AJAX request took longer than #{Capybara.default_max_wait_time} seconds."
end
end
end