Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update CDE cases #484

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
330 changes: 41 additions & 289 deletions src/utils/dataModelUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,22 +265,6 @@ describe("updateEnums", () => {

const dataList = {
program: {
$schema: "http://json-schema.org/draft-06/schema#",
id: "program",
title: "program",
category: "study",
program: "*",
project: "*",
additionalProperties: false,
submittable: true,
constraints: null,
type: "object",
assignment: "core",
class: "primary",
desc: "Program in the Cancer Data Service refer to a broad framework of goals under which related projects or other research activities are grouped. Example - Clinical Proteomic Tumor Analysis Consortium (CPTAC)",
description:
"Program in the Cancer Data Service refer to a broad framework of goals under which related projects or other research activities are grouped. Example - Clinical Proteomic Tumor Analysis Consortium (CPTAC)",
template: "Yes",
properties: {
program_name: {
category: "program",
Expand All @@ -291,133 +275,9 @@ describe("updateEnums", () => {
isIncludedInTemplate: true,
propertyType: "required",
display: "no",
enum: ["enum one", "enum two"],
},
program_acronym: {
category: "program",
description:
"The name of the program under which related studies will be grouped, expressed in the form of the acronym by which it will identified within the UI. <br>This property is used as the key via which study records can be associated with the appropriate program during data loading, and to identify the correct records during data updates.",
type: "string",
src: "Internally-curated",
key: true,
isIncludedInTemplate: true,
propertyType: "required",
display: "no",
},
program_short_description: {
category: "program",
description: "An abbreviated, single sentence description of the program.",
type: "string",
src: "Internally-curated",
isIncludedInTemplate: true,
propertyType: "preferred",
display: "no",
},
program_full_description: {
category: "program",
description: "A more detailed, multiple sentence description of the program.",
type: "string",
src: "Internally-curated",
isIncludedInTemplate: true,
propertyType: "preferred",
display: "no",
},
program_external_url: {
category: "program",
description:
"The external url to which users should be directed in order to learn more about the program.",
type: "string",
src: "Internally-curated",
isIncludedInTemplate: true,
propertyType: "preferred",
display: "no",
},
program_sort_order: {
category: "program",
description:
"An arbitrarily-assigned value used to dictate the order in which programs are displayed within the application's UI.",
type: "integer",
src: "Internally-curated",
isIncludedInTemplate: true,
propertyType: "optional",
display: "no",
},
program_short_name: {
category: "program",
description:
"An acronym or abbreviated form of the title of a broad framework of goals under which related projects or other research activities are grouped. Example - CPTAC",
type: "String",
isIncludedInTemplate: true,
propertyType: "optional",
display: "no",
},
institution: {
category: "program",
description: "TBD",
type: "String",
isIncludedInTemplate: true,
propertyType: "preferred",
display: "no",
},
crdc_id: {
category: "program",
description: "The crdc_id is a unique identifier that is generated by Data Hub",
type: "string",
isIncludedInTemplate: false,
propertyType: "optional",
display: "no",
},
},
inclusion: {
required: ["program_name", "program_acronym"],
optional: ["program_sort_order", "program_short_name", "crdc_id"],
preferred: [
"program_short_description",
"program_full_description",
"program_external_url",
"institution",
],
},
uiDisplay: {
no: [
"program_name",
"program_acronym",
"program_short_description",
"program_full_description",
"program_external_url",
"program_sort_order",
"program_short_name",
"institution",
"crdc_id",
],
},
required: ["program_name", "program_acronym"],
preferred: [
"program_short_description",
"program_full_description",
"program_external_url",
"institution",
],
optional: ["program_sort_order", "program_short_name", "crdc_id"],
yes: [],
no: [
"program_name",
"program_acronym",
"program_short_description",
"program_full_description",
"program_external_url",
"program_sort_order",
"program_short_name",
"institution",
"crdc_id",
],
multiplicity: "Many To One",
links: [
{
Dst: "program",
Src: "study",
multiplicity: "many_to_one",
},
],
},
};

Expand All @@ -442,7 +302,7 @@ describe("updateEnums", () => {
]);
});

it("should use fallback message if permissible values are empty", () => {
it("should use fallback message if permissable values are empty", () => {
const response = [
{
...CDEresponse,
Expand All @@ -457,6 +317,19 @@ describe("updateEnums", () => {
]);
});

it("should return the enum from mdf or undefined if none when permissable values is null", () => {
const response = [
{
...CDEresponse,
PermissibleValues: null,
},
];

const result = utils.updateEnums(cdeMap, dataList, response);

expect(result.program.properties["program_name"].enum).toEqual(["enum one", "enum two"]);
});

it("should apply fallback message when response is empty and apiError is true", () => {
const result = utils.updateEnums(cdeMap, dataList, [], true);

Expand All @@ -469,22 +342,6 @@ describe("updateEnums", () => {
describe("traverseAndReplace", () => {
const node = {
program: {
$schema: "http://json-schema.org/draft-06/schema#",
id: "program",
title: "program",
category: "study",
program: "*",
project: "*",
additionalProperties: false,
submittable: true,
constraints: null,
type: "object",
assignment: "core",
class: "primary",
desc: "Program in the Cancer Data Service refer to a broad framework of goals under which related projects or other research activities are grouped. Example - Clinical Proteomic Tumor Analysis Consortium (CPTAC)",
description:
"Program in the Cancer Data Service refer to a broad framework of goals under which related projects or other research activities are grouped. Example - Clinical Proteomic Tumor Analysis Consortium (CPTAC)",
template: "Yes",
properties: {
program_name: {
category: "program",
Expand All @@ -495,139 +352,9 @@ describe("traverseAndReplace", () => {
isIncludedInTemplate: true,
propertyType: "required",
display: "no",
enum: [
"Permissible values are currently not available. Please contact the Data Hub HelpDesk at [email protected]",
],
},
program_acronym: {
category: "program",
description:
"The name of the program under which related studies will be grouped, expressed in the form of the acronym by which it will identified within the UI. <br>This property is used as the key via which study records can be associated with the appropriate program during data loading, and to identify the correct records during data updates.",
type: "string",
src: "Internally-curated",
key: true,
isIncludedInTemplate: true,
propertyType: "required",
display: "no",
},
program_short_description: {
category: "program",
description: "An abbreviated, single sentence description of the program.",
type: "string",
src: "Internally-curated",
isIncludedInTemplate: true,
propertyType: "preferred",
display: "no",
},
program_full_description: {
category: "program",
description: "A more detailed, multiple sentence description of the program.",
type: "string",
src: "Internally-curated",
isIncludedInTemplate: true,
propertyType: "preferred",
display: "no",
},
program_external_url: {
category: "program",
description:
"The external url to which users should be directed in order to learn more about the program.",
type: "string",
src: "Internally-curated",
isIncludedInTemplate: true,
propertyType: "preferred",
display: "no",
},
program_sort_order: {
category: "program",
description:
"An arbitrarily-assigned value used to dictate the order in which programs are displayed within the application's UI.",
type: "integer",
src: "Internally-curated",
isIncludedInTemplate: true,
propertyType: "optional",
display: "no",
},
program_short_name: {
category: "program",
description:
"An acronym or abbreviated form of the title of a broad framework of goals under which related projects or other research activities are grouped. Example - CPTAC",
type: "String",
isIncludedInTemplate: true,
propertyType: "optional",
display: "no",
enum: [
"Permissible values are currently not available. Please contact the Data Hub HelpDesk at [email protected]",
],
},
institution: {
category: "program",
description: "TBD",
type: "String",
isIncludedInTemplate: true,
propertyType: "preferred",
display: "no",
},
crdc_id: {
category: "program",
description: "The crdc_id is a unique identifier that is generated by Data Hub",
type: "string",
isIncludedInTemplate: false,
propertyType: "optional",
display: "no",
enum: ["enum one", "enum two"],
},
},
inclusion: {
required: ["program_name", "program_acronym"],
optional: ["program_sort_order", "program_short_name", "crdc_id"],
preferred: [
"program_short_description",
"program_full_description",
"program_external_url",
"institution",
],
},
uiDisplay: {
no: [
"program_name",
"program_acronym",
"program_short_description",
"program_full_description",
"program_external_url",
"program_sort_order",
"program_short_name",
"institution",
"crdc_id",
],
},
required: ["program_name", "program_acronym"],
preferred: [
"program_short_description",
"program_full_description",
"program_external_url",
"institution",
],
optional: ["program_sort_order", "program_short_name", "crdc_id"],
yes: [],
no: [
"program_name",
"program_acronym",
"program_short_description",
"program_full_description",
"program_external_url",
"program_sort_order",
"program_short_name",
"institution",
"crdc_id",
],
multiplicity: "Many To One",
links: [
{
Dst: "program",
Src: "study",
multiplicity: "many_to_one",
},
],
},
};

Expand Down Expand Up @@ -660,6 +387,31 @@ describe("traverseAndReplace", () => {
]);
});

it("should return the enum from mdf or undefined if there is no enum in the MDF", () => {
const resultMap = new Map();
const mapKeyPrefixes = new Map();
const mapKeyPrefixesNoValues = new Map([
["program.program_name", "program.program_name;11524549.1.00"],
]);
const thisNode = {
program: {
...node.program,
properties: {
...node.program.properties,
program_name: {
...node.program.properties.program_name,
enum: undefined,
},
},
},
};
const apiError = true;

utils.traverseAndReplace(thisNode, resultMap, mapKeyPrefixes, mapKeyPrefixesNoValues, apiError);

expect(thisNode["program"].properties["program_name"].enum).toEqual(undefined);
});

it("should use fallback message when permissible values are empty and apiError is true", () => {
const resultMap = new Map();
const mapKeyPrefixes = new Map();
Expand Down
Loading