Skip to content

Commit

Permalink
Fix dynamic bootstrapping and add a feature spec
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 12, 2024
1 parent 0ac75a5 commit b91889a
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/views/open_desk/menu/_top_menu_node.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= angular_component_tag 'op-opendesk-central-navigation' %>
<%= angular_component_tag 'opce-opendesk-central-navigation' %>
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions frontend/module/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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 });
}
}
2 changes: 1 addition & 1 deletion lib/api/v3/linked_applications/adapters/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions spec/features/central_navigation_spec.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "spec_helper"

0 comments on commit b91889a

Please sign in to comment.