Skip to content

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

Don't mark a notification as read when clicking on it

Henriette Darge44745a50ecc1
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
index 6e46ae68456..214f2a8beba 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
@@ -60,6 +60,7 @@
<div class="op-ian-item--buttons">
<i
*ngIf="!notification.readIAN"
+ data-qa-selector="mark-as-read-button"
class="op-ian-item--button icon-mark-read"
(click)="markAsRead($event, aggregatedNotifications)"
>
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
index 39b23caf48d..15ce19b1d33 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
@@ -135,10 +135,6 @@ export class InAppNotificationEntryComponent implements OnInit {
return;
}
- if (!this.notification.readIAN) {
- this.ianService.markAsRead(this.aggregatedNotifications, true);
- }
-
this
.workPackage$
.pipe(
diff --git a/spec/features/notifications/notification_center/notification_center_spec.rb b/spec/features/notifications/notification_center/notification_center_spec.rb
index e7683bd4adc..05040b93e4e 100644
--- a/spec/features/notifications/notification_center/notification_center_spec.rb
+++ b/spec/features/notifications/notification_center/notification_center_spec.rb
@@ -68,16 +68,18 @@ describe "Notification center", type: :feature, js: true do
center.expect_no_item second_notification
end
- it 'can open the split screen of the notification to mark it as read' do
+ it 'can open the split screen of the notification' 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_item_not_read notification
center.expect_work_package_item second_notification
+ center.mark_notification_as_read notification
+
retry_block do
notification.reload
raise "Expected notification to be marked read" unless notification.read_ian
@@ -120,7 +122,7 @@ describe "Notification center", type: :feature, js: true do
center.click_item fourth_notification
split_screen.expect_open
- center.expect_read_item fourth_notification
+ center.mark_notification_as_read fourth_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_falsey
@@ -131,7 +133,7 @@ describe "Notification center", type: :feature, js: true do
center.click_item third_notification
second_split_screen.expect_open
- center.expect_read_item third_notification
+ center.mark_notification_as_read third_notification
expect(second_notification.reload.read_ian).to be_truthy
expect(third_notification.reload.read_ian).to be_truthy
end
diff --git a/spec/features/notifications/notification_center/split_screen_spec.rb b/spec/features/notifications/notification_center/split_screen_spec.rb
index 055a553421b..9d137e2e6ed 100644
--- a/spec/features/notifications/notification_center/split_screen_spec.rb
+++ b/spec/features/notifications/notification_center/split_screen_spec.rb
@@ -43,21 +43,14 @@ describe "Split screen in the notification center", type: :feature, js: true do
# Opening the split screen marks the notifications as read
split_screen.expect_open
- center.expect_read_item notification
+ center.expect_work_package_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
+ center.expect_work_package_item second_notification
end
it 'can navigate between the tabs' do
diff --git a/spec/support/components/notifications/center.rb b/spec/support/components/notifications/center.rb
index e9665554867..4b26a0e13c5 100644
--- a/spec/support/components/notifications/center.rb
+++ b/spec/support/components/notifications/center.rb
@@ -48,6 +48,12 @@ module Components
click_button 'Mark all as read'
end
+ def mark_notification_as_read(notification)
+ within_item(notification) do
+ page.find('[data-qa-selector="mark-as-read-button"]').click
+ end
+ end
+
def show_all
click_button 'All'
end
@@ -65,7 +71,7 @@ module Components
def expect_item(notification, subject: notification.subject)
within_item(notification) do
- expect(page).to have_text subject
+ expect(page).to have_text subject, normalize_ws: true
end
end
@@ -79,12 +85,17 @@ module Components
.to have_selector("[data-qa-selector='op-ian-notification-item-#{notification.id}'][data-qa-ian-read]")
end
+ def expect_item_not_read(notification)
+ expect(page)
+ .not_to have_selector("[data-qa-selector='op-ian-notification-item-#{notification.id}'][data-qa-ian-read]")
+ end
+
def expect_work_package_item(notification)
work_package = notification.resource
raise(ArgumentError, "Expected work package") unless work_package.is_a?(WorkPackage)
expect_item notification,
- subject: "#{work_package.type.name.upcase} ##{work_package.id} #{work_package.subject}"
+ subject: "#{work_package.type.name.upcase} #{work_package.subject}"
end
def expect_closed