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 some more tests && render the revit add-in entry normally via the menu initializer and only toggle the visibility via JS

Henriette Darge8f60babb963a
diff --git a/frontend/src/app/features/bim/revit_add_in/revit-add-in-settings-button.service.ts b/frontend/src/app/features/bim/revit_add_in/revit-add-in-settings-button.service.ts
index 4acb514b457..82622e630fc 100644
--- a/frontend/src/app/features/bim/revit_add_in/revit-add-in-settings-button.service.ts
+++ b/frontend/src/app/features/bim/revit_add_in/revit-add-in-settings-button.service.ts
@@ -55,19 +55,15 @@ export class RevitAddInSettingsButtonService {
}
public addUserMenuItem():void {
- const userMenu = document.getElementById('op-app-header--user-menu');
+ const userMenu = document.getElementById('op-app-header--user-menu-list');
if (userMenu) {
- const menuItem:HTMLElement = document.createElement('li');
- menuItem.dataset.name = this.labelText;
- menuItem.innerHTML = `
- <a class="op-menu--item-action revit-addin-settings-menu-item ellipsis" title="${this.labelText}" href="#">
- <span class="menu-item--title ellipsis ">${this.labelText}</span>
- </a>
- `;
+ const menuItem:HTMLElement|null = document.getElementById('user-menu--revit-add-in-entry');
- menuItem.addEventListener('click', () => this.goToSettings());
- userMenu.appendChild(menuItem);
+ if (menuItem) {
+ menuItem.addEventListener('click', () => this.goToSettings());
+ menuItem.closest('li.d-none')?.classList.remove('d-none');
+ }
}
}
diff --git a/lib/redmine/menu_manager/top_menu/user_menu.rb b/lib/redmine/menu_manager/top_menu/user_menu.rb
index 09b5b52872e..af46a1aa2b2 100644
--- a/lib/redmine/menu_manager/top_menu/user_menu.rb
+++ b/lib/redmine/menu_manager/top_menu/user_menu.rb
@@ -138,7 +138,8 @@ module Redmine::MenuManager::TopMenu::UserMenu
href: allowed_node_url(item, nil),
label: item.caption,
scheme: item.scheme || :default,
- test_selector: "op-menu--item-action"
+ test_selector: "op-menu--item-action",
+ **item.html_options
) do |menu_item|
menu_item.with_leading_visual_icon(icon: item.icon) if item.icon
end
diff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rb
index 304ea65dba8..e62a060c4d1 100644
--- a/modules/bim/lib/open_project/bim/engine.rb
+++ b/modules/bim/lib/open_project/bim/engine.rb
@@ -110,6 +110,18 @@ module OpenProject::Bim
parent: :ifc_models,
partial: "/bim/menus/menu"
end
+
+ ::Redmine::MenuManager.map(:account_menu) do |menu|
+ menu.push(:revit_add_in,
+ "",
+ caption: :"js.revit.revit_add_in_settings",
+ icon: "op-view-modal",
+ html: {
+ id: "user-menu--revit-add-in-entry",
+ classes: "d-none"
+ },
+ after: :administration)
+ end
end
class_inflection_override("v2_1" => "V2_1")
diff --git a/modules/bim/spec/features/revit_add_in/bim_revit_add_in_navigation_spec.rb b/modules/bim/spec/features/revit_add_in/bim_revit_add_in_navigation_spec.rb
index 2c2fa356fe4..42f5c7c2dbc 100644
--- a/modules/bim/spec/features/revit_add_in/bim_revit_add_in_navigation_spec.rb
+++ b/modules/bim/spec/features/revit_add_in/bim_revit_add_in_navigation_spec.rb
@@ -133,7 +133,7 @@ RSpec.describe "BIM Revit Add-in navigation spec", :js,
it "the user menu has an option to go to the add-in settings" do
visit home_path
- click_link I18n.t(:label_login)
+ user_menu.open
expect(page).to have_text(I18n.t("js.revit.revit_add_in_settings"))
end
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 8721b9abc2b..b7281ca345f 100644
--- a/modules/two_factor_authentication/spec/features/account_activation_spec.rb
+++ b/modules/two_factor_authentication/spec/features/account_activation_spec.rb
@@ -57,7 +57,7 @@ RSpec.describe "activating an invited account",
expect_flash(message: "Developer strategy generated the following one-time password:")
fill_in I18n.t(:field_otp), with: sms_token
- click_button I18n.t(:button_login)
+ click_button I18n.t(:button_login), type: "submit"
wait_for_network_idle
visit my_account_path
@@ -70,7 +70,7 @@ RSpec.describe "activating an invited account",
expect_flash(message: "Developer strategy generated the following one-time password:")
fill_in I18n.t(:field_otp), with: "asdf" # faulty token
- click_button I18n.t(:button_login)
+ click_button I18n.t(:button_login), type: "submit"
expect(page).to have_current_path signin_path
expect(page).to have_content(I18n.t(:notice_account_otp_invalid))
diff --git a/modules/two_factor_authentication/spec/features/password_change_spec.rb b/modules/two_factor_authentication/spec/features/password_change_spec.rb
index d5c2215efc0..6480bf55f8f 100644
--- a/modules/two_factor_authentication/spec/features/password_change_spec.rb
+++ b/modules/two_factor_authentication/spec/features/password_change_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe "Password change with OTP", :js, with_settings: {
expect(page).to have_css("input#otp")
SeleniumHubWaiter.wait
fill_in "otp", with: sms_token
- click_button I18n.t(:button_login)
+ click_button I18n.t(:button_login), type: "submit"
end
expect(page).to have_current_path(expected_path_after_login, ignore_query: true)
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 bcdc510f050..0c0bbac5aa3 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
@@ -21,7 +21,7 @@ module SharedTwoFactorExamples
def two_factor_step(token)
expect(page).to have_css("input#otp")
fill_in "otp", with: token
- click_button I18n.t(:button_login)
+ click_button I18n.t(:button_login), type: "submit"
wait_for_network_idle
end
diff --git a/spec/features/auth/auth_source_sso_login_spec.rb b/spec/features/auth/auth_source_sso_login_spec.rb
index 6793e06e79b..c2f4ba5a006 100644
--- a/spec/features/auth/auth_source_sso_login_spec.rb
+++ b/spec/features/auth/auth_source_sso_login_spec.rb
@@ -53,6 +53,7 @@ RSpec.describe "Login with auth source SSO" do
password: user_password,
password_confirmation: user_password)
end
+ let(:user_menu) { Components::UserMenu.new }
it "can still login" do
login_with(user.login, user_password)
@@ -60,6 +61,6 @@ RSpec.describe "Login with auth source SSO" do
# on the my page
expect(page).to have_current_path home_path
- expect(page).to have_css("a[title='#{user.name}']")
+ user_menu.expect_user_shown user.name
end
end
diff --git a/spec/features/auth/login_spec.rb b/spec/features/auth/login_spec.rb
index 2498ed430ba..014b0f44ace 100644
--- a/spec/features/auth/login_spec.rb
+++ b/spec/features/auth/login_spec.rb
@@ -31,6 +31,8 @@
require "spec_helper"
RSpec.describe "Login" do
+ let(:user_menu) { Components::UserMenu.new }
+
before do
@capybara_ignore_elements = Capybara.ignore_hidden_elements
Capybara.ignore_hidden_elements = true
@@ -41,8 +43,7 @@ RSpec.describe "Login" do
end
def expect_being_logged_in(user)
- expect(page)
- .to have_css("a[title='#{user.name}']")
+ user_menu.expect_user_shown user.name
end
def expect_not_being_logged_in
diff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rb
index 8b904610ad1..04305c91c61 100644
--- a/spec/features/auth/omniauth_spec.rb
+++ b/spec/features/auth/omniauth_spec.rb
@@ -46,6 +46,7 @@ RSpec.describe "Omniauth authentication" do
firstname:,
lastname:)
end
+ let(:user_menu) { Components::UserMenu.new }
before do
@omniauth_test_mode = OmniAuth.config.test_mode
@@ -90,7 +91,7 @@ RSpec.describe "Omniauth authentication" do
fill_in("email", with: user.mail)
click_link_or_button "Sign In"
- expect(page).to have_link("omni bob")
+ user_menu.expect_user_shown "omni bob"
expect(page).to have_link("Sign out")
end
diff --git a/spec/features/notifications/notification_center/notification_center_spec.rb b/spec/features/notifications/notification_center/notification_center_spec.rb
index 01a287aafc2..3ac4462a93e 100644
--- a/spec/features/notifications/notification_center/notification_center_spec.rb
+++ b/spec/features/notifications/notification_center/notification_center_spec.rb
@@ -117,7 +117,7 @@ RSpec.describe "Notification center",
it "can dismiss all notifications of the currently selected filter" do
visit home_path
wait_for_reload
- center.expect_bell_count "99+"
+ center.expect_bell_count "•"
center.open
# side menu items show full count of notifications (inbox has two more due to the "Created" notification)
@@ -131,7 +131,7 @@ RSpec.describe "Notification center",
center.mark_all_read
wait_for_network_idle
- center.expect_bell_count "99+"
+ center.expect_bell_count "•"
side_menu.expect_item_with_count "Inbox", 152
side_menu.expect_item_with_count "Mentioned", 100
side_menu.expect_item_with_no_count "Watcher"
@@ -142,7 +142,7 @@ RSpec.describe "Notification center",
center.mark_all_read
wait_for_network_idle
- center.expect_bell_count "99+"
+ center.expect_bell_count "•"
side_menu.expect_item_with_count "Inbox", 101
side_menu.expect_item_with_count "Mentioned", 100
side_menu.expect_no_item project2.name
diff --git a/spec/features/users/create_spec.rb b/spec/features/users/create_spec.rb
index 9f9ccc6ce68..39cae05b336 100644
--- a/spec/features/users/create_spec.rb
+++ b/spec/features/users/create_spec.rb
@@ -40,6 +40,7 @@ RSpec.describe "create users" do
end
let(:mail_body) { mail.body.parts.first.body.to_s }
let(:token) { mail_body.scan(/token=(.*)$/).first.first.strip }
+ let(:user_menu) { Components::UserMenu.new }
before do
allow(User).to receive(:current).and_return current_user
@@ -93,9 +94,7 @@ RSpec.describe "create users" do
# landed on the 'my page'
expect(page).to have_text "Welcome, your account has been activated. You are logged in now."
- within_test_selector "op-app-header--user-menu-button" do
- expect(page).to have_element title: "bobfirst boblast"
- end
+ user_menu.expect_user_shown "bobfirst boblast"
end
end
end
@@ -157,9 +156,7 @@ RSpec.describe "create users" do
expect(page).to have_text "OpenProject"
expect(page).to have_current_path "/", ignore_query: true
- within_test_selector "op-app-header--user-menu-button" do
- expect(page).to have_element title: "bobfirst boblast"
- end
+ user_menu.expect_user_shown "bobfirst boblast"
end
end
end
@@ -202,9 +199,7 @@ RSpec.describe "create users" do
# landed on the 'my page'
expect(page).to have_text "Welcome, your account has been activated. You are logged in now."
- within_test_selector "op-app-header--user-menu-button" do
- expect(page).to have_element title: "bobfirst boblast"
- end
+ user_menu.expect_user_shown "bobfirst boblast"
end
end
end
diff --git a/spec/features/users/self_registration_spec.rb b/spec/features/users/self_registration_spec.rb
index 53dfa0631f3..0d5264a39fe 100644
--- a/spec/features/users/self_registration_spec.rb
+++ b/spec/features/users/self_registration_spec.rb
@@ -34,6 +34,7 @@ RSpec.describe "user self registration", :js do
let(:admin_password) { "Test123Test123" }
let(:admin) { create(:admin, password: admin_password, password_confirmation: admin_password) }
let(:home_page) { Pages::Home.new }
+ let(:user_menu) { Components::UserMenu.new }
context 'with "manual account activation"',
with_settings: { self_registration: Setting::SelfRegistration.manual.to_s } do
@@ -59,11 +60,10 @@ RSpec.describe "user self registration", :js do
it "allows self registration and activation by an admin", :signout_via_visit do
home_page.visit!
+ user_menu.open
# registration as an anonymous user
within ".op-app-header" do
- click_link "Sign in"
-
click_link "Create a new account"
end
@@ -120,10 +120,7 @@ RSpec.describe "user self registration", :js do
# Test logging in as newly created and activated user
login_with "heidi", "test123=321test"
- within ".op-app-header" do
- expect(page)
- .to have_css("a[title='#{registered_user.name}']")
- end
+ user_menu.expect_user_shown registered_user.name
end
end
end
diff --git a/spec/support/authentication_helpers.rb b/spec/support/authentication_helpers.rb
index 6611258c948..e8da590c4e5 100644
--- a/spec/support/authentication_helpers.rb
+++ b/spec/support/authentication_helpers.rb
@@ -67,7 +67,7 @@ module AuthenticationHelpers
check autologin_label
end
- click_button I18n.t(:button_login)
+ click_button I18n.t(:button_login), type: "submit"
wait_for_network_idle
end
end
diff --git a/spec/support/components/menu/user_menu.rb b/spec/support/components/menu/user_menu.rb
index 2e5adb4a57d..ccb785911d9 100644
--- a/spec/support/components/menu/user_menu.rb
+++ b/spec/support/components/menu/user_menu.rb
@@ -41,5 +41,11 @@ module Components
def close
page.find(".op-app-header--modules-menu-header .close-button").click
end
+
+ def expect_user_shown(user_name)
+ page.within_test_selector "op-app-header--user-menu-button" do
+ expect(page).to have_element "data-title": "\"#{user_name}\""
+ end
+ end
end
end