Use JavaScript in tests opening modal dialogs

This way we reproduce the user experience in the tests, and we can make
sure modal dialogs open when we expect it.
This commit is contained in:
Javi Martín
2021-03-29 13:28:41 +02:00
parent fbc78984dc
commit b2bc4d19f5
38 changed files with 221 additions and 178 deletions

View File

@@ -14,7 +14,7 @@ describe "Admin feature flags", :admin do
end
end
scenario "Disable a participatory process", :show_exceptions do
scenario "Disable a participatory process", :show_exceptions, :js do
setting = Setting.find_by(key: "process.budgets")
budget = create(:budget)
@@ -24,10 +24,11 @@ describe "Admin feature flags", :admin do
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Disable"
expect(page).not_to have_button "Enable"
click_button "Disable"
accept_confirm { click_button "Disable" }
end
visit admin_root_path
expect(page).to have_content "Value updated"
within("#side_menu") do
expect(page).not_to have_link "Participatory budgets"
@@ -43,7 +44,7 @@ describe "Admin feature flags", :admin do
expect(page).to have_content "Internal server error"
end
scenario "Enable a disabled participatory process" do
scenario "Enable a disabled participatory process", :js do
Setting["process.budgets"] = nil
setting = Setting.find_by(key: "process.budgets")
@@ -59,25 +60,28 @@ describe "Admin feature flags", :admin do
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Enable"
expect(page).not_to have_button "Disable"
click_button "Enable"
accept_confirm { click_button "Enable" }
end
visit admin_root_path
expect(page).to have_content "Value updated"
within("#side_menu") do
expect(page).to have_link "Participatory budgets"
end
end
scenario "Disable a feature" do
scenario "Disable a feature", :js do
setting = Setting.find_by(key: "feature.twitter_login")
visit admin_settings_path
click_link "Features"
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Disable"
expect(page).not_to have_button "Enable"
click_button "Disable"
accept_confirm { click_button "Disable" }
end
expect(page).to have_content "Value updated"
@@ -88,15 +92,17 @@ describe "Admin feature flags", :admin do
end
end
scenario "Enable a disabled feature" do
scenario "Enable a disabled feature", :js do
setting = Setting.find_by(key: "feature.map")
visit admin_settings_path
click_link "Features"
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Enable"
expect(page).not_to have_button "Disable"
click_button "Enable"
accept_confirm { click_button "Enable" }
end
expect(page).to have_content "Value updated"