kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
4.9 KiB
141 lines
4.9 KiB
3 years ago
|
require 'spec_helper'
|
||
|
require 'support/components/notifications/center'
|
||
|
|
||
3 years ago
|
describe "Notification center", type: :feature, js: true do
|
||
3 years ago
|
shared_let(:project) { FactoryBot.create :project }
|
||
|
shared_let(:work_package) { FactoryBot.create :work_package, project: project }
|
||
3 years ago
|
shared_let(:second_work_package) { FactoryBot.create :work_package, project: project }
|
||
3 years ago
|
shared_let(:recipient) do
|
||
|
FactoryBot.create :user,
|
||
|
member_in_project: project,
|
||
|
member_with_permissions: %i[view_work_packages]
|
||
|
end
|
||
|
shared_let(:notification) do
|
||
|
FactoryBot.create :notification,
|
||
|
recipient: recipient,
|
||
|
project: project,
|
||
|
resource: work_package,
|
||
|
journal: work_package.journals.last
|
||
|
end
|
||
|
|
||
3 years ago
|
shared_let(:second_notification) do
|
||
3 years ago
|
FactoryBot.create :notification,
|
||
|
recipient: recipient,
|
||
|
project: project,
|
||
3 years ago
|
resource: second_work_package,
|
||
3 years ago
|
journal: work_package.journals.last
|
||
|
end
|
||
|
|
||
3 years ago
|
let(:center) { ::Components::Notifications::Center.new }
|
||
3 years ago
|
let(:activity_tab) { ::Components::WorkPackages::Activities.new(work_package) }
|
||
|
let(:split_screen) { ::Pages::SplitWorkPackage.new work_package }
|
||
3 years ago
|
|
||
3 years ago
|
describe 'notification for a new journal' do
|
||
|
current_user { recipient }
|
||
|
|
||
|
it 'will not show all details of the journal' do
|
||
|
allow(notification.journal).to receive(:initial?).and_return true
|
||
|
visit home_path
|
||
3 years ago
|
center.expect_bell_count 2
|
||
3 years ago
|
center.open
|
||
|
|
||
|
center.expect_work_package_item notification
|
||
3 years ago
|
center.expect_work_package_item second_notification
|
||
3 years ago
|
center.click_item notification
|
||
3 years ago
|
split_screen.expect_open
|
||
3 years ago
|
|
||
3 years ago
|
activity_tab.expect_wp_has_been_created_activity work_package
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
describe 'basic use case' do
|
||
|
current_user { recipient }
|
||
|
|
||
|
it 'can see the notification and dismiss it' do
|
||
|
visit home_path
|
||
3 years ago
|
center.expect_bell_count 2
|
||
3 years ago
|
center.open
|
||
|
|
||
|
center.expect_work_package_item notification
|
||
3 years ago
|
center.expect_work_package_item second_notification
|
||
3 years ago
|
center.mark_all_read
|
||
|
|
||
|
center.expect_bell_count 0
|
||
|
notification.reload
|
||
|
expect(notification.read_ian).to be_truthy
|
||
3 years ago
|
|
||
|
center.expect_no_item notification
|
||
3 years ago
|
center.expect_no_item second_notification
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
3 years ago
|
it 'can open the split screen of the notification to mark it as read' do
|
||
3 years ago
|
visit home_path
|
||
3 years ago
|
center.expect_bell_count 2
|
||
3 years ago
|
center.open
|
||
|
|
||
|
center.click_item notification
|
||
3 years ago
|
split_screen.expect_open
|
||
3 years ago
|
center.expect_read_item notification
|
||
3 years ago
|
center.expect_work_package_item second_notification
|
||
3 years ago
|
|
||
|
retry_block do
|
||
|
notification.reload
|
||
|
raise "Expected notification to be marked read" unless notification.read_ian
|
||
|
end
|
||
|
|
||
3 years ago
|
center.close
|
||
|
center.expect_bell_count 1
|
||
|
|
||
|
center.open
|
||
|
center.expect_no_item notification
|
||
3 years ago
|
center.expect_work_package_item second_notification
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context 'with multiple notifications per work package' do
|
||
|
# In this context we have four notifications for two work packages.
|
||
|
shared_let(:third_notification) do
|
||
3 years ago
|
FactoryBot.create :notification,
|
||
|
recipient: recipient,
|
||
|
project: project,
|
||
|
resource: second_work_package,
|
||
|
journal: work_package.journals.last
|
||
|
end
|
||
3 years ago
|
shared_let(:fourth_notification) do
|
||
3 years ago
|
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
|
||
3 years ago
|
center.expect_bell_count 4
|
||
3 years ago
|
center.open
|
||
|
|
||
3 years ago
|
center.expect_number_of_notifications 2
|
||
|
|
||
3 years ago
|
# Click on first list item, which should be the youngest notification
|
||
3 years ago
|
center.click_item fourth_notification
|
||
3 years ago
|
|
||
|
split_screen.expect_open
|
||
3 years ago
|
center.expect_read_item fourth_notification
|
||
3 years ago
|
expect(notification.reload.read_ian).to be_truthy
|
||
|
expect(second_notification.reload.read_ian).to be_falsey
|
||
3 years ago
|
expect(third_notification.reload.read_ian).to be_falsey
|
||
|
expect(fourth_notification.reload.read_ian).to be_truthy
|
||
3 years ago
|
|
||
|
# 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.
|
||
3 years ago
|
center.click_item third_notification
|
||
3 years ago
|
|
||
|
second_split_screen.expect_open
|
||
3 years ago
|
center.expect_read_item third_notification
|
||
3 years ago
|
expect(second_notification.reload.read_ian).to be_truthy
|
||
3 years ago
|
expect(third_notification.reload.read_ian).to be_truthy
|
||
3 years ago
|
end
|
||
|
end
|
||
3 years ago
|
end
|
||
|
end
|