2018-07-23 16:54:48 +00:00
|
|
|
import * as types from './mutation_types';
|
2021-04-01 00:09:32 +00:00
|
|
|
import { countRecentlyFailedTests, formatFilePath } from './utils';
|
2018-07-23 16:54:48 +00:00
|
|
|
|
|
|
|
export default {
|
2021-04-01 00:09:32 +00:00
|
|
|
[types.SET_PATHS](state, { endpoint, headBlobPath }) {
|
2018-07-23 16:54:48 +00:00
|
|
|
state.endpoint = endpoint;
|
2021-04-01 00:09:32 +00:00
|
|
|
state.headBlobPath = headBlobPath;
|
2018-07-23 16:54:48 +00:00
|
|
|
},
|
|
|
|
[types.REQUEST_REPORTS](state) {
|
|
|
|
state.isLoading = true;
|
|
|
|
},
|
|
|
|
[types.RECEIVE_REPORTS_SUCCESS](state, response) {
|
2020-12-24 00:10:25 +00:00
|
|
|
state.hasError = response.suites.some((suite) => suite.status === 'error');
|
2018-07-23 16:54:48 +00:00
|
|
|
|
|
|
|
state.isLoading = false;
|
|
|
|
|
|
|
|
state.summary.total = response.summary.total;
|
|
|
|
state.summary.resolved = response.summary.resolved;
|
|
|
|
state.summary.failed = response.summary.failed;
|
2020-02-17 12:09:20 +00:00
|
|
|
state.summary.errored = response.summary.errored;
|
2020-11-12 21:09:19 +00:00
|
|
|
state.summary.recentlyFailed = countRecentlyFailedTests(response.suites);
|
2018-07-23 16:54:48 +00:00
|
|
|
|
2018-07-31 15:50:34 +00:00
|
|
|
state.status = response.status;
|
2018-07-23 16:54:48 +00:00
|
|
|
state.reports = response.suites;
|
2020-11-12 21:09:19 +00:00
|
|
|
|
|
|
|
state.reports.forEach((report, i) => {
|
|
|
|
if (!state.reports[i].summary) return;
|
|
|
|
state.reports[i].summary.recentlyFailed = countRecentlyFailedTests(report);
|
|
|
|
});
|
2018-07-23 16:54:48 +00:00
|
|
|
},
|
|
|
|
[types.RECEIVE_REPORTS_ERROR](state) {
|
|
|
|
state.isLoading = false;
|
|
|
|
state.hasError = true;
|
2018-08-01 14:57:05 +00:00
|
|
|
|
2018-07-31 15:50:34 +00:00
|
|
|
state.reports = [];
|
2018-08-01 14:57:05 +00:00
|
|
|
state.summary = {
|
|
|
|
total: 0,
|
|
|
|
resolved: 0,
|
|
|
|
failed: 0,
|
2020-02-17 12:09:20 +00:00
|
|
|
errored: 0,
|
2020-11-12 21:09:19 +00:00
|
|
|
recentlyFailed: 0,
|
2018-08-01 14:57:05 +00:00
|
|
|
};
|
|
|
|
state.status = null;
|
2018-07-31 15:50:34 +00:00
|
|
|
},
|
|
|
|
[types.SET_ISSUE_MODAL_DATA](state, payload) {
|
2021-04-01 00:09:32 +00:00
|
|
|
const { issue } = payload;
|
|
|
|
state.modal.title = issue.name;
|
2018-07-31 15:50:34 +00:00
|
|
|
|
2021-04-01 00:09:32 +00:00
|
|
|
Object.keys(issue).forEach((key) => {
|
2018-07-31 15:50:34 +00:00
|
|
|
if (Object.prototype.hasOwnProperty.call(state.modal.data, key)) {
|
|
|
|
state.modal.data[key] = {
|
|
|
|
...state.modal.data[key],
|
2021-04-01 00:09:32 +00:00
|
|
|
value: issue[key],
|
2018-07-31 15:50:34 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2021-01-15 15:10:31 +00:00
|
|
|
|
2021-04-01 00:09:32 +00:00
|
|
|
if (issue.file) {
|
|
|
|
state.modal.data.filename.value = {
|
|
|
|
text: issue.file,
|
|
|
|
path: `${state.headBlobPath}/${formatFilePath(issue.file)}`,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-01-15 15:10:31 +00:00
|
|
|
state.modal.open = true;
|
|
|
|
},
|
|
|
|
[types.RESET_ISSUE_MODAL_DATA](state) {
|
|
|
|
state.modal.open = false;
|
|
|
|
|
|
|
|
// Resetting modal data
|
|
|
|
state.modal.title = null;
|
|
|
|
Object.keys(state.modal.data).forEach((key) => {
|
|
|
|
state.modal.data[key] = {
|
|
|
|
...state.modal.data[key],
|
|
|
|
value: null,
|
|
|
|
};
|
|
|
|
});
|
2018-07-23 16:54:48 +00:00
|
|
|
},
|
|
|
|
};
|