Skip to content

Commit

Permalink
Close modals when turbo navigates
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 17, 2024
1 parent f4bc2d4 commit 396f824
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ export class OpenprojectAugmentingModule {
constructor(modalWrapper:OpModalWrapperAugmentService) {
// Setup augmenting services
modalWrapper.setupListener();

document.addEventListener('turbo:load', () => {
modalWrapper.setupListener();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export class OpModalWrapperAugmentService {
@Inject(DOCUMENT) protected documentElement:Document,
protected injector:Injector,
protected opModalService:OpModalService,
) {}
) {
documentElement.addEventListener('turbo:before-render', () => opModalService.close());
}

/**
* Create initial listeners for Rails-rendered modals
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require_relative "../spec_helper"
require_relative "shared_2fa_examples"

RSpec.describe "activating an invited account", :js,
RSpec.describe "activating an invited account",
:js,
:with_cuprite,
with_settings: {
plugin_openproject_two_factor_authentication: { "active_strategies" => [:developer] }
} do
Expand Down Expand Up @@ -49,12 +51,11 @@ def activate!
# rubocop:enable RSpec/AnyInstance

activate!

expect(page).to have_css(".op-toast.-success", text: "Developer strategy generated the following one-time password:")

SeleniumHubWaiter.wait
fill_in I18n.t(:field_otp), with: sms_token
click_button I18n.t(:button_login)
wait_for_network_idle

visit my_account_path
expect(page).to have_css(".form--field-container", text: user.login)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,20 @@ def expect_not_logged_in
SeleniumHubWaiter.wait
fill_in "device_phone_number", with: "invalid"
click_on "Continue"
wait_for_network_idle

# Expect error on invalid phone
expect(page).to have_css("#errorExplanation", text: "Phone number must be of format +XX XXXXXXXXX")

SeleniumHubWaiter.wait
fill_in "device_phone_number", with: "+49 123456789"
click_on "Continue"
wait_for_network_idle

# Confirm page
expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device"))
expect(page).to have_css("input#otp")

SeleniumHubWaiter.wait
# Fill in wrong token
fill_in "otp", with: "whatever"

Expand Down

0 comments on commit 396f824

Please sign in to comment.