Commit b0759564 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch...

Merge branch '13836-follow-up-from-productivity-analytics-add-error-handling-for-reporting-on-groups-which-have-no-plan' into 'master'

Resolve "Follow-up from "Productivity Analytics: Add error handling for reporting on groups which have no plan""

Closes #13836

See merge request gitlab-org/gitlab!17206
parents fd40fcbf 0c309355
......@@ -111,7 +111,7 @@ export const isSelectedMetric = state => ({ metric, chartKey }) =>
state.charts[chartKey].params.metricType === metric;
export const hasNoAccessError = state =>
state.charts[chartKeys.main].hasError === httpStatus.FORBIDDEN;
state.charts[chartKeys.main].errorCode === httpStatus.FORBIDDEN;
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};
......@@ -10,12 +10,12 @@ export default {
},
[types.RECEIVE_CHART_DATA_SUCCESS](state, { chartKey, data }) {
state.charts[chartKey].isLoading = false;
state.charts[chartKey].hasError = false;
state.charts[chartKey].errorCode = null;
state.charts[chartKey].data = data;
},
[types.RECEIVE_CHART_DATA_ERROR](state, { chartKey, status }) {
state.charts[chartKey].isLoading = false;
state.charts[chartKey].hasError = status;
state.charts[chartKey].errorCode = status;
state.charts[chartKey].data = {};
},
[types.SET_METRIC_TYPE](state, { chartKey, metricType }) {
......
......@@ -4,7 +4,7 @@ export default () => ({
charts: {
[chartKeys.main]: {
isLoading: false,
hasError: false,
errorCode: null,
data: {},
selected: [],
params: {
......@@ -13,7 +13,7 @@ export default () => ({
},
[chartKeys.timeBasedHistogram]: {
isLoading: false,
hasError: false,
errorCode: null,
data: {},
selected: [],
params: {
......@@ -23,7 +23,7 @@ export default () => ({
},
[chartKeys.commitBasedHistogram]: {
isLoading: false,
hasError: false,
errorCode: null,
data: {},
selected: [],
params: {
......@@ -33,7 +33,7 @@ export default () => ({
},
[chartKeys.scatterplot]: {
isLoading: false,
hasError: false,
errorCode: null,
data: {},
selected: [],
params: {
......
......@@ -7,13 +7,13 @@ export default {
},
[types.RECEIVE_MERGE_REQUESTS_SUCCESS](state, { pageInfo, mergeRequests }) {
state.isLoadingTable = false;
state.hasError = false;
state.errorCode = null;
state.pageInfo = pageInfo;
state.mergeRequests = mergeRequests;
},
[types.RECEIVE_MERGE_REQUESTS_ERROR](state, errCode) {
state.isLoadingTable = false;
state.hasError = errCode;
state.errorCode = errCode;
state.pageInfo = {};
state.mergeRequests = [];
},
......
......@@ -2,7 +2,7 @@ import { tableSortOrder } from '../../../constants';
export default () => ({
isLoadingTable: false,
hasError: false,
errorCode: null,
mergeRequests: [],
pageInfo: {},
sortOrder: tableSortOrder.asc.value,
......
......@@ -75,7 +75,7 @@ describe('ProductivityApp component', () => {
describe('and user has no access to the group', () => {
beforeEach(() => {
store.state.charts.charts[chartKeys.main].hasError = 403;
store.state.charts.charts[chartKeys.main].errorCode = 403;
});
it('renders the no access illustration', () => {
......@@ -88,7 +88,7 @@ describe('ProductivityApp component', () => {
describe('and user has access to the group', () => {
beforeEach(() => {
store.state.charts.charts[chartKeys.main].hasError = false;
store.state.charts.charts[chartKeys.main].errorCode = null;
});
describe('Time to merge chart', () => {
......
......@@ -179,13 +179,13 @@ describe('Productivity analytics chart getters', () => {
});
describe('hasNoAccessError', () => {
it('returns true if "hasError" is set to 403', () => {
state.charts[chartKeys.main].hasError = 403;
it('returns true if errorCode is set to 403', () => {
state.charts[chartKeys.main].errorCode = 403;
expect(getters.hasNoAccessError(state)).toEqual(true);
});
it('returns false if "hasError" is not set to 403', () => {
state.charts[chartKeys.main].hasError = false;
it('returns false if errorCode is not set to 403', () => {
state.charts[chartKeys.main].errorCode = null;
expect(getters.hasNoAccessError(state)).toEqual(false);
});
});
......
......@@ -34,18 +34,24 @@ describe('Productivity analytics chart mutations', () => {
mutations[types.RECEIVE_CHART_DATA_SUCCESS](state, { chartKey, data: mockHistogramData });
expect(state.charts[chartKey].isLoading).toBe(false);
expect(state.charts[chartKey].hasError).toBe(false);
expect(state.charts[chartKey].errorCode).toBe(null);
expect(state.charts[chartKey].data).toEqual(mockHistogramData);
});
});
describe(types.RECEIVE_CHART_DATA_ERROR, () => {
it('sets isError to error code and clears data', () => {
const status = 500;
beforeEach(() => {
mutations[types.RECEIVE_CHART_DATA_ERROR](state, { chartKey, status });
});
it('sets errorCode to 500', () => {
expect(state.charts[chartKey].isLoading).toBe(false);
expect(state.charts[chartKey].errorCode).toBe(status);
});
it('clears data', () => {
expect(state.charts[chartKey].isLoading).toBe(false);
expect(state.charts[chartKey].hasError).toBe(status);
expect(state.charts[chartKey].data).toEqual({});
});
});
......
......@@ -33,19 +33,25 @@ describe('Productivity analytics table mutations', () => {
});
expect(state.isLoadingTable).toBe(false);
expect(state.hasError).toBe(false);
expect(state.errorCode).toBe(null);
expect(state.mergeRequests).toEqual(mockMergeRequests);
expect(state.pageInfo).toEqual(pageInfo);
});
});
describe(types.RECEIVE_MERGE_REQUESTS_ERROR, () => {
it('sets hasError to error code and clears data', () => {
const errorCode = 500;
beforeEach(() => {
mutations[types.RECEIVE_MERGE_REQUESTS_ERROR](state, errorCode);
});
it('sets errorCode to 500', () => {
expect(state.isLoadingTable).toBe(false);
expect(state.errorCode).toBe(errorCode);
});
it('clears data', () => {
expect(state.isLoadingTable).toBe(false);
expect(state.hasError).toBe(errorCode);
expect(state.mergeRequests).toEqual([]);
expect(state.pageInfo).toEqual({});
});
......
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