diff --git a/components/annot-tool-groups.vue b/components/annot-tool-groups.vue index 483ea012..5c9ba4d6 100644 --- a/components/annot-tool-groups.vue +++ b/components/annot-tool-groups.vue @@ -12,7 +12,7 @@ :title="label"> diff --git a/cypress/e2e/app/simple-e2etest.cy.js b/cypress/e2e/app/simple-e2etest.cy.js index e94f7c9f..75a23fb0 100644 --- a/cypress/e2e/app/simple-e2etest.cy.js +++ b/cypress/e2e/app/simple-e2etest.cy.js @@ -34,7 +34,8 @@ describe("End to end test using a simple UI path through the app", () => { ["Subject ID", 1], ["Age", 1], - ["Diagnosis", 1] + ["Diagnosis", 1], + ["Assessment Tool", 1] ] }; @@ -79,6 +80,12 @@ describe("End to end test using a simple UI path through the app", () => { // D. Categorize "age" as "Age" and "group" as "Diagnosis" cy.categorizeColumn("Age", p_dataset["category_columns"]["Age"][0]); cy.categorizeColumn("Diagnosis", p_dataset["category_columns"]["Diagnosis"][0]); + cy.categorizeColumn("Assessment Tool", p_dataset["category_columns"]["Assessment Tool"][0]); + + cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); + cy.get("[data-cy='assessment-tool-table']").contains("MOCA").click(); + cy.get("[data-cy='assessment-column-table']").contains("iq").click(); + // Since Age and subject ID have been categorized // annotation page is no accessible. @@ -116,8 +123,6 @@ describe("End to end test using a simple UI path through the app", () => { cy.get("[data-cy='isControlButton_1']").type("Acute{enter}"); cy.get("[data-cy='categoricalSelector_2']").type("Hearing{enter}"); - - // D. Assert that next page nav and button are enabled for download page cy.assertNextPageAccess("download", true); @@ -138,6 +143,10 @@ describe("End to end test using a simple UI path through the app", () => { cy.readFile('cypress/downloads/' + folderStateAfter[folderStateAfter.length - 1]).then((fileContent) => { expect(fileContent.group.Annotations.Levels.HC.Label).to.eq("Healthy Control"); expect(fileContent.group.Annotations.Levels.HC.TermURL).to.eq("ncit:C94342"); + expect(fileContent.iq.Annotations.IsAbout.Label).to.eq("Assessment tool"); + expect(fileContent.iq.Annotations.IsAbout.TermURL).to.eq("nb:Assessment"); + expect(fileContent.iq.Annotations.IsPartOf.Label).to.eq("MOCA"); + expect(fileContent.iq.Annotations.IsPartOf.TermURL).to.eq("cogAtlas:MOCA"); }); }); diff --git a/cypress/unit/store-getter-getAssessmentToolJSONOutput.cy.js b/cypress/unit/store-getter-getAssessmentToolJSONOutput.cy.js new file mode 100644 index 00000000..f08d9017 --- /dev/null +++ b/cypress/unit/store-getter-getAssessmentToolJSONOutput.cy.js @@ -0,0 +1,51 @@ +import { getters } from "~/store"; + +let store = { + + getters: getters, + + state: { + dataDictionary: { + annotated: { + column1: { + Description: "Some cool description here.", + missingValues: ["Missing"] + } + } + }, + toolTerms: [ + { + label: "MOCA", + identifier: "cogAtlas:MOCA", + selected: false + } + ], + columnToToolMap: { + column1: "cogAtlas:MOCA" + } + + } +}; + +describe("getAssessmentToolJSONOutput", () => { + + it("Make sure Assessment tool json output is schema compliant", () => { + + const output = store.getters.getAssessmentToolJSONOutput(store.state)("column1"); + expect(output).to.deep.equal( + { + Annotations: { + IsAbout: { + "TermURL": "nb:Assessment", + "Label": "Assessment tool" + }, + "IsPartOf": { + "TermURL": "cogAtlas:MOCA", + "Label": "MOCA" + }, + MissingValues: ["Missing"] + }, + Description: "Some cool description here." + }); + }); +}); \ No newline at end of file diff --git a/store/index.js b/store/index.js index 10e0e463..ae72b0c6 100644 --- a/store/index.js +++ b/store/index.js @@ -216,6 +216,44 @@ export const getters = { return p_state.categories[p_category].componentName; }, + getAssessmentToolJSONOutput: (p_state) => (p_columnName) => { + const annotatedDictColumn = p_state.dataDictionary.annotated[p_columnName]; + const formattedOutput = { + Annotations: { + IsAbout: { + TermURL: "nb:Assessment", + Label: "Assessment tool" + }, + IsPartOf: { + TermURL: "", + Label: "" + }, + MissingValues: [] + } + }; + const tool = p_state.columnToToolMap[p_columnName]; + + p_state.toolTerms.forEach(term => { + if ( term.identifier === tool ) { + formattedOutput.Annotations.IsPartOf.Label = term.label; + formattedOutput.Annotations.IsPartOf.TermURL = term.identifier; + } + }); + + // Add existing keys from user provided dictionary + Object.keys(annotatedDictColumn).forEach(columnEntry => { + + if ( "missingValues" !== columnEntry && "valueMap" !== columnEntry ) { + + formattedOutput[columnEntry] = annotatedDictColumn[columnEntry]; + } + }); + + formattedOutput.Annotations.MissingValues = annotatedDictColumn.missingValues; + + return formattedOutput; + }, + getCategoricalJsonOutput: (p_state) => (p_columnName) => { // 0. Initialize output object @@ -456,6 +494,11 @@ export const getters = { Identifies: "participant" } }; + break; + + case "annot-tool-groups": + columnOutput = p_getters.getAssessmentToolJSONOutput(columnName); + break; } }