Commit 5342e061 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Update VSA specs with the page parameter

Updates the base specs and the action specs
to include the pagination page parameter
parent 3df8ae12
...@@ -142,7 +142,7 @@ describe('Value Stream Analytics component', () => { ...@@ -142,7 +142,7 @@ describe('Value Stream Analytics component', () => {
...opts, ...opts,
}); });
if (withStageSelected) { if (withStageSelected || selectedStage) {
await store.dispatch( await store.dispatch(
'receiveGroupStagesSuccess', 'receiveGroupStagesSuccess',
mockData.customizableStagesAndEvents.stages, mockData.customizableStagesAndEvents.stages,
...@@ -350,10 +350,7 @@ describe('Value Stream Analytics component', () => { ...@@ -350,10 +350,7 @@ describe('Value Stream Analytics component', () => {
beforeEach(async () => { beforeEach(async () => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mockRequiredRoutes(mock); mockRequiredRoutes(mock);
wrapper = await createComponent({ wrapper = await createComponent({ selectedStage: mockData.issueStage });
withStageSelected: true,
selectedStage: mockData.issueStage,
});
}); });
it('displays the stage table', () => { it('displays the stage table', () => {
...@@ -405,7 +402,7 @@ describe('Value Stream Analytics component', () => { ...@@ -405,7 +402,7 @@ describe('Value Stream Analytics component', () => {
.onGet(mockData.endpoints.stageData) .onGet(mockData.endpoints.stageData)
.reply(httpStatusCodes.NOT_FOUND, { response: { status: httpStatusCodes.NOT_FOUND } }); .reply(httpStatusCodes.NOT_FOUND, { response: { status: httpStatusCodes.NOT_FOUND } });
await createComponent({ withStageSelected: true, selectedStage: mockData.issueStage }); await createComponent({ selectedStage: mockData.issueStage });
await findError('There was an error fetching data for the selected stage'); await findError('There was an error fetching data for the selected stage');
}); });
...@@ -456,6 +453,7 @@ describe('Value Stream Analytics component', () => { ...@@ -456,6 +453,7 @@ describe('Value Stream Analytics component', () => {
project_ids: null, project_ids: null,
sort: null, sort: null,
direction: null, direction: null,
page: null,
}; };
const selectedProjectIds = mockData.selectedProjects.map(({ id }) => getIdFromGraphQLId(id)); const selectedProjectIds = mockData.selectedProjects.map(({ id }) => getIdFromGraphQLId(id));
...@@ -527,17 +525,20 @@ describe('Value Stream Analytics component', () => { ...@@ -527,17 +525,20 @@ describe('Value Stream Analytics component', () => {
describe('with selectedStage set', () => { describe('with selectedStage set', () => {
beforeEach(async () => { beforeEach(async () => {
wrapper = await createComponent(); wrapper = await createComponent({
store.dispatch('setSelectedStage', selectedStage); initialState: {
await wrapper.vm.$nextTick(); ...initialCycleAnalyticsState,
pagination: mockData.initialPaginationQuery,
},
selectedStage,
});
}); });
it('sets the stage, sort and direction parameters', async () => { it('sets the stage, sort, direction and page parameters', async () => {
await shouldMergeUrlParams(wrapper, { await shouldMergeUrlParams(wrapper, {
...defaultParams, ...defaultParams,
...mockData.initialPaginationQuery,
stage_id: selectedStage.id, stage_id: selectedStage.id,
direction: PAGINATION_SORT_DIRECTION_DESC,
sort: PAGINATION_SORT_FIELD_END_EVENT,
}); });
}); });
}); });
......
...@@ -325,11 +325,16 @@ export const selectedProjects = [ ...@@ -325,11 +325,16 @@ export const selectedProjects = [
export const pathNavIssueMetric = 172800; export const pathNavIssueMetric = 172800;
export const initialPaginationQuery = {
page: 15,
sort: PAGINATION_SORT_FIELD_END_EVENT,
direction: PAGINATION_SORT_DIRECTION_DESC,
};
export const initialPaginationState = { export const initialPaginationState = {
...initialPaginationQuery,
page: null, page: null,
hasNextPage: false, hasNextPage: false,
sort: PAGINATION_SORT_FIELD_END_EVENT,
direction: PAGINATION_SORT_DIRECTION_DESC,
}; };
export const basePaginationResult = { export const basePaginationResult = {
......
...@@ -92,7 +92,7 @@ describe('Value Stream Analytics actions', () => { ...@@ -92,7 +92,7 @@ describe('Value Stream Analytics actions', () => {
describe('setSelectedStage', () => { describe('setSelectedStage', () => {
const data = { id: 'someStageId' }; const data = { id: 'someStageId' };
const payload = { hasNextPage: null, page: 1 }; const payload = { hasNextPage: null };
it(`dispatches the ${types.SET_SELECTED_STAGE} and ${types.SET_PAGINATION} actions`, () => { it(`dispatches the ${types.SET_SELECTED_STAGE} and ${types.SET_PAGINATION} actions`, () => {
return testAction(actions.setSelectedStage, data, { ...state, selectedValueStream: {} }, [ return testAction(actions.setSelectedStage, data, { ...state, selectedValueStream: {} }, [
...@@ -625,6 +625,16 @@ describe('Value Stream Analytics actions', () => { ...@@ -625,6 +625,16 @@ describe('Value Stream Analytics actions', () => {
}); });
}); });
describe('with pagination parameters', () => {
it('dispatches "setSelectedStage" and "fetchStageData"', async () => {
const stage = { id: 2, title: 'plan' };
const pagination = { sort: 'end_event', direction: 'desc', page: 1337 };
const payload = { ...initialData, stage, pagination };
await actions.initializeCycleAnalytics(store, payload);
expect(mockCommit).toHaveBeenCalledWith('INITIALIZE_VSA', payload);
});
});
describe('without a selected stage', () => { describe('without a selected stage', () => {
it('dispatches "setDefaultSelectedStage"', async () => { it('dispatches "setDefaultSelectedStage"', async () => {
await actions.initializeCycleAnalytics(store, { await actions.initializeCycleAnalytics(store, {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment