diff --git a/TestResultSummaryService/DataManager.js b/TestResultSummaryService/DataManager.js index 39146ed6..c044236d 100644 --- a/TestResultSummaryService/DataManager.js +++ b/TestResultSummaryService/DataManager.js @@ -22,16 +22,22 @@ class DataManager { } async parseOutput(buildName, output) { - let parserType = this.findParserType(buildName, output); - let parser; - if (parserType) { - parser = new Parsers[parserType](buildName); - } else { - parser = new DefaultParser(); - parserType = 'Default'; + const parserTypes = await Promise.all( + Object.keys(Parsers).map(async (type) => { + if (Parsers[type].canParse(buildName, output)) { + const parser = new Parsers[type](buildName); + return await parser.parse(output); + } + }) + ); + let results = parserTypes.filter((element) => { + return element !== undefined; + }); + if (results.length === 0) { + const parser = new DefaultParser(); + results = await parser.parse(output); } - const obj = await parser.parse(output); - return { parserType, ...obj }; + return Object.assign.apply({}, results); } async updateOutput(data) { @@ -169,7 +175,8 @@ class DataManager { update.buildOutputId = outputId; } update.hasChildren = true; - } else if (tests && tests.length > 0) { + } + if (tests && tests.length > 0) { const testsObj = await Promise.all( tests.map(async ({ testOutput, ...test }) => { let testOutputId = null; @@ -199,7 +206,8 @@ class DataManager { ); update.tests = testsObj; update.hasChildren = false; - } else if (build === null) { + } + if (build === null) { const buildOutputId = await this.updateOutput({ id: null, output }); update.buildOutputId = buildOutputId; update.hasChildren = false; diff --git a/test-result-summary-client/src/Build/AllTestsInfo.jsx b/test-result-summary-client/src/Build/AllTestsInfo.jsx index 70ca0dba..8c2887d8 100644 --- a/test-result-summary-client/src/Build/AllTestsInfo.jsx +++ b/test-result-summary-client/src/Build/AllTestsInfo.jsx @@ -22,7 +22,7 @@ export default class Build extends Component { const { buildId, limit, hasChildren } = getParams( this.props.location.search ); - const hasChildrenBool = hasChildren === 'true'; + let hasChildrenBool = hasChildren === 'true'; let limitParam = ''; if (limit) { limitParam = `&limit=${limit}`; @@ -37,15 +37,20 @@ export default class Build extends Component { let errorMsg = ''; // if it is a parallel build. + if (!hasChildrenBool) { + const buildData = await fetchData(`/api/getData?_id=${buildId} `); + if (buildData && buildData[0].tests !== undefined) { + hasChildrenBool = true; + } + buildIds.push(buildId); + } if (hasChildrenBool) { const childrenBuilds = await fetchData( `/api/getChildBuilds?parentId=${buildId}` ); - buildIds = childrenBuilds.map( - (childrenBuilds) => childrenBuilds._id + buildIds.push( + ...childrenBuilds.map((childrenBuilds) => childrenBuilds._id) ); - } else { - buildIds.push(buildId); } await Promise.all( diff --git a/test-result-summary-client/src/Build/Summary/ResultSummary.jsx b/test-result-summary-client/src/Build/Summary/ResultSummary.jsx index 61bea904..0c4a2aab 100644 --- a/test-result-summary-client/src/Build/Summary/ResultSummary.jsx +++ b/test-result-summary-client/src/Build/Summary/ResultSummary.jsx @@ -163,6 +163,7 @@ export default class ResultSummary extends Component { childBuildsResult = setBuildsStatus(build, childBuildsResult); }); + builds.sort((a, b) => a.buildName.localeCompare(b.buildName)); builds.forEach((build) => { const buildName = build.buildName.toLowerCase(); if (getInfoFromBuildName(buildName)) {