mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Fix tests
Update config/locales/en.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update app/views/my/account.html.erb Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update app/forms/my/account_form.rb Co-authored-by: Alexander Brandon Coles <a.coles@openproject.com> Update app/forms/my/account_form.rb Co-authored-by: Alexander Brandon Coles <a.coles@openproject.com> Update app/forms/my/account_form.rb Co-authored-by: Alexander Brandon Coles <a.coles@openproject.com> Apply suggestion from @myabc Co-authored-by: Alexander Brandon Coles <a.coles@openproject.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user