From 3b645c571afca048f401946319c1629cdf256285 Mon Sep 17 00:00:00 2001 From: Wieland Lindenthal Date: Fri, 6 Aug 2021 15:46:45 +0200 Subject: [PATCH] IAN center: feature spec for notification aggregation --- .../notifications/notification_center_spec.rb | 43 +++++++++++++++++++ .../components/notifications/center.rb | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/spec/features/notifications/notification_center_spec.rb b/spec/features/notifications/notification_center_spec.rb index 0dd65541ef..be59a99fd4 100644 --- a/spec/features/notifications/notification_center_spec.rb +++ b/spec/features/notifications/notification_center_spec.rb @@ -115,5 +115,48 @@ describe "Notification center", type: :feature, js: true do 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 + FactoryBot.create :notification, + recipient: recipient, + project: project, + resource: second_work_package, + journal: work_package.journals.last + end + shared_let(:third_notification) do + FactoryBot.create :notification, + recipient: recipient, + project: project, + resource: work_package, + journal: work_package.journals.last + end + let(:second_split_screen) { ::Pages::SplitWorkPackage.new second_work_package } + + it 'aggregates notifications per work package and sets all as read when opened' do + visit home_path + center.expect_bell_count 3 + center.open + + # Click on first list item, which should be the youngest notification + center.click_item third_notification + + split_screen.expect_open + center.expect_read_item third_notification + expect(notification.reload.read_ian).to be_truthy + expect(second_notification.reload.read_ian).to be_falsey + expect(third_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 + + second_split_screen.expect_open + center.expect_read_item second_notification + expect(second_notification.reload.read_ian).to be_truthy + end + end end end diff --git a/spec/support/components/notifications/center.rb b/spec/support/components/notifications/center.rb index b39ba76323..9a9144745e 100644 --- a/spec/support/components/notifications/center.rb +++ b/spec/support/components/notifications/center.rb @@ -108,4 +108,4 @@ module Components end end end -end \ No newline at end of file +end