Skip to content

Commit

Permalink
Get page to render for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
howard-e committed Dec 7, 2023
1 parent 4fa86d0 commit 907a4f3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 16 deletions.
4 changes: 2 additions & 2 deletions client/components/TestReview/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ const TestReview = () => {
const isFirst = index === 0;

const atMode =
test.atMode.substring(0, 1) +
test.atMode.toLowerCase().substring(1);
test.atMode?.substring(0, 1) +
test.atMode?.toLowerCase().substring(1);

const specifications =
test.renderableContents[0].renderableContent.info.references.map(
Expand Down
54 changes: 40 additions & 14 deletions server/resolvers/Test/renderableContentsResolver.js
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;
19 changes: 19 additions & 0 deletions server/resolvers/Test/renderedUrlsResolver.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
const populateData = require('../../services/PopulatedData/populateData');

const renderedUrls = async (test, _, context) => {
const ats = await context.atLoader.getAll();

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]),
renderedUrl: test.renderedUrl // { renderedUrl: '/url/file/path.html' }
}
];
}

// v1: { renderedUrls: { 1: '/url/file/path.html' } }
return Object.entries(test.renderedUrls).map(([atId, renderedUrl]) => {
const at = ats.find(at => at.id == atId);
return { at, renderedUrl };
Expand Down

0 comments on commit 907a4f3

Please sign in to comment.