summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/stores/test_reports/getters.js
blob: 6c670806cc419c6431cbde48702c950d1ee63588 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { addIconStatus, formattedTime, sortTestCases } from './utils';

export const getTestSuites = state => {
  const { test_suites: testSuites = [] } = state.testReports;

  return testSuites.map(suite => ({
    ...suite,
    formattedTime: formattedTime(suite.total_time),
  }));
};

export const getSelectedSuite = state =>
  state.testReports?.test_suites?.[state.selectedSuiteIndex] || {};

export const getSuiteTests = state => {
  const { test_cases: testCases = [] } = getSelectedSuite(state);
  return testCases.sort(sortTestCases).map(addIconStatus);
};