Skip to content

A platform for community discussion. Free, open, simple.

DEV: Improve `PageObjects::Pages::UserPreferencesSecurity#visit_second_factor` (#32017)

Alan Guo Xiang Tanac26a52c6d88
diff --git a/spec/system/email_change_spec.rb b/spec/system/email_change_spec.rb
index 4af59c10816..3d473eb8b23 100644
--- a/spec/system/email_change_spec.rb
+++ b/spec/system/email_change_spec.rb
@@ -83,7 +83,7 @@ describe "Changing email", type: :system do
authenticator = page.driver.browser.add_virtual_authenticator(options)
user_preferences_security_page.visit(user)
- user_preferences_security_page.visit_second_factor(password)
+ user_preferences_security_page.visit_second_factor(user, password)
find(".security-key .new-security-key").click
expect(user_preferences_security_page).to have_css("input#security-key-name")
diff --git a/spec/system/forgot_password_spec.rb b/spec/system/forgot_password_spec.rb
index 34885e492b6..7a73d8fc038 100644
--- a/spec/system/forgot_password_spec.rb
+++ b/spec/system/forgot_password_spec.rb
@@ -27,7 +27,7 @@ shared_examples "forgot password scenarios" do
sign_in(user)
user_preferences_security_page.visit(user)
- user_preferences_security_page.visit_second_factor("supersecurepassword")
+ user_preferences_security_page.visit_second_factor(user, "supersecurepassword")
find(".security-key .new-security-key").click
expect(user_preferences_security_page).to have_css("input#security-key-name")
diff --git a/spec/system/page_objects/pages/user_preferences_security.rb b/spec/system/page_objects/pages/user_preferences_security.rb
index fe1abed1b90..6dbbc8538bd 100644
--- a/spec/system/page_objects/pages/user_preferences_security.rb
+++ b/spec/system/page_objects/pages/user_preferences_security.rb
@@ -8,11 +8,11 @@ module PageObjects
self
end
- def visit_second_factor(password)
+ def visit_second_factor(user, password)
click_button "Manage Two-Factor Authentication"
find(".confirm-session input#password").fill_in(with: password)
find(".confirm-session .btn-primary:not([disabled])").click
- has_no_css?(".confirm-session")
+ expect(page).to have_current_path("/u/#{user.username}/preferences/second-factor")
self
end
end
diff --git a/spec/system/user_page/user_preferences_security_spec.rb b/spec/system/user_page/user_preferences_security_spec.rb
index e96ef406d41..fbab198114e 100644
--- a/spec/system/user_page/user_preferences_security_spec.rb
+++ b/spec/system/user_page/user_preferences_security_spec.rb
@@ -24,7 +24,7 @@ describe "User preferences | Security", type: :system do
authenticator = page.driver.browser.add_virtual_authenticator(options)
user_preferences_security_page.visit(user)
- user_preferences_security_page.visit_second_factor(password)
+ user_preferences_security_page.visit_second_factor(user, password)
find(".security-key .new-security-key").click
expect(user_preferences_security_page).to have_css("input#security-key-name")