2018-11-18 11:00:15 +05:30
|
|
|
import * as types from './mutation_types';
|
2021-01-29 00:20:46 +05:30
|
|
|
import { countRecentlyFailedTests } from './utils';
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
[types.SET_ENDPOINT](state, endpoint) {
|
|
|
|
state.endpoint = endpoint;
|
|
|
|
},
|
|
|
|
[types.REQUEST_REPORTS](state) {
|
|
|
|
state.isLoading = true;
|
|
|
|
},
|
|
|
|
[types.RECEIVE_REPORTS_SUCCESS](state, response) {
|
2020-05-24 23:13:21 +05:30
|
|
|
state.hasError = response.suites.some(suite => suite.status === 'error');
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
state.isLoading = false;
|
|
|
|
|
|
|
|
state.summary.total = response.summary.total;
|
|
|
|
state.summary.resolved = response.summary.resolved;
|
|
|
|
state.summary.failed = response.summary.failed;
|
2020-03-09 13:42:32 +05:30
|
|
|
state.summary.errored = response.summary.errored;
|
2021-01-29 00:20:46 +05:30
|
|
|
state.summary.recentlyFailed = countRecentlyFailedTests(response.suites);
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
state.status = response.status;
|
|
|
|
state.reports = response.suites;
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
state.reports.forEach((report, i) => {
|
|
|
|
if (!state.reports[i].summary) return;
|
|
|
|
state.reports[i].summary.recentlyFailed = countRecentlyFailedTests(report);
|
|
|
|
});
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
[types.RECEIVE_REPORTS_ERROR](state) {
|
|
|
|
state.isLoading = false;
|
|
|
|
state.hasError = true;
|
|
|
|
|
|
|
|
state.reports = [];
|
|
|
|
state.summary = {
|
|
|
|
total: 0,
|
|
|
|
resolved: 0,
|
|
|
|
failed: 0,
|
2020-03-09 13:42:32 +05:30
|
|
|
errored: 0,
|
2021-01-29 00:20:46 +05:30
|
|
|
recentlyFailed: 0,
|
2018-11-18 11:00:15 +05:30
|
|
|
};
|
|
|
|
state.status = null;
|
|
|
|
},
|
|
|
|
[types.SET_ISSUE_MODAL_DATA](state, payload) {
|
|
|
|
state.modal.title = payload.issue.name;
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
Object.keys(payload.issue).forEach(key => {
|
2018-11-18 11:00:15 +05:30
|
|
|
if (Object.prototype.hasOwnProperty.call(state.modal.data, key)) {
|
|
|
|
state.modal.data[key] = {
|
|
|
|
...state.modal.data[key],
|
|
|
|
value: payload.issue[key],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|