Welcome to mirror list, hosted at ThFree Co, Russian Federation.

utils.js « test_reports « stores « pipelines « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 16fa6935cbeb1c741670749dccc3ee087c97ab34 (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
import { TestStatus } from '~/pipelines/constants';
import { formatTime, secondsToMilliseconds } from '~/lib/utils/datetime_utility';

export function iconForTestStatus(status) {
  switch (status) {
    case 'success':
      return 'status_success_borderless';
    case 'failed':
      return 'status_failed_borderless';
    default:
      return 'status_skipped_borderless';
  }
}

export const formattedTime = timeInSeconds => formatTime(secondsToMilliseconds(timeInSeconds));

export const addIconStatus = testCase => ({
  ...testCase,
  icon: iconForTestStatus(testCase.status),
  formattedTime: formattedTime(testCase.execution_time),
});

export const sortTestCases = (a, b) => {
  if (a.status === b.status) {
    return 0;
  }

  switch (b.status) {
    case TestStatus.SUCCESS:
      return -1;
    case TestStatus.FAILED:
      return 1;
    default:
      return 0;
  }
};