summaryrefslogtreecommitdiff
path: root/spec/features/alert_management
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/alert_management')
-rw-r--r--spec/features/alert_management/alert_details_spec.rb86
-rw-r--r--spec/features/alert_management/alert_management_list_spec.rb58
-rw-r--r--spec/features/alert_management/user_filters_alerts_by_status_spec.rb56
-rw-r--r--spec/features/alert_management/user_searches_alerts_spec.rb31
-rw-r--r--spec/features/alert_management/user_updates_alert_status_spec.rb36
5 files changed, 267 insertions, 0 deletions
diff --git a/spec/features/alert_management/alert_details_spec.rb b/spec/features/alert_management/alert_details_spec.rb
new file mode 100644
index 00000000000..d190e4b6939
--- /dev/null
+++ b/spec/features/alert_management/alert_details_spec.rb
@@ -0,0 +1,86 @@
+# 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
diff --git a/spec/features/alert_management/alert_management_list_spec.rb b/spec/features/alert_management/alert_management_list_spec.rb
new file mode 100644
index 00000000000..c2514d80474
--- /dev/null
+++ b/spec/features/alert_management/alert_management_list_spec.rb
@@ -0,0 +1,58 @@
+# 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
diff --git a/spec/features/alert_management/user_filters_alerts_by_status_spec.rb b/spec/features/alert_management/user_filters_alerts_by_status_spec.rb
new file mode 100644
index 00000000000..ee516418cd6
--- /dev/null
+++ b/spec/features/alert_management/user_filters_alerts_by_status_spec.rb
@@ -0,0 +1,56 @@
+# 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
diff --git a/spec/features/alert_management/user_searches_alerts_spec.rb b/spec/features/alert_management/user_searches_alerts_spec.rb
new file mode 100644
index 00000000000..568321de025
--- /dev/null
+++ b/spec/features/alert_management/user_searches_alerts_spec.rb
@@ -0,0 +1,31 @@
+# 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 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_css('[data-testid="severityField"]')
+ expect(all('tbody tr').count).to be(1)
+ expect(page).not_to have_selector('.empty-state')
+ end
+ end
+end
diff --git a/spec/features/alert_management/user_updates_alert_status_spec.rb b/spec/features/alert_management/user_updates_alert_status_spec.rb
new file mode 100644
index 00000000000..8974796662c
--- /dev/null
+++ b/spec/features/alert_management/user_updates_alert_status_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'User updates Alert Management 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(: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 alerts list and the alert service is enabled they can update an alert status' do
+ it 'shows the alert table with an alert status dropdown' do
+ expect(page).to have_selector('.gl-table')
+ expect(find('.dropdown-menu-selectable')).to have_content('Triggered')
+ end
+
+ it 'updates the alert status' do
+ find('.dropdown-menu-selectable').click
+ find('.dropdown-item', text: 'Acknowledged').click
+ wait_for_requests
+
+ expect(find('.dropdown-menu-selectable')).to have_content('Acknowledged')
+ end
+ end
+end