Use JavaScripts in tests opening new windows
IMHO opening new windows is a usability issue which has been known for twenty years since it takes control away from the user and breaks the "back button", but for now we're keeping the same behavior as we already had, while slightly increasing the complexity of the tests (which is a good indicator of a usability issue).
This commit is contained in:
@@ -934,7 +934,7 @@ describe "Admin budget investments", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Show" do
|
context "Show" do
|
||||||
scenario "Show the investment details" do
|
scenario "Show the investment details", :js do
|
||||||
user = create(:user, username: "Rachel", email: "rachel@valuators.org")
|
user = create(:user, username: "Rachel", email: "rachel@valuators.org")
|
||||||
valuator = create(:valuator, user: user)
|
valuator = create(:valuator, user: user)
|
||||||
budget_investment = create(:budget_investment,
|
budget_investment = create(:budget_investment,
|
||||||
@@ -948,8 +948,7 @@ describe "Admin budget investments", :admin do
|
|||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||||
|
|
||||||
click_link budget_investment.title
|
within_window(window_opened_by { click_link budget_investment.title }) do
|
||||||
|
|
||||||
expect(page).to have_content("Investment preview")
|
expect(page).to have_content("Investment preview")
|
||||||
expect(page).to have_content(budget_investment.title)
|
expect(page).to have_content(budget_investment.title)
|
||||||
expect(page).to have_content(budget_investment.description)
|
expect(page).to have_content(budget_investment.description)
|
||||||
@@ -967,8 +966,9 @@ describe "Admin budget investments", :admin do
|
|||||||
|
|
||||||
expect(page).to have_button "Publish comment"
|
expect(page).to have_button "Publish comment"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Show image and documents on investment details" do
|
scenario "Show image and documents on investment details", :js do
|
||||||
budget_investment = create(:budget_investment,
|
budget_investment = create(:budget_investment,
|
||||||
:with_image,
|
:with_image,
|
||||||
:unfeasible,
|
:unfeasible,
|
||||||
@@ -980,8 +980,7 @@ describe "Admin budget investments", :admin do
|
|||||||
|
|
||||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||||
|
|
||||||
click_link budget_investment.title
|
within_window(window_opened_by { click_link budget_investment.title }) do
|
||||||
|
|
||||||
expect(page).to have_content(budget_investment.title)
|
expect(page).to have_content(budget_investment.title)
|
||||||
expect(page).to have_content(budget_investment.description)
|
expect(page).to have_content(budget_investment.description)
|
||||||
expect(page).to have_content(budget_investment.author.name)
|
expect(page).to have_content(budget_investment.author.name)
|
||||||
@@ -997,6 +996,7 @@ describe "Admin budget investments", :admin do
|
|||||||
expect(page).to have_content("It is impossible")
|
expect(page).to have_content("It is impossible")
|
||||||
expect(page).to have_content("Ana (ana@admins.org)")
|
expect(page).to have_content("Ana (ana@admins.org)")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Does not show related content or hide links on preview" do
|
scenario "Does not show related content or hide links on preview" do
|
||||||
budget_investment = create(:budget_investment,
|
budget_investment = create(:budget_investment,
|
||||||
@@ -1013,17 +1013,14 @@ describe "Admin budget investments", :admin do
|
|||||||
expect(page).not_to have_content("Hide")
|
expect(page).not_to have_content("Hide")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "If budget is finished, investment cannot be edited or valuation comments created" do
|
scenario "If budget is finished, investment cannot be edited or valuation comments created", :js do
|
||||||
# Only milestones can be managed
|
|
||||||
|
|
||||||
finished_budget = create(:budget, :finished)
|
finished_budget = create(:budget, :finished)
|
||||||
budget_investment = create(:budget_investment,
|
budget_investment = create(:budget_investment,
|
||||||
budget: finished_budget,
|
budget: finished_budget,
|
||||||
administrator: administrator)
|
administrator: administrator)
|
||||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||||
|
|
||||||
click_link budget_investment.title
|
within_window(window_opened_by { click_link budget_investment.title }) do
|
||||||
|
|
||||||
expect(page).not_to have_link "Edit"
|
expect(page).not_to have_link "Edit"
|
||||||
expect(page).not_to have_link "Edit classification"
|
expect(page).not_to have_link "Edit classification"
|
||||||
expect(page).not_to have_link "Edit dossier"
|
expect(page).not_to have_link "Edit dossier"
|
||||||
@@ -1032,6 +1029,7 @@ describe "Admin budget investments", :admin do
|
|||||||
expect(page).not_to have_button "Publish comment"
|
expect(page).not_to have_button "Publish comment"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "Edit" do
|
context "Edit" do
|
||||||
scenario "Change title, incompatible, description or heading", :js do
|
scenario "Change title, incompatible, description or heading", :js do
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ describe "Admin users" do
|
|||||||
expect(page).to have_content admin.email
|
expect(page).to have_content admin.email
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "The username links to their public profile" do
|
scenario "The username links to their public profile", :js do
|
||||||
click_link user.name
|
within_window(window_opened_by { click_link user.name }) do
|
||||||
|
|
||||||
expect(page).to have_current_path(user_path(user))
|
expect(page).to have_current_path(user_path(user))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Show active or erased users using filters" do
|
scenario "Show active or erased users using filters" do
|
||||||
erased_user = create(:user, username: "Erased")
|
erased_user = create(:user, username: "Erased")
|
||||||
|
|||||||
@@ -609,7 +609,7 @@ describe "Proposals" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Retired proposals" do
|
context "Retired proposals" do
|
||||||
scenario "Retire" do
|
scenario "Retire", :js do
|
||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
login_as(proposal.author)
|
login_as(proposal.author)
|
||||||
|
|
||||||
@@ -622,8 +622,7 @@ describe "Proposals" do
|
|||||||
click_link "Edit my proposal"
|
click_link "Edit my proposal"
|
||||||
end
|
end
|
||||||
|
|
||||||
click_link "Retire proposal"
|
within_window(window_opened_by { click_link "Retire proposal" }) do
|
||||||
|
|
||||||
expect(page).to have_current_path(retire_form_proposal_path(proposal))
|
expect(page).to have_current_path(retire_form_proposal_path(proposal))
|
||||||
|
|
||||||
select "Duplicated", from: "proposal_retired_reason"
|
select "Duplicated", from: "proposal_retired_reason"
|
||||||
@@ -631,6 +630,7 @@ describe "Proposals" do
|
|||||||
click_button "Retire proposal"
|
click_button "Retire proposal"
|
||||||
|
|
||||||
expect(page).to have_content "Proposal retired"
|
expect(page).to have_content "Proposal retired"
|
||||||
|
end
|
||||||
|
|
||||||
visit proposal_path(proposal)
|
visit proposal_path(proposal)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user