diff --git a/app/forms/my/account_form.rb b/app/forms/my/account_form.rb index 730f1b9f88d..d1c4da6205c 100644 --- a/app/forms/my/account_form.rb +++ b/app/forms/my/account_form.rb @@ -44,7 +44,8 @@ class My::AccountForm < ApplicationForm input_width: :small, disabled: @login_via_provider || @login_via_ldap, caption: name_caption, - required: true + required: true, + autocomplete: "given-name" ) f.text_field( @@ -53,16 +54,19 @@ class My::AccountForm < ApplicationForm input_width: :small, disabled: @login_via_provider || @login_via_ldap, caption: name_caption, - required: true + required: true, + autocomplete: "family-name" ) f.text_field( name: :mail, + type: :email, label: User.human_attribute_name(:mail), input_width: :small, disabled: @login_via_ldap, - caption: @login_via_ldap ? t("user.text_change_disabled_for_ldap_login") : nil, - required: true + caption: @login_via_ldap ? I18n.t("user.text_change_disabled_for_ldap_login") : nil, + required: true, + autocomplete: "email" ) end @@ -75,9 +79,9 @@ class My::AccountForm < ApplicationForm def name_caption if @login_via_provider - t("user.text_change_disabled_for_provider_login") + I18n.t("user.text_change_disabled_for_provider_login") elsif @login_via_ldap - t("user.text_change_disabled_for_ldap_login") + I18n.t("user.text_change_disabled_for_ldap_login") end end end diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index f78f9900a4f..c6325cd437a 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -42,7 +42,7 @@ See COPYRIGHT and LICENSE files for more details. tag: :a, scheme: :danger, mobile_icon: :trash, - mobile_label: t("backup.label_delete_token"), + mobile_label: t("account.delete"), size: :medium, href: delete_my_account_info_path, data: { controller: "async-dialog" }, @@ -64,7 +64,10 @@ See COPYRIGHT and LICENSE files for more details. model: @user, url: { action: "update_account" }, lang: current_language, - data: password_confirmation_data_attribute({ turbo: false }) + data: password_confirmation_data_attribute( + { turbo: false, + test_selector: "my-account-form" } + ) ) do |form| render( Primer::Forms::FormList.new( diff --git a/config/locales/en.yml b/config/locales/en.yml index f39bee2b94a..00a3f3f2e04 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1163,7 +1163,7 @@ en: heading: "Delete %{name}'s account?" login_consequences: other: "This account will immediately be removed from the system and the user will no longer be able to log in with their credentials." - self: "Your account will immediately be removed from the system and you will will no longer be able to log in using your credentials." + self: "Your account will immediately be removed from the system and you will no longer be able to log in using your credentials." error_inactive_activation_by_mail: > Your account has not yet been activated. To activate your account, click on the link that was emailed to you. diff --git a/modules/two_factor_authentication/spec/features/account_activation_spec.rb b/modules/two_factor_authentication/spec/features/account_activation_spec.rb index b7281ca345f..a0e06ed7dd0 100644 --- a/modules/two_factor_authentication/spec/features/account_activation_spec.rb +++ b/modules/two_factor_authentication/spec/features/account_activation_spec.rb @@ -37,7 +37,10 @@ RSpec.describe "activating an invited account", activate! visit my_account_path - expect(page).to have_css(".form--field-container", text: user.login) + + within_test_selector "my-account-form" do + expect(page).to have_field "user_username", with: user.login + end end end @@ -61,7 +64,10 @@ RSpec.describe "activating an invited account", wait_for_network_idle visit my_account_path - expect(page).to have_css(".form--field-container", text: user.login) + + within_test_selector "my-account-form" do + expect(page).to have_field "user_username", with: user.login + end end it "handles faulty user input on two factor authentication" do diff --git a/modules/two_factor_authentication/spec/features/shared_two_factor_examples.rb b/modules/two_factor_authentication/spec/features/shared_two_factor_examples.rb index 0c0bbac5aa3..3a7b264d75d 100644 --- a/modules/two_factor_authentication/spec/features/shared_two_factor_examples.rb +++ b/modules/two_factor_authentication/spec/features/shared_two_factor_examples.rb @@ -28,12 +28,14 @@ module SharedTwoFactorExamples def expect_logged_in wait_for_network_idle visit my_account_path - expect(page).to have_css(".form--field-container", text: user.login) + within_test_selector "my-account-form" do + expect(page).to have_field "user_username", with: user.login + end end def expect_not_logged_in visit my_account_path - expect(page).to have_no_css(".form--field-container", text: user.login) + expect(page).to have_no_test_selector("my-account-form") end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 5ac803a00b8..f16fcb8ec14 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -117,7 +117,7 @@ RSpec.describe UsersController do context "when the setting users_deletable_by_self is set to true", with_settings: { users_deletable_by_self: true } do before do - get :deletion_info, params: + get :deletion_info, params:, format: :turbo_stream end it { expect(response).to have_http_status(:success) } @@ -126,13 +126,16 @@ RSpec.describe UsersController do expect(assigns(:user)).to eq(user) end - it { expect(response).to render_template("deletion_info") } + it "renders a dialog" do + expect(response).to be_successful + expect(response).to have_turbo_stream action: "dialog", target: "users-delete-dialog-component" + end end context "when the setting users_deletable_by_self is set to false", with_settings: { users_deletable_by_self: false } do before do - get :deletion_info, params: + get :deletion_info, params:, format: :turbo_stream end it { expect(response).to have_http_status(:not_found) } @@ -143,15 +146,10 @@ RSpec.describe UsersController do current_user { anonymous } before do - get :deletion_info, params: + get :deletion_info, params:, format: :turbo_stream end - it { - expect(response).to redirect_to(controller: "account", - action: "login", - back_url: controller.url_for(controller: "users", - action: "deletion_info")) - } + it { expect(response).to have_http_status(:unauthorized) } end context "when the current user is admin" do @@ -160,7 +158,7 @@ RSpec.describe UsersController do context "when the setting users_deletable_by_admins is set to true", with_settings: { users_deletable_by_admins: true } do before do - get :deletion_info, params: + get :deletion_info, params:, format: :turbo_stream end it { expect(response).to have_http_status(:success) } @@ -169,13 +167,16 @@ RSpec.describe UsersController do expect(assigns(:user)).to eq(user) end - it { expect(response).to render_template("deletion_info") } + it "renders a dialog" do + expect(response).to be_successful + expect(response).to have_turbo_stream action: "dialog", target: "users-delete-dialog-component" + end end context "when the setting users_deletable_by_admins is set to false", with_settings: { users_deletable_by_admins: false } do before do - get :deletion_info, params: + get :deletion_info, params:, format: :turbo_stream end it { expect(response).to have_http_status(:not_found) } diff --git a/spec/features/auth/auth_stages_spec.rb b/spec/features/auth/auth_stages_spec.rb index 0abec6070b7..70d4f61f127 100644 --- a/spec/features/auth/auth_stages_spec.rb +++ b/spec/features/auth/auth_stages_spec.rb @@ -109,7 +109,7 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do visit "/my/account" - expect(page).to have_text "h.wurst" # just double checking we're really logged in + expect(page).to have_text "Hans Wurst" # just double checking we're really logged in end it "redirects to authentication stage after registration via omniauth too" do @@ -129,7 +129,7 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do visit "/my/account" - expect(page).to have_text "a.apfel" # just double checking we're really logged in + expect(page).to have_text "Adam Apfel" # just double checking we're really logged in end end @@ -145,7 +145,9 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do visit "/my/account" - expect(page).to have_text user.login # just checking we're really logged in + within_test_selector "my-account-form" do + expect(page).to have_field "user_username", with: user.login # just checking we're really logged in + end end it "redirects to the login page and shows an error on verification failure" do @@ -161,7 +163,7 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do visit "/my/account" - expect(page).to have_no_text user.login # just checking we're really not logged in + expect(page).to have_no_test_selector "my-account-form" # just checking we're really not logged in end it "redirects to the login page and shows an error on authentication stage failure" do @@ -177,7 +179,7 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do visit "/my/account" - expect(page).to have_no_text user.login # just checking we're really not logged in + expect(page).to have_no_test_selector "my-account-form" # just checking we're really not logged in end it "redirects to the login page and shows an error on returning to the wrong stage" do @@ -193,7 +195,7 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do visit "/my/account" - expect(page).to have_no_text user.login # just checking we're really not logged in + expect(page).to have_no_test_selector "my-account-form" # just checking we're really not logged in end it "redirects to the referer if there is one" do @@ -217,7 +219,9 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do visit "/my/account" - expect(page).to have_text user.login # just checking we're really logged in + within_test_selector "my-account-form" do + expect(page).to have_field "user_username", with: user.login # just checking we're really logged in + end end context "with two stages" do @@ -247,7 +251,9 @@ RSpec.describe "Authentication Stages", :skip_2fa_stage do visit "/my/account" - expect(page).to have_text user.login # just checking we're really logged in + within_test_selector "my-account-form" do + expect(page).to have_field "user_username", with: user.login # just checking we're really logged in + end end end end diff --git a/spec/features/auth/consent_auth_stage_spec.rb b/spec/features/auth/consent_auth_stage_spec.rb index b34874e9286..c1ba31b9f0a 100644 --- a/spec/features/auth/consent_auth_stage_spec.rb +++ b/spec/features/auth/consent_auth_stage_spec.rb @@ -53,13 +53,17 @@ RSpec.describe "Authentication Stages" do expect(page).to have_current_path(path) visit my_account_path wait_for_network_idle - expect(page).to have_css(".form--field-container", text: user.login) + + within_test_selector "my-account-form" do + expect(page).to have_field "user_username", with: user.login + end end def expect_not_logged_in visit my_account_path wait_for_netowrk_idle - expect(page).to have_no_css(".form--field-container", text: user.login) + + expect(page).to have_no_test_selector "my-account-form" end before do diff --git a/spec/features/security/session_ttl_spec.rb b/spec/features/security/session_ttl_spec.rb index 1e46017707c..a92418be02a 100644 --- a/spec/features/security/session_ttl_spec.rb +++ b/spec/features/security/session_ttl_spec.rb @@ -48,7 +48,10 @@ RSpec.describe "Session TTL", describe "outdated TTL on Rails request" do it "expires on the next Rails request" do visit "/my/account" - expect(page).to have_css(".form--field-container", text: admin.login) + + within_test_selector "my-account-form" do + expect(page).to have_field "user_username", with: admin.login + end # Expire the session expire! diff --git a/spec/features/users/delete_spec.rb b/spec/features/users/delete_spec.rb index 2c02d058dfe..8d20103dcdb 100644 --- a/spec/features/users/delete_spec.rb +++ b/spec/features/users/delete_spec.rb @@ -105,11 +105,12 @@ RSpec.describe "user deletion:", :js do click_on "Delete" SeleniumHubWaiter.wait - fill_in "login_verification", with: user.login - click_on "Delete" + check "I understand that this deletion cannot be reversed" + click_on "Delete permanently" dialog.confirm_flow_with "wrong", should_fail: true + click_on "Delete" SeleniumHubWaiter.wait check "I understand that this deletion cannot be reversed" click_on "Delete permanently" diff --git a/spec/features/users/my_spec.rb b/spec/features/users/my_spec.rb index f4457441f34..8b8287b613e 100644 --- a/spec/features/users/my_spec.rb +++ b/spec/features/users/my_spec.rb @@ -133,7 +133,7 @@ RSpec.describe "my", :js do fill_in "user[mail]", with: "foo@mail.com" fill_in "user[firstname]", with: "Foo" fill_in "user[lastname]", with: "Bar" - click_on "Save" + click_on "Update profile" end context "when confirmation disabled", @@ -199,7 +199,7 @@ RSpec.describe "my", :js do expect(page).to have_text(I18n.t("user.text_change_disabled_for_ldap_login"), count: 3) fill_in "Hobbies", with: "Ruby, DCS" - click_on "Save" + click_on "Update profile" expect(page).to have_content I18n.t(:notice_account_updated) diff --git a/spec/lib/redmine/menu_manager_spec.rb b/spec/lib/redmine/menu_manager_spec.rb index 1ecfa383101..aefdb14d80c 100644 --- a/spec/lib/redmine/menu_manager_spec.rb +++ b/spec/lib/redmine/menu_manager_spec.rb @@ -106,7 +106,7 @@ RSpec.describe Redmine::MenuManager do context "for the my_menu" do it "includes the expected items" do expect(described_class.items(:my_menu).map(&:name)) - .to include(:account, :locale, :password, :access_tokens, :notifications, :reminders, :delete_account) + .to include(:account, :locale, :password, :access_tokens, :notifications, :reminders) end end