diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/frontend/groups/components | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/frontend/groups/components')
-rw-r--r-- | spec/frontend/groups/components/app_spec.js | 17 | ||||
-rw-r--r-- | spec/frontend/groups/components/group_item_spec.js | 18 |
2 files changed, 16 insertions, 19 deletions
diff --git a/spec/frontend/groups/components/app_spec.js b/spec/frontend/groups/components/app_spec.js index e559c9519f2..da0ff2a64ec 100644 --- a/spec/frontend/groups/components/app_spec.js +++ b/spec/frontend/groups/components/app_spec.js @@ -1,9 +1,9 @@ -import '~/flash'; import { GlModal, GlLoadingIcon } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import AxiosMockAdapter from 'axios-mock-adapter'; import Vue from 'vue'; import waitForPromises from 'helpers/wait_for_promises'; +import createFlash from '~/flash'; import appComponent from '~/groups/components/app.vue'; import groupFolderComponent from '~/groups/components/group_folder.vue'; import groupItemComponent from '~/groups/components/group_item.vue'; @@ -27,6 +27,7 @@ import { const $toast = { show: jest.fn(), }; +jest.mock('~/flash'); describe('AppComponent', () => { let wrapper; @@ -123,12 +124,12 @@ describe('AppComponent', () => { mock.onGet('/dashboard/groups.json').reply(400); jest.spyOn(window, 'scrollTo').mockImplementation(() => {}); - jest.spyOn(window, 'Flash').mockImplementation(() => {}); - return vm.fetchGroups({}).then(() => { expect(vm.isLoading).toBe(false); expect(window.scrollTo).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 }); - expect(window.Flash).toHaveBeenCalledWith('An error occurred. Please try again.'); + expect(createFlash).toHaveBeenCalledWith({ + message: 'An error occurred. Please try again.', + }); }); }); }); @@ -324,15 +325,13 @@ describe('AppComponent', () => { const message = 'An error occurred. Please try again.'; jest.spyOn(vm.service, 'leaveGroup').mockRejectedValue({ status: 500 }); jest.spyOn(vm.store, 'removeGroup'); - jest.spyOn(window, 'Flash').mockImplementation(() => {}); - vm.leaveGroup(); expect(vm.targetGroup.isBeingRemoved).toBe(true); expect(vm.service.leaveGroup).toHaveBeenCalledWith(childGroupItem.leavePath); return waitForPromises().then(() => { expect(vm.store.removeGroup).not.toHaveBeenCalled(); - expect(window.Flash).toHaveBeenCalledWith(message); + expect(createFlash).toHaveBeenCalledWith({ message }); expect(vm.targetGroup.isBeingRemoved).toBe(false); }); }); @@ -341,15 +340,13 @@ describe('AppComponent', () => { const message = 'Failed to leave the group. Please make sure you are not the only owner.'; jest.spyOn(vm.service, 'leaveGroup').mockRejectedValue({ status: 403 }); jest.spyOn(vm.store, 'removeGroup'); - jest.spyOn(window, 'Flash').mockImplementation(() => {}); - vm.leaveGroup(childGroupItem, groupItem); expect(vm.targetGroup.isBeingRemoved).toBe(true); expect(vm.service.leaveGroup).toHaveBeenCalledWith(childGroupItem.leavePath); return waitForPromises().then(() => { expect(vm.store.removeGroup).not.toHaveBeenCalled(); - expect(window.Flash).toHaveBeenCalledWith(message); + expect(createFlash).toHaveBeenCalledWith({ message }); expect(vm.targetGroup.isBeingRemoved).toBe(false); }); }); diff --git a/spec/frontend/groups/components/group_item_spec.js b/spec/frontend/groups/components/group_item_spec.js index 546cdd3cd6f..2369685f506 100644 --- a/spec/frontend/groups/components/group_item_spec.js +++ b/spec/frontend/groups/components/group_item_spec.js @@ -162,11 +162,11 @@ describe('GroupItemComponent', () => { wrapper = createComponent({ group }); }); - it('renders the group pending removal badge', () => { + it('renders the group pending deletion badge', () => { const badgeEl = wrapper.vm.$el.querySelector('.badge-warning'); expect(badgeEl).toBeDefined(); - expect(badgeEl.innerHTML).toContain('pending removal'); + expect(badgeEl.innerHTML).toContain('pending deletion'); }); }); @@ -176,10 +176,10 @@ describe('GroupItemComponent', () => { wrapper = createComponent({ group }); }); - it('does not render the group pending removal badge', () => { + it('does not render the group pending deletion badge', () => { const groupTextContainer = wrapper.vm.$el.querySelector('.group-text-container'); - expect(groupTextContainer).not.toContain('pending removal'); + expect(groupTextContainer).not.toContain('pending deletion'); }); it('renders `item-actions` component and passes correct props to it', () => { @@ -236,13 +236,13 @@ describe('GroupItemComponent', () => { describe('schema.org props', () => { describe('when showSchemaMarkup is disabled on the group', () => { it.each(['itemprop', 'itemtype', 'itemscope'], 'it does not set %s', (attr) => { - expect(wrapper.vm.$el.getAttribute(attr)).toBeNull(); + expect(wrapper.attributes(attr)).toBeUndefined(); }); it.each( ['.js-group-avatar', '.js-group-name', '.js-group-description'], 'it does not set `itemprop` on sub-nodes', (selector) => { - expect(wrapper.vm.$el.querySelector(selector).getAttribute('itemprop')).toBeNull(); + expect(wrapper.find(selector).attributes('itemprop')).toBeUndefined(); }, ); }); @@ -263,16 +263,16 @@ describe('GroupItemComponent', () => { ${'itemtype'} | ${'https://schema.org/Organization'} ${'itemprop'} | ${'subOrganization'} `('it does set correct $attr', ({ attr, value } = {}) => { - expect(wrapper.vm.$el.getAttribute(attr)).toBe(value); + expect(wrapper.attributes(attr)).toBe(value); }); it.each` selector | propValue - ${'[data-testid="group-avatar"]'} | ${'logo'} + ${'img'} | ${'logo'} ${'[data-testid="group-name"]'} | ${'name'} ${'[data-testid="group-description"]'} | ${'description'} `('it does set correct $selector', ({ selector, propValue } = {}) => { - expect(wrapper.vm.$el.querySelector(selector).getAttribute('itemprop')).toBe(propValue); + expect(wrapper.find(selector).attributes('itemprop')).toBe(propValue); }); }); }); |