diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-14 00:15:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-14 00:15:31 +0300 |
commit | 5699348c8235e2e4382859be94e5676d39db9401 (patch) | |
tree | 57c28de6b58dfd78df2c4129ca6922fb203171dc /spec/frontend/analytics | |
parent | 7b7bc31c5ba07eebe62e2f2582f111ce24285cd4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/analytics')
5 files changed, 33 insertions, 34 deletions
diff --git a/spec/frontend/analytics/cycle_analytics/base_spec.js b/spec/frontend/analytics/cycle_analytics/base_spec.js index 03f52747dd5..6a2655957b7 100644 --- a/spec/frontend/analytics/cycle_analytics/base_spec.js +++ b/spec/frontend/analytics/cycle_analytics/base_spec.js @@ -38,7 +38,8 @@ const defaultState = { createdBefore, createdAfter, stageCounts, - endpoints: { fullPath, groupPath }, + groupPath, + namespace: { fullPath }, }; function createStore({ initialState = {}, initialGetters = {} }) { diff --git a/spec/frontend/analytics/cycle_analytics/mock_data.js b/spec/frontend/analytics/cycle_analytics/mock_data.js index f820f755400..216e07844b8 100644 --- a/spec/frontend/analytics/cycle_analytics/mock_data.js +++ b/spec/frontend/analytics/cycle_analytics/mock_data.js @@ -219,6 +219,8 @@ export const group = { }; export const currentGroup = convertObjectPropsToCamelCase(group, { deep: true }); +export const groupNamespace = { id: currentGroup.id, fullPath: `groups/${currentGroup.path}` }; +export const projectNamespace = { fullPath: 'some/cool/path' }; export const selectedProjects = [ { diff --git a/spec/frontend/analytics/cycle_analytics/store/actions_spec.js b/spec/frontend/analytics/cycle_analytics/store/actions_spec.js index 3030fca126b..b2ce8596c22 100644 --- a/spec/frontend/analytics/cycle_analytics/store/actions_spec.js +++ b/spec/frontend/analytics/cycle_analytics/store/actions_spec.js @@ -13,21 +13,13 @@ import { createdBefore, initialPaginationState, reviewEvents, + projectNamespace as namespace, } from '../mock_data'; -const { id: groupId, path: groupPath } = currentGroup; -const mockMilestonesPath = 'mock-milestones.json'; -const mockLabelsPath = 'mock-labels.json'; -const mockRequestPath = 'some/cool/path'; +const { path: groupPath } = currentGroup; +const mockMilestonesPath = `/${namespace.fullPath}/-/milestones.json`; +const mockLabelsPath = `/${namespace.fullPath}/-/labels.json`; const mockFullPath = '/namespace/-/analytics/value_stream_analytics/value_streams'; -const mockEndpoints = { - fullPath: mockFullPath, - requestPath: mockRequestPath, - labelsPath: mockLabelsPath, - milestonesPath: mockMilestonesPath, - groupId, - groupPath, -}; const mockSetDateActionCommit = { payload: { createdAfter, createdBefore }, type: 'SET_DATE_RANGE', @@ -35,6 +27,7 @@ const mockSetDateActionCommit = { const defaultState = { ...getters, + namespace, selectedValueStream, createdAfter, createdBefore, @@ -81,7 +74,8 @@ describe('Project Value Stream Analytics actions', () => { const selectedAssigneeList = ['Assignee 1', 'Assignee 2']; const selectedLabelList = ['Label 1', 'Label 2']; const payload = { - endpoints: mockEndpoints, + namespace, + groupPath, selectedAuthor, selectedMilestone, selectedAssigneeList, @@ -92,7 +86,7 @@ describe('Project Value Stream Analytics actions', () => { groupEndpoint: 'foo', labelsEndpoint: mockLabelsPath, milestonesEndpoint: mockMilestonesPath, - projectEndpoint: '/namespace/-/analytics/value_stream_analytics/value_streams', + projectEndpoint: namespace.fullPath, }; it('will dispatch fetchValueStreams actions and commit SET_LOADING and INITIALIZE_VSA', () => { @@ -193,7 +187,6 @@ describe('Project Value Stream Analytics actions', () => { beforeEach(() => { state = { ...defaultState, - endpoints: mockEndpoints, selectedStage, }; mock = new MockAdapter(axios); @@ -219,7 +212,6 @@ describe('Project Value Stream Analytics actions', () => { beforeEach(() => { state = { ...defaultState, - endpoints: mockEndpoints, selectedStage, }; mock = new MockAdapter(axios); @@ -243,7 +235,6 @@ describe('Project Value Stream Analytics actions', () => { beforeEach(() => { state = { ...defaultState, - endpoints: mockEndpoints, selectedStage, }; mock = new MockAdapter(axios); @@ -265,9 +256,7 @@ describe('Project Value Stream Analytics actions', () => { const mockValueStreamPath = /\/analytics\/value_stream_analytics\/value_streams/; beforeEach(() => { - state = { - endpoints: mockEndpoints, - }; + state = { namespace }; mock = new MockAdapter(axios); mock.onGet(mockValueStreamPath).reply(HTTP_STATUS_OK); }); @@ -333,7 +322,7 @@ describe('Project Value Stream Analytics actions', () => { beforeEach(() => { state = { - endpoints: mockEndpoints, + namespace, selectedValueStream, }; mock = new MockAdapter(axios); diff --git a/spec/frontend/analytics/cycle_analytics/store/mutations_spec.js b/spec/frontend/analytics/cycle_analytics/store/mutations_spec.js index 567fac81e1f..70b7454f4a0 100644 --- a/spec/frontend/analytics/cycle_analytics/store/mutations_spec.js +++ b/spec/frontend/analytics/cycle_analytics/store/mutations_spec.js @@ -17,12 +17,14 @@ import { rawStageCounts, stageCounts, initialPaginationState as pagination, + projectNamespace as mockNamespace, } from '../mock_data'; let state; const rawEvents = rawIssueEvents.events; const convertedEvents = issueEvents.events; -const mockRequestPath = 'fake/request/path'; +const mockGroupPath = 'groups/path'; +const mockFeatures = { some: 'feature' }; const mockCreatedAfter = '2020-06-18'; const mockCreatedBefore = '2020-07-18'; @@ -64,19 +66,22 @@ describe('Project Value Stream Analytics mutations', () => { const mockSetDatePayload = { createdAfter: mockCreatedAfter, createdBefore: mockCreatedBefore }; const mockInitialPayload = { - endpoints: { requestPath: mockRequestPath }, currentGroup: { title: 'cool-group' }, id: 1337, + groupPath: mockGroupPath, + namespace: mockNamespace, + features: mockFeatures, ...mockSetDatePayload, }; const mockInitializedObj = { - endpoints: { requestPath: mockRequestPath }, ...mockSetDatePayload, }; it.each` mutation | stateKey | value - ${types.INITIALIZE_VSA} | ${'endpoints'} | ${{ requestPath: mockRequestPath }} + ${types.INITIALIZE_VSA} | ${'features'} | ${mockFeatures} + ${types.INITIALIZE_VSA} | ${'namespace'} | ${mockNamespace} + ${types.INITIALIZE_VSA} | ${'groupPath'} | ${mockGroupPath} ${types.INITIALIZE_VSA} | ${'createdAfter'} | ${mockCreatedAfter} ${types.INITIALIZE_VSA} | ${'createdBefore'} | ${mockCreatedBefore} `('$mutation will set $stateKey', ({ mutation, stateKey, value }) => { diff --git a/spec/frontend/analytics/cycle_analytics/utils_spec.js b/spec/frontend/analytics/cycle_analytics/utils_spec.js index 25edd5af622..e6d17edcadc 100644 --- a/spec/frontend/analytics/cycle_analytics/utils_spec.js +++ b/spec/frontend/analytics/cycle_analytics/utils_spec.js @@ -92,7 +92,8 @@ describe('Value stream analytics utils', () => { const createdAfter = '2021-09-01'; const createdBefore = '2021-11-06'; const groupPath = 'fake-group'; - const fullPath = 'fake-group/fake-project'; + const namespaceName = 'Fake project'; + const namespaceFullPath = 'fake-group/fake-project'; const labelsPath = '/fake-group/fake-project/-/labels.json'; const milestonesPath = '/fake-group/fake-project/-/milestones.json'; const requestPath = '/fake-group/fake-project/-/value_stream_analytics'; @@ -101,7 +102,8 @@ describe('Value stream analytics utils', () => { projectId, createdBefore, createdAfter, - fullPath, + namespaceName, + namespaceFullPath, requestPath, labelsPath, milestonesPath, @@ -122,13 +124,13 @@ describe('Value stream analytics utils', () => { expect(res.createdAfter).toEqual(new Date(createdAfter)); }); + it('sets the namespace', () => { + expect(res.namespace.name).toBe(namespaceName); + expect(res.namespace.fullPath).toBe(namespaceFullPath); + }); + it('sets the endpoints', () => { - const { endpoints } = res; - expect(endpoints.fullPath).toBe(fullPath); - expect(endpoints.requestPath).toBe(requestPath); - expect(endpoints.labelsPath).toBe(labelsPath); - expect(endpoints.milestonesPath).toBe(milestonesPath); - expect(endpoints.groupPath).toBe(`groups/${groupPath}`); + expect(res.groupPath).toBe(`groups/${groupPath}`); }); it('returns null when there is no stage', () => { |