diff options
Diffstat (limited to 'spec/frontend/vue_shared/alert_details/alert_status_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/alert_details/alert_status_spec.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/spec/frontend/vue_shared/alert_details/alert_status_spec.js b/spec/frontend/vue_shared/alert_details/alert_status_spec.js index 3fc13243bce..ba3b0335a8e 100644 --- a/spec/frontend/vue_shared/alert_details/alert_status_spec.js +++ b/spec/frontend/vue_shared/alert_details/alert_status_spec.js @@ -1,4 +1,5 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; +import { nextTick } from 'vue'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import updateAlertStatusMutation from '~/graphql_shared//mutations/alert_status_update.mutation.graphql'; @@ -121,7 +122,7 @@ describe('AlertManagementStatus', () => { it('emits an error when triggered a second time', async () => { await selectFirstStatusOption(); - await wrapper.vm.$nextTick(); + await nextTick(); await selectFirstStatusOption(); // Should emit two errors [0,1] expect(wrapper.emitted('alert-error').length > 1).toBe(true); @@ -175,17 +176,18 @@ describe('AlertManagementStatus', () => { jest.spyOn(Tracking, 'event'); }); - it('should not track alert status updates when the tracking options do not exist', () => { + it('should not track alert status updates when the tracking options do not exist', async () => { mountComponent({}); Tracking.event.mockClear(); jest.spyOn(wrapper.vm.$apollo, 'mutate').mockResolvedValue({}); findFirstStatusOption().vm.$emit('click'); - setImmediate(() => { - expect(Tracking.event).not.toHaveBeenCalled(); - }); + + await nextTick(); + + expect(Tracking.event).not.toHaveBeenCalled(); }); - it('should track alert status updates when the tracking options exist', () => { + it('should track alert status updates when the tracking options exist', async () => { const trackAlertStatusUpdateOptions = { category: 'Alert Management', action: 'update_alert_status', @@ -195,11 +197,12 @@ describe('AlertManagementStatus', () => { Tracking.event.mockClear(); jest.spyOn(wrapper.vm.$apollo, 'mutate').mockResolvedValue({}); findFirstStatusOption().vm.$emit('click'); + + await nextTick(); + const status = findFirstStatusOption().text(); - setImmediate(() => { - const { category, action, label } = trackAlertStatusUpdateOptions; - expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property: status }); - }); + const { category, action, label } = trackAlertStatusUpdateOptions; + expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property: status }); }); }); }); |