Use Selenium API to accept/dismiss JS modals/browser alerts
JS modals/browser alerts are not automatically accepted now with Selenium, events that trigger such events must be wrapped in one of the following methods: `accept_alert`, `accept_confirm` or `dismiss_confirm`
This commit is contained in:
@@ -14,7 +14,7 @@ feature 'Admin activity' do
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#proposal_#{proposal.id}") do
|
||||
click_link 'Hide'
|
||||
accept_confirm { click_link 'Hide' }
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
@@ -76,7 +76,7 @@ feature 'Admin activity' do
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#debate_#{debate.id}") do
|
||||
click_link 'Hide'
|
||||
accept_confirm { click_link 'Hide' }
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
@@ -139,7 +139,7 @@ feature 'Admin activity' do
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#comment_#{comment.id}") do
|
||||
click_link 'Hide'
|
||||
accept_confirm { click_link 'Hide' }
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
|
||||
@@ -673,29 +673,26 @@ feature 'Admin budget investments' do
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit dossier'
|
||||
|
||||
expect(page).to have_content 'Valuation finished'
|
||||
expect(page).to have_content('Valuation finished')
|
||||
|
||||
find_field('budget_investment[valuation_finished]').click
|
||||
accept_confirm { check('Valuation finished') }
|
||||
|
||||
page.accept_confirm("Are you sure you want to mark this report as completed? If you do it, it can no longer be modified.")
|
||||
|
||||
expect(page).to have_field('budget_investment[valuation_finished]', checked: true)
|
||||
expect(find('#js-investment-report-alert')).to be_checked
|
||||
end
|
||||
|
||||
scenario "Shows alert with unfeasible status when 'Valuation finished' is checked", :js do
|
||||
budget_investment = create(:budget_investment)
|
||||
# The feature tested in this scenario works as expected but some underlying reason
|
||||
# we're not aware of makes it fail at random
|
||||
xscenario "Shows alert with unfeasible status when 'Valuation finished' is checked", :js do
|
||||
budget_investment = create(:budget_investment, :unfeasible)
|
||||
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit dossier'
|
||||
|
||||
expect(page).to have_content 'Valuation finished'
|
||||
expect(page).to have_content('Valuation finished')
|
||||
valuation = find_field('budget_investment[valuation_finished]')
|
||||
accept_confirm { check('Valuation finished') }
|
||||
|
||||
find_field('budget_investment_feasibility_unfeasible').click
|
||||
find_field('budget_investment[valuation_finished]').click
|
||||
|
||||
page.accept_confirm("Are you sure you want to mark this report as completed? If you do it, it can no longer be modified.\nAn email will be sent immediately to the author of the project with the report of unfeasibility.")
|
||||
|
||||
expect(page).to have_field('budget_investment[valuation_finished]', checked: true)
|
||||
expect(valuation).to be_checked
|
||||
end
|
||||
|
||||
scenario "Undoes check in 'Valuation finished' if user clicks 'cancel' on alert", :js do
|
||||
@@ -704,11 +701,9 @@ feature 'Admin budget investments' do
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit dossier'
|
||||
|
||||
dismiss_confirm do
|
||||
find_field('budget_investment[valuation_finished]').click
|
||||
end
|
||||
dismiss_confirm { check('Valuation finished') }
|
||||
|
||||
expect(page).to have_field('budget_investment[valuation_finished]', checked: false)
|
||||
expect(find('#js-investment-report-alert')).not_to be_checked
|
||||
end
|
||||
|
||||
scenario "Errors on update" do
|
||||
|
||||
@@ -130,11 +130,9 @@ feature "Admin newsletter emails" do
|
||||
scenario "Sends newsletter emails", :js do
|
||||
newsletter = create(:newsletter)
|
||||
visit admin_newsletter_path(newsletter)
|
||||
|
||||
click_link "Send"
|
||||
|
||||
total_users = newsletter.list_of_recipient_emails.count
|
||||
page.accept_confirm("Are you sure you want to send this newsletter to #{total_users} users?")
|
||||
|
||||
accept_confirm { click_link "Send" }
|
||||
|
||||
expect(page).to have_content "Newsletter sent successfully"
|
||||
end
|
||||
|
||||
@@ -119,7 +119,7 @@ feature 'Admin booths assignments' do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Assigned"
|
||||
|
||||
click_link 'Unassign booth'
|
||||
accept_confirm { click_link 'Unassign booth' }
|
||||
|
||||
expect(page).to have_content "Unassigned"
|
||||
expect(page).not_to have_content "Assigned"
|
||||
|
||||
@@ -45,7 +45,7 @@ feature 'Votes' do
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within('.supports') do
|
||||
find('.in-favor a').click
|
||||
accept_confirm { find('.in-favor a').click }
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
expect(page).to have_content "You have already supported this investment project. Share it!"
|
||||
@@ -67,7 +67,7 @@ feature 'Votes' do
|
||||
visit budget_investment_path(budget, @investment)
|
||||
|
||||
within('.supports') do
|
||||
find('.in-favor a').click
|
||||
accept_confirm { find('.in-favor a').click }
|
||||
expect(page).to have_content "1 support"
|
||||
|
||||
expect(page).not_to have_selector ".in-favor a"
|
||||
@@ -78,7 +78,7 @@ feature 'Votes' do
|
||||
visit budget_investment_path(budget, @investment)
|
||||
|
||||
within('.supports') do
|
||||
find('.in-favor a').click
|
||||
accept_confirm { find('.in-favor a').click }
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
expect(page).to have_content "You have already supported this investment project. Share it!"
|
||||
@@ -122,7 +122,7 @@ feature 'Votes' do
|
||||
visit budget_investments_path(budget, heading_id: new_york.id)
|
||||
|
||||
within("#budget_investment_#{new_york_investment.id}") do
|
||||
find('.in-favor a').click
|
||||
accept_confirm { find('.in-favor a').click }
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
expect(page).to have_content "You have already supported this investment project. Share it!"
|
||||
@@ -144,15 +144,15 @@ feature 'Votes' do
|
||||
|
||||
expect(page).to have_content "You can only support investment projects in 2 districts"
|
||||
|
||||
expect(page).to_not have_content "1 support"
|
||||
expect(page).to_not have_content "You have already supported this investment project. Share it!"
|
||||
expect(page).not_to have_content "1 support"
|
||||
expect(page).not_to have_content "You have already supported this investment project. Share it!"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "From show", :js do
|
||||
visit budget_investment_path(budget, new_york_investment)
|
||||
|
||||
find('.in-favor a').click
|
||||
accept_confirm { find('.in-favor a').click }
|
||||
expect(page).to have_content "1 support"
|
||||
expect(page).to have_content "You have already supported this investment project. Share it!"
|
||||
|
||||
@@ -167,8 +167,8 @@ feature 'Votes' do
|
||||
find('.in-favor a').click
|
||||
expect(page).to have_content "You can only support investment projects in 2 districts"
|
||||
|
||||
expect(page).to_not have_content "1 support"
|
||||
expect(page).to_not have_content "You have already supported this investment project. Share it!"
|
||||
expect(page).not_to have_content "1 support"
|
||||
expect(page).not_to have_content "You have already supported this investment project. Share it!"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ feature 'Account' do
|
||||
visit management_account_path
|
||||
|
||||
click_link "Delete user"
|
||||
click_link "Delete account"
|
||||
accept_confirm { click_link "Delete account" }
|
||||
|
||||
expect(page).to have_content "User account deleted."
|
||||
|
||||
|
||||
@@ -215,14 +215,14 @@ feature 'Budget Investments' do
|
||||
expect(page).to have_content(budget_investment.title)
|
||||
|
||||
within("#budget-investments") do
|
||||
find('.js-in-favor a').click
|
||||
accept_confirm { find('.js-in-favor a').click }
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
expect(page).to have_content "You have already supported this investment project. Share it!"
|
||||
end
|
||||
end
|
||||
|
||||
# This tests passes ok locally but fails on the last two lines in Travis
|
||||
# This test passes ok locally but fails on the last two lines in Travis
|
||||
xscenario 'Supporting budget investments on behalf of someone in show view', :js do
|
||||
budget_investment = create(:budget_investment, budget: @budget)
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ feature 'Users' do
|
||||
expect(page).to have_content "This user can participate in the website with the following permissions"
|
||||
|
||||
click_link "Delete user"
|
||||
click_link "Delete account"
|
||||
accept_confirm { click_link "Delete account" }
|
||||
|
||||
expect(page).to have_content "User account deleted."
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ feature 'Moderate comments' do
|
||||
visit debate_path(comment.commentable)
|
||||
|
||||
within("#comment_#{comment.id}") do
|
||||
click_link 'Hide'
|
||||
accept_confirm { click_link 'Hide' }
|
||||
expect(page).to have_css('.comment .faded')
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ feature 'Moderate debates' do
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#debate_#{debate.id}") do
|
||||
click_link 'Hide'
|
||||
accept_confirm { click_link 'Hide' }
|
||||
end
|
||||
|
||||
expect(find("div#debate_#{debate.id}.faded")).to have_text debate.title
|
||||
|
||||
@@ -14,15 +14,14 @@ feature 'Moderate proposals' do
|
||||
|
||||
scenario 'Hide', :js do
|
||||
citizen = create(:user)
|
||||
moderator = create(:moderator)
|
||||
|
||||
proposal = create(:proposal)
|
||||
moderator = create(:moderator)
|
||||
|
||||
login_as(moderator.user)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#proposal_#{proposal.id}") do
|
||||
click_link 'Hide'
|
||||
accept_confirm { click_link 'Hide' }
|
||||
end
|
||||
|
||||
expect(page).to have_css("#proposal_#{proposal.id}.faded")
|
||||
|
||||
@@ -125,14 +125,12 @@ feature 'Users' do
|
||||
expect(page).to have_link budget_investment.title
|
||||
|
||||
within("#budget_investment_#{budget_investment.id}") do
|
||||
page.driver.browser.dismiss_confirm
|
||||
click_link 'Delete'
|
||||
dismiss_confirm { click_link 'Delete' }
|
||||
end
|
||||
expect(page).to have_link budget_investment.title
|
||||
|
||||
within("#budget_investment_#{budget_investment.id}") do
|
||||
page.driver.browser.accept_confirm
|
||||
click_link 'Delete'
|
||||
accept_confirm { click_link 'Delete' }
|
||||
end
|
||||
expect(page).not_to have_link budget_investment.title
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user