From 1df0468af24591023de5d454d257409d087eac8c Mon Sep 17 00:00:00 2001 From: rmanaem Date: Thu, 12 Oct 2023 15:32:00 -0400 Subject: [PATCH 01/45] Added lintfix script to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index d7aca8f3..867edc04 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "start": "nuxt start", "generate": "nuxt generate", "lint": "npx eslint --ext .vue --ext .js .", + "lintfix": "npm run lint -- --fix", "prepare": "husky install", "heroku-postbuild": "npm run build", "cypress:open": "cypress open", From 0a37a10478e8ac7a1f27b29ea7ce0e2bd1a8cfc2 Mon Sep 17 00:00:00 2001 From: rmanaem Date: Thu, 12 Oct 2023 16:15:31 -0400 Subject: [PATCH 02/45] Added assessment column table and test --- components/category-toolgroup.vue | 30 ++++++++ cypress/component/category-toolgroup.cy.js | 82 ++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 components/category-toolgroup.vue create mode 100644 cypress/component/category-toolgroup.cy.js diff --git a/components/category-toolgroup.vue b/components/category-toolgroup.vue new file mode 100644 index 00000000..1301272a --- /dev/null +++ b/components/category-toolgroup.vue @@ -0,0 +1,30 @@ + + + \ No newline at end of file diff --git a/cypress/component/category-toolgroup.cy.js b/cypress/component/category-toolgroup.cy.js new file mode 100644 index 00000000..f1f5556f --- /dev/null +++ b/cypress/component/category-toolgroup.cy.js @@ -0,0 +1,82 @@ +import categoryToolGroup from "~/components/category-toolgroup.vue"; +import { getters } from "~/store"; + +let store; +let state; + +describe("Tool Group component", () => { + + beforeEach(() => { + state = { + + columnToCategoryMap: { + column1: "Assessment Tool", + column2: "Age", + column3: "Assessment Tool" + }, + + 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" } + ] + }; + store = { + + state: state, + getters: { + getColumnsForCategory: getters.getColumnsForCategory(state) + } + }; + }); + + it("mounts", () => { + cy.mount(categoryToolGroup, { + mocks: { + + $store: store + } + }); + + }); + + 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 + } + + }); + + cy.get("[data-cy='assessment-column-table']").contains("column1"); + cy.get("[data-cy='assessment-column-table']").contains("column3"); + }); + +}); From 8fb4cd39119edcb29934181c5378e477fc12015f Mon Sep 17 00:00:00 2001 From: rmanaem Date: Thu, 12 Oct 2023 16:48:32 -0400 Subject: [PATCH 03/45] Added tool group dropdown and assessment tool table updated the component test --- components/category-toolgroup.vue | 51 ++++++++++++++++++---- cypress/component/category-toolgroup.cy.js | 32 ++++++++++++++ 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/components/category-toolgroup.vue b/components/category-toolgroup.vue index 1301272a..297cc6ba 100644 --- a/components/category-toolgroup.vue +++ b/components/category-toolgroup.vue @@ -1,13 +1,33 @@ \ No newline at end of file diff --git a/cypress/component/category-toolgroup.cy.js b/cypress/component/category-toolgroup.cy.js index f1f5556f..33bf645f 100644 --- a/cypress/component/category-toolgroup.cy.js +++ b/cypress/component/category-toolgroup.cy.js @@ -79,4 +79,36 @@ describe("Tool Group component", () => { cy.get("[data-cy='assessment-column-table']").contains("column3"); }); + it("has a dropdown with different assessment tools", () => { + cy.mount(categoryToolGroup, { + mocks: { + + $store: store + } + }); + + cy.get("[data-cy='toolgroup-select']").should("be.visible"); + cy.get("[data-cy='toolgroup-select']").click(); + // For now the tool groups come from inside the component and we know they will include MOCA + cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); + cy.get("[data-cy='toolgroup-select']").should("contain", "MOCA"); + }); + + it("checks tool table functionality", () => { + cy.mount(categoryToolGroup, { + mocks: { + $store: store + } + }); + cy.get("[data-cy='assessment-tool-table']").should("not.exist"); + cy.get("[data-cy='toolgroup-select']").click(); + cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); + cy.get("[data-cy='toolgroup-select']").should("contain", "MOCA"); + cy.get("[data-cy='assessment-tool-table']").should("be.visible"); + cy.get("[data-cy='assessment-tool-table']").contains("MOCA"); + + + }); + + }); From 7e54fcbf1d57b9a24270a5c877a565ce66e4a22a Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Thu, 12 Oct 2023 18:33:03 -0400 Subject: [PATCH 04/45] Prevent duplicate tools from being created --- components/category-toolgroup.vue | 6 ++++- cypress/component/category-toolgroup.cy.js | 31 +++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/components/category-toolgroup.vue b/components/category-toolgroup.vue index 297cc6ba..fc1032a7 100644 --- a/components/category-toolgroup.vue +++ b/components/category-toolgroup.vue @@ -15,7 +15,8 @@ label="Select a tool" :options="toolGroups" outlined - @input="selectTool" /> + @input="selectTool" + :selectable="(option) => !selectedTools.some(el => el.tool.includes(option))" /> { cy.get("[data-cy='toolgroup-select']").should("contain", "MOCA"); }); - it("checks tool table functionality", () => { + it("lets me create new tools and shows them in a table", () => { cy.mount(categoryToolGroup, { mocks: { $store: store @@ -107,8 +107,33 @@ describe("Tool Group component", () => { cy.get("[data-cy='assessment-tool-table']").should("be.visible"); cy.get("[data-cy='assessment-tool-table']").contains("MOCA"); - }); - + it("if I have already made a tool, I cannot make another one ", () => { + cy.mount(categoryToolGroup, { + mocks: { + $store: store + } + }); + // Do it the first time + cy.get("[data-cy='toolgroup-select']").click(); + cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); + cy.get("[data-cy='toolgroup-select']").click(); + cy.get("[data-cy='toolgroup-select']").type("SomeOtherThing{enter}"); + // I hope nobody asks me to explain this + cy.get("[data-cy='assessment-tool-table']") + .find("tr:contains('MOCA')") + .filter((index, element) => Cypress.$(element).text() === "MOCA") + .should("have.length", 1); + + // Do it again + cy.get("[data-cy='toolgroup-select']").click(); + // The reason this is expected to fail is because the dropdown will not permit the + // user to type and enter again. Maybe we should make the assert more explicit + cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); + cy.get("[data-cy='assessment-tool-table']") + .find("tr:contains('MOCA')") + .filter((index, element) => Cypress.$(element).text() === "MOCA") + .should("have.length", 1); + }); }); From 55aafd8ba3e5faa9c76651c803d036787b8625ab Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Fri, 13 Oct 2023 14:41:49 -0400 Subject: [PATCH 05/45] Updated test --- cypress/component/category-toolgroup.cy.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cypress/component/category-toolgroup.cy.js b/cypress/component/category-toolgroup.cy.js index 5b002b29..4231f08a 100644 --- a/cypress/component/category-toolgroup.cy.js +++ b/cypress/component/category-toolgroup.cy.js @@ -136,4 +136,26 @@ describe("Tool Group component", () => { .filter((index, element) => Cypress.$(element).text() === "MOCA") .should("have.length", 1); }); + + it("when I click on a tool the tool gets highlighted", () => { + cy.mount(categoryToolGroup, { + mocks: { + $store: store + } + }); + cy.get("[data-cy='toolgroup-select']").click(); + cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); + // assert that the element has white background + cy.get("[data-cy='assessment-tool-table']").contains("MOCA").should("have.css", "background-color", "rgb(255, 255, 255)"); + cy.get("[data-cy='assessment-tool-table']").contains("MOCA").click(); + cy.get("[data-cy='assessment-tool-table']").contains("MOCA").should("have.css", "background-color", "rgb(255, 0, 0)"); + }); + + it("when I selet a tool and then click on a column, the column gets highlighted", () => { + cy.mount(categoryToolGroup, { + mocks: { + $store: store + } + }); + }); }); From 4a71e4aedce838eabdb91fe71f0989de0d35a698 Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Fri, 13 Oct 2023 16:03:04 -0400 Subject: [PATCH 06/45] Added functionality for highlighting selected tool Co-authored-by: Arman Jahanpour --- components/category-toolgroup.vue | 51 +++++++++++++++------- cypress/component/category-toolgroup.cy.js | 15 ++++--- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/components/category-toolgroup.vue b/components/category-toolgroup.vue index fc1032a7..21829786 100644 --- a/components/category-toolgroup.vue +++ b/components/category-toolgroup.vue @@ -1,13 +1,23 @@ @@ -39,7 +39,8 @@ data() { return { toolGroups: ["MOCA", "UPDRSIII", "SomeOtherThing", "AnotherThing"], - selectedTools: [] + selectedTools: [], + selectedTool: null }; }, @@ -58,10 +59,28 @@ selectTool(selectedTool) { this.selectedTools.push({ tool: selectedTool}); - console.log('selected', selectedTool); - console.log('list', this.selectedTools); + }, + highlightRow(rows) { + if ( 0 !== rows.length ) { + this.selectedTool = rows[0].tool; + } + + }, + + styleTableRow(p_row) { + if (p_row.tool === this.selectedTool) { + return "selected-tool"; + } + return ""; } } }; - \ No newline at end of file + + \ No newline at end of file diff --git a/cypress/component/category-toolgroup.cy.js b/cypress/component/category-toolgroup.cy.js index 4231f08a..971fad08 100644 --- a/cypress/component/category-toolgroup.cy.js +++ b/cypress/component/category-toolgroup.cy.js @@ -145,13 +145,18 @@ describe("Tool Group component", () => { }); cy.get("[data-cy='toolgroup-select']").click(); cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); - // assert that the element has white background - cy.get("[data-cy='assessment-tool-table']").contains("MOCA").should("have.css", "background-color", "rgb(255, 255, 255)"); - cy.get("[data-cy='assessment-tool-table']").contains("MOCA").click(); - cy.get("[data-cy='assessment-tool-table']").contains("MOCA").should("have.css", "background-color", "rgb(255, 0, 0)"); + + // Grab the element background color before beiing + cy.get("[data-cy='assessment-tool-table']").find("tr:contains('MOCA')") + .invoke("css", "background-color").then((InitialBackgroundColor) => { + cy.get("[data-cy='assessment-tool-table']") + .find("tr:contains('MOCA')").click(); + // assert that element has different color after + cy.get("[data-cy='assessment-tool-table']").find("tr:contains('MOCA')").should("not.have.css", "background-color", InitialBackgroundColor); + }); }); - it("when I selet a tool and then click on a column, the column gets highlighted", () => { + it("when I select a tool and then click on a column, the column gets highlighted", () => { cy.mount(categoryToolGroup, { mocks: { $store: store From cb22d7fe38b1794f9077a392639c1640d0157a18 Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Fri, 13 Oct 2023 16:12:16 -0400 Subject: [PATCH 07/45] don't need clicks --- cypress/component/category-toolgroup.cy.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cypress/component/category-toolgroup.cy.js b/cypress/component/category-toolgroup.cy.js index 971fad08..a5fba408 100644 --- a/cypress/component/category-toolgroup.cy.js +++ b/cypress/component/category-toolgroup.cy.js @@ -88,7 +88,6 @@ describe("Tool Group component", () => { }); cy.get("[data-cy='toolgroup-select']").should("be.visible"); - cy.get("[data-cy='toolgroup-select']").click(); // For now the tool groups come from inside the component and we know they will include MOCA cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); cy.get("[data-cy='toolgroup-select']").should("contain", "MOCA"); @@ -101,7 +100,6 @@ describe("Tool Group component", () => { } }); cy.get("[data-cy='assessment-tool-table']").should("not.exist"); - cy.get("[data-cy='toolgroup-select']").click(); cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); cy.get("[data-cy='toolgroup-select']").should("contain", "MOCA"); cy.get("[data-cy='assessment-tool-table']").should("be.visible"); @@ -116,9 +114,7 @@ describe("Tool Group component", () => { } }); // Do it the first time - cy.get("[data-cy='toolgroup-select']").click(); cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); - cy.get("[data-cy='toolgroup-select']").click(); cy.get("[data-cy='toolgroup-select']").type("SomeOtherThing{enter}"); // I hope nobody asks me to explain this cy.get("[data-cy='assessment-tool-table']") @@ -127,7 +123,6 @@ describe("Tool Group component", () => { .should("have.length", 1); // Do it again - cy.get("[data-cy='toolgroup-select']").click(); // The reason this is expected to fail is because the dropdown will not permit the // user to type and enter again. Maybe we should make the assert more explicit cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); @@ -143,7 +138,6 @@ describe("Tool Group component", () => { $store: store } }); - cy.get("[data-cy='toolgroup-select']").click(); cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); // Grab the element background color before beiing @@ -156,11 +150,15 @@ describe("Tool Group component", () => { }); }); - it("when I select a tool and then click on a column, the column gets highlighted", () => { + it("when a tool is selected and I click on a column, the column gets highlighted", () => { cy.mount(categoryToolGroup, { mocks: { $store: store } }); + cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); + // select the first tool + cy.get("[data-cy='assessment-tool-table']").find("tr:contains('MOCA')").click(); + }); }); From 17a736772aa670cac47854dba1c36fc00e421d4a Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Fri, 13 Oct 2023 16:53:59 -0400 Subject: [PATCH 08/45] Added capability to map column to tool also reflected visually --- components/category-toolgroup.vue | 40 +++++++++++++++++----- cypress/component/category-toolgroup.cy.js | 9 ++++- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/components/category-toolgroup.vue b/components/category-toolgroup.vue index 21829786..c4c20b0f 100644 --- a/components/category-toolgroup.vue +++ b/components/category-toolgroup.vue @@ -12,13 +12,6 @@ @row-selected="highlightRow" :tbody-tr-class="styleTableRow" thead-class="hidden" /> - + + + @@ -40,7 +44,13 @@ return { toolGroups: ["MOCA", "UPDRSIII", "SomeOtherThing", "AnotherThing"], selectedTools: [], - selectedTool: null + selectedTool: null, + //Todo: populate keys using columns that are coming from the store + column2ToolMap: { + column1: null, + column2: null, + column3: null + } }; }, @@ -73,6 +83,20 @@ return "selected-tool"; } return ""; + }, + mapColumnToTool(row) { + if (this.column2ToolMap[row.column] === this.selectedTool) { + this.column2ToolMap[row.column] = null; + } else { + this.column2ToolMap[row.column] = this.selectedTool; + } + }, + styleRow(p_row) { + if (this.column2ToolMap[p_row.column] === this.selectedTool) { + return "selected-tool"; + } else { + return ""; + } } } }; diff --git a/cypress/component/category-toolgroup.cy.js b/cypress/component/category-toolgroup.cy.js index a5fba408..114e169e 100644 --- a/cypress/component/category-toolgroup.cy.js +++ b/cypress/component/category-toolgroup.cy.js @@ -159,6 +159,13 @@ describe("Tool Group component", () => { cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}"); // select the first tool cy.get("[data-cy='assessment-tool-table']").find("tr:contains('MOCA')").click(); - + // Then the column gets highlighted + cy.get("[data-cy='assessment-column-table']").find("tr:contains('column1')") + .invoke("css", "background-color").then((InitialBackgroundColor) => { + cy.get("[data-cy='assessment-column-table']") + .find("tr:contains('column1')").click(); + // assert that element has different color after + cy.get("[data-cy='assessment-column-table']").find("tr:contains('column1')").should("not.have.css", "background-color", InitialBackgroundColor); + }); }); }); From bd91e5b3eca111828c78e4f6e5821c7f0ae0c0a4 Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Mon, 16 Oct 2023 09:55:36 -0400 Subject: [PATCH 09/45] Basic layout --- components/category-toolgroup.vue | 70 +++++++++++++++++-------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/components/category-toolgroup.vue b/components/category-toolgroup.vue index c4c20b0f..e45029e5 100644 --- a/components/category-toolgroup.vue +++ b/components/category-toolgroup.vue @@ -1,37 +1,44 @@ @@ -75,7 +82,6 @@ if ( 0 !== rows.length ) { this.selectedTool = rows[0].tool; } - }, styleTableRow(p_row) { From 9c013678e8760fcd932a914efca496ba9632cde3 Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Mon, 16 Oct 2023 11:16:52 -0400 Subject: [PATCH 10/45] First attempt at getting tool list from store --- components/category-toolgroup.vue | 18 ++++++++++-------- cypress/component/category-toolgroup.cy.js | 7 +++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/components/category-toolgroup.vue b/components/category-toolgroup.vue index e45029e5..59dd8b88 100644 --- a/components/category-toolgroup.vue +++ b/components/category-toolgroup.vue @@ -4,11 +4,10 @@ + :selectable="(option) => !selectedTools.some(el => el.tool.includes(option.label))" /> @@ -44,12 +43,11 @@ \ No newline at end of file diff --git a/cypress/component/annot-tool.cy.js b/cypress/component/annot-tool.cy.js new file mode 100644 index 00000000..ad1cfda8 --- /dev/null +++ b/cypress/component/annot-tool.cy.js @@ -0,0 +1,41 @@ +import annotTool from "~/components/annot-tool.vue"; + + + + +describe("Annotation tool component", () => { + + it("mounts", () => { + cy.mount(annotTool, { + computed: { + getSelectedTools: () => { + return [ + { + label: "MOCA", + identifier: "cogAtlas:MOCA", + selected: false + } + ]; + } + } + }); + + }); + + it("Takes a list of tools and makes a tab for each tool", () => { + cy.mount(annotTool, { + computed: { + getSelectedTools: () => { + return [ + { + label: "MOCA", + identifier: "cogAtlas:MOCA", + selected: false + } + ]; + } + } + }); + cy.contains('MOCA'); + }); +}); From 81f3bdf8efb31e51d4b289041cb8c43198b30915 Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Thu, 19 Oct 2023 16:20:20 -0400 Subject: [PATCH 33/45] [WIP] we're not yet passing props correctly --- components/annot-single-tool.vue | 54 ++++++++++++ .../{annot-tool.vue => annot-tool-groups.vue} | 3 +- cypress/component/annot-tool.cy.js | 82 +++++++++++++------ 3 files changed, 113 insertions(+), 26 deletions(-) create mode 100644 components/annot-single-tool.vue rename components/{annot-tool.vue => annot-tool-groups.vue} (87%) diff --git a/components/annot-single-tool.vue b/components/annot-single-tool.vue new file mode 100644 index 00000000..78641245 --- /dev/null +++ b/components/annot-single-tool.vue @@ -0,0 +1,54 @@ + + + \ No newline at end of file diff --git a/components/annot-tool.vue b/components/annot-tool-groups.vue similarity index 87% rename from components/annot-tool.vue rename to components/annot-tool-groups.vue index fc941e18..356a0f6e 100644 --- a/components/annot-tool.vue +++ b/components/annot-tool-groups.vue @@ -10,7 +10,8 @@ v-for="({label, identifier}, index) in getSelectedTools" :key="index" :title="label"> - {{ identifier }} + diff --git a/cypress/component/annot-tool.cy.js b/cypress/component/annot-tool.cy.js index ad1cfda8..8fd64386 100644 --- a/cypress/component/annot-tool.cy.js +++ b/cypress/component/annot-tool.cy.js @@ -1,41 +1,73 @@ -import annotTool from "~/components/annot-tool.vue"; +import annotToolGroups from "~/components/annot-tool-groups.vue"; +import annotSingleTool from "~/components/annot-single-tool.vue"; +const getters = { + getSelectedTools: () => { + return [ + { + label: "MOCA", + identifier: "cogAtlas:MOCA", + selected: true + }, + { + label: "my best tool", + identifier: "cogAtlas:SuperTool", + selected: true + } + ]; + } +}; + +const stubs = { + + "annot-single-tool": annotSingleTool +}; +const props = [ + { + column: "column1", + value: "val1" + }, + { + column: "column2", + value: "val1" + }, + { + column: "column2", + value: "val2" + } +]; + describe("Annotation tool component", () => { it("mounts", () => { - cy.mount(annotTool, { - computed: { - getSelectedTools: () => { - return [ - { - label: "MOCA", - identifier: "cogAtlas:MOCA", - selected: false - } - ]; - } - } + cy.mount(annotToolGroups, { + computed: getters, + stubs: stubs, + props: props }); }); it("Takes a list of tools and makes a tab for each tool", () => { - cy.mount(annotTool, { - computed: { - getSelectedTools: () => { - return [ - { - label: "MOCA", - identifier: "cogAtlas:MOCA", - selected: false - } - ]; - } - } + cy.mount(annotToolGroups, { + computed: getters, + stubs: stubs, + props: props + }); + cy.contains('MOCA'); + cy.contains('my best tool'); + }); + + it("mounts a subcomponent for each tool and provides the correct props to it", () => { + cy.mount(annotToolGroups, { + computed: getters, + stubs: stubs, + props: props }); cy.contains('MOCA'); + cy.contains('my best tool'); }); }); From 42fc3ba5180867577b83fbe9a5601afb06f3d86d Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Thu, 19 Oct 2023 20:13:54 -0400 Subject: [PATCH 34/45] Add getter for columns mapped to tools --- .../unit/store-getter-getColumnsForTool.cy.js | 29 +++++++++++++++++++ store/index.js | 6 ++++ 2 files changed, 35 insertions(+) create mode 100644 cypress/unit/store-getter-getColumnsForTool.cy.js diff --git a/cypress/unit/store-getter-getColumnsForTool.cy.js b/cypress/unit/store-getter-getColumnsForTool.cy.js new file mode 100644 index 00000000..6a88c50d --- /dev/null +++ b/cypress/unit/store-getter-getColumnsForTool.cy.js @@ -0,0 +1,29 @@ +import { getters } from "~/store"; + +const store = { + + state: { + + columnToToolMap: { + "column1": "cogatlas:MOCA", + "column2": null, + "column3": "cogatlas:MOCA", + "column4": "cogatlas:UPDRS" + } + } +}; + +describe("getColumnsForTool", () => { + + it("Gets list of columns mapped to a given tool", () => { + + // Assert + expect(getters.getColumnsForTool(store.state)("cogatlas:MOCA")).to.deep.equal(["column1", "column3"]); + }); + + it("Gets empty list if no column was assigned to this tool", () => { + + // Assert + expect(getters.getColumnsForTool(store.state)("cogatlas:SomethingElse")).to.deep.equal([]); + }); +}); diff --git a/store/index.js b/store/index.js index 7cb731e8..e88610f0 100644 --- a/store/index.js +++ b/store/index.js @@ -565,6 +565,12 @@ export const getters = { return columns; }, + getColumnsForTool: (p_state) => (p_tool) => { + + return Object.keys(p_state.columnToToolMap) + .filter(key => p_state.columnToToolMap[key] === p_tool); + }, + getUniqueColumnValues: (p_state) => (columnName, p_maxValues="None") => { let uniqueColumnValues = new Set(); for ( let index = 0; index < p_state.dataTable.length; index++ ) { From 457a87c3c58c0bef783d247da7578924845df329 Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Thu, 19 Oct 2023 20:33:15 -0400 Subject: [PATCH 35/45] Parseing unique values for tool columns --- components/annot-tool-groups.vue | 16 ++++++++++++++-- cypress/component/annot-tool.cy.js | 14 ++++++++++---- store/index.js | 2 +- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/components/annot-tool-groups.vue b/components/annot-tool-groups.vue index 356a0f6e..a796ae52 100644 --- a/components/annot-tool-groups.vue +++ b/components/annot-tool-groups.vue @@ -11,7 +11,8 @@ :key="index" :title="label"> + :name="identifier" + :uniqueColumnValues="provideUniqueValues(identifier)" /> @@ -28,8 +29,19 @@ export default { computed: { ...mapGetters([ - "getSelectedTools" + "getSelectedTools", + "getColumnsForTool", + "getUniqueColumnValues" ]) + }, + methods: { + provideUniqueValues(identifier) { + const toolColumns = this.getColumnsForTool(identifier); + return toolColumns + .map(column => this.getUniqueColumnValues(column) + .map(value => ({"column": column, "value": value}))) + .flat(); + } } }; diff --git a/cypress/component/annot-tool.cy.js b/cypress/component/annot-tool.cy.js index 8fd64386..fac726d2 100644 --- a/cypress/component/annot-tool.cy.js +++ b/cypress/component/annot-tool.cy.js @@ -10,11 +10,17 @@ const getters = { selected: true }, { - label: "my best tool", - identifier: "cogAtlas:SuperTool", + label: "UPDRS", + identifier: "cogAtlas:UPDRS", selected: true } ]; + }, + getColumnsForTool: () => (p_tool) => { + return ["column1", "column2"]; + }, + getUniqueColumnValues: () => (column) => { + return [1, 2, 3]; } }; @@ -58,7 +64,7 @@ describe("Annotation tool component", () => { props: props }); cy.contains('MOCA'); - cy.contains('my best tool'); + cy.contains('UPDRS'); }); it("mounts a subcomponent for each tool and provides the correct props to it", () => { @@ -68,6 +74,6 @@ describe("Annotation tool component", () => { props: props }); cy.contains('MOCA'); - cy.contains('my best tool'); + cy.contains('UPDRS'); }); }); diff --git a/store/index.js b/store/index.js index e88610f0..6165ea0c 100644 --- a/store/index.js +++ b/store/index.js @@ -69,7 +69,7 @@ export const state = () => ({ }, "Assessment Tool": { - componentName: "annot-tool", + componentName: "annot-tool-groups", explanation: "This is an explanation for how to annotate a tool.", identifier: "nb:AssessmentTool" } From e1616152447ed5e5f50b043b3e9e8b75f5657e03 Mon Sep 17 00:00:00 2001 From: Sebastian Urchs Date: Thu, 19 Oct 2023 21:04:55 -0400 Subject: [PATCH 36/45] Single annot component + test also: props work now --- components/annot-single-tool.vue | 2 +- ...not-tool.cy.js => annot-tool-groups.cy.js} | 0 cypress/component/annot-tool-single.cy.js | 47 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) rename cypress/component/{annot-tool.cy.js => annot-tool-groups.cy.js} (100%) create mode 100644 cypress/component/annot-tool-single.cy.js diff --git a/components/annot-single-tool.vue b/components/annot-single-tool.vue index 78641245..721aaee2 100644 --- a/components/annot-single-tool.vue +++ b/components/annot-single-tool.vue @@ -1,6 +1,6 @@