From a445aaa0cf2c5825da0ed34c66f97198d651a04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 26 Feb 2019 09:29:01 +0100 Subject: [PATCH] Create regression test for hierarchy toggle https://community.openproject.com/wp/29578 --- .../my/my_page_assigned_to_me_spec.rb | 52 +++++++++++++++++-- .../components/work_packages/hierarchies.rb | 4 ++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/modules/grids/spec/features/my/my_page_assigned_to_me_spec.rb b/modules/grids/spec/features/my/my_page_assigned_to_me_spec.rb index 901556689c..03abb8aa68 100644 --- a/modules/grids/spec/features/my/my_page_assigned_to_me_spec.rb +++ b/modules/grids/spec/features/my/my_page_assigned_to_me_spec.rb @@ -36,6 +36,7 @@ describe 'Assigned to me embedded query on my page', type: :feature, js: true do let!(:assigned_work_package) do FactoryBot.create :work_package, project: project, + subject: 'Assigned to me', type: type, author: user, assigned_to: user @@ -43,6 +44,7 @@ describe 'Assigned to me embedded query on my page', type: :feature, js: true do let!(:assigned_to_other_work_package) do FactoryBot.create :work_package, project: project, + subject: 'Not assigend to me', type: type, author: user, assigned_to: other_user @@ -61,16 +63,61 @@ describe 'Assigned to me embedded query on my page', type: :feature, js: true do let(:my_page) do Pages::My::Page.new end + let(:assigned_area) { Components::Grids::GridArea.new('.grid--area', text: 'Work packages assigned to me') } + let(:embedded_table) { Pages::EmbeddedWorkPackagesTable.new(assigned_area.area) } + let(:hierarchies) { ::Components::WorkPackages::Hierarchies.new } before do login_as user + end - my_page.visit! + context 'with parent work package' do + let!(:assigned_work_package_child) do + FactoryBot.create :work_package, + subject: 'Child', + parent: assigned_work_package, + project: project, + type: type, + author: user, + assigned_to: user + end + + it 'can toggle hierarchy mode in embedded tables (Regression test #29578)' do + my_page.visit! + + # exists as default + assigned_area.expect_to_exist + + page.within(assigned_area.area) do + # expect hierarchy in child + hierarchies.expect_mode_enabled + + hierarchies.expect_hierarchy_at assigned_work_package + hierarchies.expect_leaf_at assigned_work_package_child + + # toggle parent + hierarchies.toggle_row assigned_work_package + hierarchies.expect_hierarchy_at assigned_work_package, collapsed: true + + # disable + hierarchies.disable_via_header + hierarchies.expect_no_hierarchies + + # re-enable + hierarchies.enable_via_header + + hierarchies.expect_mode_enabled + # Re-enabling resets collapsed state for now + hierarchies.expect_hierarchy_at assigned_work_package, collapsed: false + hierarchies.expect_leaf_at assigned_work_package_child + end + end end it 'can create a new ticket with correct me values (Regression test #28488)' do + my_page.visit! + # exists as default - assigned_area = Components::Grids::GridArea.new('.grid--area', text: 'Work packages assigned to me') assigned_area.expect_to_exist expect(assigned_area.area) @@ -79,7 +126,6 @@ describe 'Assigned to me embedded query on my page', type: :feature, js: true do expect(assigned_area.area) .to have_no_selector('.subject', text: assigned_to_other_work_package.subject) - embedded_table = Pages::EmbeddedWorkPackagesTable.new(assigned_area.area) embedded_table.click_inline_create subject_field = embedded_table.edit_field(nil, :subject) diff --git a/spec/support/components/work_packages/hierarchies.rb b/spec/support/components/work_packages/hierarchies.rb index a22a371467..c555efa494 100644 --- a/spec/support/components/work_packages/hierarchies.rb +++ b/spec/support/components/work_packages/hierarchies.rb @@ -44,6 +44,10 @@ module Components page.find('.wp-table--table-header .icon-no-hierarchy').click end + def disable_via_header + page.find('.wp-table--table-header .icon-hierarchy').click + end + def disable_hierarchy ::Components::WorkPackages::TableConfigurationModal.do_and_save do |modal| modal.open_and_set_display_mode :default