diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/frontend/ide/services/index_spec.js | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/frontend/ide/services/index_spec.js')
-rw-r--r-- | spec/frontend/ide/services/index_spec.js | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js index eacf1244d55..0fab828dfb3 100644 --- a/spec/frontend/ide/services/index_spec.js +++ b/spec/frontend/ide/services/index_spec.js @@ -6,7 +6,7 @@ import dismissUserCallout from '~/graphql_shared/mutations/dismiss_user_callout. import services from '~/ide/services'; import { query, mutate } from '~/ide/services/gql'; import { escapeFileUrl } from '~/lib/utils/url_utility'; -import ciConfig from '~/pipeline_editor/graphql/queries/ci_config.graphql'; +import ciConfig from '~/pipeline_editor/graphql/queries/ci_config.query.graphql'; import { projectData } from '../mock_data'; jest.mock('~/api'); @@ -216,29 +216,6 @@ describe('IDE services', () => { ); }); - describe('getProjectData', () => { - it('combines gql and API requests', () => { - const gqlProjectData = { - userPermissions: { - bogus: true, - }, - }; - Api.project.mockReturnValue(Promise.resolve({ data: { ...projectData } })); - query.mockReturnValue(Promise.resolve({ data: { project: gqlProjectData } })); - - return services.getProjectData(TEST_NAMESPACE, TEST_PROJECT).then((response) => { - expect(response).toEqual({ data: { ...projectData, ...gqlProjectData } }); - expect(Api.project).toHaveBeenCalledWith(TEST_PROJECT_ID); - expect(query).toHaveBeenCalledWith({ - query: getIdeProject, - variables: { - projectPath: TEST_PROJECT_ID, - }, - }); - }); - }); - }); - describe('getFiles', () => { let mock; let relativeUrlRoot; @@ -330,4 +307,38 @@ describe('IDE services', () => { }); }); }); + + describe('getProjectPermissionsData', () => { + const TEST_PROJECT_PATH = 'foo/bar'; + + it('queries for the project permissions', () => { + const result = { data: { project: projectData } }; + query.mockResolvedValue(result); + + return services.getProjectPermissionsData(TEST_PROJECT_PATH).then((data) => { + expect(data).toEqual(result.data.project); + expect(query).toHaveBeenCalledWith( + expect.objectContaining({ + query: getIdeProject, + variables: { projectPath: TEST_PROJECT_PATH }, + }), + ); + }); + }); + + it('converts the returned GraphQL id to the regular ID number', () => { + const projectId = 2; + const gqlProjectData = { + id: `gid://gitlab/Project/${projectId}`, + userPermissions: { + bogus: true, + }, + }; + + query.mockResolvedValue({ data: { project: gqlProjectData } }); + return services.getProjectPermissionsData(TEST_PROJECT_PATH).then((data) => { + expect(data.id).toBe(projectId); + }); + }); + }); }); |