Use visible texts in tests

Content like lowercase letters with `text-transform: uppercase` or
spaces after elements with `display: block` or "You're on page:" are not
seen that way by users with a browser supporting CSS.

So we're testing what most users actually experience.
This commit is contained in:
Javi Martín
2021-03-30 20:00:57 +02:00
parent 23945c2a7c
commit 9cfcbf2f3b
15 changed files with 122 additions and 121 deletions

View File

@@ -807,7 +807,7 @@ describe "Admin budget investments", :admin do
end end
end end
context "Sorting" do context "Sorting", :js do
before do before do
create(:budget_investment, title: "B First Investment", budget: budget, cached_votes_up: 50) create(:budget_investment, title: "B First Investment", budget: budget, cached_votes_up: 50)
create(:budget_investment, title: "A Second Investment", budget: budget, cached_votes_up: 25) create(:budget_investment, title: "A Second Investment", budget: budget, cached_votes_up: 25)
@@ -831,7 +831,7 @@ describe "Admin budget investments", :admin do
expect("B First Investment").to appear_before("A Second Investment") expect("B First Investment").to appear_before("A Second Investment")
expect("A Second Investment").to appear_before("C Third Investment") expect("A Second Investment").to appear_before("C Third Investment")
within("th", text: "ID") do within("th", text: "ID") do
expect(page).to have_css(".icon-sortable.desc") expect(page).to have_css ".icon-sortable.desc", visible: :all
end end
end end
@@ -841,7 +841,7 @@ describe "Admin budget investments", :admin do
expect("A Second Investment").to appear_before("B First Investment") expect("A Second Investment").to appear_before("B First Investment")
expect("B First Investment").to appear_before("C Third Investment") expect("B First Investment").to appear_before("C Third Investment")
within("th", text: "Title") do within("th", text: "Title") do
expect(page).to have_css(".icon-sortable.desc") expect(page).to have_css ".icon-sortable.desc", visible: :all
end end
end end
@@ -851,7 +851,7 @@ describe "Admin budget investments", :admin do
expect("C Third Investment").to appear_before("A Second Investment") expect("C Third Investment").to appear_before("A Second Investment")
expect("A Second Investment").to appear_before("B First Investment") expect("A Second Investment").to appear_before("B First Investment")
within("th", text: "Supports") do within("th", text: "Supports") do
expect(page).to have_css(".icon-sortable.desc") expect(page).to have_css ".icon-sortable.desc", visible: :all
end end
end end
end end
@@ -863,7 +863,7 @@ describe "Admin budget investments", :admin do
expect("C Third Investment").to appear_before("A Second Investment") expect("C Third Investment").to appear_before("A Second Investment")
expect("A Second Investment").to appear_before("B First Investment") expect("A Second Investment").to appear_before("B First Investment")
within("th", text: "ID") do within("th", text: "ID") do
expect(page).to have_css(".icon-sortable.asc") expect(page).to have_css ".icon-sortable.asc", visible: :all
end end
end end
@@ -873,7 +873,7 @@ describe "Admin budget investments", :admin do
expect("C Third Investment").to appear_before("B First Investment") expect("C Third Investment").to appear_before("B First Investment")
expect("B First Investment").to appear_before("A Second Investment") expect("B First Investment").to appear_before("A Second Investment")
within("th", text: "Title") do within("th", text: "Title") do
expect(page).to have_css(".icon-sortable.asc") expect(page).to have_css ".icon-sortable.asc", visible: :all
end end
end end
@@ -883,7 +883,7 @@ describe "Admin budget investments", :admin do
expect("B First Investment").to appear_before("A Second Investment") expect("B First Investment").to appear_before("A Second Investment")
expect("A Second Investment").to appear_before("C Third Investment") expect("A Second Investment").to appear_before("C Third Investment")
within("th", text: "Supports") do within("th", text: "Supports") do
expect(page).to have_css(".icon-sortable.asc") expect(page).to have_css ".icon-sortable.asc", visible: :all
end end
end end
end end
@@ -895,7 +895,7 @@ describe "Admin budget investments", :admin do
expect("B First Investment").to appear_before("A Second Investment") expect("B First Investment").to appear_before("A Second Investment")
expect("A Second Investment").to appear_before("C Third Investment") expect("A Second Investment").to appear_before("C Third Investment")
within("th", text: "ID") do within("th", text: "ID") do
expect(page).to have_css(".icon-sortable.desc") expect(page).to have_css ".icon-sortable.desc", visible: :all
end end
end end
@@ -905,7 +905,7 @@ describe "Admin budget investments", :admin do
expect("A Second Investment").to appear_before("B First Investment") expect("A Second Investment").to appear_before("B First Investment")
expect("B First Investment").to appear_before("C Third Investment") expect("B First Investment").to appear_before("C Third Investment")
within("th", text: "Title") do within("th", text: "Title") do
expect(page).to have_css(".icon-sortable.desc") expect(page).to have_css ".icon-sortable.desc", visible: :all
end end
end end
@@ -915,7 +915,7 @@ describe "Admin budget investments", :admin do
expect("C Third Investment").to appear_before("A Second Investment") expect("C Third Investment").to appear_before("A Second Investment")
expect("A Second Investment").to appear_before("B First Investment") expect("A Second Investment").to appear_before("B First Investment")
within("th", text: "Supports") do within("th", text: "Supports") do
expect(page).to have_css(".icon-sortable.desc") expect(page).to have_css ".icon-sortable.desc", visible: :all
end end
end end
end end
@@ -927,7 +927,7 @@ describe "Admin budget investments", :admin do
expect("B First Investment").to appear_before("A Second Investment") expect("B First Investment").to appear_before("A Second Investment")
expect("A Second Investment").to appear_before("C Third Investment") expect("A Second Investment").to appear_before("C Third Investment")
within("th", text: "ID") do within("th", text: "ID") do
expect(page).to have_css(".icon-sortable.desc") expect(page).to have_css ".icon-sortable.desc", visible: :all
end end
end end
end end

View File

@@ -26,7 +26,7 @@ describe "Admin budgets", :admin do
expect(page).to have_content "Accepting projects" expect(page).to have_content "Accepting projects"
end end
scenario "Filters by phase" do scenario "Filters by phase", :js do
drafting_budget = create(:budget, :drafting) drafting_budget = create(:budget, :drafting)
accepting_budget = create(:budget, :accepting) accepting_budget = create(:budget, :accepting)
selecting_budget = create(:budget, :selecting) selecting_budget = create(:budget, :selecting)
@@ -41,7 +41,7 @@ describe "Admin budgets", :admin do
expect(page).to have_content(finished_budget.name) expect(page).to have_content(finished_budget.name)
within "#budget_#{finished_budget.id}" do within "#budget_#{finished_budget.id}" do
expect(page).to have_content("Completed") expect(page).to have_content("COMPLETED")
end end
click_link "Finished" click_link "Finished"

View File

@@ -112,7 +112,7 @@ describe "Homepage", :admin do
xscenario "Deactivate" xscenario "Deactivate"
end end
scenario "Cards" do scenario "Cards", :js do
card1 = create(:widget_card, label: "Card1 label", card1 = create(:widget_card, label: "Card1 label",
title: "Card1 text", title: "Card1 text",
description: "Card1 description", description: "Card1 description",
@@ -130,8 +130,8 @@ describe "Homepage", :admin do
expect(page).to have_css(".card", count: 2) expect(page).to have_css(".card", count: 2)
within("#widget_card_#{card1.id}") do within("#widget_card_#{card1.id}") do
expect(page).to have_content("Card1 label") expect(page).to have_content("CARD1 LABEL")
expect(page).to have_content("Card1 text") expect(page).to have_content("CARD1 TEXT")
expect(page).to have_content("Card1 description") expect(page).to have_content("Card1 description")
expect(page).to have_content("Link1 text") expect(page).to have_content("Link1 text")
expect(page).to have_link(href: "consul1.dev") expect(page).to have_link(href: "consul1.dev")
@@ -139,8 +139,8 @@ describe "Homepage", :admin do
end end
within("#widget_card_#{card2.id}") do within("#widget_card_#{card2.id}") do
expect(page).to have_content("Card2 label") expect(page).to have_content("CARD2 LABEL")
expect(page).to have_content("Card2 text") expect(page).to have_content("CARD2 TEXT")
expect(page).to have_content("Card2 description") expect(page).to have_content("Card2 description")
expect(page).to have_content("Link2 text") expect(page).to have_content("Link2 text")
expect(page).to have_link(href: "consul2.dev") expect(page).to have_link(href: "consul2.dev")

View File

@@ -1,7 +1,7 @@
require "rails_helper" require "rails_helper"
describe "Stats", :admin do describe "Stats", :admin do
context "Summary" do context "Summary", :js do
scenario "General" do scenario "General" do
create(:debate) create(:debate)
2.times { create(:proposal) } 2.times { create(:proposal) }
@@ -10,10 +10,10 @@ describe "Stats", :admin do
visit admin_stats_path visit admin_stats_path
expect(page).to have_content "Debates 1" expect(page).to have_content "DEBATES\n1"
expect(page).to have_content "Proposals 2" expect(page).to have_content "PROPOSALS\n2"
expect(page).to have_content "Comments 3" expect(page).to have_content "COMMENTS\n3"
expect(page).to have_content "Visits 4" expect(page).to have_content "VISITS\n4"
end end
scenario "Votes" do scenario "Votes" do
@@ -23,14 +23,14 @@ describe "Stats", :admin do
visit admin_stats_path visit admin_stats_path
expect(page).to have_content "Debate votes 1" expect(page).to have_content "DEBATE VOTES\n1"
expect(page).to have_content "Proposal votes 2" expect(page).to have_content "PROPOSAL VOTES\n2"
expect(page).to have_content "Comment votes 3" expect(page).to have_content "COMMENT VOTES\n3"
expect(page).to have_content "Total votes 6" expect(page).to have_content "TOTAL VOTES\n6"
end end
end end
context "Users" do context "Users", :js do
scenario "Summary" do scenario "Summary" do
1.times { create(:user, :level_three) } 1.times { create(:user, :level_three) }
2.times { create(:user, :level_two) } 2.times { create(:user, :level_two) }
@@ -38,11 +38,11 @@ describe "Stats", :admin do
visit admin_stats_path visit admin_stats_path
expect(page).to have_content "Level three users 1" expect(page).to have_content "LEVEL THREE USERS\n1"
expect(page).to have_content "Level two users 2" expect(page).to have_content "LEVEL TWO USERS\n2"
expect(page).to have_content "Verified users 3" expect(page).to have_content "VERIFIED USERS\n3"
expect(page).to have_content "Unverified users 4" expect(page).to have_content "UNVERIFIED USERS\n4"
expect(page).to have_content "Total users 7" expect(page).to have_content "TOTAL USERS\n7"
end end
scenario "Do not count erased users" do scenario "Do not count erased users" do
@@ -52,11 +52,11 @@ describe "Stats", :admin do
visit admin_stats_path visit admin_stats_path
expect(page).to have_content "Level three users 0" expect(page).to have_content "LEVEL THREE USERS\n0"
expect(page).to have_content "Level two users 0" expect(page).to have_content "LEVEL TWO USERS\n0"
expect(page).to have_content "Verified users 0" expect(page).to have_content "VERIFIED USERS\n0"
expect(page).to have_content "Unverified users 1" expect(page).to have_content "UNVERIFIED USERS\n1"
expect(page).to have_content "Total users 1" expect(page).to have_content "TOTAL USERS\n1"
end end
scenario "Do not count hidden users" do scenario "Do not count hidden users" do
@@ -66,11 +66,11 @@ describe "Stats", :admin do
visit admin_stats_path visit admin_stats_path
expect(page).to have_content "Level three users 0" expect(page).to have_content "LEVEL THREE USERS\n0"
expect(page).to have_content "Level two users 0" expect(page).to have_content "LEVEL TWO USERS\n0"
expect(page).to have_content "Verified users 0" expect(page).to have_content "VERIFIED USERS\n0"
expect(page).to have_content "Unverified users 1" expect(page).to have_content "UNVERIFIED USERS\n1"
expect(page).to have_content "Total users 1" expect(page).to have_content "TOTAL USERS\n1"
end end
scenario "Level 2 user Graph" do scenario "Level 2 user Graph" do
@@ -82,17 +82,17 @@ describe "Stats", :admin do
visit admin_stats_path visit admin_stats_path
expect(page).to have_content "Level two users 1" expect(page).to have_content "LEVEL TWO USERS\n1"
end end
end end
describe "Budget investments" do describe "Budget investments", :js do
context "Supporting phase" do context "Supporting phase" do
let(:budget) { create(:budget) } let(:budget) { create(:budget) }
let(:group_all_city) { create(:budget_group, budget: budget) } let(:group_all_city) { create(:budget_group, budget: budget) }
let!(:heading_all_city) { create(:budget_heading, group: group_all_city) } let!(:heading_all_city) { create(:budget_heading, group: group_all_city) }
scenario "Number of supports in investment projects" do scenario "Number of supports in investment projects", :js do
group_2 = create(:budget_group, budget: budget) group_2 = create(:budget_group, budget: budget)
create(:budget_investment, heading: create(:budget_heading, group: group_2), voters: [create(:user)]) create(:budget_investment, heading: create(:budget_heading, group: group_2), voters: [create(:user)])
@@ -104,7 +104,7 @@ describe "Stats", :admin do
click_link "Supporting phase" click_link "Supporting phase"
end end
expect(page).to have_content "Votes 3" expect(page).to have_content "VOTES\n3"
expect(page).to have_link "Go back", count: 1 expect(page).to have_link "Go back", count: 1
end end
@@ -123,7 +123,7 @@ describe "Stats", :admin do
click_link "Supporting phase" click_link "Supporting phase"
end end
expect(page).to have_content "Participants 2" expect(page).to have_content "PARTICIPANTS\n2"
end end
scenario "Number of users that have supported investments projects per geozone" do scenario "Number of users that have supported investments projects per geozone" do
@@ -196,7 +196,7 @@ describe "Stats", :admin do
click_link "Final voting" click_link "Final voting"
end end
expect(page).to have_content "Votes 3" expect(page).to have_content "VOTES\n3"
end end
scenario "Number of users that have voted a investment project" do scenario "Number of users that have voted a investment project" do
@@ -210,7 +210,7 @@ describe "Stats", :admin do
click_link "Final voting" click_link "Final voting"
end end
expect(page).to have_content "Participants 2" expect(page).to have_content "PARTICIPANTS\n2"
end end
end end
end end

View File

@@ -188,14 +188,14 @@ describe "Cards", :admin do
expect(page).to have_css("#widget_card_#{card_3.id}.medium-2") expect(page).to have_css("#widget_card_#{card_3.id}.medium-2")
end end
scenario "Show label only if it is present" do scenario "Show label only if it is present", :js do
card_1 = create(:widget_card, cardable: custom_page, title: "Card one", label: "My label") card_1 = create(:widget_card, cardable: custom_page, title: "Card one", label: "My label")
card_2 = create(:widget_card, cardable: custom_page, title: "Card two") card_2 = create(:widget_card, cardable: custom_page, title: "Card two")
visit custom_page.url visit custom_page.url
within("#widget_card_#{card_1.id}") do within("#widget_card_#{card_1.id}") do
expect(page).to have_selector("span", text: "My label") expect(page).to have_selector("span", text: "MY LABEL")
end end
within("#widget_card_#{card_2.id}") do within("#widget_card_#{card_2.id}") do

View File

@@ -16,7 +16,7 @@ describe "Budgets" do
end end
context "Index" do context "Index" do
scenario "Show normal index with links" do scenario "Show normal index with links", :js do
group1 = create(:budget_group, budget: budget) group1 = create(:budget_group, budget: budget)
group2 = create(:budget_group, budget: budget) group2 = create(:budget_group, budget: budget)
heading1 = create(:budget_heading, group: group1) heading1 = create(:budget_heading, group: group1)
@@ -33,7 +33,7 @@ describe "Budgets" do
end end
within(".budget-subheader") do within(".budget-subheader") do
expect(page).to have_content "Current phase" expect(page).to have_content "CURRENT PHASE"
expect(page).to have_content "Information" expect(page).to have_content "Information"
end end
@@ -99,7 +99,7 @@ describe "Budgets" do
end end
end end
scenario "Show informing index without links" do scenario "Show informing index without links", :js do
budget.update!(phase: "informing") budget.update!(phase: "informing")
heading = create(:budget_heading, budget: budget) heading = create(:budget_heading, budget: budget)
@@ -107,7 +107,7 @@ describe "Budgets" do
within("#budget_info") do within("#budget_info") do
expect(page).not_to have_link heading.name expect(page).not_to have_link heading.name
expect(page).to have_content "#{heading.name} €1,000,000" expect(page).to have_content "#{heading.name}\n€1,000,000"
expect(page).not_to have_link("List of all investment projects") expect(page).not_to have_link("List of all investment projects")
expect(page).not_to have_link("List of all unfeasible investment projects") expect(page).not_to have_link("List of all unfeasible investment projects")
@@ -117,7 +117,7 @@ describe "Budgets" do
end end
end end
scenario "Show finished index without heading links" do scenario "Show finished index without heading links", :js do
budget.update!(phase: "finished") budget.update!(phase: "finished")
heading = create(:budget_heading, budget: budget) heading = create(:budget_heading, budget: budget)
@@ -125,7 +125,7 @@ describe "Budgets" do
within("#budget_info") do within("#budget_info") do
expect(page).not_to have_link heading.name expect(page).not_to have_link heading.name
expect(page).to have_content "#{heading.name} €1,000,000" expect(page).to have_content "#{heading.name}\n€1,000,000"
expect(page).to have_css("div.map") expect(page).to have_css("div.map")
end end

View File

@@ -305,7 +305,7 @@ describe "Budget Investments" do
expect(order).to eq(new_order) expect(order).to eq(new_order)
end end
scenario "Random order maintained with pagination" do scenario "Random order maintained with pagination", :js do
(per_page + 2).times { create(:budget_investment, heading: heading) } (per_page + 2).times { create(:budget_investment, heading: heading) }
visit budget_investments_path(budget, heading_id: heading.id) visit budget_investments_path(budget, heading_id: heading.id)
@@ -314,10 +314,10 @@ describe "Budget Investments" do
expect(order).not_to be_empty expect(order).not_to be_empty
click_link "Next" click_link "Next"
expect(page).to have_content "You're on page 2" expect(page).to have_css ".pagination .current", text: "2"
click_link "Previous" click_link "Previous"
expect(page).to have_content "You're on page 1" expect(page).to have_css ".pagination .current", text: "1"
new_order = all(".budget-investment h3").map(&:text) new_order = all(".budget-investment h3").map(&:text)
expect(order).to eq(new_order) expect(order).to eq(new_order)
@@ -338,7 +338,7 @@ describe "Budget Investments" do
expect(order).to eq(new_order) expect(order).to eq(new_order)
end end
scenario "Investments are not repeated with random order" do scenario "Investments are not repeated with random order", :js do
(per_page + 2).times { create(:budget_investment, heading: heading) } (per_page + 2).times { create(:budget_investment, heading: heading) }
visit budget_investments_path(budget, order: "random") visit budget_investments_path(budget, order: "random")
@@ -346,7 +346,7 @@ describe "Budget Investments" do
first_page_investments = investments_order first_page_investments = investments_order
click_link "Next" click_link "Next"
expect(page).to have_content "You're on page 2" expect(page).to have_css ".pagination .current", text: "2"
second_page_investments = investments_order second_page_investments = investments_order
@@ -376,7 +376,7 @@ describe "Budget Investments" do
expect(page).to have_current_path(/page=1/) expect(page).to have_current_path(/page=1/)
end end
scenario "Each user has a different and consistent random budget investment order" do scenario "Each user has a different and consistent random budget investment order", :js do
(per_page * 1.3).to_i.times { create(:budget_investment, heading: heading) } (per_page * 1.3).to_i.times { create(:budget_investment, heading: heading) }
first_user_investments_order = nil first_user_investments_order = nil
second_user_investments_order = nil second_user_investments_order = nil
@@ -395,20 +395,20 @@ describe "Budget Investments" do
in_browser(:one) do in_browser(:one) do
click_link "Next" click_link "Next"
expect(page).to have_content "You're on page 2" expect(page).to have_css ".pagination .current", text: "2"
click_link "Previous" click_link "Previous"
expect(page).to have_content "You're on page 1" expect(page).to have_css ".pagination .current", text: "1"
expect(investments_order).to eq(first_user_investments_order) expect(investments_order).to eq(first_user_investments_order)
end end
in_browser(:two) do in_browser(:two) do
click_link "Next" click_link "Next"
expect(page).to have_content "You're on page 2" expect(page).to have_css ".pagination .current", text: "2"
click_link "Previous" click_link "Previous"
expect(page).to have_content "You're on page 1" expect(page).to have_css ".pagination .current", text: "1"
expect(investments_order).to eq(second_user_investments_order) expect(investments_order).to eq(second_user_investments_order)
end end
@@ -919,7 +919,7 @@ describe "Budget Investments" do
expect(page).to have_content("This investment project has not been selected for balloting phase") expect(page).to have_content("This investment project has not been selected for balloting phase")
end end
scenario "Show title (no message)" do scenario "Show title (no message)", :js do
investment = create(:budget_investment, investment = create(:budget_investment,
:feasible, :feasible,
:finished, :finished,
@@ -932,7 +932,7 @@ describe "Budget Investments" do
visit budget_investment_path(budget, id: investment.id) visit budget_investment_path(budget, id: investment.id)
within("aside") do within("aside") do
expect(page).to have_content("Investment project") expect(page).to have_content("INVESTMENT PROJECT")
expect(page).to have_css(".label-budget-investment") expect(page).to have_css(".label-budget-investment")
end end
end end
@@ -1080,12 +1080,12 @@ describe "Budget Investments" do
end end
end end
scenario "Sidebar in show should display support text" do scenario "Sidebar in show should display support text", :js do
investment = create(:budget_investment, budget: budget) investment = create(:budget_investment, budget: budget)
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("aside") do within("aside") do
expect(page).to have_content "Supports" expect(page).to have_content "SUPPORTS"
end end
end end
end end
@@ -1095,13 +1095,13 @@ describe "Budget Investments" do
budget.update(phase: "valuating") budget.update(phase: "valuating")
end end
scenario "Sidebar in show should display support text and count" do scenario "Sidebar in show should display support text and count", :js do
investment = create(:budget_investment, :selected, budget: budget, voters: [create(:user)]) investment = create(:budget_investment, :selected, budget: budget, voters: [create(:user)])
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("aside") do within("aside") do
expect(page).to have_content "Supports" expect(page).to have_content "SUPPORTS"
expect(page).to have_content "1 support" expect(page).to have_content "1 support"
end end
end end
@@ -1116,13 +1116,13 @@ describe "Budget Investments" do
end end
end end
scenario "Show should display support text and count" do scenario "Show should display support text and count", :js do
investment = create(:budget_investment, budget: budget, heading: heading, voters: [create(:user)]) investment = create(:budget_investment, budget: budget, heading: heading, voters: [create(:user)])
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
expect(page).to have_content "Supports" expect(page).to have_content "SUPPORTS"
expect(page).to have_content "1 support" expect(page).to have_content "1 support"
end end
end end
@@ -1209,12 +1209,12 @@ describe "Budget Investments" do
expect(page).to have_content "€10,000" expect(page).to have_content "€10,000"
end end
scenario "Sidebar in show should display vote text" do scenario "Sidebar in show should display vote text", :js do
investment = create(:budget_investment, :selected, budget: budget) investment = create(:budget_investment, :selected, budget: budget)
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("aside") do within("aside") do
expect(page).to have_content "Votes" expect(page).to have_content "VOTES"
end end
end end
@@ -1304,7 +1304,7 @@ describe "Budget Investments" do
end end
end end
scenario "Ballot is visible" do scenario "Ballot is visible", :js do
login_as(author) login_as(author)
visit budget_investments_path(budget, heading_id: heading.id) visit budget_investments_path(budget, heading_id: heading.id)
@@ -1313,7 +1313,7 @@ describe "Budget Investments" do
expect(page).to have_css("#progress_bar") expect(page).to have_css("#progress_bar")
within("#sidebar") do within("#sidebar") do
expect(page).to have_content("My ballot") expect(page).to have_content("MY BALLOT")
expect(page).to have_link("Submit my ballot") expect(page).to have_link("Submit my ballot")
end end
end end
@@ -1505,20 +1505,20 @@ describe "Budget Investments" do
end end
end end
scenario "Contains edit button in the accepting phase" do scenario "Contains edit button in the accepting phase", :js do
investment = create(:budget_investment, heading: heading, author: author) investment = create(:budget_investment, heading: heading, author: author)
login_as(author) login_as(author)
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("aside") do within("aside") do
expect(page).to have_content "Author" expect(page).to have_content "AUTHOR"
expect(page).to have_link "Edit" expect(page).to have_link "Edit"
expect(page).not_to have_link "Remove image" expect(page).not_to have_link "Remove image"
end end
end end
scenario "Contains remove image button in phases different from accepting" do scenario "Contains remove image button in phases different from accepting", :js do
budget.update!(phase: "reviewing") budget.update!(phase: "reviewing")
investment = create(:budget_investment, :with_image, heading: heading, author: author) investment = create(:budget_investment, :with_image, heading: heading, author: author)
@@ -1526,7 +1526,7 @@ describe "Budget Investments" do
visit budget_investment_path(budget, investment) visit budget_investment_path(budget, investment)
within("aside") do within("aside") do
expect(page).to have_content "Author" expect(page).to have_content "AUTHOR"
expect(page).not_to have_link "Edit" expect(page).not_to have_link "Edit"
expect(page).to have_link "Remove image" expect(page).to have_link "Remove image"
end end

View File

@@ -2,7 +2,7 @@ require "rails_helper"
describe "Communities" do describe "Communities" do
context "Show" do context "Show" do
scenario "Should display default content" do scenario "Should display default content", :js do
proposal = create(:proposal) proposal = create(:proposal)
community = proposal.community community = proposal.community
user = create(:user) user = create(:user)
@@ -10,7 +10,7 @@ describe "Communities" do
visit community_path(community) visit community_path(community)
expect(page).to have_content "Proposal community" expect(page).to have_content "PROPOSAL COMMUNITY"
expect(page).to have_content proposal.title expect(page).to have_content proposal.title
expect(page).to have_content "Participate in the community of this proposal" expect(page).to have_content "Participate in the community of this proposal"
expect(page).to have_link("Create topic", href: new_community_topic_path(community)) expect(page).to have_link("Create topic", href: new_community_topic_path(community))

View File

@@ -379,7 +379,7 @@ describe "Proposal's dashboard" do
anchor: "tab-notifications")) anchor: "tab-notifications"))
end end
scenario "Dashboard has a related content section" do scenario "Dashboard has a related content section", :js do
related_debate = create(:debate) related_debate = create(:debate)
related_proposal = create(:proposal) related_proposal = create(:proposal)
@@ -399,9 +399,9 @@ describe "Proposal's dashboard" do
within(".dashboard-related-content") do within(".dashboard-related-content") do
expect(page).to have_content("Related content (2)") expect(page).to have_content("Related content (2)")
expect(page).to have_selector(".related-content-title", text: "Proposal") expect(page).to have_selector(".related-content-title", text: "PROPOSAL")
expect(page).to have_link related_proposal.title expect(page).to have_link related_proposal.title
expect(page).to have_selector(".related-content-title", text: "Debate") expect(page).to have_selector(".related-content-title", text: "DEBATE")
expect(page).to have_link related_debate.title expect(page).to have_link related_debate.title
end end
end end

View File

@@ -800,13 +800,14 @@ describe "Debates" do
end end
end end
scenario "Index include featured debates", :admin do scenario "Index include featured debates", :admin, :js do
create(:debate, featured_at: Time.current) create(:debate, featured_at: Time.current)
create(:debate) create(:debate)
visit debates_path visit debates_path
within("#debates") do within("#debates") do
expect(page).to have_content("Featured") expect(page).to have_content("FEATURED")
end end
end end

View File

@@ -162,17 +162,17 @@ describe "Legislation" do
end end
end end
scenario "show draft publication and final result publication dates" do scenario "show draft publication and final result publication dates", :js do
process = create(:legislation_process, draft_publication_date: Date.new(2019, 01, 10), process = create(:legislation_process, draft_publication_date: Date.new(2019, 01, 10),
result_publication_date: Date.new(2019, 01, 20)) result_publication_date: Date.new(2019, 01, 20))
visit legislation_process_path(process) visit legislation_process_path(process)
within("aside") do within("aside") do
expect(page).to have_content("Draft publication") expect(page).to have_content "DRAFT PUBLICATION"
expect(page).to have_content("10 Jan 2019") expect(page).to have_content "10 Jan 2019"
expect(page).to have_content("Final result publication") expect(page).to have_content "FINAL RESULT PUBLICATION"
expect(page).to have_content("20 Jan 2019") expect(page).to have_content "20 Jan 2019"
end end
end end

View File

@@ -82,11 +82,11 @@ describe "Legislation Proposals" do
expect(legislation_proposals_order).to eq(first_page_proposals_order) expect(legislation_proposals_order).to eq(first_page_proposals_order)
end end
scenario "Does not crash when the seed is not a number" do scenario "Does not crash when the seed is not a number", :js do
login_as user login_as user
visit legislation_process_proposals_path(process, random_seed: "Spoof") visit legislation_process_proposals_path(process, random_seed: "Spoof")
expect(page).to have_content "You're on page 1" expect(page).to have_content "Random"
end end
end end
@@ -200,13 +200,13 @@ describe "Legislation Proposals" do
expect(page).to have_content("-6 votes") expect(page).to have_content("-6 votes")
end end
scenario "Show link to process on show" do scenario "Show link to process on show", :js do
create(:legislation_proposal, legislation_process_id: process.id) create(:legislation_proposal, legislation_process_id: process.id)
visit legislation_process_proposal_path(proposal.process, proposal) visit legislation_process_proposal_path(proposal.process, proposal)
within(".process-proposal") do within(".process-proposal") do
expect(page).to have_content("Collaborative legislation process") expect(page).to have_content("COLLABORATIVE LEGISLATION PROCESS")
expect(page).to have_link(process.title) expect(page).to have_link(process.title)
end end
end end

View File

@@ -14,7 +14,7 @@ describe "Legislation" do
create(:legislation_question, process: process, title: "Question 3") create(:legislation_question, process: process, title: "Question 3")
end end
scenario "shows question list" do scenario "shows question list", :js do
visit legislation_process_path(process) visit legislation_process_path(process)
expect(page).to have_content("Participate in the debate") expect(page).to have_content("Participate in the debate")
@@ -26,17 +26,17 @@ describe "Legislation" do
click_link "Question 1" click_link "Question 1"
expect(page).to have_content("Question 1") expect(page).to have_content("Question 1")
expect(page).to have_content("Next question") expect(page).to have_content("NEXT QUESTION")
click_link "Next question" click_link "Next question"
expect(page).to have_content("Question 2") expect(page).to have_content("Question 2")
expect(page).to have_content("Next question") expect(page).to have_content("NEXT QUESTION")
click_link "Next question" click_link "Next question"
expect(page).to have_content("Question 3") expect(page).to have_content("Question 3")
expect(page).not_to have_content("Next question") expect(page).not_to have_content("NEXT QUESTION")
end end
scenario "shows question page" do scenario "shows question page" do
@@ -46,21 +46,21 @@ describe "Legislation" do
expect(page).to have_content("Open answers (0)") expect(page).to have_content("Open answers (0)")
end end
scenario "shows next question link in question page" do scenario "shows next question link in question page", :js do
visit legislation_process_question_path(process, process.questions.first) visit legislation_process_question_path(process, process.questions.first)
expect(page).to have_content("Question 1") expect(page).to have_content("Question 1")
expect(page).to have_content("Next question") expect(page).to have_content("NEXT QUESTION")
click_link "Next question" click_link "Next question"
expect(page).to have_content("Question 2") expect(page).to have_content("Question 2")
expect(page).to have_content("Next question") expect(page).to have_content("NEXT QUESTION")
click_link "Next question" click_link "Next question"
expect(page).to have_content("Question 3") expect(page).to have_content("Question 3")
expect(page).not_to have_content("Next question") expect(page).not_to have_content("NEXT QUESTION")
end end
scenario "answer question", :no_js do scenario "answer question", :no_js do

View File

@@ -87,13 +87,13 @@ describe "Custom Pages" do
expect(page).to have_content("Subtitle for custom page") expect(page).to have_content("Subtitle for custom page")
end end
scenario "Show widget cards for that page" do scenario "Show widget cards for that page", :js do
custom_page = create(:site_customization_page, :published) custom_page = create(:site_customization_page, :published)
create(:widget_card, cardable: custom_page, title: "Card Highlights") create(:widget_card, cardable: custom_page, title: "Card Highlights")
visit custom_page.url visit custom_page.url
expect(page).to have_content "Card Highlights" expect(page).to have_content "CARD HIGHLIGHTS"
end end
end end
end end

View File

@@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
describe "Stats" do describe "Stats", :js do
context "Summary" do context "Summary" do
scenario "General" do scenario "General" do
create(:debate) create(:debate)
@@ -10,10 +10,10 @@ describe "Stats" do
visit stats_path visit stats_path
expect(page).to have_content "Debates 1" expect(page).to have_content "DEBATES\n1"
expect(page).to have_content "Proposals 2" expect(page).to have_content "PROPOSALS\n2"
expect(page).to have_content "Comments 3" expect(page).to have_content "COMMENTS\n3"
expect(page).to have_content "Visits 4" expect(page).to have_content "VISITS\n4"
end end
scenario "Votes" do scenario "Votes" do
@@ -23,10 +23,10 @@ describe "Stats" do
visit stats_path visit stats_path
expect(page).to have_content "Votes on debates 1" expect(page).to have_content "VOTES ON DEBATES\n1"
expect(page).to have_content "Votes on proposals 2" expect(page).to have_content "VOTES ON PROPOSALS\n2"
expect(page).to have_content "Votes on comments 3" expect(page).to have_content "VOTES ON COMMENTS\n3"
expect(page).to have_content "Total votes 6" expect(page).to have_content "TOTAL VOTES\n6"
end end
scenario "Users" do scenario "Users" do
@@ -36,8 +36,8 @@ describe "Stats" do
visit stats_path visit stats_path
expect(page).to have_content "Verified users 3" expect(page).to have_content "VERIFIED USERS\n3"
expect(page).to have_content "Unverified users 2" expect(page).to have_content "UNVERIFIED USERS\n2"
end end
end end
end end