Commit bca25c0b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'alert-list-dropdown-header' into 'master'

Hide dropdown header on list view

See merge request gitlab-org/gitlab!35954
parents 84f9c5c7 ce9fb73b
...@@ -88,7 +88,7 @@ export default { ...@@ -88,7 +88,7 @@ export default {
@keydown.esc.native="$emit('hide-dropdown')" @keydown.esc.native="$emit('hide-dropdown')"
@hide="$emit('hide-dropdown')" @hide="$emit('hide-dropdown')"
> >
<div class="dropdown-title text-center"> <div v-if="isSidebar" class="dropdown-title text-center">
<span class="alert-title">{{ s__('AlertManagement|Assign status') }}</span> <span class="alert-title">{{ s__('AlertManagement|Assign status') }}</span>
<gl-button <gl-button
:aria-label="__('Close')" :aria-label="__('Close')"
......
---
title: Hide dropdown header on list view
merge_request: 35954
author:
type: other
...@@ -207,6 +207,15 @@ describe('AlertManagementList', () => { ...@@ -207,6 +207,15 @@ describe('AlertManagementList', () => {
expect(findStatusDropdown().exists()).toBe(true); expect(findStatusDropdown().exists()).toBe(true);
}); });
it('does not display a dropdown status header', () => {
mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
data: { alerts: { list: mockAlerts }, alertsCount, errored: false },
loading: false,
});
expect(findStatusDropdown().contains('.dropdown-title')).toBe(false);
});
it('shows correct severity icons', () => { it('shows correct severity icons', () => {
mountComponent({ mountComponent({
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true }, props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
......
...@@ -5,7 +5,7 @@ import { GlDropdownItem } from '@gitlab/ui'; ...@@ -5,7 +5,7 @@ import { GlDropdownItem } from '@gitlab/ui';
import SidebarAssignee from '~/alert_management/components/sidebar/sidebar_assignee.vue'; import SidebarAssignee from '~/alert_management/components/sidebar/sidebar_assignee.vue';
import SidebarAssignees from '~/alert_management/components/sidebar/sidebar_assignees.vue'; import SidebarAssignees from '~/alert_management/components/sidebar/sidebar_assignees.vue';
import AlertSetAssignees from '~/alert_management/graphql/mutations/alert_set_assignees.mutation.graphql'; import AlertSetAssignees from '~/alert_management/graphql/mutations/alert_set_assignees.mutation.graphql';
import mockAlerts from '../mocks/alerts.json'; import mockAlerts from '../../mocks/alerts.json';
const mockAlert = mockAlerts[0]; const mockAlert = mockAlerts[0];
......
...@@ -3,7 +3,7 @@ import axios from 'axios'; ...@@ -3,7 +3,7 @@ import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import AlertSidebar from '~/alert_management/components/alert_sidebar.vue'; import AlertSidebar from '~/alert_management/components/alert_sidebar.vue';
import SidebarAssignees from '~/alert_management/components/sidebar/sidebar_assignees.vue'; import SidebarAssignees from '~/alert_management/components/sidebar/sidebar_assignees.vue';
import mockAlerts from '../mocks/alerts.json'; import mockAlerts from '../../mocks/alerts.json';
const mockAlert = mockAlerts[0]; const mockAlert = mockAlerts[0];
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlDropdownItem, GlLoadingIcon } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlLoadingIcon } from '@gitlab/ui';
import { trackAlertStatusUpdateOptions } from '~/alert_management/constants'; import { trackAlertStatusUpdateOptions } from '~/alert_management/constants';
import AlertSidebarStatus from '~/alert_management/components/sidebar/sidebar_status.vue'; import AlertSidebarStatus from '~/alert_management/components/sidebar/sidebar_status.vue';
import updateAlertStatus from '~/alert_management/graphql/mutations/update_alert_status.mutation.graphql'; import updateAlertStatus from '~/alert_management/graphql/mutations/update_alert_status.mutation.graphql';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import mockAlerts from '../mocks/alerts.json'; import mockAlerts from '../../mocks/alerts.json';
const mockAlert = mockAlerts[0]; const mockAlert = mockAlerts[0];
describe('Alert Details Sidebar Status', () => { describe('Alert Details Sidebar Status', () => {
let wrapper; let wrapper;
const findStatusDropdown = () => wrapper.find(GlDropdown);
const findStatusDropdownItem = () => wrapper.find(GlDropdownItem); const findStatusDropdownItem = () => wrapper.find(GlDropdownItem);
const findStatusLoadingIcon = () => wrapper.find(GlLoadingIcon); const findStatusLoadingIcon = () => wrapper.find(GlLoadingIcon);
...@@ -41,18 +42,7 @@ describe('Alert Details Sidebar Status', () => { ...@@ -41,18 +42,7 @@ describe('Alert Details Sidebar Status', () => {
} }
}); });
describe('updating the alert status', () => { describe('Alert Sidebar Dropdown Status', () => {
const mockUpdatedMutationResult = {
data: {
updateAlertStatus: {
errors: [],
alert: {
status: 'acknowledged',
},
},
},
};
beforeEach(() => { beforeEach(() => {
mountComponent({ mountComponent({
data: { alert: mockAlert }, data: { alert: mockAlert },
...@@ -61,46 +51,78 @@ describe('Alert Details Sidebar Status', () => { ...@@ -61,46 +51,78 @@ describe('Alert Details Sidebar Status', () => {
}); });
}); });
it('calls `$apollo.mutate` with `updateAlertStatus` mutation and variables containing `iid`, `status`, & `projectPath`', () => { it('displays status dropdown', () => {
jest.spyOn(wrapper.vm.$apollo, 'mutate').mockResolvedValue(mockUpdatedMutationResult); expect(findStatusDropdown().exists()).toBe(true);
findStatusDropdownItem().vm.$emit('click'); });
it('displays the dropdown status header', () => {
expect(findStatusDropdown().contains('.dropdown-title')).toBe(true);
});
expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({ describe('updating the alert status', () => {
mutation: updateAlertStatus, const mockUpdatedMutationResult = {
variables: { data: {
iid: '1527542', updateAlertStatus: {
status: 'TRIGGERED', errors: [],
projectPath: 'projectPath', alert: {
status: 'acknowledged',
},
},
}, },
};
beforeEach(() => {
mountComponent({
data: { alert: mockAlert },
sidebarCollapsed: false,
loading: false,
});
}); });
});
it('stops updating when the request fails', () => { it('calls `$apollo.mutate` with `updateAlertStatus` mutation and variables containing `iid`, `status`, & `projectPath`', () => {
jest.spyOn(wrapper.vm.$apollo, 'mutate').mockReturnValue(Promise.reject(new Error())); jest.spyOn(wrapper.vm.$apollo, 'mutate').mockResolvedValue(mockUpdatedMutationResult);
findStatusDropdownItem().vm.$emit('click'); findStatusDropdownItem().vm.$emit('click');
expect(findStatusLoadingIcon().exists()).toBe(false);
expect(wrapper.find('[data-testid="status"]').text()).toBe('Triggered');
});
});
describe('Snowplow tracking', () => { expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
beforeEach(() => { mutation: updateAlertStatus,
jest.spyOn(Tracking, 'event'); variables: {
mountComponent({ iid: '1527542',
props: { alertManagementEnabled: true, userCanEnableAlertManagement: true }, status: 'TRIGGERED',
data: { alert: mockAlert }, projectPath: 'projectPath',
loading: false, },
});
});
it('stops updating when the request fails', () => {
jest.spyOn(wrapper.vm.$apollo, 'mutate').mockReturnValue(Promise.reject(new Error()));
findStatusDropdownItem().vm.$emit('click');
expect(findStatusLoadingIcon().exists()).toBe(false);
expect(wrapper.find('[data-testid="status"]').text()).toBe('Triggered');
}); });
}); });
it('should track alert status updates', () => { describe('Snowplow tracking', () => {
Tracking.event.mockClear(); beforeEach(() => {
jest.spyOn(wrapper.vm.$apollo, 'mutate').mockResolvedValue({}); jest.spyOn(Tracking, 'event');
findStatusDropdownItem().vm.$emit('click'); mountComponent({
const status = findStatusDropdownItem().text(); props: { alertManagementEnabled: true, userCanEnableAlertManagement: true },
setImmediate(() => { data: { alert: mockAlert },
const { category, action, label } = trackAlertStatusUpdateOptions; loading: false,
expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property: status }); });
});
it('should track alert status updates', () => {
Tracking.event.mockClear();
jest.spyOn(wrapper.vm.$apollo, 'mutate').mockResolvedValue({});
findStatusDropdownItem().vm.$emit('click');
const status = findStatusDropdownItem().text();
setImmediate(() => {
const { category, action, label } = trackAlertStatusUpdateOptions;
expect(Tracking.event).toHaveBeenCalledWith(category, action, {
label,
property: status,
});
});
}); });
}); });
}); });
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import SystemNote from '~/alert_management/components/system_notes/system_note.vue'; import SystemNote from '~/alert_management/components/system_notes/system_note.vue';
import mockAlerts from '../mocks/alerts.json'; import mockAlerts from '../../mocks/alerts.json';
const mockAlert = mockAlerts[1]; const mockAlert = mockAlerts[1];
......
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