diff --git a/test/system/profile_interface_test.rb b/test/system/profile_interface_test.rb deleted file mode 100644 index 9a6fa0df673..00000000000 --- a/test/system/profile_interface_test.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "application_system_test_case" -require "test_helper" - -class ProfileInterfaceTest < ApplicationSystemTestCase - setup do - @user = create(:user, email: "nick@example.com", password: PasswordHelpers::SECURE_TEST_PASSWORD, handle: "nick1", mail_fails: 1) - end - - def sign_in - visit sign_in_path - fill_in "Email or Username", with: @user.reload.email - fill_in "Password", with: @user.password - click_button "Sign in" - end - - test "adding X(formerly Twitter) username without filling in your password" do - twitter_username = "nick1twitter" - - sign_in - visit profile_path("nick1") - - click_link "Edit Profile" - fill_in "user_twitter_username", with: twitter_username - - assert_equal twitter_username, page.find_by_id("user_twitter_username").value - - click_button "Update" - - # Verify that the newly added Twitter username is still on the form so that the user does not need to re-enter it - assert_equal twitter_username, page.find_by_id("user_twitter_username").value - - fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD - click_button "Update" - - assert page.has_content? "Your profile was updated." - assert_equal twitter_username, page.find_by_id("user_twitter_username").value - end -end diff --git a/test/integration/profile_test.rb b/test/system/profile_test.rb similarity index 80% rename from test/integration/profile_test.rb rename to test/system/profile_test.rb index 8585cfed4ad..6e00a0e8840 100644 --- a/test/integration/profile_test.rb +++ b/test/system/profile_test.rb @@ -1,6 +1,7 @@ +require "application_system_test_case" require "test_helper" -class ProfileTest < SystemTest +class ProfileTest < ApplicationSystemTestCase include ActiveJob::TestHelper setup do @@ -15,7 +16,7 @@ def sign_in end def sign_out - page.driver.browser.clear_cookies # rack-test specific + reset_session! visit "/" end @@ -31,7 +32,7 @@ def sign_out fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD click_button "Update" - assert page.has_content? "nick2" + assert_equal "nick2", page.find_field("user_handle").value end test "changing to an existing handle" do @@ -127,20 +128,45 @@ def sign_out fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD click_button "Update" - click_link "Sign out" + sign_out visit profile_path("nick1") assert page.has_link?("@nick1", href: "https://twitter.com/nick1") end + test "adding X(formerly Twitter) username without filling in your password" do + twitter_username = "nick1twitter" + + sign_in + visit profile_path("nick1") + + click_link "Edit Profile" + fill_in "user_twitter_username", with: twitter_username + + assert_equal twitter_username, page.find_by_id("user_twitter_username").value + + click_button "Update" + + # Verify that the newly added Twitter username is still on the form so that the user does not need to re-enter it + assert_equal twitter_username, page.find_by_id("user_twitter_username").value + + fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD + click_button "Update" + + assert page.has_content? "Your profile was updated." + assert_equal twitter_username, page.find_by_id("user_twitter_username").value + end + test "deleting profile" do sign_in visit profile_path("nick1") click_link "Edit Profile" click_button "Delete" - fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD - click_button "Confirm" + accept_confirm do + fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD + click_button "Confirm" + end assert page.has_content? "Your account deletion request has been enqueued. " \ "We will send you a confirmation mail when your request has been processed." @@ -150,16 +176,20 @@ def sign_out sign_in visit delete_profile_path - fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD - click_button "Confirm" + accept_confirm do + fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD + click_button "Confirm" + end sign_in visit delete_profile_path 2.times { perform_enqueued_jobs } - fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD - click_button "Confirm" + accept_confirm do + fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD + click_button "Confirm" + end assert_no_enqueued_jobs end @@ -189,9 +219,9 @@ def sign_out downloads = page.all(".gems__gem__downloads__count") - assert_equal("7 Downloads", downloads[0].text) - assert_equal("5 Downloads", downloads[1].text) - assert_equal("2 Downloads", downloads[2].text) + assert_equal("7\nDOWNLOADS", downloads[0].text) + assert_equal("5\nDOWNLOADS", downloads[1].text) + assert_equal("2\nDOWNLOADS", downloads[2].text) end test "seeing the latest version when there is a newer previous version" do