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

Add test case for switching between different split screens

Henriette Dargee1e8665a8433
diff --git a/spec/features/notifications/notification_center_spec.rb b/spec/features/notifications/notification_center_spec.rb
index 2539836c763..0dd65541ef1 100644
--- a/spec/features/notifications/notification_center_spec.rb
+++ b/spec/features/notifications/notification_center_spec.rb
@@ -4,6 +4,7 @@ require 'support/components/notifications/center'
describe "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(:work_package2) { FactoryBot.create :work_package, project: project }
shared_let(:recipient) do
FactoryBot.create :user,
member_in_project: project,
@@ -17,6 +18,14 @@ describe "Notification center", type: :feature, js: true do
journal: work_package.journals.last
end
+ shared_let(:notification2) do
+ FactoryBot.create :notification,
+ recipient: recipient,
+ project: project,
+ resource: work_package2,
+ journal: work_package.journals.last
+ end
+
let(:center) { ::Components::Notifications::Center.new }
let(:activity_tab) { ::Components::WorkPackages::Activities.new(work_package) }
let(:split_screen) { ::Pages::SplitWorkPackage.new work_package }
@@ -27,10 +36,11 @@ describe "Notification center", type: :feature, js: true do
it 'will not show all details of the journal' do
allow(notification.journal).to receive(:initial?).and_return true
visit home_path
- center.expect_bell_count 1
+ center.expect_bell_count 2
center.open
center.expect_work_package_item notification
+ center.expect_work_package_item notification2
center.click_item notification
split_screen.expect_open
@@ -43,31 +53,62 @@ describe "Notification center", type: :feature, js: true do
it 'can see the notification and dismiss it' do
visit home_path
- center.expect_bell_count 1
+ center.expect_bell_count 2
center.open
center.expect_work_package_item notification
+ center.expect_work_package_item notification2
center.mark_all_read
center.expect_bell_count 0
notification.reload
expect(notification.read_ian).to be_truthy
+
+ center.expect_no_item notification
+ center.expect_no_item notification2
end
it 'can open the split screen of the notification to mark it as read' do
visit home_path
- center.expect_bell_count 1
+ 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
retry_block do
notification.reload
raise "Expected notification to be marked read" unless notification.read_ian
end
+ center.close
+ center.expect_bell_count 1
+
+ center.open
+ center.expect_no_item notification
+ center.expect_work_package_item notification2
+ end
+
+ 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
diff --git a/spec/support/components/notifications/center.rb b/spec/support/components/notifications/center.rb
index 4e4faa70077..b39ba76323d 100644
--- a/spec/support/components/notifications/center.rb
+++ b/spec/support/components/notifications/center.rb
@@ -65,6 +65,11 @@ module Components
end
end
+ def expect_no_item(notification)
+ expect(page)
+ .to have_no_selector("[data-qa-selector='op-ian-notification-item-#{notification.id}']")
+ end
+
def expect_read_item(notification)
expect(page)
.to have_selector("[data-qa-selector='op-ian-notification-item-#{notification.id}'][data-qa-ian-read]")