diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-16 00:14:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-16 00:14:31 +0300 |
commit | c568cb4dbc0421212a28f3cd5b77223aad8888ba (patch) | |
tree | be3ab3b5d6cf5c23a71b557ed82758c905a437bd /spec/frontend | |
parent | 4481a56a94c579f52e1cdef1cc1f4995f0ee1412 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 156 insertions, 4 deletions
diff --git a/spec/frontend/crm/contacts_root_spec.js b/spec/frontend/crm/contacts_root_spec.js new file mode 100644 index 00000000000..79b85969eb4 --- /dev/null +++ b/spec/frontend/crm/contacts_root_spec.js @@ -0,0 +1,60 @@ +import { GlLoadingIcon } from '@gitlab/ui'; +import Vue from 'vue'; +import VueApollo from 'vue-apollo'; +import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import createMockApollo from 'helpers/mock_apollo_helper'; +import waitForPromises from 'helpers/wait_for_promises'; +import createFlash from '~/flash'; +import ContactsRoot from '~/crm/components/contacts_root.vue'; +import getGroupContactsQuery from '~/crm/components/queries/get_group_contacts.query.graphql'; +import { getGroupContactsQueryResponse } from './mock_data'; + +jest.mock('~/flash'); + +describe('Customer relations contacts root app', () => { + Vue.use(VueApollo); + let wrapper; + let fakeApollo; + + const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); + const findRowByName = (rowName) => wrapper.findAllByRole('row', { name: rowName }); + const successQueryHandler = jest.fn().mockResolvedValue(getGroupContactsQueryResponse); + + const mountComponent = ({ + queryHandler = successQueryHandler, + mountFunction = shallowMountExtended, + } = {}) => { + fakeApollo = createMockApollo([[getGroupContactsQuery, queryHandler]]); + wrapper = mountFunction(ContactsRoot, { + provide: { groupFullPath: 'flightjs' }, + apolloProvider: fakeApollo, + }); + }; + + afterEach(() => { + wrapper.destroy(); + fakeApollo = null; + }); + + it('should render loading spinner', () => { + mountComponent(); + + expect(findLoadingIcon().exists()).toBe(true); + }); + + it('should render error message on reject', async () => { + mountComponent({ queryHandler: jest.fn().mockRejectedValue('ERROR') }); + await waitForPromises(); + + expect(createFlash).toHaveBeenCalled(); + }); + + it('renders correct results', async () => { + mountComponent({ mountFunction: mountExtended }); + await waitForPromises(); + + expect(findRowByName(/Marty/i)).toHaveLength(1); + expect(findRowByName(/George/i)).toHaveLength(1); + expect(findRowByName(/jd@gitlab.com/i)).toHaveLength(1); + }); +}); diff --git a/spec/frontend/crm/mock_data.js b/spec/frontend/crm/mock_data.js new file mode 100644 index 00000000000..86c5c48cf03 --- /dev/null +++ b/spec/frontend/crm/mock_data.js @@ -0,0 +1,47 @@ +export const getGroupContactsQueryResponse = { + data: { + group: { + __typename: 'Group', + id: 'gid://gitlab/Group/26', + contacts: { + nodes: [ + { + __typename: 'CustomerRelationsContact', + id: 'gid://gitlab/CustomerRelations::Contact/12', + firstName: 'Marty', + lastName: 'McFly', + email: 'example@gitlab.com', + phone: null, + description: null, + organization: { + __typename: 'CustomerRelationsOrganization', + id: 'gid://gitlab/CustomerRelations::Organization/2', + name: 'Tech Giant Inc', + }, + }, + { + __typename: 'CustomerRelationsContact', + id: 'gid://gitlab/CustomerRelations::Contact/16', + firstName: 'Boy', + lastName: 'George', + email: null, + phone: null, + description: null, + organization: null, + }, + { + __typename: 'CustomerRelationsContact', + id: 'gid://gitlab/CustomerRelations::Contact/13', + firstName: 'Jane', + lastName: 'Doe', + email: 'jd@gitlab.com', + phone: '+44 44 4444 4444', + description: 'Vice President', + organization: null, + }, + ], + __typename: 'CustomerRelationsContactConnection', + }, + }, + }, +}; diff --git a/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap b/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap index c255fcce321..af7cb1b24a3 100644 --- a/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap +++ b/spec/frontend/projects/components/__snapshots__/project_delete_button_spec.js.snap @@ -52,9 +52,44 @@ exports[`Project remove modal initialized matches the snapshot 1`] = ` title="You are about to permanently delete this project" variant="danger" > - <gl-sprintf-stub - message="Once a project is permanently deleted, it %{strongStart}cannot be recovered%{strongEnd}. Permanently deleting this project will %{strongStart}immediately delete%{strongEnd} its repositories and %{strongStart}all related resources%{strongEnd}, including issues, merge requests etc." - /> + <p> + This project is + <strong> + NOT + </strong> + a fork, and has the following: + </p> + + <ul> + <li> + 1 issue + </li> + + <li> + 2 merge requests + </li> + + <li> + 3 forks + </li> + + <li> + 4 stars + </li> + </ul> + Once a project is permanently deleted, it + <strong> + cannot be recovered + </strong> + . Permanently deleting this project will + <strong> + immediately delete + </strong> + its repositories and + <strong> + all related resources + </strong> + , including issues, merge requests etc. </gl-alert-stub> <p diff --git a/spec/frontend/projects/components/project_delete_button_spec.js b/spec/frontend/projects/components/project_delete_button_spec.js index 444e465ebaa..bb6021fadda 100644 --- a/spec/frontend/projects/components/project_delete_button_spec.js +++ b/spec/frontend/projects/components/project_delete_button_spec.js @@ -1,4 +1,5 @@ import { shallowMount } from '@vue/test-utils'; +import { GlSprintf } from '@gitlab/ui'; import ProjectDeleteButton from '~/projects/components/project_delete_button.vue'; import SharedDeleteButton from '~/projects/components/shared/delete_button.vue'; @@ -12,6 +13,11 @@ describe('Project remove modal', () => { const defaultProps = { confirmPhrase: 'foo', formPath: 'some/path', + isFork: false, + issuesCount: 1, + mergeRequestsCount: 2, + forksCount: 3, + starsCount: 4, }; const createComponent = (props = {}) => { @@ -21,6 +27,7 @@ describe('Project remove modal', () => { ...props, }, stubs: { + GlSprintf, SharedDeleteButton, }, }); @@ -41,7 +48,10 @@ describe('Project remove modal', () => { }); it('passes confirmPhrase and formPath props to the shared delete button', () => { - expect(findSharedDeleteButton().props()).toEqual(defaultProps); + expect(findSharedDeleteButton().props()).toEqual({ + confirmPhrase: defaultProps.confirmPhrase, + formPath: defaultProps.formPath, + }); }); }); }); |