debian-mirror-gitlab/app/assets/javascripts/reports/grouped_test_report/grouped_test_reports_app.vue

205 lines
6 KiB
Vue
Raw Normal View History

2018-11-18 11:00:15 +05:30
<script>
2021-04-17 20:07:23 +05:30
import { GlButton, GlIcon } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapActions, mapGetters, mapState } from 'vuex';
2021-04-29 21:17:54 +05:30
import api from '~/api';
2020-05-24 23:13:21 +05:30
import { sprintf, s__ } from '~/locale';
2021-04-17 20:07:23 +05:30
import GroupedIssuesList from '../components/grouped_issues_list.vue';
import { componentNames } from '../components/issue_body';
import ReportSection from '../components/report_section.vue';
import SummaryRow from '../components/summary_row.vue';
import Modal from './components/modal.vue';
import createStore from './store';
2021-01-29 00:20:46 +05:30
import {
summaryTextBuilder,
reportTextBuilder,
statusIcon,
recentFailuresTextBuilder,
2021-04-17 20:07:23 +05:30
} from './store/utils';
2018-11-18 11:00:15 +05:30
2018-12-13 13:39:08 +05:30
export default {
name: 'GroupedTestReportsApp',
store: createStore(),
components: {
ReportSection,
SummaryRow,
2021-04-17 20:07:23 +05:30
GroupedIssuesList,
2018-12-13 13:39:08 +05:30
Modal,
2020-07-28 23:09:34 +05:30
GlButton,
2021-04-17 20:07:23 +05:30
GlIcon,
2018-12-13 13:39:08 +05:30
},
props: {
endpoint: {
type: String,
required: true,
2018-11-18 11:00:15 +05:30
},
2020-07-28 23:09:34 +05:30
pipelinePath: {
type: String,
required: false,
default: '',
},
2021-04-29 21:17:54 +05:30
headBlobPath: {
type: String,
required: true,
},
2018-12-13 13:39:08 +05:30
},
componentNames,
computed: {
...mapState(['reports', 'isLoading', 'hasError', 'summary']),
...mapState({
2021-03-08 18:12:59 +05:30
modalTitle: (state) => state.modal.title || '',
modalData: (state) => state.modal.data || {},
modalOpen: (state) => state.modal.open || false,
2018-12-13 13:39:08 +05:30
}),
...mapGetters(['summaryStatus']),
groupedSummaryText() {
if (this.isLoading) {
return s__('Reports|Test summary results are being parsed');
}
2018-11-18 11:00:15 +05:30
2018-12-13 13:39:08 +05:30
if (this.hasError) {
return s__('Reports|Test summary failed loading results');
}
2018-11-18 11:00:15 +05:30
2018-12-13 13:39:08 +05:30
return summaryTextBuilder(s__('Reports|Test summary'), this.summary);
2018-11-18 11:00:15 +05:30
},
2020-07-28 23:09:34 +05:30
testTabURL() {
return `${this.pipelinePath}/test_report`;
},
showViewFullReport() {
2020-10-24 23:57:45 +05:30
return this.pipelinePath.length;
2020-07-28 23:09:34 +05:30
},
2018-12-13 13:39:08 +05:30
},
created() {
2021-04-29 21:17:54 +05:30
this.setPaths({
endpoint: this.endpoint,
headBlobPath: this.headBlobPath,
});
2018-11-18 11:00:15 +05:30
2018-12-13 13:39:08 +05:30
this.fetchReports();
},
methods: {
2021-04-29 21:17:54 +05:30
...mapActions(['setPaths', 'fetchReports', 'closeModal']),
handleToggleEvent() {
2021-11-18 22:05:49 +05:30
api.trackRedisHllUserEvent(this.$options.expandEvent);
2021-04-29 21:17:54 +05:30
},
2018-12-13 13:39:08 +05:30
reportText(report) {
2020-05-24 23:13:21 +05:30
const { name, summary } = report || {};
if (report.status === 'error') {
return sprintf(s__('Reports|An error occurred while loading %{name} results'), { name });
}
if (!report.name) {
2021-04-17 20:07:23 +05:30
return s__('Reports|An error occurred while loading report');
2020-05-24 23:13:21 +05:30
}
return reportTextBuilder(name, summary);
2018-12-13 13:39:08 +05:30
},
2021-01-29 00:20:46 +05:30
hasRecentFailures(summary) {
2021-03-08 18:12:59 +05:30
return summary?.recentlyFailed > 0;
2021-01-29 00:20:46 +05:30
},
recentFailuresText(summary) {
return recentFailuresTextBuilder(summary);
},
2018-12-13 13:39:08 +05:30
getReportIcon(report) {
return statusIcon(report.status);
2018-11-18 11:00:15 +05:30
},
2018-12-13 13:39:08 +05:30
shouldRenderIssuesList(report) {
return (
report.existing_failures.length > 0 ||
report.new_failures.length > 0 ||
2020-03-13 15:44:24 +05:30
report.resolved_failures.length > 0 ||
report.existing_errors.length > 0 ||
report.new_errors.length > 0 ||
report.resolved_errors.length > 0
2018-12-13 13:39:08 +05:30
);
2018-11-18 11:00:15 +05:30
},
2020-03-13 15:44:24 +05:30
unresolvedIssues(report) {
2021-04-17 20:07:23 +05:30
return [
...report.new_failures,
...report.new_errors,
...report.existing_failures,
...report.existing_errors,
];
2020-03-13 15:44:24 +05:30
},
resolvedIssues(report) {
return report.resolved_failures.concat(report.resolved_errors);
},
2018-12-13 13:39:08 +05:30
},
2021-04-29 21:17:54 +05:30
expandEvent: 'i_testing_summary_widget_total',
2018-12-13 13:39:08 +05:30
};
2018-11-18 11:00:15 +05:30
</script>
<template>
<report-section
:status="summaryStatus"
:success-text="groupedSummaryText"
:loading-text="groupedSummaryText"
:error-text="groupedSummaryText"
:has-issues="reports.length > 0"
2021-01-29 00:20:46 +05:30
:should-emit-toggle-event="true"
2018-12-13 13:39:08 +05:30
class="mr-widget-section grouped-security-reports mr-report"
2021-04-29 21:17:54 +05:30
@toggleEvent.once="handleToggleEvent"
2018-11-18 11:00:15 +05:30
>
2021-01-29 00:20:46 +05:30
<template v-if="showViewFullReport" #action-buttons>
2020-07-28 23:09:34 +05:30
<gl-button
:href="testTabURL"
2020-10-24 23:57:45 +05:30
target="_blank"
2020-07-28 23:09:34 +05:30
icon="external-link"
data-testid="group-test-reports-full-link"
class="gl-mr-3"
>
{{ s__('ciReport|View full report') }}
</gl-button>
</template>
2021-01-29 00:20:46 +05:30
<template v-if="hasRecentFailures(summary)" #sub-heading>
{{ recentFailuresText(summary) }}
</template>
2020-06-23 00:09:42 +05:30
<template #body>
<div class="mr-widget-grouped-section report-block">
<template v-for="(report, i) in reports">
2021-04-17 20:07:23 +05:30
<summary-row
:key="`summary-row-${i}`"
:status-icon="getReportIcon(report)"
nested-summary
>
2021-01-29 00:20:46 +05:30
<template #summary>
<div class="gl-display-inline-flex gl-flex-direction-column">
<div>{{ reportText(report) }}</div>
2021-04-17 20:07:23 +05:30
<div v-if="report.suite_errors">
<div v-if="report.suite_errors.head">
<gl-icon name="warning" class="gl-mx-2 gl-text-orange-500" />
{{ s__('Reports|Head report parsing error:') }}
{{ report.suite_errors.head }}
</div>
<div v-if="report.suite_errors.base">
<gl-icon name="warning" class="gl-mx-2 gl-text-orange-500" />
{{ s__('Reports|Base report parsing error:') }}
{{ report.suite_errors.base }}
</div>
</div>
2021-01-29 00:20:46 +05:30
<div v-if="hasRecentFailures(report.summary)">
{{ recentFailuresText(report.summary) }}
</div>
</div>
</template>
</summary-row>
2021-04-17 20:07:23 +05:30
<grouped-issues-list
2020-06-23 00:09:42 +05:30
v-if="shouldRenderIssuesList(report)"
:key="`issues-list-${i}`"
:unresolved-issues="unresolvedIssues(report)"
:resolved-issues="resolvedIssues(report)"
:component="$options.componentNames.TestIssueBody"
2021-04-17 20:07:23 +05:30
:nested-level="2"
2020-06-23 00:09:42 +05:30
/>
</template>
2021-03-08 18:12:59 +05:30
<modal
:visible="modalOpen"
:title="modalTitle"
:modal-data="modalData"
@hide="closeModal"
/>
2020-06-23 00:09:42 +05:30
</div>
</template>
2018-11-18 11:00:15 +05:30
</report-section>
</template>