diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts index 0979826f6503..9c41f1a46587 100644 --- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts +++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts @@ -111,7 +111,28 @@ export class IanCenterService extends UntilDestroyedMixin { notifications$ = this .aggregatedCenterNotifications$ .pipe( - map((items) => Object.values(items)), + map((items) => { + return Object.values(items).reduce((acc, workPackageNotificationGroup) => { + const { reminders, others } = workPackageNotificationGroup.reduce((result, notification) => { + if (notification.reason === 'reminder') { + result.reminders.push(notification); + } else { + result.others.push(notification); + } + return result; + }, { reminders: [] as INotification[], others: [] as INotification[] }); + + // Extract reminders into standalone groups so they can be displayed individually + if (reminders.length > 0) { + reminders.forEach((reminder) => acc.push([reminder])); + } + if (others.length > 0) { + acc.push(others); + } + + return acc; + }, [] as INotification[][]); + }), distinctUntilChanged(), ); diff --git a/spec/features/notifications/notification_center/notification_center_reminder_spec.rb b/spec/features/notifications/notification_center/notification_center_reminder_spec.rb index 3b9f45e28aec..015aa20a36f1 100644 --- a/spec/features/notifications/notification_center/notification_center_reminder_spec.rb +++ b/spec/features/notifications/notification_center/notification_center_reminder_spec.rb @@ -4,6 +4,7 @@ RSpec.describe "Notification center reminder, mention and date alert", :js, :with_cuprite, + with_ee: %i[date_alerts], with_settings: { journal_aggregation_time_minutes: 0 } do shared_let(:project) { create(:project) } shared_let(:actor) { create(:user, firstname: "Actor", lastname: "User") } @@ -46,13 +47,18 @@ wait_for_reload end - context "with reminders", with_ee: %i[date_alerts] do - it "shows only the reminder alert time and note" do - center.within_item(notification_reminder) do - expect(page).to have_text("Date alert, Mentioned, Reminder") - expect(page).to have_no_text("Actor user") - expect(page).to have_text("a few seconds ago.\nNote: “This is an important reminder”") - end + it "shows the reminder alert in own entry" do + center.within_item(notification_reminder) do + expect(page).to have_text("##{work_package.id}\n- #{project.name} -\nReminder") + expect(page).to have_no_text("Actor user") + expect(page).to have_text("a few seconds ago.\nNote: “This is an important reminder”") + end + end + + it "shows other notification reasons aggregated" do + center.within_item(notification_date_alert) do + expect(page).to have_text("##{work_package.id}\n- #{project.name} -\nDate alert, Mentioned") + expect(page).to have_no_text("Actor user") end end end