diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js b/spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js index d5be5b623b8..b00a20dab1a 100644 --- a/spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js +++ b/spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js @@ -1,6 +1,5 @@ -import { GlDropdown, GlDropdownItem, GlLoadingIcon } from '@gitlab/ui'; -import { mountExtended } from 'helpers/vue_test_utils_helper'; -import updateAlertStatusMutation from '~/graphql_shared/mutations/alert_status_update.mutation.graphql'; +import { GlDropdown, GlLoadingIcon } from '@gitlab/ui'; +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import AlertStatus from '~/vue_shared/alert_details/components/alert_status.vue'; import AlertSidebarStatus from '~/vue_shared/alert_details/components/sidebar/sidebar_status.vue'; import { PAGE_CONFIG } from '~/vue_shared/alert_details/constants'; @@ -11,9 +10,7 @@ const mockAlert = mockAlerts[0]; describe('Alert Details Sidebar Status', () => { let wrapper; const findStatusDropdown = () => wrapper.findComponent(GlDropdown); - const findStatusDropdownItem = () => wrapper.findComponent(GlDropdownItem); const findStatusLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); - const findStatusDropdownHeader = () => wrapper.findByTestId('dropdown-header'); const findAlertStatus = () => wrapper.findComponent(AlertStatus); const findStatus = () => wrapper.findByTestId('status'); const findSidebarIcon = () => wrapper.findByTestId('status-icon'); @@ -25,7 +22,7 @@ describe('Alert Details Sidebar Status', () => { stubs = {}, provide = {}, } = {}) { - wrapper = mountExtended(AlertSidebarStatus, { + wrapper = shallowMountExtended(AlertSidebarStatus, { propsData: { alert: { ...mockAlert }, ...data, @@ -63,11 +60,7 @@ describe('Alert Details Sidebar Status', () => { }); it('displays status dropdown', () => { - expect(findStatusDropdown().exists()).toBe(true); - }); - - it('displays the dropdown status header', () => { - expect(findStatusDropdownHeader().exists()).toBe(true); + expect(findAlertStatus().exists()).toBe(true); }); it('does not display the collapsed sidebar icon', () => { @@ -75,42 +68,24 @@ describe('Alert Details Sidebar Status', () => { }); describe('updating the alert status', () => { - const mockUpdatedMutationResult = { - data: { - updateAlertStatus: { - errors: [], - alert: { - status: 'acknowledged', - }, - }, - }, - }; - - beforeEach(() => { + it('ensures dropdown is hidden when loading', async () => { mountComponent({ data: { alert: mockAlert }, sidebarCollapsed: false, loading: false, }); - }); - - it('calls `$apollo.mutate` with `updateAlertStatus` mutation and variables containing `iid`, `status`, & `projectPath`', () => { - jest.spyOn(wrapper.vm.$apollo, 'mutate').mockResolvedValue(mockUpdatedMutationResult); - findStatusDropdownItem().vm.$emit('click'); - - expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({ - mutation: updateAlertStatusMutation, - variables: { - iid: '1527542', - status: 'TRIGGERED', - projectPath: 'projectPath', - }, - }); + findAlertStatus().vm.$emit('handle-updating', true); + await wrapper.vm.$nextTick(); + expect(findStatusLoadingIcon().exists()).toBe(true); }); it('stops updating when the request fails', () => { - jest.spyOn(wrapper.vm.$apollo, 'mutate').mockReturnValue(Promise.reject(new Error())); - findStatusDropdownItem().vm.$emit('click'); + mountComponent({ + data: { alert: mockAlert }, + sidebarCollapsed: false, + loading: false, + }); + findAlertStatus().vm.$emit('handle-updating', false); expect(findStatusLoadingIcon().exists()).toBe(false); expect(findStatus().text()).toBe('Triggered'); }); |