diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-04 03:16:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-04 03:16:09 +0000 |
commit | 242358bb7b8e031b9b975340750be33b19015cfa (patch) | |
tree | 55cf5342bc232ba517698a1f82e859d5fdf25fac /spec/frontend | |
parent | 517f254952ababb661160d3afd659902d18e29cd (diff) | |
download | gitlab-ce-242358bb7b8e031b9b975340750be33b19015cfa.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/jira_import/components/jira_import_form_spec.js | 55 | ||||
-rw-r--r-- | spec/frontend/jira_import/mock_data.js | 3 |
2 files changed, 58 insertions, 0 deletions
diff --git a/spec/frontend/jira_import/components/jira_import_form_spec.js b/spec/frontend/jira_import/components/jira_import_form_spec.js index 7cc7b40f4c8..6ef28a71f48 100644 --- a/spec/frontend/jira_import/components/jira_import_form_spec.js +++ b/spec/frontend/jira_import/components/jira_import_form_spec.js @@ -10,6 +10,7 @@ import { imports, issuesPath, jiraProjects, + jiraUsersResponse, projectId, projectPath, userMappings as defaultUserMappings, @@ -38,7 +39,10 @@ describe('JiraImportForm', () => { const getHeader = name => getByRole(wrapper.element, 'columnheader', { name }); + const findLoadMoreUsersButton = () => wrapper.find('[data-testid="load-more-users-button"]'); + const mountComponent = ({ + hasMoreUsers = false, isSubmitting = false, loading = false, mutate = mutateSpy, @@ -55,6 +59,7 @@ describe('JiraImportForm', () => { projectPath, }, data: () => ({ + hasMoreUsers, isFetching: false, isSubmitting, searchTerm: '', @@ -300,6 +305,7 @@ describe('JiraImportForm', () => { variables: { input: { projectPath, + startAt: 0, }, }, }; @@ -318,4 +324,53 @@ describe('JiraImportForm', () => { }); }); }); + + describe('load more users button', () => { + describe('when all users have been loaded', () => { + it('is not shown', () => { + wrapper = mountComponent(); + + expect(findLoadMoreUsersButton().exists()).toBe(false); + }); + }); + + describe('when all users have not been loaded', () => { + it('is shown', () => { + wrapper = mountComponent({ hasMoreUsers: true }); + + expect(findLoadMoreUsersButton().exists()).toBe(true); + }); + }); + + describe('when clicked', () => { + beforeEach(() => { + mutateSpy = jest.fn(() => + Promise.resolve({ + data: { + jiraImportStart: { errors: [] }, + jiraImportUsers: { jiraUsers: jiraUsersResponse, errors: [] }, + }, + }), + ); + + wrapper = mountComponent({ hasMoreUsers: true }); + }); + + it('calls the GraphQL user mapping mutation', async () => { + const mutationArguments = { + mutation: getJiraUserMappingMutation, + variables: { + input: { + projectPath, + startAt: 0, + }, + }, + }; + + findLoadMoreUsersButton().vm.$emit('click'); + + expect(mutateSpy).toHaveBeenCalledWith(expect.objectContaining(mutationArguments)); + }); + }); + }); }); diff --git a/spec/frontend/jira_import/mock_data.js b/spec/frontend/jira_import/mock_data.js index 8ea40080f32..51dd939283e 100644 --- a/spec/frontend/jira_import/mock_data.js +++ b/spec/frontend/jira_import/mock_data.js @@ -1,5 +1,6 @@ import getJiraImportDetailsQuery from '~/jira_import/queries/get_jira_import_details.query.graphql'; import { IMPORT_STATE } from '~/jira_import/utils/jira_import_utils'; +import { userMappingsPageSize } from '~/jira_import/utils/constants'; export const fullPath = 'gitlab-org/gitlab-test'; @@ -87,6 +88,8 @@ export const jiraProjects = [ { text: 'Migrate to GitLab (MTG)', value: 'MTG' }, ]; +export const jiraUsersResponse = new Array(userMappingsPageSize); + export const imports = [ { jiraProjectKey: 'MTG', |