From b91889ae0d14777142dd79d01d13627b6e7f8ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 12 Sep 2024 09:01:46 +0200 Subject: [PATCH] Fix dynamic bootstrapping and add a feature spec --- .../open_desk/menu/_top_menu_node.html.erb | 2 +- .../central-navigation.component.ts | 3 -- frontend/module/main.ts | 9 ++-- .../adapters/development.rb | 2 +- .../patches/custom_styles_helper_patch.rb | 2 +- spec/features/central_navigation_spec.rb | 53 +++++++++++++++++++ spec/spec_helper.rb | 1 + 7 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 spec/features/central_navigation_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/app/views/open_desk/menu/_top_menu_node.html.erb b/app/views/open_desk/menu/_top_menu_node.html.erb index a186c88..34a2422 100644 --- a/app/views/open_desk/menu/_top_menu_node.html.erb +++ b/app/views/open_desk/menu/_top_menu_node.html.erb @@ -1 +1 @@ -<%= angular_component_tag 'op-opendesk-central-navigation' %> +<%= angular_component_tag 'opce-opendesk-central-navigation' %> diff --git a/frontend/module/central-navigation/central-navigation.component.ts b/frontend/module/central-navigation/central-navigation.component.ts index 521e08b..92d8382 100644 --- a/frontend/module/central-navigation/central-navigation.component.ts +++ b/frontend/module/central-navigation/central-navigation.component.ts @@ -16,10 +16,7 @@ import { } from '@angular/platform-browser'; import { I18nService } from 'core-app/core/i18n/i18n.service'; -export const openDeskCentralNavigationSelector = 'op-opendesk-central-navigation'; - @Component({ - selector: openDeskCentralNavigationSelector, templateUrl: './central-navigation.component.html', styleUrls: ['./central-navigation.component.sass'], changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/frontend/module/main.ts b/frontend/module/main.ts index 5a92711..43f7c10 100644 --- a/frontend/module/main.ts +++ b/frontend/module/main.ts @@ -30,11 +30,11 @@ import { } from '@angular/core'; import { CentralNavigationComponent, - openDeskCentralNavigationSelector, } from './central-navigation/central-navigation.component'; -import { HookService } from 'core-app/features/plugins/hook-service'; import { ContentLoaderModule } from '@ngneat/content-loader'; import { OpSharedModule } from 'core-app/shared/shared.module'; +import { registerCustomElement } from 'core-app/shared/helpers/angular/custom-elements.helper'; + @NgModule({ imports: [ @@ -50,9 +50,6 @@ import { OpSharedModule } from 'core-app/shared/shared.module'; }) export class PluginModule { constructor(injector:Injector) { - const hookService = injector.get(HookService); - hookService.register('openProjectAngularBootstrap', () => [ - { selector: openDeskCentralNavigationSelector, cls: CentralNavigationComponent }, - ]); + registerCustomElement('opce-opendesk-central-navigation', CentralNavigationComponent, { injector }); } } diff --git a/lib/api/v3/linked_applications/adapters/development.rb b/lib/api/v3/linked_applications/adapters/development.rb index 1b56da5..60fff84 100644 --- a/lib/api/v3/linked_applications/adapters/development.rb +++ b/lib/api/v3/linked_applications/adapters/development.rb @@ -32,7 +32,7 @@ module LinkedApplications module Adapters class Development < OpenDesk def self.applicable? - Rails.env.development? + Rails.env.development? || Rails.env.test? end protected diff --git a/lib/open_project/open_desk/patches/custom_styles_helper_patch.rb b/lib/open_project/open_desk/patches/custom_styles_helper_patch.rb index 900294a..133432b 100644 --- a/lib/open_project/open_desk/patches/custom_styles_helper_patch.rb +++ b/lib/open_project/open_desk/patches/custom_styles_helper_patch.rb @@ -34,7 +34,7 @@ def self.included(base) module InstanceMethods # Always apply custom styles for open desk def apply_custom_styles?(*) - true + CustomStyle.current.present? end end end diff --git a/spec/features/central_navigation_spec.rb b/spec/features/central_navigation_spec.rb new file mode 100644 index 0000000..c5ac7bc --- /dev/null +++ b/spec/features/central_navigation_spec.rb @@ -0,0 +1,53 @@ +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +require "spec_helper" +require_module_spec_helper + +RSpec.describe "OpenDesk central navigation", :js do + current_user { create(:admin) } + + it "opens the central navigation" do + visit home_path + + click_link_or_button "openDesk navigation" + + expect(page).to have_css(".op-opendesk-navigation--group", count: 4) + expect(page).to have_css(".op-opendesk-navigation--item", text: "E-Mail") + expect(page).to have_css(".op-opendesk-navigation--item", text: "Calendar") + expect(page).to have_css(".op-opendesk-navigation--item", text: "Contacts") + expect(page).to have_css(".op-opendesk-navigation--item", text: "Tasks") + + expect(page).to have_css(".op-opendesk-navigation--item", text: "Files") + expect(page).to have_css(".op-opendesk-navigation--item", text: "Activity") + expect(page).to have_css(".op-opendesk-navigation--item", text: "Projects") + expect(page).to have_css(".op-opendesk-navigation--item", text: "Knowledge") + expect(page).to have_css(".op-opendesk-navigation--item", text: "Collaboration") + expect(page).to have_css(".op-opendesk-navigation--item", text: "Ad hoc videoconference") + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..671fd6c --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1 @@ +require "spec_helper"