Use JavaScript in tests with flash messages
So now we feel in the tests the same usability problems users feel when they want to click a link and the flash message is in their way.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Sessions" do
|
||||
scenario "Staying in the same page after doing login/logout" do
|
||||
scenario "Staying in the same page after doing login/logout", :js do
|
||||
user = create(:user, sign_in_count: 10)
|
||||
debate = create(:debate)
|
||||
|
||||
@@ -14,6 +14,8 @@ describe "Sessions" do
|
||||
expect(page).to have_content("You have been signed in successfully")
|
||||
expect(page).to have_current_path(debate_path(debate))
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
|
||||
click_link "Sign out"
|
||||
|
||||
expect(page).to have_content("You have been signed out successfully")
|
||||
|
||||
@@ -57,7 +57,7 @@ describe "Users" do
|
||||
expect(page).to have_content "You have been signed in successfully."
|
||||
end
|
||||
|
||||
scenario "Avoid username-email collisions" do
|
||||
scenario "Avoid username-email collisions", :js do
|
||||
u1 = create(:user, username: "Spidey", email: "peter@nyc.dev", password: "greatpower")
|
||||
u2 = create(:user, username: "peter@nyc.dev", email: "venom@nyc.dev", password: "symbiote")
|
||||
|
||||
@@ -78,6 +78,7 @@ describe "Users" do
|
||||
|
||||
expect(page).to have_content "You have been signed out successfully."
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "Sign in"
|
||||
fill_in "user_login", with: "peter@nyc.dev"
|
||||
fill_in "user_password", with: "symbiote"
|
||||
@@ -212,7 +213,7 @@ describe "Users" do
|
||||
}
|
||||
end
|
||||
|
||||
scenario "Sign up when Oauth provider has a verified email" do
|
||||
scenario "Sign up when Oauth provider has a verified email", :js do
|
||||
OmniAuth.config.add_mock(:twitter, twitter_hash_with_verified_email)
|
||||
|
||||
visit "/"
|
||||
@@ -222,14 +223,16 @@ describe "Users" do
|
||||
|
||||
expect_to_be_signed_in
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_field("account_username", with: "manuela")
|
||||
|
||||
visit edit_user_registration_path
|
||||
expect(page).to have_field("user_email", with: "manuelacarmena@example.com")
|
||||
end
|
||||
|
||||
scenario "Sign up when Oauth provider has an unverified email" do
|
||||
scenario "Sign up when Oauth provider has an unverified email", :js do
|
||||
OmniAuth.config.add_mock(:twitter, twitter_hash_with_email)
|
||||
|
||||
visit "/"
|
||||
@@ -248,14 +251,16 @@ describe "Users" do
|
||||
click_link "Sign in with Twitter"
|
||||
expect_to_be_signed_in
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_field("account_username", with: "manuela")
|
||||
|
||||
visit edit_user_registration_path
|
||||
expect(page).to have_field("user_email", with: "manuelacarmena@example.com")
|
||||
end
|
||||
|
||||
scenario "Sign up, when no email was provided by OAuth provider" do
|
||||
scenario "Sign up, when no email was provided by OAuth provider", :js do
|
||||
OmniAuth.config.add_mock(:twitter, twitter_hash)
|
||||
|
||||
visit "/"
|
||||
@@ -276,7 +281,9 @@ describe "Users" do
|
||||
click_link "Sign in with Twitter"
|
||||
expect_to_be_signed_in
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_field("account_username", with: "manuela")
|
||||
|
||||
visit edit_user_registration_path
|
||||
@@ -297,7 +304,7 @@ describe "Users" do
|
||||
expect_not_to_be_signed_in
|
||||
end
|
||||
|
||||
scenario "Sign in, user was already signed up with OAuth" do
|
||||
scenario "Sign in, user was already signed up with OAuth", :js do
|
||||
user = create(:user, email: "manuela@consul.dev", password: "judgementday")
|
||||
create(:identity, uid: "12345", provider: "twitter", user: user)
|
||||
OmniAuth.config.add_mock(:twitter, twitter_hash)
|
||||
@@ -308,7 +315,9 @@ describe "Users" do
|
||||
|
||||
expect_to_be_signed_in
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_field("account_username", with: user.username)
|
||||
|
||||
visit edit_user_registration_path
|
||||
@@ -343,7 +352,7 @@ describe "Users" do
|
||||
expect(page).to have_field("user_email", with: "manuelacarmena@example.com")
|
||||
end
|
||||
|
||||
scenario "Try to register with the email of an already existing user, when no email was provided by oauth" do
|
||||
scenario "Try to register with the email of an already existing user, when no email was provided by oauth", :js do
|
||||
create(:user, username: "peter", email: "manuela@example.com")
|
||||
OmniAuth.config.add_mock(:twitter, twitter_hash)
|
||||
|
||||
@@ -371,14 +380,16 @@ describe "Users" do
|
||||
click_link "Sign in with Twitter"
|
||||
expect_to_be_signed_in
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_field("account_username", with: "manuela")
|
||||
|
||||
visit edit_user_registration_path
|
||||
expect(page).to have_field("user_email", with: "somethingelse@example.com")
|
||||
end
|
||||
|
||||
scenario "Try to register with the email of an already existing user, when an unconfirmed email was provided by oauth" do
|
||||
scenario "Try to register with the email of an already existing user, when an unconfirmed email was provided by oauth", :js do
|
||||
create(:user, username: "peter", email: "manuelacarmena@example.com")
|
||||
OmniAuth.config.add_mock(:twitter, twitter_hash_with_email)
|
||||
|
||||
@@ -402,7 +413,9 @@ describe "Users" do
|
||||
click_link "Sign in with Twitter"
|
||||
expect_to_be_signed_in
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_field("account_username", with: "manuela")
|
||||
|
||||
visit edit_user_registration_path
|
||||
@@ -421,7 +434,7 @@ describe "Users" do
|
||||
|
||||
before { Setting["feature.wordpress_login"] = true }
|
||||
|
||||
scenario "Sign up" do
|
||||
scenario "Sign up", :js do
|
||||
OmniAuth.config.add_mock(:wordpress_oauth2, wordpress_hash)
|
||||
|
||||
visit "/"
|
||||
@@ -440,14 +453,16 @@ describe "Users" do
|
||||
click_link "Sign in with Wordpress"
|
||||
expect_to_be_signed_in
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_field("account_username", with: "manuela")
|
||||
|
||||
visit edit_user_registration_path
|
||||
expect(page).to have_field("user_email", with: "manuelacarmena@example.com")
|
||||
end
|
||||
|
||||
scenario "Try to register with username and email of an already existing user" do
|
||||
scenario "Try to register with username and email of an already existing user", :js do
|
||||
create(:user, username: "manuela", email: "manuelacarmena@example.com", password: "judgementday")
|
||||
OmniAuth.config.add_mock(:wordpress_oauth2, wordpress_hash)
|
||||
|
||||
@@ -479,7 +494,9 @@ describe "Users" do
|
||||
|
||||
expect_to_be_signed_in
|
||||
|
||||
within("#notice") { click_button "Close" }
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_field("account_username", with: "manuela2")
|
||||
|
||||
visit edit_user_registration_path
|
||||
|
||||
Reference in New Issue
Block a user