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', () => {
...opts,
});
if (withStageSelected) {
if (withStageSelected || selectedStage) {
await store.dispatch(
'receiveGroupStagesSuccess',
mockData.customizableStagesAndEvents.stages,
......@@ -350,10 +350,7 @@ describe('Value Stream Analytics component', () => {
beforeEach(async () => {
mock = new MockAdapter(axios);
mockRequiredRoutes(mock);
wrapper = await createComponent({
withStageSelected: true,
selectedStage: mockData.issueStage,
});
wrapper = await createComponent({ selectedStage: mockData.issueStage });
});
it('displays the stage table', () => {
......@@ -405,7 +402,7 @@ describe('Value Stream Analytics component', () => {
.onGet(mockData.endpoints.stageData)
.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');
});
......@@ -456,6 +453,7 @@ describe('Value Stream Analytics component', () => {
project_ids: null,
sort: null,
direction: null,
page: null,
};
const selectedProjectIds = mockData.selectedProjects.map(({ id }) => getIdFromGraphQLId(id));
......@@ -527,17 +525,20 @@ describe('Value Stream Analytics component', () => {
describe('with selectedStage set', () => {
beforeEach(async () => {
wrapper = await createComponent();
store.dispatch('setSelectedStage', selectedStage);
await wrapper.vm.$nextTick();
wrapper = await createComponent({
initialState: {
...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, {
...defaultParams,
...mockData.initialPaginationQuery,
stage_id: selectedStage.id,
direction: PAGINATION_SORT_DIRECTION_DESC,
sort: PAGINATION_SORT_FIELD_END_EVENT,
});
});
});
......
......@@ -325,11 +325,16 @@ export const selectedProjects = [
export const pathNavIssueMetric = 172800;
export const initialPaginationQuery = {
page: 15,
sort: PAGINATION_SORT_FIELD_END_EVENT,
direction: PAGINATION_SORT_DIRECTION_DESC,
};
export const initialPaginationState = {
...initialPaginationQuery,
page: null,
hasNextPage: false,
sort: PAGINATION_SORT_FIELD_END_EVENT,
direction: PAGINATION_SORT_DIRECTION_DESC,
};
export const basePaginationResult = {
......
......@@ -92,7 +92,7 @@ describe('Value Stream Analytics actions', () => {
describe('setSelectedStage', () => {
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`, () => {
return testAction(actions.setSelectedStage, data, { ...state, selectedValueStream: {} }, [
......@@ -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', () => {
it('dispatches "setDefaultSelectedStage"', async () => {
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