Skip to content

Commit

Permalink
Merge branch 'master' into repo-sync/workflows/default
Browse files Browse the repository at this point in the history
  • Loading branch information
surchs authored Oct 26, 2023
2 parents 7ca1345 + f3e4964 commit 8613eb0
Show file tree
Hide file tree
Showing 12 changed files with 1,165 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[codespell]
skip = .git,*.pdf,*.svg,package-lock.json
skip = .git,*.pdf,*.svg,package-lock.json,./static/toolTerms.json
#
# ignore-words-list =
2 changes: 1 addition & 1 deletion .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up node env
uses: actions/[email protected]
with:
node-version: 16
node-version: 18

- name: Install dependencies
run: yarn
Expand Down
19 changes: 18 additions & 1 deletion components/annot-categorical.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
{{ uiText.missingValueButton }}
</b-button>
</template>
<template #cell(isControl)="row" v-if="activeCategory === 'Diagnosis'">
<b-button
:data-cy="'isControlButton_' + row.index"
variant="info"
@click="selectOptionAndUpdate('ncit:C94342', row.item['columnName'], row.item['rawValue'])">
{{ uiText.isControlButton }}
</b-button>
</template>

</b-table>

Expand Down Expand Up @@ -85,7 +93,8 @@
instructions: "Annotate each unique value",
missingValueButton: "Mark as missing",
saveButton: "Save Annotation"
saveButton: "Save Annotation",
isControlButton: "Mark as healthy control"
}
};
Expand Down Expand Up @@ -125,6 +134,14 @@
}
},
mounted() {
if (this.activeCategory == 'Diagnosis') {
this.exampleFields.push("isControl");
}
},
methods: {
...mapMutations([
Expand Down
2 changes: 1 addition & 1 deletion components/annot-tool-groups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:title="label">
<annot-single-tool
:name="identifier"
:uniqueColumnValues="provideUniqueValues(identifier)"
:unique-column-values="provideUniqueValues(identifier)"
@declareMissing="changeMissingStatus(Object.assign($event, {markAsMissing: true}))" />
</b-tab>

Expand Down
52 changes: 47 additions & 5 deletions cypress/component/annot-categorical.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import annotCategorical from "~/components/annot-categorical.vue";


let store;

const props = {

activeCategory: "category1"
};
let props;


describe("Categorical annotation", () => {

beforeEach(() => {
props = {

activeCategory: "category1"
};

store = {

Expand Down Expand Up @@ -175,4 +175,46 @@ describe("Categorical annotation", () => {
propsData: props
});
});

it("Does not display the is healthy control button when the active category is not 'Diagnosis' ", () => {
cy.mount(annotCategorical, {
computed: store.getters,
mocks: {$store: store},
propsData: props
});
cy.get("[data-cy='isControlButton_0']").should("not.exist");
cy.get("[data-cy='categoricalTable']").should("not.contain", "Is Control");

});

it("Can find the is healthy control button", () => {
props.activeCategory = "Diagnosis";
cy.mount(annotCategorical, {
computed: store.getters,
mocks: {$store: store},
propsData: props
});
cy.get("[data-cy='isControlButton_0']").should("be.visible");
});

it("Fires the selectCategorialOption mutation with the correct payload if the is healthy control button is clicked", () => {

// Setup
props.activeCategory = "Diagnosis";

cy.spy(store, "commit").as("spy");

cy.mount(annotCategorical, {
computed: store.getters,
mocks: {$store: store},
propsData: props
});
cy.get("[data-cy='isControlButton_1']").click();
cy.get("@spy").should("have.been.calledWith", "selectCategoricalOption", {
optionValue: "ncit:C94342",
columnName: "column1",
rawValue: "HC"
});
});

});
36 changes: 34 additions & 2 deletions cypress/e2e/app/simple-e2etest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ describe("End to end test using a simple UI path through the app", () => {
categories: [

["Subject ID", 1],
["Age", 1]
["Age", 1],
["Diagnosis", 1],
["Assessment Tool", 1]
]
};

Expand Down Expand Up @@ -75,8 +77,15 @@ describe("End to end test using a simple UI path through the app", () => {
// at least one other column must be categorized.
cy.assertNextPageAccess("annotation", false);

// D. Categorize "age" as "Age"
// 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("Wechsler Abbreviated Scale of Intelligence{enter}");
cy.get("[data-cy='assessment-tool-table']").contains("Wechsler Abbreviated Scale of Intelligence").click();
cy.get("[data-cy='assessment-column-table']").contains("iq").click();


// Since Age and subject ID have been categorized
// annotation page is no accessible.
Expand Down Expand Up @@ -104,6 +113,16 @@ describe("End to end test using a simple UI path through the app", () => {
cy.get("[data-cy='selectTransform_age']").click();
cy.get("[data-cy='selectTransform_age']").type("float{enter}");


// B. Click on the 'Diagnosis' tab
cy.get("[data-cy='annotation-category-tabs'] ul")
.contains("li", "Diagnosis")
.click();

cy.get("[data-cy='categoricalSelector_0']").type("Acute{enter}");
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);

Expand All @@ -118,6 +137,19 @@ describe("End to end test using a simple UI path through the app", () => {

// B. Assert that csv file has downloaded
// cy.verifyDownload(".json", { contains: true });

// C. Check the contents of the output
cy.task("downloads", "cypress/downloads").then(folderStateAfter => {
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("Wechsler Abbreviated Scale of Intelligence");
expect(fileContent.iq.Annotations.IsPartOf.TermURL).to.eq("cogAtlas:trm_4b94affc43245");
});
});

}
}
});
Expand Down
5 changes: 5 additions & 0 deletions cypress/e2e/page/download-pagetests.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ describe("tests on download page ui via programmatic state loading and store int

expect(folderStateAfter[folderStateAfter.length - 1]).to.contain(dataDictionaryFilenameNoExt);
});
// C. Check if the last file retrieved contains the Identifies property and its value under the participant_id key
cy.readFile('cypress/downloads/' + folderStateAfter[folderStateAfter.length - 1]).then((fileContent) => {
expect(fileContent.participant_id.Annotations).to.have.property("Identifies");
expect(fileContent.participant_id.Annotations.Identifies).to.eq("participant");
});
});
});
});
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/page/my_happy_annotation-page_tests.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ describe("to annotate an assessment ", () => {
cy.get("[data-cy='column-linking-table']").contains(desiredColumnMapping.column).click();
});
// Create two tools
cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}");
cy.get("[data-cy='toolgroup-select']").type("UPDRS{enter}");
cy.get("[data-cy='toolgroup-select']").type("Wechsler Abbreviated Scale of Intelligence{enter}");
cy.get("[data-cy='toolgroup-select']").type("Unified Parkinson's Disease Rating Scale{enter}");
// Map columns to tools
const desiredColumnToolMappings = [
{
"column": "iq",
"tool": "MOCA"
"tool": "Wechsler Abbreviated Scale of Intelligence"
},
{
"column": "stroop",
"tool": "UPDRS"
"tool": "Unified Parkinson's Disease Rating Scale"
}
];
desiredColumnToolMappings.forEach(desiredColumnToolMapping => {
Expand Down
51 changes: 51 additions & 0 deletions cypress/unit/store-getter-getAssessmentToolJSONOutput.cy.js
Original file line number Diff line number Diff line change
@@ -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."
});
});
});
86 changes: 86 additions & 0 deletions static/diagnosisTerms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"label":"Acute depression",
"identifier":"snomed:712823008"
},
{
"label":"Anxiety",
"identifier":"snomed:48694002"
},
{
"label":"Anxiety disorder",
"identifier":"snomed:197480006"
},
{
"label":"Attention deficit hyperactivity disorder",
"identifier":"snomed:406506008"
},
{
"label":"Autism spectrum disorder",
"identifier":"snomed:35919005"
},
{
"label":"Borderline personality disorder",
"identifier":"snomed:20010003"
},
{
"label":"Concussion injury of brain",
"identifier":"snomed:110030002"
},
{
"label":"Disorder of cardiovascular system",
"identifier":"snomed:49601007"
},
{
"label":"Dyslexia",
"identifier":"snomed:59770006"
},
{
"label":"Fibromyalgia",
"identifier":"snomed:203082005"
},
{
"label":"Hearing problem",
"identifier":"snomed:300228004"
},
{
"label":"Mental disorder",
"identifier":"snomed:74732009"
},
{
"label":"Migraine",
"identifier":"snomed:37796009"
},
{
"label":"Schizophrenia",
"identifier":"snomed:58214004"
},
{
"label":"Separation anxiety",
"identifier":"snomed:126943008"
},
{
"label":"Smoker",
"identifier":"snomed:77176002"
},
{
"label":"Social phobia",
"identifier":"snomed:25501002"
},
{
"label":"Specific spelling disorder",
"identifier":"snomed:268738002"
},
{
"label":"Traumatic brain injury",
"identifier":"snomed:127295002"
},
{
"label":"Visual impairment",
"identifier":"snomed:397540003"
},
{
"label":"Healthy Control",
"identifier":"ncit:C94342"
}
]
Loading

0 comments on commit 8613eb0

Please sign in to comment.