Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flaky volunteers & supervisors system specs #6006

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions spec/system/supervisors/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
RSpec.describe "supervisors/index", type: :system do
shared_examples_for "functioning sort buttons" do
it "sorts table columns" do
expect(page).to have_selector("tr:nth-child(1)", text: expected_first_ordered_value)
expect(page).to have_css("tr:nth-child(1)", text: expected_first_ordered_value)

find("th", text: column_to_sort).click

expect(page).to have_selector("th.sorting_asc", text: column_to_sort)
expect(page).to have_selector("tr:nth-child(1)", text: expected_last_ordered_value)
expect(page).to have_css("th.sorting_asc", text: column_to_sort)
expect(page).to have_css("tr:nth-child(1)", text: expected_last_ordered_value)
end
end

Expand Down Expand Up @@ -86,7 +86,7 @@
context "with active and deactivated supervisors" do
it "shows deactivated supervisor on show button click", js: true do
expect(page).to have_text("Showing 1 to 2 of 2 entries (filtered from 3 total entries)")
expect(page).not_to have_text("Deactivated supervisor")
expect(page).to have_no_text("Deactivated supervisor")

find(".supervisor-filters").click_on("Filter Status")
check("status_option_inactive")
Expand All @@ -97,7 +97,7 @@
uncheck("status_option_inactive")

expect(page).to have_text("Showing 1 to 2 of 2 entries (filtered from 3 total entries)")
expect(page).not_to have_text("Deactivated supervisor")
expect(page).to have_no_text("Deactivated supervisor")
end
end

Expand All @@ -115,7 +115,7 @@
expect(page).to have_text("Assigned to Case(s)")
expect(page).to have_text(unassigned_volunteer_name)

expect(page).not_to have_text("There are no unassigned volunteers")
expect(page).to have_no_text("There are no unassigned volunteers")
end

it "links to edit page of volunteer" do
Expand All @@ -133,8 +133,8 @@
it "will not show a list of volunteers not assigned to supervisors", js: true do
expect(page).to have_text("There are no active volunteers without supervisors to display here")

expect(page).not_to have_text("Active volunteers not assigned to supervisors")
expect(page).not_to have_text("Assigned to Case(s)")
expect(page).to have_no_text("Active volunteers not assigned to supervisors")
expect(page).to have_no_text("Assigned to Case(s)")
end
end
end
Expand Down Expand Up @@ -167,7 +167,7 @@

within("table#supervisors") do
expect(page).to have_text("Active Supervisor")
expect(page).not_to have_text("Inactive Supervisor")
expect(page).to have_no_text("Inactive Supervisor")
end
end
end
Expand All @@ -182,7 +182,7 @@
end

within("table#supervisors") do
expect(page).not_to have_content("Active Supervisor")
expect(page).to have_no_content("Active Supervisor")
expect(page).to have_content("Inactive Supervisor")
end
end
Expand Down
65 changes: 29 additions & 36 deletions spec/system/volunteers/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@

visit volunteers_path

expect(page).to have_selector("#casa-logo[src*='default-logo']")
expect(page).to have_selector("#casa-logo[alt='CASA Logo']")
expect(page).to have_css("#casa-logo[src*='default-logo']")
expect(page).to have_css("#casa-logo[alt='CASA Logo']")
end
end

it "displays last attempted contact by default", js: true do
travel_to Date.new(2021, 1, 1)
create(:volunteer, :with_assigned_supervisor, display_name: "User 1", email: "[email protected]", casa_org: organization)

sign_in admin
Expand All @@ -68,7 +67,7 @@
uncheck "Contact Made In Past 60 Days"
uncheck "Last Attempted Contact"
within(".modal-dialog") do
click_button "Close"
click_on "Close"
end

expect(page).to have_text("Name")
Expand All @@ -87,7 +86,7 @@
sign_in admin

visit volunteers_path
expect(page).to have_selector(".volunteer-filters")
expect(page).to have_css(".volunteer-filters")

assigned_volunteers.each do |assigned_volunteer|
expect(page).to have_text assigned_volunteer.display_name
Expand All @@ -104,15 +103,15 @@
inactive_volunteers.each do |inactive_volunteer|
expect(page).to have_text inactive_volunteer.display_name
end
expect(page).to have_selector("table#volunteers tbody tr", count: inactive_volunteers.count)
expect(page).to have_css("table#volunteers tbody tr", count: inactive_volunteers.count)

visit volunteers_path
click_on "Supervisor"
find(:css, "#unassigned-vol-filter").set(false)
find_by_id("unassigned-vol-filter").set(false)
assigned_volunteers.each do |assigned_volunteer|
expect(page).to have_text assigned_volunteer.display_name
end
expect(page).to have_selector("table#volunteers tbody tr", count: assigned_volunteers.count)
expect(page).to have_css("table#volunteers tbody tr", count: assigned_volunteers.count)
end

it "can go to the volunteer edit page from the volunteer list", js: true do
Expand All @@ -136,7 +135,7 @@
click_on "New Volunteer"

expect(page).to have_text("New Volunteer")
expect(page).to have_selector("form#new_volunteer")
expect(page).to have_css("form#new_volunteer")
end

describe "supervisor column of volunteers table" do
Expand All @@ -146,9 +145,9 @@

visit volunteers_path
click_on "Supervisor"
find(:css, "#unassigned-vol-filter").set(true)
find_by_id("unassigned-vol-filter").set(true)

expect(page).to have_selector("tbody .supervisor-column", text: "")
expect(page).to have_css("tbody .supervisor-column", text: "")
end

it "displays supervisor's name when volunteer has supervisor", js: true do
Expand All @@ -158,7 +157,7 @@
sign_in admin

visit volunteers_path
expect(page).to have_selector("tbody .supervisor-column", text: name)
expect(page).to have_css("tbody .supervisor-column", text: name)
end

it "is blank when volunteer's supervisor is inactive", js: true do
Expand All @@ -167,9 +166,9 @@

visit volunteers_path
click_on "Supervisor"
find(:css, "#unassigned-vol-filter").set(true)
find_by_id("unassigned-vol-filter").set(true)

expect(page).to have_selector("tbody .supervisor-column", text: "")
expect(page).to have_css("tbody .supervisor-column", text: "")
end
end

Expand All @@ -190,7 +189,7 @@

it "does not display by default" do
visit volunteers_path
expect(page).not_to have_text "Manage Volunteer"
expect(page).to have_no_text "Manage Volunteer"
end

context "when one or more volunteers selected" do
Expand All @@ -205,14 +204,14 @@
visit volunteers_path
volunteers.each_with_index do |volunteer, index|
find("#supervisor_volunteer_volunteer_ids_#{volunteer.id}").click
expect(page).to have_selector("[data-select-all-target='buttonLabel']", text: "#{index + 1})")
expect(page).to have_css("[data-select-all-target='buttonLabel']", text: "#{index + 1})")
end
end

it "text matches pluralization of volunteers selected" do
visit volunteers_path
find("#supervisor_volunteer_volunteer_ids_#{volunteers[0].id}").click
expect(page).not_to have_text "Manage Volunteers"
expect(page).to have_no_text "Manage Volunteers"

find("#supervisor_volunteer_volunteer_ids_#{volunteers[1].id}").click
expect(page).to have_text "Manage Volunteers"
Expand All @@ -224,7 +223,7 @@
expect(page).to have_text "Manage Volunteer"

find("#supervisor_volunteer_volunteer_ids_#{volunteers[0].id}").click
expect(page).not_to have_text "Manage Volunteer"
expect(page).to have_no_text "Manage Volunteer"
end
end
end
Expand All @@ -245,7 +244,7 @@
it "selects all volunteers" do
visit volunteers_path
find("#supervisor_volunteer_volunteer_ids_#{volunteers[0].id}") # Wait for data table to be loaded
find("#checkbox-toggle-all").click
find_by_id("checkbox-toggle-all").click

volunteers.each do |volunteer|
expect(page).to have_field("supervisor_volunteer_volunteer_ids_#{volunteer.id}", checked: true)
Expand All @@ -259,7 +258,7 @@
find("#supervisor_volunteer_volunteer_ids_#{volunteer.id}").click
end

find("#checkbox-toggle-all").click
find_by_id("checkbox-toggle-all").click
expect(page).to have_field("checkbox-toggle-all", checked: false)

volunteers.each do |volunteer|
Expand All @@ -274,13 +273,13 @@
find("#supervisor_volunteer_volunteer_ids_#{volunteers[0].id}").click

expect(page).to have_field("checkbox-toggle-all", checked: false)
expect(find("#checkbox-toggle-all")[:indeterminate]).to eq("true")
expect(find_by_id("checkbox-toggle-all")[:indeterminate]).to eq("true")
end

it "selects all volunteers" do
visit volunteers_path
find("#supervisor_volunteer_volunteer_ids_#{volunteers[0].id}").click
find("#checkbox-toggle-all").click
find_by_id("checkbox-toggle-all").click

volunteers.each do |volunteer|
expect(page).to have_field("supervisor_volunteer_volunteer_ids_#{volunteer.id}", checked: true)
Expand Down Expand Up @@ -357,8 +356,8 @@
sign_in supervisor

visit volunteers_path
expect(page).to have_selector(".volunteer-filters")
expect(page).to have_selector("table#volunteers tbody tr", count: 1)
expect(page).to have_css(".volunteer-filters")
expect(page).to have_css("table#volunteers tbody tr", count: 1)

click_on "Status"
find(:css, 'input[data-value="true"]').set(false)
Expand All @@ -368,11 +367,10 @@
inactive_volunteers.each do |inactive_volunteer|
expect(page).to have_text inactive_volunteer.display_name
end
expect(page).to have_selector("table#volunteers tbody tr", count: inactive_volunteers.count)
expect(page).to have_css("table#volunteers tbody tr", count: inactive_volunteers.count)
end

it "can show/hide columns on volunteers table", js: true do
travel_to Date.new(2021, 1, 1)
sign_in supervisor

visit volunteers_path
Expand All @@ -388,7 +386,7 @@
uncheck "Contact Made In Past 60 Days"
uncheck "Last Attempted Contact"
within(".modal-dialog") do
click_button "Close"
click_on "Close"
end

expect(page).to have_text("Name")
Expand All @@ -415,15 +413,15 @@
expect(page).to have_text("Contacts Made in Past 60 Day")
end

click_button "Pick displayed columns"
click_on "Pick displayed columns"

uncheck "Name"
uncheck "Status"
uncheck "Contact Made In Past 60 Days"
uncheck "Last Attempted Contact"

within(".modal-dialog") do
click_button "Close"
click_on "Close"
end

within("#volunteers") do
Expand All @@ -436,12 +434,7 @@
expect(page).to have_text("Case Number(s)")
end

sign_out supervisor
visit volunteers_path

sign_in supervisor
visit volunteers_path

refresh
# Expectations after page reload
within("#volunteers") do
expect(page).to have_no_text("Name")
Expand All @@ -466,7 +459,7 @@
visit supervisors_path
visit volunteers_path

expect(page).to have_selector("#volunteers_filter input", text: "")
expect(page).to have_css("#volunteers_filter input", text: "")
end
end
end
Expand Down