2020-10-01 11:10:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Incident details', :js do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:developer) { create(:user) }
|
2020-10-05 11:08:56 -04:00
|
|
|
let_it_be(:incident) { create(:incident, project: project, author: developer, description: 'description') }
|
2022-06-30 11:09:03 -04:00
|
|
|
let_it_be(:issue) { create(:issue, project: project, author: developer, description: 'Issue description') }
|
2022-03-15 08:07:44 -04:00
|
|
|
let_it_be(:escalation_status) { create(:incident_management_issuable_escalation_status, issue: incident) }
|
2020-10-01 11:10:05 -04:00
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_developer(developer)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(developer)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a developer+ displays the incident' do
|
2022-06-30 11:09:03 -04:00
|
|
|
before do
|
|
|
|
visit project_issues_incident_path(project, incident)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows correct elements on the page', :aggregate_failures do
|
|
|
|
# shows the incident
|
2020-10-01 11:10:05 -04:00
|
|
|
page.within('.issuable-details') do
|
2022-02-22 04:18:00 -05:00
|
|
|
expect(find('h1')).to have_content(incident.title)
|
2020-10-01 11:10:05 -04:00
|
|
|
end
|
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
# does not show design management
|
2020-10-01 11:10:05 -04:00
|
|
|
expect(page).not_to have_selector('.js-design-management')
|
2020-10-05 11:08:56 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
# shows the incident tabs
|
2020-10-05 11:08:56 -04:00
|
|
|
page.within('.issuable-details') do
|
|
|
|
incident_tabs = find('[data-testid="incident-tabs"]')
|
|
|
|
|
2022-02-22 04:18:00 -05:00
|
|
|
expect(find('h1')).to have_content(incident.title)
|
2020-10-05 11:08:56 -04:00
|
|
|
expect(incident_tabs).to have_content('Summary')
|
|
|
|
expect(incident_tabs).to have_content(incident.description)
|
|
|
|
end
|
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
# shows the right sidebar mounted with type issue
|
2020-10-05 11:08:56 -04:00
|
|
|
page.within('.layout-page') do
|
|
|
|
sidebar = find('.right-sidebar')
|
|
|
|
|
|
|
|
expect(page).to have_selector('.right-sidebar[data-issuable-type="issue"]')
|
|
|
|
expect(sidebar).to have_selector('.incident-severity')
|
2021-01-15 10:10:31 -05:00
|
|
|
expect(sidebar).to have_selector('.milestone')
|
2022-03-15 08:07:44 -04:00
|
|
|
expect(sidebar).to have_selector('[data-testid="escalation_status_container"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
describe 'escalation status' do
|
2022-03-15 08:07:44 -04:00
|
|
|
let(:sidebar) { page.find('.right-sidebar') }
|
|
|
|
let(:widget) { sidebar.find('[data-testid="escalation_status_container"]') }
|
|
|
|
let(:expected_dropdown_options) { escalation_status.class::STATUSES.keys.take(3).map { |key| key.to_s.titleize } }
|
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
it 'has an interactable escalation status widget', :aggregate_failures do
|
2022-03-15 08:07:44 -04:00
|
|
|
expect(current_status).to have_text(escalation_status.status_name.to_s.titleize)
|
|
|
|
|
|
|
|
# list the available statuses
|
|
|
|
widget.find('[data-testid="edit-button"]').click
|
|
|
|
expect(dropdown_options.map(&:text)).to eq(expected_dropdown_options)
|
|
|
|
expect(widget).not_to have_selector('#escalation-status-help')
|
|
|
|
|
|
|
|
# update the status
|
|
|
|
select_resolved(dropdown_options)
|
|
|
|
expect(current_status).to have_text('Resolved')
|
|
|
|
expect(escalation_status.reload).to be_resolved
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def dropdown_options
|
|
|
|
widget.all('[data-testid="status-dropdown-item"]', count: 3)
|
|
|
|
end
|
|
|
|
|
|
|
|
def select_resolved(options)
|
|
|
|
options.last.click
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_status
|
|
|
|
widget.find('[data-testid="collapsed-content"]')
|
2020-10-05 11:08:56 -04:00
|
|
|
end
|
|
|
|
end
|
2020-10-01 11:10:05 -04:00
|
|
|
end
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
it 'routes the user to the incident details page when the `issue_type` is set to incident' do
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
project_path = "/#{project.full_path}"
|
|
|
|
click_button 'Edit title and description'
|
|
|
|
wait_for_requests
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
page.within('[data-testid="issuable-form"]') do
|
|
|
|
click_button 'Issue'
|
|
|
|
click_button 'Incident'
|
|
|
|
click_button 'Save changes'
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
wait_for_requests
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
expect(page).to have_current_path("#{project_path}/-/issues/incident/#{issue.iid}")
|
2021-05-19 17:12:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
it 'routes the user to the issue details page when the `issue_type` is set to issue' do
|
|
|
|
visit project_issues_incident_path(project, incident)
|
|
|
|
wait_for_requests
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
project_path = "/#{project.full_path}"
|
|
|
|
click_button 'Edit title and description'
|
|
|
|
wait_for_requests
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
page.within('[data-testid="issuable-form"]') do
|
|
|
|
click_button 'Incident'
|
|
|
|
click_button 'Issue'
|
|
|
|
click_button 'Save changes'
|
2021-05-19 17:12:42 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_current_path("#{project_path}/-/issues/#{incident.iid}")
|
2021-05-19 17:12:42 -04:00
|
|
|
end
|
|
|
|
end
|
2020-10-01 11:10:05 -04:00
|
|
|
end
|