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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix preview of SplitViewComponent
Henriette Dargea47284f28bd4
diff --git a/app/components/work_packages/details/tab_component.html.erb b/app/components/work_packages/details/tab_component.html.erbindex dbe0306c5cd..5c88f03c2f1 100644--- a/app/components/work_packages/details/tab_component.html.erb+++ b/app/components/work_packages/details/tab_component.html.erb@@ -1,6 +1,6 @@<%=flex_layout(classes: "op-work-package-details-tab-component") do |flex|- flex.with_column(flex: 1, classes: "op-work-package-details-tab-component--tabs") do+ flex.with_column(flex: 1, classes: "op-work-package-details-tab-component--tabs", test_selector: "wp-details-tab-component--tabs") dorender(Primer::Alpha::UnderlineNav.new(align: :left, label: "Tabs", classes: "op-primer-adjustment--UnderlineNav_spaciousLeft")) do |component|menu_items.each do |node|component.with_tab(selected: @tab == node.name,diff --git a/app/components/work_packages/split_view_component.html.erb b/app/components/work_packages/split_view_component.html.erbindex 850b970171e..48b1549e621 100644--- a/app/components/work_packages/split_view_component.html.erb+++ b/app/components/work_packages/split_view_component.html.erb@@ -17,7 +17,7 @@flex.with_row(flex: 1) dohelpers.angular_component_tag "opce-wp-split-view",inputs: {- work_package_id: params[:work_package_id],+ work_package_id: params[:work_package_id] || @work_package.id,activeTab: @tab}enddiff --git a/config/routes.rb b/config/routes.rbindex 44e5ae35f53..c54e101879c 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -738,6 +738,9 @@ Rails.application.routes.draw doendif OpenProject::Configuration.lookbook_enabled?+ # Dummy route for the split screen controller+ get :close_split_view, controller: "homescreen"+mount Lookbook::Engine, at: "/lookbook"enddiff --git a/frontend/src/global_styles/layout/_viewcomponent_previews.sass b/frontend/src/global_styles/layout/_viewcomponent_previews.sassindex a403a62ca0c..1b19fb8e037 100644--- a/frontend/src/global_styles/layout/_viewcomponent_previews.sass+++ b/frontend/src/global_styles/layout/_viewcomponent_previews.sass@@ -1,3 +1,4 @@.viewcomponent-preview&--contentmargin: 1rem+ height: 100%diff --git a/lookbook/previews/open_project/work_packages/split_view_component_preview.rb b/lookbook/previews/open_project/work_packages/split_view_component_preview.rbnew file mode 100644index 00000000000..55a82b755b0--- /dev/null+++ b/lookbook/previews/open_project/work_packages/split_view_component_preview.rb@@ -0,0 +1,11 @@+# frozen_string_literal: true++module OpenProject::WorkPackages+ # @logical_path OpenProject/WorkPackages+ class SplitViewComponentPreview < ViewComponent::Preview+ # @display min_height 400px+ def default+ render(WorkPackages::SplitViewComponent.new(id: 1, tab: "overview", base_route: work_packages_path))+ end+ end+enddiff --git a/spec/components/previews/work_packages/split_view_component_preview.rb b/spec/components/previews/work_packages/split_view_component_preview.rbdeleted file mode 100644index 775f6279f59..00000000000--- a/spec/components/previews/work_packages/split_view_component_preview.rb+++ /dev/null@@ -1,7 +0,0 @@-# frozen_string_literal: true--class WorkPackages::SplitViewComponentPreview < ViewComponent::Preview- def default- render(WorkPackages::SplitViewComponent.new(id: "1", tab: "tab", base_url: work_packages_path))- end-enddiff --git a/spec/components/work_packages/split_view_component_spec.rb b/spec/components/work_packages/split_view_component_spec.rbindex 87b68bfad55..92749e2a385 100644--- a/spec/components/work_packages/split_view_component_spec.rb+++ b/spec/components/work_packages/split_view_component_spec.rb@@ -3,13 +3,27 @@require "rails_helper"RSpec.describe WorkPackages::SplitViewComponent, type: :component do- pending "add some examples to (or delete) #{__FILE__}"-- # it "renders something useful" do- # expect(- # render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html- # ).to include(- # "Hello, components!"- # )- # end+ include OpenProject::StaticRouting::UrlHelpers++ let(:project) { create(:project) }+ let(:work_package) { create(:work_package, project:) }++ subject do+ with_request_url("/notifications/details/:work_package_id") do+ render_inline(described_class.new(id: work_package.id, base_route: notifications_path))+ end+ end++ before do+ allow(WorkPackage).to receive(:visible).and_return(WorkPackage.where(id: work_package.id))+ end++ it "renders successfully" do+ subject++ expect(page).to have_text("Overview")+ expect(page).to have_test_selector("wp-details-tab-component--tabs")+ expect(page).to have_test_selector("wp-details-tab-component--close")+ expect(page).to have_test_selector("wp-details-tab-component--full-screen")+ endend