1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
import { uniqueId } from 'lodash';
import axios from '~/lib/utils/axios_utils';
import { EXTENSION_ICONS } from '../../constants';
import { summaryTextBuilder, reportTextBuilder, reportSubTextBuilder } from './utils';
import { i18n, TESTS_FAILED_STATUS, ERROR_STATUS } from './constants';
export default {
name: 'WidgetTestSummary',
enablePolling: true,
i18n,
expandEvent: 'i_testing_summary_widget_total',
props: ['testResultsPath', 'headBlobPath', 'pipeline'],
computed: {
summary(data) {
if (data.parsingInProgress) {
return this.$options.i18n.loading;
}
if (data.hasSuiteError) {
return this.$options.i18n.error;
}
return summaryTextBuilder(this.$options.i18n.label, data.summary);
},
statusIcon(data) {
if (data.parsingInProgress) {
return null;
}
if (data.status === TESTS_FAILED_STATUS) {
return EXTENSION_ICONS.warning;
}
if (data.hasSuiteError) {
return EXTENSION_ICONS.failed;
}
return EXTENSION_ICONS.success;
},
tertiaryButtons() {
return [
{
text: this.$options.i18n.fullReport,
href: `${this.pipeline.path}/test_report`,
target: '_blank',
},
];
},
},
methods: {
fetchCollapsedData() {
return axios.get(this.testResultsPath).then(({ data = {}, status }) => {
return {
data: {
hasSuiteError: data.suites?.some((suite) => suite.status === ERROR_STATUS),
parsingInProgress: status === 204,
...data,
},
};
});
},
fetchFullData() {
return Promise.resolve(this.prepareReports());
},
suiteIcon(suite) {
if (suite.status === ERROR_STATUS) {
return EXTENSION_ICONS.error;
}
if (suite.status === TESTS_FAILED_STATUS) {
return EXTENSION_ICONS.failed;
}
return EXTENSION_ICONS.success;
},
prepareReports() {
return this.collapsedData.suites.map((suite) => {
return {
id: uniqueId('suite-'),
text: reportTextBuilder(suite),
subtext: reportSubTextBuilder(suite),
icon: {
name: this.suiteIcon(suite),
},
};
});
},
},
};
|