debian-mirror-gitlab/spec/features/projects/show/user_manages_notifications_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

88 lines
2.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Projects > Show > User manages notifications', :js, feature_category: :projects do
2018-10-15 14:42:47 +05:30
let(:project) { create(:project, :public, :repository) }
before do
2023-03-04 22:38:38 +05:30
stub_feature_flags(vscode_web_ide: false)
2022-04-04 11:22:00 +05:30
sign_in(project.first_owner)
2018-10-15 14:42:47 +05:30
end
2019-02-15 15:39:39 +05:30
def click_notifications_button
2021-04-17 20:07:23 +05:30
first('[data-testid="notification-dropdown"]').click
2019-02-15 15:39:39 +05:30
end
it 'changes the notification setting' do
2020-04-08 14:13:33 +05:30
visit project_path(project)
2019-02-15 15:39:39 +05:30
click_notifications_button
2021-04-17 20:07:23 +05:30
click_button 'On mention'
2018-10-15 14:42:47 +05:30
2021-04-17 20:07:23 +05:30
wait_for_requests
2019-02-15 15:39:39 +05:30
click_notifications_button
2021-04-17 20:07:23 +05:30
page.within first('[data-testid="notification-dropdown"]') do
2023-03-04 22:38:38 +05:30
expect(page.find('.gl-dropdown-item.is-active')).to have_content('On mention')
2021-04-17 20:07:23 +05:30
expect(page).to have_css('[data-testid="notifications-icon"]')
end
2019-07-31 22:56:46 +05:30
end
it 'changes the notification setting to disabled' do
2020-04-08 14:13:33 +05:30
visit project_path(project)
2019-07-31 22:56:46 +05:30
click_notifications_button
2021-04-17 20:07:23 +05:30
click_button 'Disabled'
2019-07-31 22:56:46 +05:30
2021-04-17 20:07:23 +05:30
page.within first('[data-testid="notification-dropdown"]') do
expect(page).to have_css('[data-testid="notifications-off-icon"]')
2021-01-03 14:25:43 +05:30
end
2018-10-15 14:42:47 +05:30
end
2018-11-18 11:00:15 +05:30
context 'custom notification settings' do
let(:email_events) do
[
:new_note,
:new_issue,
:reopen_issue,
:close_issue,
:reassign_issue,
:issue_due,
:new_merge_request,
:push_to_merge_request,
:reopen_merge_request,
:close_merge_request,
:reassign_merge_request,
:merge_merge_request,
:failed_pipeline,
2020-04-08 14:13:33 +05:30
:fixed_pipeline,
2020-10-24 23:57:45 +05:30
:success_pipeline,
:moved_project
2018-11-18 11:00:15 +05:30
]
end
it 'shows notification settings checkbox' do
2020-04-08 14:13:33 +05:30
visit project_path(project)
2019-02-15 15:39:39 +05:30
click_notifications_button
2021-04-17 20:07:23 +05:30
click_button 'Custom'
wait_for_requests
2018-11-18 11:00:15 +05:30
2021-04-17 20:07:23 +05:30
page.within('#custom-notifications-modal') do
2018-11-18 11:00:15 +05:30
email_events.each do |event_name|
2021-04-17 20:07:23 +05:30
expect(page).to have_selector("[data-testid='notification-setting-#{event_name}']")
2018-11-18 11:00:15 +05:30
end
end
end
end
2019-10-12 21:52:04 +05:30
context 'when project emails are disabled' do
let(:project) { create(:project, :public, :repository, emails_disabled: true) }
it 'is disabled' do
2020-04-08 14:13:33 +05:30
visit project_path(project)
2021-04-17 20:07:23 +05:30
expect(page).to have_selector('[data-testid="notification-dropdown"] .disabled', visible: true)
2019-10-12 21:52:04 +05:30
end
end
2018-10-15 14:42:47 +05:30
end