Commit be32200a authored by Martin Wortschack's avatar Martin Wortschack

Update URL date params properly

- This updates the merged_at_after and
merged_at_before URL params with a date string instead of an object
parent 41537027
import dateFormat from 'dateformat';
import { historyPushState } from '~/lib/utils/common_utils';
import { setUrlParams } from '~/lib/utils/url_utility';
import { beginOfDayTime, endOfDayTime } from '~/lib/utils/datetime_utility';
import * as types from './mutation_types';
import { chartKeys } from '../../../constants';
import { dateFormats } from '../../../../shared/constants';
export const setInitialData = ({ commit, dispatch }, { skipFetch = false, data }) => {
commit(types.SET_INITIAL_DATA, data);
......@@ -77,7 +80,12 @@ export const setFilters = (
export const setDateRange = ({ commit, dispatch }, { startDate, endDate }) => {
commit(types.SET_DATE_RANGE, { startDate, endDate });
historyPushState(setUrlParams({ merged_at_after: startDate, merged_at_before: endDate }));
const mergedAtAfter = `${dateFormat(startDate, dateFormats.isoDate)}${beginOfDayTime}`;
const mergedAtBefore = `${dateFormat(endDate, dateFormats.isoDate)}${endOfDayTime}`;
historyPushState(
setUrlParams({ merged_at_after: mergedAtAfter, merged_at_before: mergedAtBefore }),
);
dispatch('charts/resetMainChartSelection', true, { root: true });
......
......@@ -11,9 +11,8 @@ jest.mock('~/lib/utils/url_utility');
describe('Productivity analytics filter actions', () => {
let store;
const currentYear = new Date().getFullYear();
const startDate = new Date(currentYear, 8, 1);
const endDate = new Date(currentYear, 8, 7);
const startDate = new Date('2019-09-01');
const endDate = new Date('2019-09-07');
const groupNamespace = 'gitlab-org';
const projectPath = 'gitlab-org/gitlab-test';
const initialData = {
......@@ -250,8 +249,8 @@ describe('Productivity analytics filter actions', () => {
.setDateRange(store, { startDate, endDate })
.then(() => {
expect(setUrlParams).toHaveBeenCalledWith({
merged_at_after: startDate,
merged_at_before: endDate,
merged_at_after: '2019-09-01T00:00:00Z',
merged_at_before: '2019-09-07T23:59:59Z',
});
expect(historyPushState).toHaveBeenCalled();
......
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