Skip to content

Commit

Permalink
Added tests for the healthy control workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanaem committed Oct 26, 2023
1 parent 3dd299a commit 8d4284b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 7 deletions.
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"
});
});

});
27 changes: 25 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,8 @@ describe("End to end test using a simple UI path through the app", () => {
categories: [

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

Expand Down Expand Up @@ -75,8 +76,9 @@ 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]);

// Since Age and subject ID have been categorized
// annotation page is no accessible.
Expand Down Expand Up @@ -104,6 +106,18 @@ 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 +132,15 @@ 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");
});
});

}
}
});
Expand Down

0 comments on commit 8d4284b

Please sign in to comment.