Use JavaScript in tests dealing with tabs

So what we write in the tests is close to what users experience.
This commit is contained in:
Javi Martín
2021-03-30 18:49:42 +02:00
parent baaec3a29c
commit 23945c2a7c
5 changed files with 35 additions and 30 deletions

View File

@@ -207,7 +207,7 @@ describe "Admin booths assignments", :admin do
end
end
scenario "Doesn't show system recounts for old polls" do
scenario "Doesn't show system recounts for old polls", :js do
poll = create(:poll, :old)
booth_assignment = create(:poll_booth_assignment, poll: poll)
@@ -216,6 +216,8 @@ describe "Admin booths assignments", :admin do
visit admin_poll_booth_assignment_path(poll, booth_assignment)
click_link "Recounts"
within("#totals") do
within("#total_final") do
expect(page).to have_content "10"

View File

@@ -75,6 +75,7 @@ describe "Admin settings", :admin do
Setting["feature.map"] = true
visit admin_settings_path
click_link "Map configuration"
within "#map-form" do
click_on "Update"

View File

@@ -149,7 +149,7 @@ describe "Budgets" do
end
end
scenario "Index shows only published phases" do
scenario "Index shows only published phases", :js do
budget.update!(phase: :finished)
phases = budget.phases
@@ -185,35 +185,15 @@ describe "Budgets" do
visit budgets_path
expect(page).not_to have_content "Description of reviewing phase"
expect(page).not_to have_content "January 11, 2018 - January 20, 2018"
expect(page).not_to have_content "Description of valuating phase"
expect(page).not_to have_content "February 10, 2018 - February 20, 2018"
expect(page).not_to have_content "Description of publishing_prices phase"
expect(page).not_to have_content "February 21, 2018 - March 01, 2018"
expect(page).not_to have_content "Description of reviewing_ballots phase"
expect(page).not_to have_content "March 11, 2018 - March 20, 2018"
expect(page).not_to have_link "Reviewing projects"
expect(page).not_to have_link "Valuating projects"
expect(page).not_to have_link "Publishing projects prices"
expect(page).not_to have_link "Reviewing voting"
click_link "Custom name for informing phase"
expect(page).to have_content "Description of informing phase"
expect(page).to have_content "December 30, 2017 - December 31, 2017"
expect(page).to have_content "Description of accepting phase"
expect(page).to have_content "January 01, 2018 - January 20, 2018"
expect(page).to have_content "Description of selecting phase"
expect(page).to have_content "January 21, 2018 - March 01, 2018"
expect(page).to have_content "Description of balloting phase"
expect(page).to have_content "March 02, 2018 - March 20, 2018"
expect(page).to have_content "Description of finished phase"
expect(page).to have_content "March 21, 2018 - March 29, 2018"
expect(page).to have_css(".tabs-panel.is-active", count: 1)
within("#budget_phases_tabs") do
expect(page).to have_link "Custom name for informing phase"
expect(page).to have_link "Custom name for accepting phase"
expect(page).to have_link "Custom name for selecting phase"
expect(page).to have_link phases.balloting.name
expect(page).to have_link "Current phase #{phases.finished.name}"
end
click_link "Custom name for accepting phase"
@@ -221,6 +201,26 @@ describe "Budgets" do
expect(page).to have_link "Previous phase", href: "#phase-1-custom-name-for-informing-phase"
expect(page).to have_link "Next phase", href: "#phase-3-custom-name-for-selecting-phase"
end
expect(page).to have_content "Description of accepting phase"
expect(page).to have_content "January 01, 2018 - January 20, 2018"
click_link "Custom name for selecting phase"
expect(page).to have_content "Description of selecting phase"
expect(page).to have_content "January 21, 2018 - March 01, 2018"
click_link "Voting projects"
expect(page).to have_content "Description of balloting phase"
expect(page).to have_content "March 02, 2018 - March 20, 2018"
click_link "Current phase Finished budget"
expect(page).to have_content "Description of finished phase"
expect(page).to have_content "March 21, 2018 - March 29, 2018"
expect(page).to have_css(".tabs-panel.is-active", count: 1)
end
context "Index map" do

View File

@@ -24,13 +24,14 @@ describe "Moderate proposal notifications" do
expect(page).to have_content "Notifications (0)"
end
scenario "Can not hide own proposal notification" do
scenario "Can not hide own proposal notification", :js do
moderator = create(:moderator)
proposal = create(:proposal, author: moderator.user)
proposal_notification = create(:proposal_notification, proposal: proposal, created_at: Date.current - 4.days)
login_as(moderator.user)
visit proposal_path(proposal)
click_link "Notifications (1)"
within("#proposal_notification_#{proposal_notification.id}") do
expect(page).not_to have_link("Hide")

View File

@@ -75,7 +75,7 @@ describe "Proposal Notifications" do
expect(Notification.count).to eq(0)
end
scenario "Show notifications" do
scenario "Show notifications", :js do
proposal = create(:proposal)
create(:proposal_notification,
@@ -86,6 +86,7 @@ describe "Proposal Notifications" do
body: "We are almost there please share with your peoples!")
visit proposal_path(proposal)
click_link "Notifications (2)"
expect(page).to have_content "Hey guys"
expect(page).to have_content "Just wanted to let you know that..."