From 39348afb459bac410ce159bf27f56383d37a04f1 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:35:40 -0700 Subject: [PATCH 1/7] Added undo/redo to component rename test in calculator.spec. Also fixed lint error in graph.spec. --- v3/cypress/e2e/calculator.spec.ts | 19 ++++++++++--------- v3/cypress/e2e/graph.spec.ts | 5 +++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/v3/cypress/e2e/calculator.spec.ts b/v3/cypress/e2e/calculator.spec.ts index 4561c5b3dd..e859fa791a 100644 --- a/v3/cypress/e2e/calculator.spec.ts +++ b/v3/cypress/e2e/calculator.spec.ts @@ -14,21 +14,20 @@ context("Calculator", () => { it("populates default title", () => { c.getComponentTitle("calculator").should("contain", calculatorName) }) - it("updates calculator title", () => { + it("updates calculator title with undo/redo", () => { const newCalculatorName = "my calc" c.getComponentTitle("calculator").should("have.text", calculatorName) c.changeComponentTitle("calculator", newCalculatorName) c.getComponentTitle("calculator").should("have.text", newCalculatorName) - // Undo title change - // Note: This title does not update. Instead it goes to "my Cal" when the undo button is pressed - // See PT bug #187033159 - // toolbar.getUndoTool().click() - // c.getComponentTitle("calculator").should("have.text", calculatorName) + cy.log("Check update calculator title with undo/redo") + // Undo title change + toolbar.getUndoTool().click() + c.getComponentTitle("calculator").should("have.text", calculatorName) - // Redo title change - // toolbar.getRedoTool().click() - // c.getComponentTitle("calculator").should("have.text", newCalculatorName) + // Redo title change + toolbar.getRedoTool().click() + c.getComponentTitle("calculator").should("have.text", newCalculatorName) }) it("close calculator from toolshelf with undo/redo", () => { const newCalculatorName = "my calc" @@ -39,6 +38,8 @@ context("Calculator", () => { c.getIconFromToolshelf("calc").click() c.checkComponentDoesNotExist("calculator") + cy.log("Check undo/redo of close and open calculator component") + // Undo closing calculator (Reopen) toolbar.getUndoTool().click() c.checkComponentExists("calculator") diff --git a/v3/cypress/e2e/graph.spec.ts b/v3/cypress/e2e/graph.spec.ts index 3d4bb26d26..f248b6fc60 100644 --- a/v3/cypress/e2e/graph.spec.ts +++ b/v3/cypress/e2e/graph.spec.ts @@ -539,7 +539,7 @@ context("Graph UI", () => { expect(valueNum).to.be.closeTo(4, 0.1) }) }) - it("shows a bar graph when there's one categorical attr on primary axis and 'Fuse Dots into Bars' is checked", () => { + it("shows a bar graph for one categorical attr on primary axis with 'Fuse Dots into Bars' checked", () => { cy.dragAttributeToTarget("table", "Habitat", "bottom") cy.get("[data-testid=bar-cover]").should("not.exist") graph.getDisplayConfigButton().click() @@ -547,7 +547,8 @@ context("Graph UI", () => { .and("not.be.checked") cy.get("[data-testid=bar-chart-checkbox]").click() cy.get("[data-testid=bar-chart-checkbox]").find("input").should("be.checked") - // TODO: It would be better to check for the exact number of bars, but the number seems to vary depending on whether + // TODO: It would be better to check for the exact number of bars, + // but the number seems to vary depending on whether // you're running the test locally or in CI for some mysterious reason. // cy.get("[data-testid=bar-cover]").should("exist").and("have.length", 3) cy.get("[data-testid=bar-cover]").should("exist") From 57d5007775d9daad09b6483ac022563d0326538d Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:53:44 -0700 Subject: [PATCH 2/7] outline code for csv and json import --- v3/cypress/e2e/cfm.spec.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/v3/cypress/e2e/cfm.spec.ts b/v3/cypress/e2e/cfm.spec.ts index 1bf3249451..1e5aadcf04 100644 --- a/v3/cypress/e2e/cfm.spec.ts +++ b/v3/cypress/e2e/cfm.spec.ts @@ -30,4 +30,13 @@ context("CloudFileManager", () => { cfm.getModalDialog().should("not.exist") cy.get(".codap-component.codap-case-table").contains(".title-bar", "Mammals").should("exist") }) + // it("Opens a CODAP document via CFM Open dialog", () => { + + // }) + // it("Opens a csv document via CFM Open dialog", () => { + + // }) + // it("Opens a JSON document via CFM Open dialog", () => { + + // }) }) From 5cfcd1fa59ef9572b2562028b29869f5719c79cb Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:45:21 -0700 Subject: [PATCH 3/7] added test for open local file --- v3/cypress/e2e/cfm.spec.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/v3/cypress/e2e/cfm.spec.ts b/v3/cypress/e2e/cfm.spec.ts index 1e5aadcf04..59cac2c312 100644 --- a/v3/cypress/e2e/cfm.spec.ts +++ b/v3/cypress/e2e/cfm.spec.ts @@ -1,4 +1,5 @@ import { CfmElements as cfm } from "../support/elements/cfm" +import { TableTileElements as table } from "../support/elements/table-tile" context("CloudFileManager", () => { beforeEach(function () { @@ -30,9 +31,25 @@ context("CloudFileManager", () => { cfm.getModalDialog().should("not.exist") cy.get(".codap-component.codap-case-table").contains(".title-bar", "Mammals").should("exist") }) - // it("Opens a CODAP document via CFM Open dialog", () => { + it.only("Opens a CODAP document using different methods", () => { + // cfm.getHamburgerMenuButton().click() + // cfm.getHamburgerMenu().contains("li", "Open...").click() + // cfm.getHamburgerMenu().should("not.exist") + // cfm.getModalDialog().contains(".modal-dialog-title", "Open") + // cfm.getModalDialog().contains("", "Local File").click() + // cfm.getModalDialog() + // .contains(".dropArea", "Drop file here or click here to select a file.") + // .should("exist") + // .click({force:true}) + // cy.wait(1000) - // }) + cy.log("Opens a CODAP document from a local file") + const fileName = "../v3/cypress/fixtures/mammals.codap" + cfm.openLocalDoc(fileName) + table.getAttribute("Order").should("have.text", "Order") + table.getGridCell(2, 2).should("contain", "African Elephant") + + }) // it("Opens a csv document via CFM Open dialog", () => { // }) From 27ec1568f28ab54fad6df2f3b46eeb5cab3279a7 Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:47:50 -0700 Subject: [PATCH 4/7] added tests to open and close local CSV and CODAP documents --- v3/cypress/e2e/cfm.spec.ts | 69 ++++++++++++++++++++++-------- v3/cypress/support/elements/cfm.ts | 9 ++++ 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/v3/cypress/e2e/cfm.spec.ts b/v3/cypress/e2e/cfm.spec.ts index 59cac2c312..d041345b7e 100644 --- a/v3/cypress/e2e/cfm.spec.ts +++ b/v3/cypress/e2e/cfm.spec.ts @@ -1,4 +1,5 @@ import { CfmElements as cfm } from "../support/elements/cfm" +import { ComponentElements as c } from "../support/elements/component-elements" import { TableTileElements as table } from "../support/elements/table-tile" context("CloudFileManager", () => { @@ -31,29 +32,61 @@ context("CloudFileManager", () => { cfm.getModalDialog().should("not.exist") cy.get(".codap-component.codap-case-table").contains(".title-bar", "Mammals").should("exist") }) - it.only("Opens a CODAP document using different methods", () => { - // cfm.getHamburgerMenuButton().click() - // cfm.getHamburgerMenu().contains("li", "Open...").click() - // cfm.getHamburgerMenu().should("not.exist") - // cfm.getModalDialog().contains(".modal-dialog-title", "Open") - // cfm.getModalDialog().contains("", "Local File").click() - // cfm.getModalDialog() - // .contains(".dropArea", "Drop file here or click here to select a file.") - // .should("exist") - // .click({force:true}) - // cy.wait(1000) - - cy.log("Opens a CODAP document from a local file") + it("Opens a local document using different methods", () => { const fileName = "../v3/cypress/fixtures/mammals.codap" + const CSVFileName = "../v3/cypress/fixtures/map-data.csv" + const JSONFileName = "../v3/cypress/fixtures/hierarchical.json" + + cy.log("Opens a CODAP document from a local file using CFM dialog") + + // Open the document from Hamburger menu + // Select file from dialog + cfm.getHamburgerMenuButton().click() + cfm.getHamburgerMenu().contains("li", "Open...").click() + cfm.getHamburgerMenu().should("not.exist") + cfm.getModalDialog().contains(".modal-dialog-title", "Open") + cfm.getModalDialog().contains("", "Local File").click() + cfm.getModalDialog() + .contains(".dropArea", "Drop file here or click here to select a file.") + .should("exist") + .click({force:true}) + cy.get('input[type=file]').selectFile(fileName) + + // Verify table in Mammals exists + table.getAttribute("Order").should("have.text", "Order") + table.getGridCell(2, 2).should("contain", "African Elephant") + + // Close the document + cfm.closeDocument() + + // Verify document was closed (table doesn't exist) + c.checkComponentDoesNotExist("table") + + cy.log("Opens a CODAP document from a local file using drag and drop") + // Open file using drag and drop cfm.openLocalDoc(fileName) + + // Verify existence of table in Mammals table.getAttribute("Order").should("have.text", "Order") table.getGridCell(2, 2).should("contain", "African Elephant") - }) - // it("Opens a csv document via CFM Open dialog", () => { + // Close the document + cfm.closeDocument() - // }) - // it("Opens a JSON document via CFM Open dialog", () => { + // Verify document was closed (table doesn't exist) + c.checkComponentDoesNotExist("table") - // }) + cy.log("Opens a CSV document from a local file using drag and drop") + cfm.openLocalDoc(CSVFileName) + + // Verify existence of table in Map data + table.getAttribute("state").should("have.text", "state") + table.getGridCell(2, 2).should("contain", "Alabama") + + // Close the document + cfm.closeDocument() + + // Verify document was closed (Map data table doesn't exist) + c.checkComponentDoesNotExist("table") + }) }) diff --git a/v3/cypress/support/elements/cfm.ts b/v3/cypress/support/elements/cfm.ts index 18d24b9d7a..10c00b95d4 100644 --- a/v3/cypress/support/elements/cfm.ts +++ b/v3/cypress/support/elements/cfm.ts @@ -2,6 +2,10 @@ export const CfmElements = { openLocalDoc(filename: string) { cy.get('#codap-app-id').selectFile(filename, { action: 'drag-drop' }) }, + closeDocument() { + this.getHamburgerMenuButton().click() + this.getHamburgerMenu().contains("li", "Close").click() + }, getMenuBar() { return cy.get('#codap-menu-bar-id') }, @@ -19,5 +23,10 @@ export const CfmElements = { this.getHamburgerMenu().find("li").contains("Open...").click() this.getModalDialog().find(".selectable").contains(filename).eq(0).click() this.getModalDialog().find("button").contains("Open").click() + }, + openLocalFile(filename: string) { + this.getHamburgerMenuButton().click() + this.getHamburgerMenu().find("li").contains("Open...").click() + this.getModalDialog().find(".selectable").contains(filename).eq(1).click() } } From 773735b613c419bc98aac89c9adb46d3fe5fd92e Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:49:44 -0700 Subject: [PATCH 5/7] removed unnecessary variable --- v3/cypress/e2e/cfm.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/v3/cypress/e2e/cfm.spec.ts b/v3/cypress/e2e/cfm.spec.ts index d041345b7e..36d0ce06a3 100644 --- a/v3/cypress/e2e/cfm.spec.ts +++ b/v3/cypress/e2e/cfm.spec.ts @@ -35,7 +35,6 @@ context("CloudFileManager", () => { it("Opens a local document using different methods", () => { const fileName = "../v3/cypress/fixtures/mammals.codap" const CSVFileName = "../v3/cypress/fixtures/map-data.csv" - const JSONFileName = "../v3/cypress/fixtures/hierarchical.json" cy.log("Opens a CODAP document from a local file using CFM dialog") From 749a1c049a46be7f31b3debeb45848308a6c9fde Mon Sep 17 00:00:00 2001 From: nstclair-cc <20171905+nstclair-cc@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:47:33 -0700 Subject: [PATCH 6/7] revert changes on this file --- v3/cypress/e2e/graph.spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/v3/cypress/e2e/graph.spec.ts b/v3/cypress/e2e/graph.spec.ts index f248b6fc60..3d4bb26d26 100644 --- a/v3/cypress/e2e/graph.spec.ts +++ b/v3/cypress/e2e/graph.spec.ts @@ -539,7 +539,7 @@ context("Graph UI", () => { expect(valueNum).to.be.closeTo(4, 0.1) }) }) - it("shows a bar graph for one categorical attr on primary axis with 'Fuse Dots into Bars' checked", () => { + it("shows a bar graph when there's one categorical attr on primary axis and 'Fuse Dots into Bars' is checked", () => { cy.dragAttributeToTarget("table", "Habitat", "bottom") cy.get("[data-testid=bar-cover]").should("not.exist") graph.getDisplayConfigButton().click() @@ -547,8 +547,7 @@ context("Graph UI", () => { .and("not.be.checked") cy.get("[data-testid=bar-chart-checkbox]").click() cy.get("[data-testid=bar-chart-checkbox]").find("input").should("be.checked") - // TODO: It would be better to check for the exact number of bars, - // but the number seems to vary depending on whether + // TODO: It would be better to check for the exact number of bars, but the number seems to vary depending on whether // you're running the test locally or in CI for some mysterious reason. // cy.get("[data-testid=bar-cover]").should("exist").and("have.length", 3) cy.get("[data-testid=bar-cover]").should("exist") From dcf31500873f235628b1c0300c8c6076a23d4655 Mon Sep 17 00:00:00 2001 From: Kirk Swenson Date: Wed, 5 Jun 2024 15:01:20 -0700 Subject: [PATCH 7/7] chore: code review tweaks --- v3/cypress/e2e/cfm.spec.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/v3/cypress/e2e/cfm.spec.ts b/v3/cypress/e2e/cfm.spec.ts index 36d0ce06a3..01d46933f6 100644 --- a/v3/cypress/e2e/cfm.spec.ts +++ b/v3/cypress/e2e/cfm.spec.ts @@ -4,10 +4,10 @@ import { TableTileElements as table } from "../support/elements/table-tile" context("CloudFileManager", () => { beforeEach(function () { - const queryParams = "?mouseSensor" - const url = `${Cypress.config("index")}${queryParams}` - cy.visit(url) - cy.wait(2500) + const queryParams = "?mouseSensor" + const url = `${Cypress.config("index")}${queryParams}` + cy.visit(url) + cy.wait(2500) }) it("Opens Mammals example document via CFM Open dialog", () => { // hamburger menu is hidden initially @@ -32,7 +32,7 @@ context("CloudFileManager", () => { cfm.getModalDialog().should("not.exist") cy.get(".codap-component.codap-case-table").contains(".title-bar", "Mammals").should("exist") }) - it("Opens a local document using different methods", () => { + it("Opens a local document using different methods", () => { const fileName = "../v3/cypress/fixtures/mammals.codap" const CSVFileName = "../v3/cypress/fixtures/map-data.csv" @@ -46,9 +46,9 @@ context("CloudFileManager", () => { cfm.getModalDialog().contains(".modal-dialog-title", "Open") cfm.getModalDialog().contains("", "Local File").click() cfm.getModalDialog() - .contains(".dropArea", "Drop file here or click here to select a file.") - .should("exist") - .click({force:true}) + .contains(".dropArea", "Drop file here or click here to select a file.") + .should("exist") + .click({force:true}) cy.get('input[type=file]').selectFile(fileName) // Verify table in Mammals exists @@ -87,5 +87,5 @@ context("CloudFileManager", () => { // Verify document was closed (Map data table doesn't exist) c.checkComponentDoesNotExist("table") - }) + }) })