summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/components/test_reports/test_suite_table.vue
blob: d57b1466177bea2755a11b3ef68d5a8b120e86f0 (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
<script>
import { mapGetters } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue';
import { __ } from '~/locale';
import { GlTooltipDirective } from '@gitlab/ui';
import SmartVirtualList from '~/vue_shared/components/smart_virtual_list.vue';

export default {
  name: 'TestsSuiteTable',
  components: {
    Icon,
    SmartVirtualList,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    heading: {
      type: String,
      required: false,
      default: __('Tests'),
    },
  },
  computed: {
    ...mapGetters(['getSuiteTests']),
    hasSuites() {
      return this.getSuiteTests.length > 0;
    },
  },
  maxShownRows: 30,
  typicalRowHeight: 75,
};
</script>

<template>
  <div>
    <div class="row gl-mt-3">
      <div class="col-12">
        <h4>{{ heading }}</h4>
      </div>
    </div>

    <div v-if="hasSuites" class="test-reports-table gl-mb-3 js-test-cases-table">
      <div role="row" class="gl-responsive-table-row table-row-header font-weight-bold fgray">
        <div role="rowheader" class="table-section section-20">
          {{ __('Suite') }}
        </div>
        <div role="rowheader" class="table-section section-20">
          {{ __('Name') }}
        </div>
        <div role="rowheader" class="table-section section-10 text-center">
          {{ __('Status') }}
        </div>
        <div role="rowheader" class="table-section flex-grow-1">
          {{ __('Trace'), }}
        </div>
        <div role="rowheader" class="table-section section-10 text-right">
          {{ __('Duration') }}
        </div>
      </div>

      <smart-virtual-list
        :length="getSuiteTests.length"
        :remain="$options.maxShownRows"
        :size="$options.typicalRowHeight"
      >
        <div
          v-for="(testCase, index) in getSuiteTests"
          :key="index"
          class="gl-responsive-table-row rounded align-items-md-start mt-xs-3 js-case-row"
        >
          <div class="table-section section-20 section-wrap">
            <div role="rowheader" class="table-mobile-header">{{ __('Suite') }}</div>
            <div
              v-gl-tooltip
              :title="testCase.classname"
              class="table-mobile-content pr-md-1 text-truncate"
            >
              {{ testCase.classname }}
            </div>
          </div>

          <div class="table-section section-20 section-wrap">
            <div role="rowheader" class="table-mobile-header">{{ __('Name') }}</div>
            <div
              v-gl-tooltip
              :title="testCase.name"
              class="table-mobile-content pr-md-1 text-truncate"
            >
              {{ testCase.name }}
            </div>
          </div>

          <div class="table-section section-10 section-wrap">
            <div role="rowheader" class="table-mobile-header">{{ __('Status') }}</div>
            <div class="table-mobile-content text-center">
              <div
                class="add-border ci-status-icon d-flex align-items-center justify-content-end justify-content-md-center"
                :class="`ci-status-icon-${testCase.status}`"
              >
                <icon :size="24" :name="testCase.icon" />
              </div>
            </div>
          </div>

          <div class="table-section flex-grow-1">
            <div role="rowheader" class="table-mobile-header">{{ __('Trace'), }}</div>
            <div class="table-mobile-content">
              <pre
                v-if="testCase.system_output"
                class="build-trace build-trace-rounded text-left"
              ><code class="bash p-0">{{testCase.system_output}}</code></pre>
            </div>
          </div>

          <div class="table-section section-10 section-wrap">
            <div role="rowheader" class="table-mobile-header">
              {{ __('Duration') }}
            </div>
            <div class="table-mobile-content text-right pr-sm-1">
              {{ testCase.formattedTime }}
            </div>
          </div>
        </div>
      </smart-virtual-list>
    </div>

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