-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,50 @@ | ||
const populateData = require('../../services/PopulatedData/populateData'); | ||
|
||
const renderableContents = async (test, _, context) => { | ||
const ats = await context.atLoader.getAll(); | ||
|
||
// console.log(Object.entries(test.renderableContent)) | ||
// console.log(test.atIds) | ||
const { testPlanVersion } = await populateData( | ||
{ testId: test.id }, | ||
{ context } | ||
); | ||
|
||
const isV2 = testPlanVersion.metadata.testFormatVersion === 2; | ||
if (isV2) { | ||
// TODO: This is only accounting for 1 test however so this needs to be fixed | ||
return [ | ||
{ | ||
at: ats.find(at => at.id === test.atIds[0]), | ||
renderableContent: test.renderableContent // { renderableContent: { info, ... } } | ||
} | ||
]; | ||
} | ||
|
||
// v1: { renderableContent: { 1: { info, ... }, 2: { ... }, ... } } | ||
return Object.entries(test.renderableContent).map( | ||
([atIds, renderableContent]) => { | ||
// console.log(renderableContent); | ||
// console.log(atIds); | ||
|
||
// if (renderableContent.info) { | ||
// console.log('INFO'); | ||
// const at = ats.find(at => at.id == atId); | ||
// return { at, renderableContent }; | ||
// } | ||
// const at = ats.find(at => at.id == atIds); | ||
const at = ats.find(at => at.id == test.atIds); | ||
console.log(at); | ||
([atId, renderableContent]) => { | ||
const at = ats.find(at => at.id == atId); | ||
return { at, renderableContent }; | ||
} | ||
); | ||
|
||
// console.log(Object.entries(test.renderableContent)) | ||
// console.log(test.atIds) | ||
// return Object.entries(test.renderableContent).map( | ||
// ([atIds, renderableContent]) => { | ||
// // console.log(renderableContent); | ||
// // console.log(atIds); | ||
// | ||
// // if (renderableContent.info) { | ||
// // console.log('INFO'); | ||
// // const at = ats.find(at => at.id == atId); | ||
// // return { at, renderableContent }; | ||
// // } | ||
// // const at = ats.find(at => at.id == atIds); | ||
// const at = ats.find(at => at.id == test.atIds); | ||
// console.log(at); | ||
// return { at, renderableContent }; | ||
// } | ||
// ); | ||
}; | ||
|
||
module.exports = renderableContents; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters