diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 03:08:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 03:08:53 +0300 |
commit | 9214cac69b0f0306a86056720cfc62b738449c19 (patch) | |
tree | 79c6fdbc2c8b379dd908294faa54c3fa2ab97551 /spec/frontend | |
parent | 13d851c795a48b670b859a7ec5bd6e2886d2789e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 94 insertions, 6 deletions
diff --git a/spec/frontend/groups/components/empty_states/groups_dashboard_empty_state_spec.js b/spec/frontend/groups/components/empty_states/groups_dashboard_empty_state_spec.js new file mode 100644 index 00000000000..d2afbad802c --- /dev/null +++ b/spec/frontend/groups/components/empty_states/groups_dashboard_empty_state_spec.js @@ -0,0 +1,29 @@ +import { GlEmptyState } from '@gitlab/ui'; + +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import GroupsDashboardEmptyState from '~/groups/components/empty_states/groups_dashboard_empty_state.vue'; + +let wrapper; + +const defaultProvide = { + groupsEmptyStateIllustration: '/assets/illustrations/empty-state/empty-groups-md.svg', +}; + +const createComponent = () => { + wrapper = shallowMountExtended(GroupsDashboardEmptyState, { + provide: defaultProvide, + }); +}; + +describe('GroupsDashboardEmptyState', () => { + it('renders empty state', () => { + createComponent(); + + expect(wrapper.findComponent(GlEmptyState).props()).toMatchObject({ + title: 'A group is a collection of several projects', + description: + "If you organize your projects under a group, it works like a folder. You can manage your group member's permissions and access to each project in the group.", + svgPath: defaultProvide.groupsEmptyStateIllustration, + }); + }); +}); diff --git a/spec/frontend/groups/components/empty_states/groups_explore_empty_state_spec.js b/spec/frontend/groups/components/empty_states/groups_explore_empty_state_spec.js new file mode 100644 index 00000000000..f4c425902f5 --- /dev/null +++ b/spec/frontend/groups/components/empty_states/groups_explore_empty_state_spec.js @@ -0,0 +1,27 @@ +import { GlEmptyState } from '@gitlab/ui'; + +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import GroupsExploreEmptyState from '~/groups/components/empty_states/groups_explore_empty_state.vue'; + +let wrapper; + +const defaultProvide = { + groupsEmptyStateIllustration: '/assets/illustrations/empty-state/empty-groups-md.svg', +}; + +const createComponent = () => { + wrapper = shallowMountExtended(GroupsExploreEmptyState, { + provide: defaultProvide, + }); +}; + +describe('GroupsExploreEmptyState', () => { + it('renders empty state', () => { + createComponent(); + + expect(wrapper.findComponent(GlEmptyState).props()).toMatchObject({ + title: 'No public groups', + svgPath: defaultProvide.groupsEmptyStateIllustration, + }); + }); +}); diff --git a/spec/frontend/projects/commit/components/form_modal_spec.js b/spec/frontend/projects/commit/components/form_modal_spec.js index d40e2d7a48c..7ea3a74418d 100644 --- a/spec/frontend/projects/commit/components/form_modal_spec.js +++ b/spec/frontend/projects/commit/components/form_modal_spec.js @@ -72,11 +72,11 @@ describe('CommitFormModal', () => { it('Shows modal', () => { createComponent(); - const rootEmit = jest.spyOn(wrapper.vm.$root, '$emit'); + const rootWrapper = createWrapper(wrapper.vm.$root); - wrapper.vm.show(); + eventHub.$emit(mockData.modalPropsData.openModal); - expect(rootEmit).toHaveBeenCalledWith(BV_SHOW_MODAL, mockData.modalPropsData.modalId); + expect(rootWrapper.emitted(BV_SHOW_MODAL)[0]).toContain(mockData.modalPropsData.modalId); }); it('Clears the modal state once modal is hidden', () => { @@ -150,8 +150,9 @@ describe('CommitFormModal', () => { it('Action primary button dispatches submit action', () => { getByText(mockData.modalPropsData.i18n.actionPrimaryText).trigger('click'); + const formSubmitSpy = jest.spyOn(findForm().element, 'submit'); - expect(wrapper.vm.$refs.form.$el.submit).toHaveBeenCalled(); + expect(formSubmitSpy).toHaveBeenCalled(); }); it('Changes the start_branch input value', async () => { diff --git a/spec/frontend/vue_shared/components/markdown/comment_templates_dropdown_spec.js b/spec/frontend/vue_shared/components/markdown/comment_templates_dropdown_spec.js index cd9f27dccbd..11c57fc5768 100644 --- a/spec/frontend/vue_shared/components/markdown/comment_templates_dropdown_spec.js +++ b/spec/frontend/vue_shared/components/markdown/comment_templates_dropdown_spec.js @@ -12,6 +12,7 @@ import savedRepliesQuery from '~/vue_shared/components/markdown/saved_replies.qu import { TRACKING_SAVED_REPLIES_USE, TRACKING_SAVED_REPLIES_USE_IN_MR, + TRACKING_SAVED_REPLIES_USE_IN_OTHER, } from '~/vue_shared/components/markdown/constants'; let wrapper; @@ -87,6 +88,12 @@ describe('Comment templates dropdown', () => { }); describe('tracking', () => { + it('always sends two tracking events', async () => { + await selectSavedReply(); + + expect(trackingSpy).toHaveBeenCalledTimes(2); + }); + it('tracks overall usage', async () => { await selectSavedReply(); @@ -108,7 +115,6 @@ describe('Comment templates dropdown', () => { TRACKING_SAVED_REPLIES_USE_IN_MR, expect.any(Object), ); - expect(trackingSpy).toHaveBeenCalledTimes(2); }); it('is not sent when not in an MR', async () => { @@ -121,7 +127,32 @@ describe('Comment templates dropdown', () => { TRACKING_SAVED_REPLIES_USE_IN_MR, expect.any(Object), ); - expect(trackingSpy).toHaveBeenCalledTimes(1); + }); + }); + + describe('non-MR usage event', () => { + it('is sent when not in an MR', async () => { + window.location.toString.mockReturnValue('this/looks/like/a/-/issues/1'); + + await selectSavedReply(); + + expect(trackingSpy).toHaveBeenCalledWith( + expect.any(String), + TRACKING_SAVED_REPLIES_USE_IN_OTHER, + expect.any(Object), + ); + }); + + it('is not sent when in an MR', async () => { + window.location.toString.mockReturnValue('this/looks/like/a/-/merge_requests/1'); + + await selectSavedReply(); + + expect(trackingSpy).not.toHaveBeenCalledWith( + expect.any(String), + TRACKING_SAVED_REPLIES_USE_IN_OTHER, + expect.any(Object), + ); }); }); }); |