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 spec for date alerts displaying
Oliver Günther34bb1740002f
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex bee2fdc2982..fe305779aa1 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -592,7 +592,7 @@ en:prioritized: 'prioritized'dateAlert: 'Date alert'date_alerts:- work_package_is: 'Work package is'+ milestone_date: 'Milestone date'overdue: 'Overdue'overdue_since: 'since %{difference_in_days}'property_is: 'is in %{difference_in_days}'diff --git a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.tsindex 44f84cd6b8f..ede993fbf78 100644--- a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts+++ b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts@@ -48,7 +48,7 @@ export class InAppNotificationDateAlertComponent implements OnInit {this.I18n.t('js.notifications.date_alerts.property_was', { difference_in_days }),startDate: this.I18n.t('js.work_packages.properties.startDate'),dueDate: this.I18n.t('js.work_packages.properties.dueDate'),- date: this.I18n.t('js.work_packages.properties.date'),+ date: this.I18n.t('js.notifications.date_alerts.milestone_date'),};constructor(diff --git a/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb b/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rbnew file mode 100644index 00000000000..1fe1aaeae8b--- /dev/null+++ b/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb@@ -0,0 +1,113 @@+require 'spec_helper'++describe "Notification center date alerts", js: true, with_settings: { journal_aggregation_time_minutes: 0 } do+ create_shared_association_defaults_for_work_package_factory++ shared_let(:project) { project_with_types }+ shared_let(:role) { create :role, permissions: %i[view_work_packages edit_work_packages work_package_assigned] }+ shared_let(:membership) { create :member, principal: user, project: project_with_types, roles: [role] }+ shared_let(:milestone_type) { create :type_milestone }++ shared_let(:milestone_wp_past) { create :work_package, project:, type: milestone_type, due_date: 2.days.ago }+ shared_let(:milestone_wp_future) { create :work_package, project:, type: milestone_type, due_date: 1.day.from_now }++ shared_let(:wp_start_past) { create :work_package, project:, start_date: 1.day.ago }+ shared_let(:wp_start_future) { create :work_package, project:, start_date: 2.days.from_now }++ shared_let(:wp_due_past) { create :work_package, project:, due_date: 3.days.ago }+ shared_let(:wp_due_future) { create :work_package, project:, due_date: 3.days.from_now }++ shared_let(:wp_double_notification) { create :work_package, project:, due_date: 1.days.from_now }++ shared_let(:notification_milestone_past) do+ create :notification,+ reason: :date_alert_due_date,+ recipient: user,+ resource: milestone_wp_past,+ project:+ end++ shared_let(:notification_milestone_future) do+ create :notification,+ reason: :date_alert_due_date,+ recipient: user,+ resource: milestone_wp_future,+ project:+ end++ shared_let(:notification_wp_start_past) do+ create :notification,+ reason: :date_alert_start_date,+ recipient: user,+ resource: wp_start_past,+ project:+ end++ shared_let(:notification_wp_start_future) do+ create :notification,+ reason: :date_alert_start_date,+ recipient: user,+ resource: wp_start_future,+ project:+ end++ shared_let(:notification_wp_due_past) do+ create :notification,+ reason: :date_alert_due_date,+ recipient: user,+ resource: wp_due_past,+ project:+ end++ shared_let(:notification_wp_due_future) do+ create :notification,+ reason: :date_alert_due_date,+ recipient: user,+ resource: wp_due_future,+ project:+ end++ shared_let(:notification_wp_double_date_alert) do+ create :notification,+ reason: :date_alert_due_date,+ recipient: user,+ resource: wp_double_notification,+ project:+ end++ shared_let(:notification_wp_double_mention) do+ create :notification,+ reason: :mentioned,+ recipient: user,+ resource: wp_double_notification,+ project:+ end++ let(:center) { ::Pages::Notifications::Center.new }+ let(:side_menu) { ::Components::Notifications::Sidemenu.new }++ before do+ login_as user+ visit notifications_center_path+ end++ it 'shows the date alerts according to specification' do+ center.expect_item(notification_wp_start_past, 'Start date was 1 day ago')+ center.expect_item(notification_wp_start_future, 'Start date is in 2 days')++ center.expect_item(notification_wp_due_past, 'Overdue since 3 days')+ center.expect_item(notification_wp_due_future, 'Finish date is in 3 days')++ center.expect_item(notification_milestone_past, 'Overdue since 2 days')+ center.expect_item(notification_milestone_future, 'Finish date is in 1 day')++ # Doesn't show the date alert for the mention, not the alert+ center.expect_item(notification_wp_double_mention, /(seconds|minutes) ago by Anonymous/)+ center.expect_no_item(notification_wp_double_date_alert)++ # When switch to date alerts, it shows the alert, no longer the mention+ side_menu.click_item 'Date alert'+ center.expect_item(notification_wp_double_date_alert, 'Finish date is in 1 day')+ center.expect_no_item(notification_wp_double_mention)+ end+enddiff --git a/spec/support/pages/notifications/center.rb b/spec/support/pages/notifications/center.rbindex caec80dd2c6..5740771ae2e 100644--- a/spec/support/pages/notifications/center.rb+++ b/spec/support/pages/notifications/center.rb@@ -63,9 +63,9 @@ module Pagespage.within("[data-qa-selector='op-ian-notification-item-#{notification.id}']", &)end- def expect_item(notification, subject: notification.subject)+ def expect_item(notification, expected_text = notification.subject)within_item(notification) do- expect(page).to have_text subject, normalize_ws: true+ expect(page).to have_text expected_text, normalize_ws: trueendend@@ -97,7 +97,7 @@ module Pagesraise(ArgumentError, "Expected work package") unless work_package.is_a?(WorkPackage)expect_item notification,- subject: "#{work_package.type.name.upcase} #{work_package.subject}"+ "#{work_package.type.name.upcase} #{work_package.subject}"endend