Skip to content

Commit

Permalink
Second round of review edits
Browse files Browse the repository at this point in the history
  • Loading branch information
surchs committed Oct 24, 2023
1 parent cd4f8f1 commit 76356fb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 109 deletions.
6 changes: 3 additions & 3 deletions components/annot-tool-groups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
:title="label">
<annot-single-tool
:name="identifier"
:uniqueColumnValues="provideUniqueValues(identifier)"
@declareMissing="changeMissingStatus(Object.assign($event, {markAsMissing: true}))" />
:columns="getColumnsForTool(identifier)"
@declareMissing="changeMissingStatus(Object.assign({}, $event, {markAsMissing: true}))" />
</b-tab>

</b-tabs>
Expand All @@ -26,7 +26,7 @@

<script>
import { mapGetters, mapMutations } from "vuex";
// @declareMissing="changeMissingStatus(Object.assign($event, {markAsMissing: true}))" />
export default {
computed: {
...mapGetters([
Expand Down
157 changes: 55 additions & 102 deletions cypress/component/category-toolgroup.cy.js
Original file line number Diff line number Diff line change
@@ -1,112 +1,75 @@
import categoryToolGroup from "~/components/category-toolgroup.vue";
import { getters } from "~/store";

let store;
let state;

// TODO see if we can replace this by manipulating state and passing by reference
const makeGetters =(state) => {
return {
getColumnsForCategory: getters.getColumnsForCategory(state),
getSelectedTools: getters.getSelectedTools(state)
};
};
let getters;

describe("Tool Group component", () => {

beforeEach(() => {
state = {

columnToCategoryMap: {
column1: "Assessment Tool",
column2: "Age",
column3: "Assessment Tool"
},

columnToToolMap: {
column1: 'cogatlas:MOCA',
column2: null,
column3: 'cogatlas:UPDRSIII'
},

dataDictionary: {

annotated: {

column1: { missingValues: [] },
column2: { missingValues: [] },
column3: { missingValues: ["column3_value1", "column3_value2"] }
}
},

dataTable: [

{ column1: 1, column2: "column2_value1", column3: "column3_value1" },
{ column1: 2, column2: "column2_value2", column3: "column3_value2" },
{ column1: 1, column2: "column2_value3", column3: "column3_value3" },
{ column1: 3, column2: "column2_value2", column3: "column3_value4" }
],

toolTerms: [
{label: 'MOCA', identifier: 'cogatlas:MOCA', selected: false},
{label: 'UPDRSIII', identifier: 'cogatlas:UPDRSIII', selected: false},
{label: 'SomeOtherThing', identifier: 'cogatlas:SomeOtherThing', selected: false},
{label: 'AnotherThing', identifier: 'cogatlas:AnotherThing', selected: false}
]
};
getters = {
getColumnsForCategory: () => (p_category) => {
return ["column1", "column3"];
},
getSelectedTools: () => {
return [
{label: 'MOCA', identifier: 'cogatlas:MOCA', selected: true},
{label: 'UPDRSIII', identifier: 'cogatlas:UPDRSIII', selected: true}
];
}
};
store = {

commit: () => {},
state: state,
getters: makeGetters(state)
getters: getters
};
});

it("if nothing is selected or mapped, component is empty", () => {
store.state.columnToCategoryMap = {
column1: null,
column2: null,
column3: null
};
store.state.columnToToolMap = {
column1: null,
column2: null,
column3: null
};
cy.mount(categoryToolGroup, {
mocks: {
$store: store
mocks: { $store: store },
computed: {
getColumnsForCategory: () => (p_category) => {
return [];
},
getSelectedTools: () => {
return [];
}
}
});

cy.get("[data-cy='toolgroup-select']").should('not.exist');
cy.get("[data-cy='assessment-tool-table']").should('not.exist');
cy.get("[data-cy='assessment-column-table']").should('not.exist');

});

it("has a table of columns about assessment tools on the right", () => {

cy.mount(categoryToolGroup, {
mocks: {

$store: store
}
});

cy.get("[data-cy='assessment-column-table']").should("be.visible");

});

it("gets columns about assessment tools from the store and shows them to me", () => {

cy.mount(categoryToolGroup, {
mocks: {

$store: store
}

mocks: { $store: store },
computed: Object.assign(store.getters, {getSelectedTools: () => {
return [];
}})
});

cy.get("[data-cy='assessment-column-table']").should("be.visible");
cy.get("[data-cy='assessment-column-table']").contains("column1");
cy.get("[data-cy='assessment-column-table']").contains("column3");
});
Expand All @@ -119,10 +82,10 @@ describe("Tool Group component", () => {
};

cy.mount(categoryToolGroup, {
mocks: {

$store: store
}
mocks: { $store: store },
computed: Object.assign(store.getters, {getSelectedTools: () => {
return [];
}})
});

cy.get("[data-cy='assessment-column-table']").find("tr:contains('column1')").should('not.have.class', 'selected-tool');
Expand All @@ -132,10 +95,8 @@ describe("Tool Group component", () => {

it("gets assessment tool names from the store and shows them in a dropdown", () => {
cy.mount(categoryToolGroup, {
mocks: {

$store: store
}
mocks: { $store: store },
computed: store.getters
});

cy.get("[data-cy='toolgroup-select']").should("be.visible");
Expand All @@ -146,9 +107,10 @@ describe("Tool Group component", () => {
it("selecting a tool group fires a createTool mutation", () => {
cy.spy(store, "commit").as("commitSpy");
cy.mount(categoryToolGroup, {
mocks: {
$store: store
}
mocks: { $store: store },
computed: Object.assign(store.getters, {getSelectedTools: () => {
return [];
}})
});

cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}");
Expand All @@ -158,9 +120,10 @@ describe("Tool Group component", () => {

it("clearing the dropdown selection does not crash the app", () => {
cy.mount(categoryToolGroup, {
mocks: {
$store: store
}
mocks: { $store: store },
computed: Object.assign(store.getters, {getSelectedTools: () => {
return [];
}})
});

cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}");
Expand All @@ -170,11 +133,10 @@ describe("Tool Group component", () => {

it("when a tool is selected in the store, it appears in the tool table", () => {
store.state.toolTerms[0]['selected'] = true;
store.getters = makeGetters(store.state);

cy.mount(categoryToolGroup, {
mocks: {
$store: store
}
mocks: { $store: store },
computed: store.getters
});

cy.get("[data-cy='assessment-tool-table']").contains('MOCA');
Expand All @@ -183,11 +145,10 @@ describe("Tool Group component", () => {
it("tools in the tool-table start unselected and become styled when clicked", () => {
store.state.toolTerms[0]['selected'] = true;
store.state.toolTerms[2]['selected'] = true;
store.getters = makeGetters(store.state);

cy.mount(categoryToolGroup, {
mocks: {
$store: store
}
mocks: { $store: store },
computed: store.getters
});

cy.get("[data-cy='assessment-tool-table']").find("tr:contains('MOCA')")
Expand All @@ -201,14 +162,12 @@ describe("Tool Group component", () => {

it("if a tool is already created, trying to create it again has no effect", () => {
store.state.toolTerms[0]['selected'] = true;
store.getters = makeGetters(store.state);

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

cy.mount(categoryToolGroup, {
mocks: {
$store: store
}
mocks: { $store: store },
computed: store.getters
});
cy.get("[data-cy='assessment-tool-table']").contains("MOCA").click();
cy.get("@commitSpy").should("not.have.been.called");
Expand All @@ -217,12 +176,10 @@ describe("Tool Group component", () => {

it("when I click on a tool the tool gets highlighted", () => {
store.state.toolTerms[0]['selected'] = true;
store.getters = makeGetters(store.state);

cy.mount(categoryToolGroup, {
mocks: {
$store: store
}
mocks: { $store: store },
computed: store.getters
});

cy.get("[data-cy='assessment-tool-table']").find("tr:contains('MOCA')")
Expand All @@ -236,14 +193,12 @@ describe("Tool Group component", () => {

it("clicking on column with tool fires mapping mutation every time", () => {
store.state.toolTerms[0]['selected'] = true;
store.getters = makeGetters(store.state);

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

cy.mount(categoryToolGroup, {
mocks: {
$store: store
}
mocks: { $store: store },
computed: store.getters
});

cy.get("[data-cy='assessment-tool-table']").contains('MOCA').click();
Expand All @@ -260,12 +215,10 @@ describe("Tool Group component", () => {
store.state.toolTerms[0]['selected'] = true;
// UPDRS
store.state.toolTerms[1]['selected'] = true;
store.getters = makeGetters(store.state);

cy.mount(categoryToolGroup, {
mocks: {
$store: store
}
mocks: { $store: store },
computed: store.getters
});
// Starting out with a different tool selected
cy.get("[data-cy='assessment-tool-table']").find("tr:contains('MOCA')").click();
Expand Down
4 changes: 0 additions & 4 deletions cypress/unit/store-getter-getUniqueValues.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ describe("getUniqueValues getter", () => {

store = {
getters: {
// getColumnsForCategory: () => (p_category) => {
// return ["column1", "column2", "column3"];
// },
getColumnsForCategory: getters.getColumnsForCategory(state),

getUniqueColumnValues: getters.getUniqueColumnValues(state)
},

Expand Down

0 comments on commit 76356fb

Please sign in to comment.