diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-25 09:09:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-25 09:09:39 +0300 |
commit | be7378bb7f3086f7ff6bce402d6b12812b505e77 (patch) | |
tree | 8991d2ee697f198d92f19b2f07ad4d7ee2223c08 /spec/frontend/sidebar | |
parent | 3b0494df16590fbb3dd085841655b9099ecc7564 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/sidebar')
-rw-r--r-- | spec/frontend/sidebar/components/severity/sidebar_severity_spec.js | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js b/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js index 8f936240b7a..71c6c259c32 100644 --- a/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js +++ b/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js @@ -1,12 +1,12 @@ import { GlDropdown, GlDropdownItem, GlLoadingIcon, GlTooltip, GlSprintf } from '@gitlab/ui'; import { nextTick } from 'vue'; -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import { mountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { createAlert } from '~/flash'; import { INCIDENT_SEVERITY, ISSUABLE_TYPES } from '~/sidebar/constants'; import updateIssuableSeverity from '~/sidebar/queries/update_issuable_severity.mutation.graphql'; import SeverityToken from '~/sidebar/components/severity/severity.vue'; -import SidebarSeverity from '~/sidebar/components/severity/sidebar_severity.vue'; +import SidebarSeverityWidget from '~/sidebar/components/severity/sidebar_severity_widget.vue'; jest.mock('~/flash'); @@ -27,7 +27,7 @@ describe('SidebarSeverity', () => { ...props, }; mutate = jest.fn(); - wrapper = shallowMountExtended(SidebarSeverity, { + wrapper = mountExtended(SidebarSeverityWidget, { propsData, provide: { canUpdate, @@ -48,13 +48,11 @@ describe('SidebarSeverity', () => { }); afterEach(() => { - if (wrapper) { - wrapper.destroy(); - } + wrapper.destroy(); }); const findSeverityToken = () => wrapper.findAllComponents(SeverityToken); - const findEditBtn = () => wrapper.findByTestId('editButton'); + const findEditBtn = () => wrapper.findByTestId('edit-button'); const findDropdown = () => wrapper.findComponent(GlDropdown); const findCriticalSeverityDropdownItem = () => wrapper.findComponent(GlDropdownItem); const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); @@ -127,30 +125,15 @@ describe('SidebarSeverity', () => { }); describe('Switch between collapsed/expanded view of the sidebar', () => { - const HIDDDEN_CLASS = 'gl-display-none'; - const SHOWN_CLASS = 'show'; - describe('collapsed', () => { it('should have collapsed icon class', () => { expect(findCollapsedSeverity().classes('sidebar-collapsed-icon')).toBe(true); }); it('should display only icon with a tooltip', () => { - expect(findSeverityToken().at(0).attributes('icononly')).toBe('true'); - expect(findSeverityToken().at(0).attributes('iconsize')).toBe('14'); - expect(findTooltip().text().replace(/\s+/g, ' ')).toContain( - `Severity: ${INCIDENT_SEVERITY[severity].label}`, - ); - }); - - it('should expand the dropdown on collapsed icon click', async () => { - wrapper.vm.isDropdownShowing = false; - await nextTick(); - expect(findDropdown().classes(HIDDDEN_CLASS)).toBe(true); - - findCollapsedSeverity().trigger('click'); - await nextTick(); - expect(findDropdown().classes(SHOWN_CLASS)).toBe(true); + expect(findSeverityToken().exists()).toBe(true); + expect(findTooltip().text()).toContain(INCIDENT_SEVERITY[severity].label); + expect(findEditBtn().exists()).toBe(false); }); }); @@ -158,17 +141,16 @@ describe('SidebarSeverity', () => { it('toggles dropdown with edit button', async () => { canUpdate = true; createComponent(); - wrapper.vm.isDropdownShowing = false; await nextTick(); - expect(findDropdown().classes(HIDDDEN_CLASS)).toBe(true); + expect(findDropdown().isVisible()).toBe(false); findEditBtn().vm.$emit('click'); await nextTick(); - expect(findDropdown().classes(SHOWN_CLASS)).toBe(true); + expect(findDropdown().isVisible()).toBe(true); findEditBtn().vm.$emit('click'); await nextTick(); - expect(findDropdown().classes(HIDDDEN_CLASS)).toBe(true); + expect(findDropdown().isVisible()).toBe(false); }); }); }); |