debian-mirror-gitlab/app/assets/javascripts/pipelines/stores/test_reports/getters.js

32 lines
995 B
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { addIconStatus, formatFilePath, formattedTime } from './utils';
2019-12-26 22:10:19 +05:30
2021-03-08 18:12:59 +05:30
export const getTestSuites = (state) => {
2019-12-26 22:10:19 +05:30
const { test_suites: testSuites = [] } = state.testReports;
2021-03-08 18:12:59 +05:30
return testSuites.map((suite) => ({
2019-12-26 22:10:19 +05:30
...suite,
formattedTime: formattedTime(suite.total_time),
}));
};
2021-03-08 18:12:59 +05:30
export const getSelectedSuite = (state) =>
2020-07-28 23:09:34 +05:30
state.testReports?.test_suites?.[state.selectedSuiteIndex] || {};
2019-12-26 22:10:19 +05:30
2021-03-08 18:12:59 +05:30
export const getSuiteTests = (state) => {
2020-07-28 23:09:34 +05:30
const { test_cases: testCases = [] } = getSelectedSuite(state);
2021-02-22 17:27:13 +05:30
const { page, perPage } = state.pageInfo;
const start = (page - 1) * perPage;
2021-03-11 19:13:27 +05:30
return testCases
.map((testCase) => ({
...testCase,
classname: testCase.classname || '',
name: testCase.name || '',
filePath: testCase.file ? `${state.blobPath}/${formatFilePath(testCase.file)}` : null,
}))
.map(addIconStatus)
.slice(start, start + perPage);
2019-12-26 22:10:19 +05:30
};
2021-02-22 17:27:13 +05:30
2021-03-08 18:12:59 +05:30
export const getSuiteTestCount = (state) => getSelectedSuite(state)?.test_cases?.length || 0;