Commit f3d36d39 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'incident-management-feature-specs' into 'master'

Incident management test coverage

See merge request gitlab-org/gitlab!44590
parents 9c31b4a8 68ed1561
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Alert details', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:alert) { create(:alert_management_alert, project: project, status: 'triggered', title: 'Alert') }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
visit details_project_alert_management_path(project, alert)
wait_for_requests
end
context 'when a developer displays the alert' do
it 'shows the alert' do
page.within('.alert-management-details') do
expect(find('h2')).to have_content(alert.title)
end
end
it 'shows the alert tabs' do
page.within('.alert-management-details') do
alert_tabs = find('[data-testid="alertDetailsTabs"]')
expect(alert_tabs).to have_content('Alert details')
end
end
it 'shows the right sidebar mounted with correct widgets' do
page.within('.layout-page') do
sidebar = find('.right-sidebar')
expect(sidebar).to have_selector('.alert-status')
expect(sidebar).to have_selector('.alert-assignees')
expect(sidebar).to have_content('Triggered')
end
end
it 'updates the alert todo button from the right sidebar' do
expect(page).to have_selector('[data-testid="alert-todo-button"]')
todo_button = find('[data-testid="alert-todo-button"]')
expect(todo_button).to have_content('Add a To-Do')
find('[data-testid="alert-todo-button"]').click
wait_for_requests
expect(todo_button).to have_content('Mark as done')
end
it 'updates the alert status from the right sidebar' do
page.within('.alert-status') do
alert_status = find('[data-testid="status"]')
expect(alert_status).to have_content('Triggered')
find('.btn-link').click
find('.gl-new-dropdown-item', text: 'Acknowledged').click
wait_for_requests
expect(alert_status).to have_content('Acknowledged')
end
end
it 'updates the alert assignee from the right sidebar' do
page.within('.right-sidebar') do
alert_assignee = find('.alert-assignees')
expect(alert_assignee).to have_content('None - assign yourself')
find('[data-testid="unassigned-users"]').click
wait_for_requests
expect(alert_assignee).to have_content('Assignee Edit John Doe')
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Alert Management index', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:alert) { create(:alert_management_alert, project: project, status: 'triggered') }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
visit project_alert_management_index_path(project)
wait_for_requests
end
context 'when a developer displays the alert list and the alert service is not enabled' do
it 'shows the alert page title' do
expect(page).to have_content('Alerts')
end
it 'shows the empty state by default' do
expect(page).to have_content('Surface alerts in GitLab')
end
it 'does not show the filtered search' do
page.within('.layout-page') do
expect(page).not_to have_css('[data-testid="search-icon"]')
end
end
it 'does not show the alert table' do
expect(page).not_to have_selector('.gl-table')
end
end
context 'when a developer displays the alert list and the alert service is enabled' do
let_it_be(:alerts_service) { create(:alerts_service, project: project) }
it 'shows the alert page title' do
expect(page).to have_content('Alerts')
end
it 'shows the filtered search' do
page.within('.layout-page') do
expect(page).to have_css('[data-testid="search-icon"]')
end
end
it 'shows the alert table' do
expect(page).to have_selector('.gl-table')
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User filters Alert Management table by status', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:alerts_service) { create(:alerts_service, project: project) }
let_it_be(:alert1, reload: true) { create(:alert_management_alert, :triggered, project: project) }
let_it_be(:alert2, reload: true) { create(:alert_management_alert, :acknowledged, project: project) }
let_it_be(:alert3, reload: true) { create(:alert_management_alert, :acknowledged, project: project) }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
visit project_alert_management_index_path(project)
wait_for_requests
end
context 'when a developer displays the alert list and the alert service is enabled they can filter the table by an alert status' do
it 'shows the alert table items with alert status of Open by default' do
expect(page).to have_selector('.gl-table')
expect(page).to have_content('Open 3')
end
it 'shows the alert table items with alert status of Acknowledged' do
find('.gl-tab-nav-item', text: 'Acknowledged').click
expect(page).to have_selector('.gl-tab-nav-item-active')
expect(find('.gl-tab-nav-item-active')).to have_content('Acknowledged 2')
expect(all('.dropdown-menu-selectable').count).to be(2)
end
it 'shows the alert table items with alert status of Triggered' do
find('.gl-tab-nav-item', text: 'Triggered').click
wait_for_requests
expect(page).to have_selector('.gl-tab-nav-item-active')
expect(find('.gl-tab-nav-item-active')).to have_content('Triggered 1')
expect(all('.dropdown-menu-selectable').count).to be(1)
end
it 'shows the an empty table for a status with no alerts' do
find('.gl-tab-nav-item', text: 'Resolved').click
wait_for_requests
expect(page).to have_selector('.gl-tab-nav-item-active')
expect(find('.gl-tab-nav-item-active')).to have_content('Resolved 0')
expect(page).to have_content('No alerts to display.')
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User searches Alert Management alerts', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:alerts_service) { create(:alerts_service, project: project) }
let_it_be(:alert) { create(:alert_management_alert, project: project, status: 'triggered') }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
visit project_alert_management_index_path(project)
wait_for_requests
end
context 'when a developer displays the alert list and the alert service is enabled they can search an alert' do
it 'shows the alert table with an alert for a valid search' do
expect(page).to have_selector('[data-testid="search-icon"]')
find('.gl-search-box-by-type-input').set('Alert')
expect(all('.dropdown-menu-selectable').count).to be(1)
end
it 'shows the an empty table with an invalid search' do
find('.gl-search-box-by-type-input').set('invalid search text')
expect(page).not_to have_selector('.dropdown-menu-selectable')
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Incident Management index', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:incident) { create(:incident, project: project) }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
visit project_incidents_path(project)
wait_for_requests
end
context 'when a developer displays the incident list' do
it 'shows the status tabs' do
expect(page).to have_selector('.gl-tabs')
end
it 'shows the filtered search' do
expect(page).to have_selector('.filtered-search-wrapper')
end
it 'shows the alert table' do
expect(page).to have_selector('.gl-table')
end
it 'alert page title' do
expect(page).to have_content('Incidents')
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Incident Management index', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:incident) { create(:incident, project: project) }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
visit project_incidents_path(project)
wait_for_requests
end
context 'when a developer displays the incident list' do
it 'shows the create new issue button' do
expect(page).to have_selector('.create-incident-button')
end
it 'shows the create issue page with the Incident type pre-selected when clicked' do
find('.create-incident-button').click
wait_for_requests
expect(page).to have_selector(".dropdown-menu-toggle")
expect(page).to have_selector(".js-issuable-type-filter-dropdown-wrap")
page.within('.js-issuable-type-filter-dropdown-wrap') do
expect(page).to have_content('Incident')
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User filters Incident Management table by status', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
before_all do
project.add_developer(developer)
create_list(:incident, 2, project: project, state: 'opened')
create(:incident, project: project, state: 'closed')
end
before do
sign_in(developer)
visit project_incidents_path(project)
wait_for_requests
end
context 'when a developer displays the incident list they can filter the table by an incident status' do
def the_page_shows_the_nav_text_with_correct_count
expect(page).to have_selector('.gl-table')
expect(page).to have_content('All 3')
expect(page).to have_content('Open 2')
expect(page).to have_content('Closed 1')
end
it 'shows the incident table items with incident status of Open by default' do
expect(find('.gl-tab-nav-item-active')).to have_content('Open 2')
expect(all('tbody tr').count).to be(2)
the_page_shows_the_nav_text_with_correct_count
end
it 'shows the incident table items with incident status of Closed' do
find('.gl-tab-nav-item', text: 'Closed').click
wait_for_requests
expect(find('.gl-tab-nav-item-active')).to have_content('Closed 1')
expect(all('tbody tr').count).to be(1)
the_page_shows_the_nav_text_with_correct_count
end
it 'shows the incident table items with all status' do
find('.gl-tab-nav-item', text: 'All').click
wait_for_requests
expect(find('.gl-tab-nav-item-active')).to have_content('All 3')
expect(all('[data-testid="incident-assignees"]').count).to be(3)
expect(all('tbody tr').count).to be(3)
the_page_shows_the_nav_text_with_correct_count
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User searches Incident Management incidents', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:incident) { create(:incident, project: project) }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
visit project_incidents_path(project)
wait_for_requests
end
context 'when a developer displays the incident list they can search for an incident' do
it 'shows the incident table with an incident for a valid search filter bar' do
expect(page).to have_selector('.filtered-search-wrapper')
expect(page).to have_selector('.gl-table')
expect(page).to have_selector('.incident-severity')
expect(all('tbody tr').count).to be(1)
expect(page).not_to have_selector('.empty-state')
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment