From 9c758019fd82f041eb97ea57ec677cf2461ba1db Mon Sep 17 00:00:00 2001 From: Ethan McElroy Date: Tue, 25 Jun 2024 16:12:08 -0400 Subject: [PATCH 1/7] feat: Categorical Graph copy retains data (PT-185741802) [#185741802](https://www.pivotaltracker.com/story/show/185741802) --- src/plugins/graph/models/graph-model.ts | 62 ++++++++++++++++++------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/src/plugins/graph/models/graph-model.ts b/src/plugins/graph/models/graph-model.ts index 411c137f0f..4f09a0f70e 100644 --- a/src/plugins/graph/models/graph-model.ts +++ b/src/plugins/graph/models/graph-model.ts @@ -735,19 +735,18 @@ export const GraphModel = TileContentModel } }, afterAttach() { - if (self.layers.length === 1 && !self.layers[0].config.dataset && !self.layers[0].config.isEmpty) { - // Non-empty DataConfiguration lacking a dataset reference = legacy data needing a one-time fix. - // We can't do that fix until the SharedModelManager is ready, though. - addDisposer(self, reaction( - () => { - return self.tileEnv?.sharedModelManager?.isReady; - }, - (ready) => { - if (!ready) return; - this.setDataConfigurationReferences(); - } - )); - } + // Some shared model references may need to be updated. We can't update them until the SharedModelManager + // is ready, though. + addDisposer(self, reaction( + () => { + return self.tileEnv?.sharedModelManager?.isReady; + }, + (ready) => { + if (!ready) return; + this.initializeSharedModelReferences(); + + }, { fireImmediately: true } + )); // Automatically asign colors to anything that might need them. addDisposer(self, reaction( @@ -765,13 +764,40 @@ export const GraphModel = TileContentModel } )); }, - setDataConfigurationReferences() { - // Updates pre-existing DataConfiguration objects that don't have the now-required references - // for dataset and metadata. We can determine these from the unique shared models these - // legacy tile models should have. + initializeSharedModelReferences() { const smm = getSharedModelManager(self); if (smm && smm.isReady) { const sharedDataSets = smm.getTileSharedModelsByType(self, SharedDataSet); + let sharedMetadata = smm.getTileSharedModelsByType(self, SharedCaseMetadata); + + // If there's a shared dataset without corresponding shared case metadata, create a new shared case + // metadata instance, link it to the dataset, and add it to the tile. This is needed when graph tiles are + // copied since the original graph tile's case metadata is not copied along with the shared dataset. + sharedDataSets.forEach((sds) => { + if (!isSharedDataSet(sds)) return; + const hasLinkedCaseMetadata = sharedMetadata.some((smd) => { + if (isSharedCaseMetadata(smd)) { + return smd.data === sds.dataSet; + } + }); + if (!hasLinkedCaseMetadata) { + const smd = SharedCaseMetadata.create(); + smd.setData(sds.dataSet); + smm.addTileSharedModel(self, smd); + const datasetLayer = self.layers.find((layer) => layer.config.dataset === sds.dataSet); + if (datasetLayer) { + datasetLayer.config.metadata = smd; + } + } + }); + + // Update pre-existing, legacy DataConfiguration objects that don't have the now-required references + // for dataset and metadata. We can determine these from the unique shared models these + // legacy tile models should have. + const legacyGraph = self.layers.length === 1 && !self.layers[0].config.dataset && + !self.layers[0].config.isEmpty; + if (!legacyGraph) return; + if (sharedDataSets.length === 1) { const sds = sharedDataSets[0]; if (isSharedDataSet(sds)) { @@ -779,7 +805,7 @@ export const GraphModel = TileContentModel console.log('Updated legacy document - set dataset reference'); } } - const sharedMetadata = smm.getTileSharedModelsByType(self, SharedCaseMetadata); + sharedMetadata = smm.getTileSharedModelsByType(self, SharedCaseMetadata); if (sharedMetadata.length === 1) { const smd = sharedMetadata[0]; if (isSharedCaseMetadata(smd)) { From d8d896fa5268c579c6246e27ab4346661f99e079 Mon Sep 17 00:00:00 2001 From: Ethan McElroy Date: Thu, 27 Jun 2024 09:18:26 -0400 Subject: [PATCH 2/7] chore: test coverage --- .../document_tests/tiles_copy_test_spec.js | 85 +++++++++++++++---- 1 file changed, 68 insertions(+), 17 deletions(-) diff --git a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js index fab8cbdd32..50fdf65d5e 100644 --- a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js +++ b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js @@ -30,22 +30,28 @@ let canvas = new Canvas; const imageName = "Image Tile"; const simName = "Test Simulation"; const diagramName = "Test Diagram"; +const numericGraphName = "XY Plot Test"; +const categoricalGraphName = "Categorical Graph Test"; + const studentWorkspace = 'QA 1.1 Solving a Mystery with Proportional Reasoning'; const studentWorkspaceCopyTiles = 'Test Workspace Copy Tiles'; const studentClassWorkCopyTiles = 'Test Class Work Copy Tiles'; -const tiles1 = [{ "name": "table" }, -{ "name": "geometry" }, -{ "name": "drawing" }, -{ "name": "expression" }, -{ "name": "numberline" }, -{ "name": "image" }]; +const tiles1 = [ + { "name": "table" }, + { "name": "geometry" }, + { "name": "drawing" }, + { "name": "expression" }, + { "name": "numberline" }, + { "name": "image" } +]; const tiles2 = [ - { "name": "data-card" }, - { "name": "dataflow" }, - { "name": "simulator" }, - { "name": "graph" }, - { "name": "diagram" } + { "name": "data-card", instance: 1 }, + { "name": "dataflow", instance: 1 }, + { "name": "simulator", instance: 1 }, + { "name": "graph", instance: 1 }, + { "name": "diagram", instance: 1 }, + { "name": "graph", instance: 2 } ]; function beforeTest(queryParams) { @@ -81,7 +87,28 @@ function testPrimaryWorkspace2() { // Make sure the simulator tile were copied correctly simulatorTile.getTileTitle().should("contain", simName); // Make sure the XY plot tile were copied correctly - cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').should("contain", "XY Plot test"); + + // Make sure both graph tiles were copied correctly. The order of the tiles is not guaranteed, so we put the title + // text of all graph tiles into an array and make sure the expected titles are present. + cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").then($elements => { + const tileTitles = $elements.map((i, el) => Cypress.$(el).text()).get(); + expect(tileTitles).to.have.length(2); + expect(tileTitles).to.include(numericGraphName); + expect(tileTitles).to.include(categoricalGraphName); + + // Also make sure the categorical graph has the correct number of dots and that they're placed in a way that + // indicates they're being plotted correctly. + $elements.each((i, el) => { + const titleText = Cypress.$(el).text().trim(); + + if (titleText === categoricalGraphName) { + cy.wrap(el).closest(".graph-wrapper").find("g.graph-dot").should("have.length", 3).each(($g) => { + cy.wrap($g).should("have.attr", "transform").should("not.be.empty"); + }); + } + }); + }); + //Verify my work document tiles are copied correctly diagramTile.getTileTitleText().should("contain", diagramName); @@ -244,11 +271,10 @@ context('Test copy tiles from one document to other document', function () { cy.log("Add XY plot tile"); clueCanvas.addTile("graph"); - const title = "XY Plot test"; cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').first().should("contain", "Graph 1"); cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').first().click(); - cy.get('.primary-workspace .graph-wrapper .editable-tile-title').first().type(title + '{enter}'); - cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').should("contain", title); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title').first().type(numericGraphName + '{enter}'); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').should("contain", numericGraphName); cy.log('Add diagram tile'); clueCanvas.addTile("diagram"); @@ -257,6 +283,31 @@ context('Test copy tiles from one document to other document', function () { diagramTile.getTileTitleContainer().type(diagramName + '{enter}'); diagramTile.getTileTitleText().should("contain", diagramName); + // Add table tile and populate it with two columns of categorical data. Then create a graph tile from it. + cy.log("Add table tile with categorical data"); + clueCanvas.addTile("table"); + cy.get(".primary-workspace").within((workspace) => { + tableToolTile.typeInTableCellXY(0, 0, "small"); + tableToolTile.getTableCellXY(0, 0).should("contain", "small"); + tableToolTile.typeInTableCellXY(1, 0, "medium"); + tableToolTile.getTableCellXY(1, 0).should("contain", "medium"); + tableToolTile.typeInTableCellXY(2, 0, "large"); + tableToolTile.getTableCellXY(2, 0).should("contain", "large"); + tableToolTile.typeInTableCellXY(0, 1, "red"); + tableToolTile.getTableCellXY(0, 1).should("contain", "red"); + tableToolTile.typeInTableCellXY(1, 1, "green"); + tableToolTile.getTableCellXY(1, 1).should("contain", "green"); + tableToolTile.typeInTableCellXY(2, 1, "blue"); + tableToolTile.getTableCellXY(2, 1).should("contain", "blue"); + }); + cy.get(".primary-workspace .tile-toolbar button.toolbar-button").eq(2).click(); + cy.get("[data-test=link-tile-select]").select("New Graph"); + cy.get(".modal-button").contains("Graph It").click(); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').eq(1).should("contain", "Graph 1"); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').eq(1).click(); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title').eq(1).type(categoricalGraphName + '{enter}'); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').eq(1).should("contain", categoricalGraphName); + //Publish the document canvas.publishCanvas("investigation"); @@ -272,7 +323,7 @@ context('Test copy tiles from one document to other document', function () { tiles2.forEach(tool => { cy.get(`.nav-tab-panel .my-work .${tool.name}-tool-tile`) - .first().within(dragTile); + .eq(tool.instance - 1).within(dragTile); }); //Verify my work document tiles are copied correctly @@ -294,7 +345,7 @@ context('Test copy tiles from one document to other document', function () { tiles2.forEach(tool => { cy.get(`.nav-tab-panel .class-work .${tool.name}-tool-tile`) - .first().within(dragTile); + .eq(tool.instance - 1).within(dragTile); }); //Verify class work document tiles are copied correctly From 4f230ef8e1647c6540a008559d515644d715dd10 Mon Sep 17 00:00:00 2001 From: Ethan McElroy Date: Thu, 27 Jun 2024 16:29:48 -0400 Subject: [PATCH 3/7] chore: redo test coverage with new Copy button test --- .../document_tests/tiles_copy_test_spec.js | 113 +++++++++--------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js index 50fdf65d5e..79f538f285 100644 --- a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js +++ b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js @@ -30,8 +30,8 @@ let canvas = new Canvas; const imageName = "Image Tile"; const simName = "Test Simulation"; const diagramName = "Test Diagram"; -const numericGraphName = "XY Plot Test"; const categoricalGraphName = "Categorical Graph Test"; +const categoricalGraphCopyName = "Categorical Graph Test 1"; const studentWorkspace = 'QA 1.1 Solving a Mystery with Proportional Reasoning'; const studentWorkspaceCopyTiles = 'Test Workspace Copy Tiles'; @@ -46,12 +46,12 @@ const tiles1 = [ { "name": "image" } ]; const tiles2 = [ - { "name": "data-card", instance: 1 }, - { "name": "dataflow", instance: 1 }, - { "name": "simulator", instance: 1 }, - { "name": "graph", instance: 1 }, - { "name": "diagram", instance: 1 }, - { "name": "graph", instance: 2 } + { "name": "data-card" }, + { "name": "dataflow" }, + { "name": "simulator" }, + { "name": "graph" }, + { "name": "diagram" }, + { "name": "graph" } ]; function beforeTest(queryParams) { @@ -87,27 +87,7 @@ function testPrimaryWorkspace2() { // Make sure the simulator tile were copied correctly simulatorTile.getTileTitle().should("contain", simName); // Make sure the XY plot tile were copied correctly - - // Make sure both graph tiles were copied correctly. The order of the tiles is not guaranteed, so we put the title - // text of all graph tiles into an array and make sure the expected titles are present. - cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").then($elements => { - const tileTitles = $elements.map((i, el) => Cypress.$(el).text()).get(); - expect(tileTitles).to.have.length(2); - expect(tileTitles).to.include(numericGraphName); - expect(tileTitles).to.include(categoricalGraphName); - - // Also make sure the categorical graph has the correct number of dots and that they're placed in a way that - // indicates they're being plotted correctly. - $elements.each((i, el) => { - const titleText = Cypress.$(el).text().trim(); - - if (titleText === categoricalGraphName) { - cy.wrap(el).closest(".graph-wrapper").find("g.graph-dot").should("have.length", 3).each(($g) => { - cy.wrap($g).should("have.attr", "transform").should("not.be.empty"); - }); - } - }); - }); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').should("contain", "XY Plot test"); //Verify my work document tiles are copied correctly diagramTile.getTileTitleText().should("contain", diagramName); @@ -271,10 +251,11 @@ context('Test copy tiles from one document to other document', function () { cy.log("Add XY plot tile"); clueCanvas.addTile("graph"); + const title = "XY Plot test"; cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').first().should("contain", "Graph 1"); cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').first().click(); - cy.get('.primary-workspace .graph-wrapper .editable-tile-title').first().type(numericGraphName + '{enter}'); - cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').should("contain", numericGraphName); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title').first().type(title + '{enter}'); + cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').should("contain", title); cy.log('Add diagram tile'); clueCanvas.addTile("diagram"); @@ -283,31 +264,6 @@ context('Test copy tiles from one document to other document', function () { diagramTile.getTileTitleContainer().type(diagramName + '{enter}'); diagramTile.getTileTitleText().should("contain", diagramName); - // Add table tile and populate it with two columns of categorical data. Then create a graph tile from it. - cy.log("Add table tile with categorical data"); - clueCanvas.addTile("table"); - cy.get(".primary-workspace").within((workspace) => { - tableToolTile.typeInTableCellXY(0, 0, "small"); - tableToolTile.getTableCellXY(0, 0).should("contain", "small"); - tableToolTile.typeInTableCellXY(1, 0, "medium"); - tableToolTile.getTableCellXY(1, 0).should("contain", "medium"); - tableToolTile.typeInTableCellXY(2, 0, "large"); - tableToolTile.getTableCellXY(2, 0).should("contain", "large"); - tableToolTile.typeInTableCellXY(0, 1, "red"); - tableToolTile.getTableCellXY(0, 1).should("contain", "red"); - tableToolTile.typeInTableCellXY(1, 1, "green"); - tableToolTile.getTableCellXY(1, 1).should("contain", "green"); - tableToolTile.typeInTableCellXY(2, 1, "blue"); - tableToolTile.getTableCellXY(2, 1).should("contain", "blue"); - }); - cy.get(".primary-workspace .tile-toolbar button.toolbar-button").eq(2).click(); - cy.get("[data-test=link-tile-select]").select("New Graph"); - cy.get(".modal-button").contains("Graph It").click(); - cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').eq(1).should("contain", "Graph 1"); - cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').eq(1).click(); - cy.get('.primary-workspace .graph-wrapper .editable-tile-title').eq(1).type(categoricalGraphName + '{enter}'); - cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').eq(1).should("contain", categoricalGraphName); - //Publish the document canvas.publishCanvas("investigation"); @@ -323,7 +279,7 @@ context('Test copy tiles from one document to other document', function () { tiles2.forEach(tool => { cy.get(`.nav-tab-panel .my-work .${tool.name}-tool-tile`) - .eq(tool.instance - 1).within(dragTile); + .first().within(dragTile); }); //Verify my work document tiles are copied correctly @@ -345,7 +301,7 @@ context('Test copy tiles from one document to other document', function () { tiles2.forEach(tool => { cy.get(`.nav-tab-panel .class-work .${tool.name}-tool-tile`) - .eq(tool.instance - 1).within(dragTile); + .first().within(dragTile); }); //Verify class work document tiles are copied correctly @@ -353,3 +309,46 @@ context('Test copy tiles from one document to other document', function () { }); }); + +context("Test copy tile within a document", function () { + it("Copies a graph tile within a document", function () { + beforeTest(student5); + + // Add table tile and populate it with categorical data. + cy.log("Add table tile with categorical data"); + clueCanvas.addTile("table"); + cy.get(".primary-workspace").within((workspace) => { + tableToolTile.typeInTableCellXY(0, 0, "small"); + tableToolTile.getTableCellXY(0, 0).should("contain", "small"); + tableToolTile.typeInTableCellXY(1, 0, "medium"); + tableToolTile.getTableCellXY(1, 0).should("contain", "medium"); + tableToolTile.typeInTableCellXY(0, 1, "red"); + tableToolTile.getTableCellXY(0, 1).should("contain", "red"); + tableToolTile.typeInTableCellXY(1, 1, "green"); + tableToolTile.getTableCellXY(1, 1).should("contain", "green"); + }); + + // Graph the table data in a new graph tile + cy.get(".primary-workspace .tile-toolbar button.toolbar-button").eq(2).click(); + cy.get("[data-test=link-tile-select]").select("New Graph"); + cy.get(".modal-button").contains("Graph It").click(); + cy.get(".primary-workspace .graph-wrapper").should("have.length", 1); + cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").first().should("contain", "Graph 1"); + cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").first().click(); + cy.get(".primary-workspace .graph-wrapper .editable-tile-title").first().type(categoricalGraphName + "{enter}"); + cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").first().should("contain", categoricalGraphName); + cy.get(".primary-workspace .graph-wrapper").first().find("g.graph-dot").should("have.length", 2).each(($g) => { + cy.wrap($g).should("have.attr", "transform").should("not.be.empty"); + }); + + // Click on new graph tile to select it, then copy it + cy.get(".primary-workspace .graph-wrapper").first().click(); + cy.get("[data-testid=tool-duplicate]").click(); + cy.get(".primary-workspace .graph-wrapper").should("have.length", 2); + cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").eq(1).should("contain", categoricalGraphCopyName); + cy.get(".primary-workspace .graph-wrapper").eq(1).find("g.graph-dot").should("have.length", 2).each(($g) => { + cy.wrap($g).should("have.attr", "transform").should("not.be.empty"); + }); + + }); +}); From 342c26e2944e41b39d3b36a5c576e0dc04b7046a Mon Sep 17 00:00:00 2001 From: Ethan McElroy Date: Thu, 27 Jun 2024 16:42:30 -0400 Subject: [PATCH 4/7] chore: remove unwanted artifacts of first test coverage commit --- cypress/e2e/functional/document_tests/tiles_copy_test_spec.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js index 79f538f285..ab7b8c8b89 100644 --- a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js +++ b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js @@ -50,8 +50,7 @@ const tiles2 = [ { "name": "dataflow" }, { "name": "simulator" }, { "name": "graph" }, - { "name": "diagram" }, - { "name": "graph" } + { "name": "diagram" } ]; function beforeTest(queryParams) { @@ -88,7 +87,6 @@ function testPrimaryWorkspace2() { simulatorTile.getTileTitle().should("contain", simName); // Make sure the XY plot tile were copied correctly cy.get('.primary-workspace .graph-wrapper .editable-tile-title-text').should("contain", "XY Plot test"); - //Verify my work document tiles are copied correctly diagramTile.getTileTitleText().should("contain", diagramName); From 7529d7d8af4ef16dbef120cec7022056016d7b5c Mon Sep 17 00:00:00 2001 From: Ethan McElroy Date: Fri, 28 Jun 2024 11:14:29 -0400 Subject: [PATCH 5/7] chore: improve copy test --- cypress/e2e/functional/document_tests/tiles_copy_test_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js index ab7b8c8b89..ac02cb5f7f 100644 --- a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js +++ b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js @@ -327,7 +327,7 @@ context("Test copy tile within a document", function () { }); // Graph the table data in a new graph tile - cy.get(".primary-workspace .tile-toolbar button.toolbar-button").eq(2).click(); + cy.get(".primary-workspace .tile-toolbar button.toolbar-button.link-graph").click(); cy.get("[data-test=link-tile-select]").select("New Graph"); cy.get(".modal-button").contains("Graph It").click(); cy.get(".primary-workspace .graph-wrapper").should("have.length", 1); From 5b0d82d721526280c9d1e334bd38f98254ba5e40 Mon Sep 17 00:00:00 2001 From: Ethan McElroy Date: Tue, 2 Jul 2024 13:55:35 -0400 Subject: [PATCH 6/7] chore: adjust test step --- cypress/e2e/functional/document_tests/tiles_copy_test_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js index ac02cb5f7f..cfd5c49c24 100644 --- a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js +++ b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js @@ -327,7 +327,7 @@ context("Test copy tile within a document", function () { }); // Graph the table data in a new graph tile - cy.get(".primary-workspace .tile-toolbar button.toolbar-button.link-graph").click(); + cy.get("[data-original-title='Graph It!']").click(); cy.get("[data-test=link-tile-select]").select("New Graph"); cy.get(".modal-button").contains("Graph It").click(); cy.get(".primary-workspace .graph-wrapper").should("have.length", 1); From 2f98e82238efc2b541eeb08c5a5c0c68cf35189f Mon Sep 17 00:00:00 2001 From: Ethan McElroy Date: Wed, 3 Jul 2024 10:51:32 -0400 Subject: [PATCH 7/7] chore: code review tweaks --- .../document_tests/tiles_copy_test_spec.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js index cfd5c49c24..8b28aafbe8 100644 --- a/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js +++ b/cypress/e2e/functional/document_tests/tiles_copy_test_spec.js @@ -10,6 +10,7 @@ import DataCardToolTile from '../../../support/elements/tile/DataCardToolTile'; import DataflowToolTile from '../../../support/elements/tile/DataflowToolTile'; import SimulatorTile from '../../../support/elements/tile/SimulatorTile'; import DiagramToolTile from '../../../support/elements/tile/DiagramToolTile'; +import XYPlotToolTile from "../../../support/elements/tile/XYPlotToolTile"; const student5 = `${Cypress.config("qaUnitStudent5")}`; const student6 = `${Cypress.config("qaUnitStudent6")}`; @@ -24,7 +25,8 @@ let clueCanvas = new ClueCanvas, dc = new DataCardToolTile, dataflowToolTile = new DataflowToolTile, simulatorTile = new SimulatorTile, - diagramTile = new DiagramToolTile; + diagramTile = new DiagramToolTile, + graphTile = new XYPlotToolTile; let canvas = new Canvas; const imageName = "Image Tile"; @@ -330,21 +332,21 @@ context("Test copy tile within a document", function () { cy.get("[data-original-title='Graph It!']").click(); cy.get("[data-test=link-tile-select]").select("New Graph"); cy.get(".modal-button").contains("Graph It").click(); - cy.get(".primary-workspace .graph-wrapper").should("have.length", 1); - cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").first().should("contain", "Graph 1"); - cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").first().click(); + graphTile.getTile().should("have.length", 1); + graphTile.getXYPlotTitle().first().should("contain", "Graph 1"); + graphTile.getXYPlotTitle().first().click(); cy.get(".primary-workspace .graph-wrapper .editable-tile-title").first().type(categoricalGraphName + "{enter}"); - cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").first().should("contain", categoricalGraphName); - cy.get(".primary-workspace .graph-wrapper").first().find("g.graph-dot").should("have.length", 2).each(($g) => { + graphTile.getXYPlotTitle().first().should("contain", categoricalGraphName); + graphTile.getGraphDot().should("have.length", 2).each(($g) => { cy.wrap($g).should("have.attr", "transform").should("not.be.empty"); }); // Click on new graph tile to select it, then copy it - cy.get(".primary-workspace .graph-wrapper").first().click(); + graphTile.getTile().first().click(); cy.get("[data-testid=tool-duplicate]").click(); - cy.get(".primary-workspace .graph-wrapper").should("have.length", 2); - cy.get(".primary-workspace .graph-wrapper .editable-tile-title-text").eq(1).should("contain", categoricalGraphCopyName); - cy.get(".primary-workspace .graph-wrapper").eq(1).find("g.graph-dot").should("have.length", 2).each(($g) => { + graphTile.getTile().should("have.length", 2); + graphTile.getXYPlotTitle().eq(1).should("contain", categoricalGraphCopyName); + graphTile.getTile().eq(1).find("g.graph-dot").should("have.length", 2).each(($g) => { cy.wrap($g).should("have.attr", "transform").should("not.be.empty"); });