debian-mirror-gitlab/spec/features/projects/settings/monitor_settings_spec.rb

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

221 lines
6.2 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Projects > Settings > For a forked project', :js, feature_category: :projects do
2023-05-27 22:25:52 +05:30
include ListboxHelpers
2021-06-08 01:23:25 +05:30
let_it_be(:project) { create(:project, :repository, create_templates: :issue) }
2022-04-04 11:22:00 +05:30
let(:user) { project.first_owner }
2019-02-15 15:39:39 +05:30
before do
sign_in(user)
end
2021-06-08 01:23:25 +05:30
describe 'Sidebar > Monitor' do
it 'renders the menu in the sidebar' do
2019-02-15 15:39:39 +05:30
visit project_path(project)
wait_for_requests
2021-11-18 22:05:49 +05:30
expect(page).to have_selector('.sidebar-sub-level-items a[aria-label="Monitor"]',
text: 'Monitor', visible: :hidden)
2021-06-08 01:23:25 +05:30
end
2019-02-15 15:39:39 +05:30
end
2019-07-07 11:18:12 +05:30
2021-06-08 01:23:25 +05:30
describe 'Settings > Monitor' do
2020-03-13 15:44:24 +05:30
describe 'Incidents' do
2021-02-22 17:27:13 +05:30
let(:create_issue) { 'Create an incident. Incidents are created for each alert triggered.' }
2021-04-17 20:07:23 +05:30
let(:send_email) { 'Send a single email notification to Owners and Maintainers for new alerts.' }
2020-03-13 15:44:24 +05:30
before do
create(:project_incident_management_setting, send_email: true, project: project)
visit project_settings_operations_path(project)
wait_for_requests
2021-09-04 01:27:46 +05:30
click_settings_tab
2020-03-13 15:44:24 +05:30
end
it 'renders form for incident management' do
2020-10-24 23:57:45 +05:30
expect(page).to have_selector('h4', text: 'Incidents')
2020-03-13 15:44:24 +05:30
end
it 'sets correct default values' do
expect(find_field(create_issue)).not_to be_checked
expect(find_field(send_email)).to be_checked
end
2021-11-18 22:05:49 +05:30
it 'updates form values' do
2020-03-13 15:44:24 +05:30
check(create_issue)
uncheck(send_email)
2020-10-24 23:57:45 +05:30
click_on('No template selected')
2023-05-27 22:25:52 +05:30
select_listbox_item('bug')
2020-03-13 15:44:24 +05:30
save_form
2021-09-04 01:27:46 +05:30
click_settings_tab
2020-03-13 15:44:24 +05:30
expect(find_field(create_issue)).to be_checked
expect(find_field(send_email)).not_to be_checked
2021-11-18 22:05:49 +05:30
expect(page).to have_selector(:id, 'alert-integration-settings-issue-template', text: 'bug')
2020-03-13 15:44:24 +05:30
end
2021-09-04 01:27:46 +05:30
def click_settings_tab
within '[data-testid="alert-integration-settings"]' do
click_link 'Alert settings'
2020-03-13 15:44:24 +05:30
end
end
def save_form
2021-09-04 01:27:46 +05:30
page.within '[data-testid="alert-integration-settings"]' do
click_button 'Save changes'
2020-03-13 15:44:24 +05:30
end
2021-11-18 22:05:49 +05:30
wait_for_all_requests
2020-03-13 15:44:24 +05:30
end
end
2021-11-18 22:05:49 +05:30
describe 'error tracking settings form' do
2019-07-07 11:18:12 +05:30
let(:sentry_list_projects_url) { 'http://sentry.example.com/api/0/projects/' }
2021-11-18 22:05:49 +05:30
context 'when project dropdown is loaded' do
2019-07-07 11:18:12 +05:30
let(:projects_sample_response) do
Gitlab::Utils.deep_indifferent_access(
2020-05-24 23:13:21 +05:30
Gitlab::Json.parse(fixture_file('sentry/list_projects_sample_response.json'))
2019-07-07 11:18:12 +05:30
)
end
before do
WebMock.stub_request(:get, sentry_list_projects_url)
.to_return(
status: 200,
headers: { 'Content-Type' => 'application/json' },
body: projects_sample_response.to_json
)
end
it 'successfully fills and submits the form' do
visit project_settings_operations_path(project)
wait_for_requests
2019-09-04 21:01:54 +05:30
within '.js-error-tracking-settings' do
click_button('Expand')
2021-11-18 22:05:49 +05:30
choose('cloud-hosted Sentry')
2019-09-04 21:01:54 +05:30
end
2021-11-18 22:05:49 +05:30
2019-07-07 11:18:12 +05:30
expect(page).to have_content('Sentry API URL')
expect(page.body).to include('Error Tracking')
expect(page).to have_button('Connect')
check('Active')
fill_in('error-tracking-api-host', with: 'http://sentry.example.com')
fill_in('error-tracking-token', with: 'token')
click_button('Connect')
within('div#project-dropdown') do
click_button('Select project')
2023-03-17 16:20:25 +05:30
find('li', text: 'Sentry | internal').click
2019-07-07 11:18:12 +05:30
end
click_button('Save changes')
wait_for_requests
assert_text('Your changes have been saved')
end
end
2021-11-18 22:05:49 +05:30
context 'when project dropdown fails to load' do
2019-07-07 11:18:12 +05:30
before do
WebMock.stub_request(:get, sentry_list_projects_url)
.to_return(
status: 400,
headers: { 'Content-Type' => 'application/json' },
body: {
message: 'Sentry response code: 401'
}.to_json
)
end
it 'displays error message' do
visit project_settings_operations_path(project)
wait_for_requests
2019-09-04 21:01:54 +05:30
within '.js-error-tracking-settings' do
click_button('Expand')
2021-11-18 22:05:49 +05:30
choose('cloud-hosted Sentry')
check('Active')
2019-09-04 21:01:54 +05:30
end
2021-11-18 22:05:49 +05:30
2019-07-07 11:18:12 +05:30
fill_in('error-tracking-api-host', with: 'http://sentry.example.com')
fill_in('error-tracking-token', with: 'token')
click_button('Connect')
2021-04-29 21:17:54 +05:30
assert_text('Connection failed. Check Auth Token and try again.')
2019-07-07 11:18:12 +05:30
end
end
2021-11-11 11:23:49 +05:30
2021-11-18 22:05:49 +05:30
context 'with integrated error tracking backend' do
2021-11-11 11:23:49 +05:30
it 'successfully fills and submits the form' do
visit project_settings_operations_path(project)
wait_for_requests
within '.js-error-tracking-settings' do
click_button('Expand')
end
expect(page).to have_content('Error tracking backend')
within '.js-error-tracking-settings' do
check('Active')
choose('GitLab')
end
expect(page).not_to have_content('Sentry API URL')
click_button('Save changes')
wait_for_requests
assert_text('Your changes have been saved')
2021-11-18 22:05:49 +05:30
within '.js-error-tracking-settings' do
click_button('Expand')
end
expect(page).to have_content('Paste this DSN into your Sentry SDK')
2021-11-11 11:23:49 +05:30
end
end
2019-07-07 11:18:12 +05:30
end
2019-12-26 22:10:19 +05:30
2021-11-18 22:05:49 +05:30
describe 'grafana integration settings form' do
2019-12-26 22:10:19 +05:30
it 'successfully fills and completes the form' do
visit project_settings_operations_path(project)
wait_for_requests
within '.js-grafana-integration' do
click_button('Expand')
end
expect(page).to have_content('Grafana URL')
2021-04-17 20:07:23 +05:30
expect(page).to have_content('API token')
expect(page).to have_button('Save changes')
2019-12-26 22:10:19 +05:30
fill_in('grafana-url', with: 'http://gitlab-test.grafana.net')
fill_in('grafana-token', with: 'token')
2021-04-17 20:07:23 +05:30
click_button('Save changes')
2019-12-26 22:10:19 +05:30
wait_for_requests
assert_text('Your changes have been saved')
end
end
2019-07-07 11:18:12 +05:30
end
2019-02-15 15:39:39 +05:30
end