diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 18:07:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 18:07:55 +0000 |
commit | 603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc (patch) | |
tree | 907f5b8ee1b6f5aad396e95e3327a08400b9e8ea /spec/frontend/code_navigation | |
parent | 120f4aaedc8fe830a3f572491d240d8ee6addefb (diff) | |
download | gitlab-ce-603c7d4cac5e28bc1c75e50c23ed2cbe56f1aafc.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/code_navigation')
4 files changed, 31 insertions, 34 deletions
diff --git a/spec/frontend/code_navigation/components/app_spec.js b/spec/frontend/code_navigation/components/app_spec.js index cfdc0dcc6cc..d5693cc4173 100644 --- a/spec/frontend/code_navigation/components/app_spec.js +++ b/spec/frontend/code_navigation/components/app_spec.js @@ -16,6 +16,7 @@ function factory(initialState = {}) { state: { ...createState(), ...initialState, + definitionPathPrefix: 'https://test.com/blob/master', }, actions: { fetchData, diff --git a/spec/frontend/code_navigation/components/popover_spec.js b/spec/frontend/code_navigation/components/popover_spec.js index ad05504a224..df3bbc7c1c6 100644 --- a/spec/frontend/code_navigation/components/popover_spec.js +++ b/spec/frontend/code_navigation/components/popover_spec.js @@ -1,6 +1,8 @@ import { shallowMount } from '@vue/test-utils'; import Popover from '~/code_navigation/components/popover.vue'; +const DEFINITION_PATH_PREFIX = 'http:/'; + const MOCK_CODE_DATA = Object.freeze({ hover: [ { @@ -8,7 +10,7 @@ const MOCK_CODE_DATA = Object.freeze({ value: 'console.log', }, ], - definition_url: 'http://test.com', + definition_path: 'test.com', }); const MOCK_DOCS_DATA = Object.freeze({ @@ -18,13 +20,13 @@ const MOCK_DOCS_DATA = Object.freeze({ value: 'console.log', }, ], - definition_url: 'http://test.com', + definition_path: 'test.com', }); let wrapper; -function factory(position, data) { - wrapper = shallowMount(Popover, { propsData: { position, data } }); +function factory(position, data, definitionPathPrefix) { + wrapper = shallowMount(Popover, { propsData: { position, data, definitionPathPrefix } }); } describe('Code navigation popover component', () => { @@ -33,14 +35,14 @@ describe('Code navigation popover component', () => { }); it('renders popover', () => { - factory({ x: 0, y: 0, height: 0 }, MOCK_CODE_DATA); + factory({ x: 0, y: 0, height: 0 }, MOCK_CODE_DATA, DEFINITION_PATH_PREFIX); expect(wrapper.element).toMatchSnapshot(); }); describe('code output', () => { it('renders code output', () => { - factory({ x: 0, y: 0, height: 0 }, MOCK_CODE_DATA); + factory({ x: 0, y: 0, height: 0 }, MOCK_CODE_DATA, DEFINITION_PATH_PREFIX); expect(wrapper.find({ ref: 'code-output' }).exists()).toBe(true); expect(wrapper.find({ ref: 'doc-output' }).exists()).toBe(false); @@ -49,7 +51,7 @@ describe('Code navigation popover component', () => { describe('documentation output', () => { it('renders code output', () => { - factory({ x: 0, y: 0, height: 0 }, MOCK_DOCS_DATA); + factory({ x: 0, y: 0, height: 0 }, MOCK_DOCS_DATA, DEFINITION_PATH_PREFIX); expect(wrapper.find({ ref: 'code-output' }).exists()).toBe(false); expect(wrapper.find({ ref: 'doc-output' }).exists()).toBe(true); diff --git a/spec/frontend/code_navigation/store/actions_spec.js b/spec/frontend/code_navigation/store/actions_spec.js index 9c44480ca67..f58dc283ada 100644 --- a/spec/frontend/code_navigation/store/actions_spec.js +++ b/spec/frontend/code_navigation/store/actions_spec.js @@ -27,12 +27,10 @@ describe('Code navigation actions', () => { describe('fetchData', () => { let mock; - const state = { - projectPath: 'gitlab-org/gitlab', - commitId: '123', - blobPath: 'index', - }; - const apiUrl = '/api/1/projects/gitlab-org%2Fgitlab/commits/123/lsif/info'; + + const codeNavUrl = + 'gitlab-org/gitlab-shell/-/jobs/1114/artifacts/raw/lsif/cmd/check/main.go.json'; + const state = { codeNavUrl }; beforeEach(() => { window.gon = { api_version: '1' }; @@ -45,20 +43,18 @@ describe('Code navigation actions', () => { describe('success', () => { beforeEach(() => { - mock.onGet(apiUrl).replyOnce(200, { - index: [ - { - start_line: 0, - start_char: 0, - hover: { value: '123' }, - }, - { - start_line: 1, - start_char: 0, - hover: null, - }, - ], - }); + mock.onGet(codeNavUrl).replyOnce(200, [ + { + start_line: 0, + start_char: 0, + hover: { value: '123' }, + }, + { + start_line: 1, + start_char: 0, + hover: null, + }, + ]); }); it('commits REQUEST_DATA_SUCCESS with normalized data', done => { @@ -106,7 +102,7 @@ describe('Code navigation actions', () => { describe('error', () => { beforeEach(() => { - mock.onGet(apiUrl).replyOnce(500); + mock.onGet(codeNavUrl).replyOnce(500); }); it('dispatches requestDataError', done => { diff --git a/spec/frontend/code_navigation/store/mutations_spec.js b/spec/frontend/code_navigation/store/mutations_spec.js index 117a2ed2f14..305386f4d0b 100644 --- a/spec/frontend/code_navigation/store/mutations_spec.js +++ b/spec/frontend/code_navigation/store/mutations_spec.js @@ -11,14 +11,12 @@ describe('Code navigation mutations', () => { describe('SET_INITIAL_DATA', () => { it('sets initial data', () => { mutations.SET_INITIAL_DATA(state, { - projectPath: 'test', - commitId: '123', - blobPath: 'index.js', + codeNavUrl: 'https://test.com/builds/1005', + definitionPathPrefix: 'https://test.com/blob/master', }); - expect(state.projectPath).toBe('test'); - expect(state.commitId).toBe('123'); - expect(state.blobPath).toBe('index.js'); + expect(state.codeNavUrl).toBe('https://test.com/builds/1005'); + expect(state.definitionPathPrefix).toBe('https://test.com/blob/master'); }); }); |