Use JavaScript in tests using the admin menu

This menu requires JavaScript to open/close subnavigation menus, so
we're now testing the way users with a browser supporting JavaScript
(98%-99% of the users) deal with the menu.
This commit is contained in:
Javi Martín
2021-03-30 15:16:00 +02:00
parent e3deff8bdc
commit 222e4c9542
7 changed files with 25 additions and 13 deletions

View File

@@ -1,22 +1,24 @@
require "rails_helper"
describe "Admin booths", :admin do
scenario "Index empty" do
scenario "Index empty", :js do
visit admin_root_path
within("#side_menu") do
click_link "Voting booths"
click_link "Booths location"
end
expect(page).to have_content "There are no active booths for any upcoming poll."
end
scenario "Index" do
scenario "Index", :js do
3.times { create(:poll_booth) }
visit admin_root_path
within("#side_menu") do
click_link "Voting booths"
click_link "Booths location"
end
@@ -30,13 +32,14 @@ describe "Admin booths", :admin do
expect(page).not_to have_content "There are no booths"
end
scenario "Available" do
scenario "Available", :js do
booth_for_current_poll = create(:poll_booth, polls: [create(:poll, :current)])
booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)])
visit admin_root_path
within("#side_menu") do
click_link "Voting booths"
click_link "Manage shifts"
end