Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix cancelling modal on submit due to first button being called

Oliver Güntherc6361aba1fe8
diff --git a/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.html b/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.html
index 8d18ccac94c..28b3bd93029 100644
--- a/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.html
+++ b/frontend/src/app/shared/components/modals/request-for-confirmation/password-confirmation.modal.html
@@ -31,12 +31,14 @@
<div class="spot-action-bar">
<div class="spot-action-bar--right">
<button
+ type="button"
class="button button_no-margin spot-modal--cancel-button spot-action-bar--action"
[textContent]="additionalText.cancel_button"
(click)="closeMe()"
>
</button>
<button
+ type="submit"
class="button button_no-margin -highlight spot-action-bar--action"
[textContent]="additionalText.confirm_button"
data-qa-selector="confirmation-modal--confirmed"
diff --git a/spec/features/users/delete_spec.rb b/spec/features/users/delete_spec.rb
index 975472ce510..dd51cdb942c 100644
--- a/spec/features/users/delete_spec.rb
+++ b/spec/features/users/delete_spec.rb
@@ -115,6 +115,24 @@ describe 'user deletion:', type: :feature, js: true do
expect(page).to have_current_path '/users'
end
+ it 'can delete and confirm with keyboard (Regression #44499)', selenium: true do
+ Setting.users_deletable_by_admins = 1
+ visit edit_user_path(user)
+
+ expect(page).to have_content "#{user.firstname} #{user.lastname}"
+
+ click_on 'Delete'
+
+ SeleniumHubWaiter.wait
+ fill_in 'login_verification', with: user.login
+ click_on 'Delete'
+
+ dialog.confirm_flow_with user_password, with_keyboard: true, should_fail: false
+
+ expect(page).to have_content 'Account successfully deleted'
+ expect(page).to have_current_path '/users'
+ end
+
it 'cannot delete other users if the settings forbid it' do
Setting.users_deletable_by_admins = 0
visit edit_user_path(user)
diff --git a/spec/support/components/password_confirmation_dialog.rb b/spec/support/components/password_confirmation_dialog.rb
index 966afaee153..f057d2add44 100644
--- a/spec/support/components/password_confirmation_dialog.rb
+++ b/spec/support/components/password_confirmation_dialog.rb
@@ -32,14 +32,14 @@ module Components
include Capybara::RSpecMatchers
include RSpec::Matchers
- def confirm_flow_with(password, should_fail: false)
+ def confirm_flow_with(password, with_keyboard: false, should_fail: false)
expect_open
expect(submit_button).to be_disabled
fill_in 'request_for_confirmation_password', with: password
expect(submit_button).not_to be_disabled
- submit(should_fail)
+ submit(should_fail:, with_keyboard:)
end
def expect_open
@@ -60,8 +60,12 @@ module Components
'.password-confirm-dialog--modal'
end
- def submit(should_fail)
- submit_button.click
+ def submit(should_fail:, with_keyboard:)
+ if with_keyboard
+ find_field('request_for_confirmation_password').send_keys :enter
+ else
+ submit_button.click
+ end
if should_fail
expect(page).to have_selector('.flash.error',