Skip to content

Commit

Permalink
Merge pull request #1296 from concord-consortium/185315412-automation…
Browse files Browse the repository at this point in the history
…-csv-local-import

185315412 automation csv local import
  • Loading branch information
kswenson authored Jun 5, 2024
2 parents 5efd406 + dcf3150 commit 375cec6
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
66 changes: 62 additions & 4 deletions v3/cypress/e2e/cfm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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", () => {
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
Expand All @@ -30,4 +32,60 @@ 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", () => {
const fileName = "../v3/cypress/fixtures/mammals.codap"
const CSVFileName = "../v3/cypress/fixtures/map-data.csv"

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")

// Close the document
cfm.closeDocument()

// 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")
})
})
9 changes: 9 additions & 0 deletions v3/cypress/support/elements/cfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
},
Expand All @@ -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()
}
}

0 comments on commit 375cec6

Please sign in to comment.