summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/components/test_reports/test_summary_table.vue
blob: 4dfb67dd8e831242c13271bd9a5fe4d992fbb78e (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<script>
import { mapGetters } from 'vuex';
import { s__ } from '~/locale';
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import store from '~/pipelines/stores/test_reports';
import SmartVirtualList from '~/vue_shared/components/smart_virtual_list.vue';

export default {
  name: 'TestsSummaryTable',
  components: {
    GlIcon,
    SmartVirtualList,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  store,
  props: {
    heading: {
      type: String,
      required: false,
      default: s__('TestReports|Test suites'),
    },
  },
  computed: {
    ...mapGetters(['getTestSuites']),
    hasSuites() {
      return this.getTestSuites.length > 0;
    },
  },
  methods: {
    tableRowClick(suite) {
      this.$emit('row-click', suite);
    },
  },
  maxShownRows: 20,
  typicalRowHeight: 55,
};
</script>

<template>
  <div>
    <div class="row prepend-top-default">
      <div class="col-12">
        <h4>{{ heading }}</h4>
      </div>
    </div>

    <div v-if="hasSuites" class="test-reports-table append-bottom-default js-test-suites-table">
      <div role="row" class="gl-responsive-table-row table-row-header font-weight-bold">
        <div role="rowheader" class="table-section section-25 pl-3">
          {{ __('Suite') }}
        </div>
        <div role="rowheader" class="table-section section-25">
          {{ __('Duration') }}
        </div>
        <div role="rowheader" class="table-section section-10 text-center">
          {{ __('Failed') }}
        </div>
        <div role="rowheader" class="table-section section-10 text-center">
          {{ __('Errors'), }}
        </div>
        <div role="rowheader" class="table-section section-10 text-center">
          {{ __('Skipped'), }}
        </div>
        <div role="rowheader" class="table-section section-10 text-center">
          {{ __('Passed'), }}
        </div>
        <div role="rowheader" class="table-section section-10 pr-3 text-right">
          {{ __('Total') }}
        </div>
      </div>

      <smart-virtual-list
        :length="getTestSuites.length"
        :remain="$options.maxShownRows"
        :size="$options.typicalRowHeight"
      >
        <div
          v-for="(testSuite, index) in getTestSuites"
          :key="index"
          role="row"
          class="gl-responsive-table-row test-reports-summary-row rounded js-suite-row"
          :class="{
            'gl-responsive-table-row-clickable cursor-pointer': !testSuite.suite_error,
          }"
          @click="tableRowClick(testSuite)"
        >
          <div class="table-section section-25">
            <div role="rowheader" class="table-mobile-header font-weight-bold">
              {{ __('Suite') }}
            </div>
            <div class="table-mobile-content underline cgray pl-3">
              {{ testSuite.name }}
              <gl-icon
                v-if="testSuite.suite_error"
                ref="suiteErrorIcon"
                v-gl-tooltip
                name="error"
                :title="testSuite.suite_error"
                class="vertical-align-middle"
              />
            </div>
          </div>

          <div class="table-section section-25">
            <div role="rowheader" class="table-mobile-header font-weight-bold">
              {{ __('Duration') }}
            </div>
            <div class="table-mobile-content text-md-left">
              {{ testSuite.formattedTime }}
            </div>
          </div>

          <div class="table-section section-10 text-center">
            <div role="rowheader" class="table-mobile-header font-weight-bold">
              {{ __('Failed') }}
            </div>
            <div class="table-mobile-content">{{ testSuite.failed_count }}</div>
          </div>

          <div class="table-section section-10 text-center">
            <div role="rowheader" class="table-mobile-header font-weight-bold">
              {{ __('Errors') }}
            </div>
            <div class="table-mobile-content">{{ testSuite.error_count }}</div>
          </div>

          <div class="table-section section-10 text-center">
            <div role="rowheader" class="table-mobile-header font-weight-bold">
              {{ __('Skipped') }}
            </div>
            <div class="table-mobile-content">{{ testSuite.skipped_count }}</div>
          </div>

          <div class="table-section section-10 text-center">
            <div role="rowheader" class="table-mobile-header font-weight-bold">
              {{ __('Passed') }}
            </div>
            <div class="table-mobile-content">{{ testSuite.success_count }}</div>
          </div>

          <div class="table-section section-10 text-right pr-md-3">
            <div role="rowheader" class="table-mobile-header font-weight-bold">
              {{ __('Total') }}
            </div>
            <div class="table-mobile-content">{{ testSuite.total_count }}</div>
          </div>
        </div>
      </smart-virtual-list>
    </div>

    <div v-else>
      <p class="js-no-tests-suites">{{ s__('TestReports|There are no test suites to show.') }}</p>
    </div>
  </div>
</template>