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
Add test for navigating between the split screen tabs
Henriette Darge3bd1ec428d52
diff --git a/spec/features/notifications/notification_center_spec.rb b/spec/features/notifications/notification_center/notification_center_spec.rbsimilarity index 70%rename from spec/features/notifications/notification_center_spec.rbrename to spec/features/notifications/notification_center/notification_center_spec.rbindex be59a99fd47..c62df9a3cef 100644--- a/spec/features/notifications/notification_center_spec.rb+++ b/spec/features/notifications/notification_center/notification_center_spec.rb@@ -4,7 +4,7 @@ require 'support/components/notifications/center'describe "Notification center", type: :feature, js: true doshared_let(:project) { FactoryBot.create :project }shared_let(:work_package) { FactoryBot.create :work_package, project: project }- shared_let(:work_package2) { FactoryBot.create :work_package, project: project }+ shared_let(:second_work_package) { FactoryBot.create :work_package, project: project }shared_let(:recipient) doFactoryBot.create :user,member_in_project: project,@@ -18,11 +18,11 @@ describe "Notification center", type: :feature, js: true dojournal: work_package.journals.lastend- shared_let(:notification2) do+ shared_let(:second_notification) doFactoryBot.create :notification,recipient: recipient,project: project,- resource: work_package2,+ resource: second_work_package,journal: work_package.journals.lastend@@ -40,11 +40,11 @@ describe "Notification center", type: :feature, js: true docenter.opencenter.expect_work_package_item notification- center.expect_work_package_item notification2+ center.expect_work_package_item second_notificationcenter.click_item notificationsplit_screen.expect_open- activity_tab.expect_activity_listed "created on #{work_package.created_at.strftime('%m/%d/%Y')}"+ activity_tab.expect_wp_has_been_created_activity work_packageendend@@ -57,7 +57,7 @@ describe "Notification center", type: :feature, js: true docenter.opencenter.expect_work_package_item notification- center.expect_work_package_item notification2+ center.expect_work_package_item second_notificationcenter.mark_all_readcenter.expect_bell_count 0@@ -65,7 +65,7 @@ describe "Notification center", type: :feature, js: true doexpect(notification.read_ian).to be_truthycenter.expect_no_item notification- center.expect_no_item notification2+ center.expect_no_item second_notificationendit 'can open the split screen of the notification to mark it as read' do@@ -76,7 +76,7 @@ describe "Notification center", type: :feature, js: true docenter.click_item notificationsplit_screen.expect_opencenter.expect_read_item notification- center.expect_work_package_item notification2+ center.expect_work_package_item second_notificationretry_block donotification.reload@@ -88,45 +88,19 @@ describe "Notification center", type: :feature, js: true docenter.opencenter.expect_no_item notification- center.expect_work_package_item notification2+ center.expect_work_package_item second_notificationend- it 'can switch between multiple notifications and the split screen remains open and updates accordingly' do- visit home_path- center.expect_bell_count 2- center.open-- center.click_item notification- split_screen.expect_open- center.expect_read_item notification- center.expect_work_package_item notification2-- center.click_item notification2- split_screen = ::Pages::SplitWorkPackage.new(work_package2, project)- split_screen.expect_open- center.expect_read_item notification2-- split_screen.close- split_screen.expect_closed-- center.close- center.expect_bell_count 0-- center.open- center.expect_empty- end-- context 'with mutliple notifications per work package' do- # In this context we have three notifications for two work packages.- shared_let(:second_work_package) { FactoryBot.create :work_package, project: project }- shared_let(:second_notification) do+ context 'with multiple notifications per work package' do+ # In this context we have four notifications for two work packages.+ shared_let(:third_notification) doFactoryBot.create :notification,recipient: recipient,project: project,resource: second_work_package,journal: work_package.journals.lastend- shared_let(:third_notification) do+ shared_let(:fourth_notification) doFactoryBot.create :notification,recipient: recipient,project: project,@@ -137,25 +111,29 @@ describe "Notification center", type: :feature, js: true doit 'aggregates notifications per work package and sets all as read when opened' dovisit home_path- center.expect_bell_count 3+ center.expect_bell_count 4center.open+ center.expect_number_of_notifications 2+# Click on first list item, which should be the youngest notification- center.click_item third_notification+ center.click_item fourth_notificationsplit_screen.expect_open- center.expect_read_item third_notification+ center.expect_read_item fourth_notificationexpect(notification.reload.read_ian).to be_truthyexpect(second_notification.reload.read_ian).to be_falsey- expect(third_notification.reload.read_ian).to be_truthy+ expect(third_notification.reload.read_ian).to be_falsey+ expect(fourth_notification.reload.read_ian).to be_truthy# Click on second list item, which should be the youngest notification that does# not belong to the work package that represents the first list item.- center.click_item second_notification+ center.click_item third_notificationsecond_split_screen.expect_open- center.expect_read_item second_notification+ center.expect_read_item third_notificationexpect(second_notification.reload.read_ian).to be_truthy+ expect(third_notification.reload.read_ian).to be_truthyendendenddiff --git a/spec/features/notifications/notification_center/split_screen_spec.rb b/spec/features/notifications/notification_center/split_screen_spec.rbnew file mode 100644index 00000000000..055a553421b--- /dev/null+++ b/spec/features/notifications/notification_center/split_screen_spec.rb@@ -0,0 +1,91 @@+require 'spec_helper'+require 'support/components/notifications/center'++describe "Split screen in the notification center", type: :feature, js: true do+ shared_let(:project) { FactoryBot.create :project }+ shared_let(:work_package) { FactoryBot.create :work_package, project: project }+ shared_let(:second_work_package) { FactoryBot.create :work_package, project: project }+ shared_let(:recipient) do+ FactoryBot.create :user,+ member_in_project: project,+ member_with_permissions: %i[view_work_packages]+ end+ shared_let(:notification) do+ FactoryBot.create :notification,+ recipient: recipient,+ project: project,+ resource: work_package,+ journal: work_package.journals.last+ end++ shared_let(:second_notification) do+ FactoryBot.create :notification,+ recipient: recipient,+ project: project,+ resource: second_work_package,+ journal: work_package.journals.last+ end++ let(:center) { ::Components::Notifications::Center.new }+ let(:split_screen) { ::Pages::SplitWorkPackage.new work_package }++ describe 'basic use case' do+ current_user { recipient }++ before do+ visit home_path+ center.open+ end++ it 'can switch between multiple notifications and the split screen remains open and updates accordingly' do+ center.expect_bell_count 2+ center.click_item notification++ # Opening the split screen marks the notifications as read+ split_screen.expect_open+ center.expect_read_item notification+ center.expect_work_package_item second_notification++ # Clicking on a another notification changes the split screen content+ center.click_item second_notification+ split_screen = ::Pages::SplitWorkPackage.new(second_work_package, project)+ split_screen.expect_open+ center.expect_read_item second_notification++ # Since both are marked as read, there are no notifications left+ center.close+ center.expect_bell_count 0++ center.open+ center.expect_empty+ end++ it 'can navigate between the tabs' do+ center.expect_bell_count 2+ center.click_item notification+ split_screen.expect_open++ # Activity is selected as default+ split_screen.expect_tab :activity+ activity_tab = ::Components::WorkPackages::Activities.new(work_package)+ activity_tab.expect_wp_has_been_created_activity work_package++ # Navigate to the relations tab+ split_screen.switch_to_tab tab: 'relations'+ split_screen.expect_tab :relations+ relations_tab = ::Components::WorkPackages::Relations.new(work_package)+ relations_tab.expect_no_relation work_package++ # Navigate to full view and back+ wp_full = split_screen.switch_to_fullscreen+ wp_full.expect_tab :relations++ wp_full.go_back+ split_screen.expect_tab :relations++ # The split screen can be closed+ split_screen.close+ split_screen.expect_closed+ end+ end+enddiff --git a/spec/support/components/notifications/center.rb b/spec/support/components/notifications/center.rbindex 9a9144745e6..1969aadd892 100644--- a/spec/support/components/notifications/center.rb+++ b/spec/support/components/notifications/center.rb@@ -95,6 +95,14 @@ module Componentsexpect(page).to have_text 'No unread notifications'end+ def expect_number_of_notifications(count)+ if count == 0+ expect(page).to have_no_selector('[data-qa-selector^="op-ian-notification-item-"]')+ else+ expect(page).to have_selector('[data-qa-selector^="op-ian-notification-item-"]', count: count, wait: 20)+ end+ end+def expect_bell_count(count)if count == 0expect(page).to have_no_selector('[data-qa-selector="op-ian-notifications-count"]')diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rbindex c258686f2e9..c0b936ea067 100644--- a/spec/support/components/work_packages/activities.rb+++ b/spec/support/components/work_packages/activities.rb@@ -39,9 +39,9 @@ module Components@container = '.work-package-details-activities-list'end- def expect_activity_listed(activity)+ def expect_wp_has_been_created_activity(work_package)within @container do- expect(page).to have_content(activity)+ expect(page).to have_content("created on #{work_package.created_at.strftime('%m/%d/%Y')}")endenddiff --git a/spec/support/pages/work_packages/split_work_package.rb b/spec/support/pages/work_packages/split_work_package.rbindex 30ef22726d2..5fb20724306 100644--- a/spec/support/pages/work_packages/split_work_package.rb+++ b/spec/support/pages/work_packages/split_work_package.rb@@ -49,10 +49,7 @@ module Pagesdef expect_openexpect(page).to have_selector(@selector)-- within container do- expect(page).to have_selector('.work-packages--details--subject', text: work_package.subject)- end+ expect_subjectenddef close