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
|
||||
|
||||
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")
|
||||
valuator = create(:valuator, user: user)
|
||||
budget_investment = create(:budget_investment,
|
||||
@@ -948,8 +948,7 @@ describe "Admin budget investments", :admin do
|
||||
|
||||
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(budget_investment.title)
|
||||
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"
|
||||
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,
|
||||
:with_image,
|
||||
:unfeasible,
|
||||
@@ -980,8 +980,7 @@ describe "Admin budget investments", :admin do
|
||||
|
||||
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.description)
|
||||
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("Ana (ana@admins.org)")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Does not show related content or hide links on preview" do
|
||||
budget_investment = create(:budget_investment,
|
||||
@@ -1013,17 +1013,14 @@ describe "Admin budget investments", :admin do
|
||||
expect(page).not_to have_content("Hide")
|
||||
end
|
||||
|
||||
scenario "If budget is finished, investment cannot be edited or valuation comments created" do
|
||||
# Only milestones can be managed
|
||||
|
||||
scenario "If budget is finished, investment cannot be edited or valuation comments created", :js do
|
||||
finished_budget = create(:budget, :finished)
|
||||
budget_investment = create(:budget_investment,
|
||||
budget: finished_budget,
|
||||
administrator: administrator)
|
||||
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 classification"
|
||||
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"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Edit" 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
|
||||
end
|
||||
|
||||
scenario "The username links to their public profile" do
|
||||
click_link user.name
|
||||
|
||||
scenario "The username links to their public profile", :js do
|
||||
within_window(window_opened_by { click_link user.name }) do
|
||||
expect(page).to have_current_path(user_path(user))
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Show active or erased users using filters" do
|
||||
erased_user = create(:user, username: "Erased")
|
||||
|
||||
@@ -609,7 +609,7 @@ describe "Proposals" do
|
||||
end
|
||||
|
||||
context "Retired proposals" do
|
||||
scenario "Retire" do
|
||||
scenario "Retire", :js do
|
||||
proposal = create(:proposal)
|
||||
login_as(proposal.author)
|
||||
|
||||
@@ -622,8 +622,7 @@ describe "Proposals" do
|
||||
click_link "Edit my proposal"
|
||||
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))
|
||||
|
||||
select "Duplicated", from: "proposal_retired_reason"
|
||||
@@ -631,6 +630,7 @@ describe "Proposals" do
|
||||
click_button "Retire proposal"
|
||||
|
||||
expect(page).to have_content "Proposal retired"
|
||||
end
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user