Skip to content

Commit

Permalink
update cypress to discard doc changes
Browse files Browse the repository at this point in the history
This should be removed more closely. It isn't obvious why one document in the import-v2 spec is dirty and the other is not.
  • Loading branch information
scytacki committed Oct 30, 2024
1 parent 77bbda9 commit 611a2a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 3 additions & 1 deletion v3/cypress/e2e/cfm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ context("CloudFileManager", () => {
table.getGridCell(2, 2).should("contain", "African Elephant")

// Close the document
// Note: because we aren't changing the document we can close it without the dialog
cfm.closeDocument()

// Verify document was closed (table doesn't exist)
Expand All @@ -74,6 +75,7 @@ context("CloudFileManager", () => {
table.getGridCell(2, 2).should("contain", "African Elephant")

// Close the document
// Note: because we aren't changing the document we can close it without the dialog
cfm.closeDocument()

// Verify document was closed (table doesn't exist)
Expand All @@ -87,7 +89,7 @@ context("CloudFileManager", () => {
table.getGridCell(2, 2).should("contain", "Alabama")

// Close the document
cfm.closeDocument()
cfm.closeDocument({discardChanges: true})

// Verify document was closed (Map data table doesn't exist)
c.checkComponentDoesNotExist("table")
Expand Down
4 changes: 3 additions & 1 deletion v3/cypress/e2e/import-v2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ context("import codap v2 documents", () => {
cy.wait(1000)
webView.getIFrame().find(".welcome").should("contain.text",
"Save Madeline the dog by winning at Rock Paper Scissors.")
// In this case the document is not dirty for some reason
cfm.openExampleDocument("Parachute Model")
webView.getTitle().should("contain.text", "Terminal Velocity")
cfm.openExampleDocument("Getting started with CODAP")
// In this case the document is dirty for some reason
cfm.openExampleDocument("Getting started with CODAP", {discardChanges: true})
cy.wait(1000)
webView.getIFrame().find(".App-list").should("contain.text",
"Drag this data file into CODAP")
Expand Down
17 changes: 15 additions & 2 deletions v3/cypress/support/elements/cfm.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
interface IDocumentOptions {
discardChanges?: boolean
}
export const CfmElements = {
openLocalDoc(filename: string) {
cy.get('#codap-app-id').selectFile(filename, { action: 'drag-drop' })
},
closeDocument() {
closeDocument(options?: IDocumentOptions) {
this.getHamburgerMenuButton().click()
this.getHamburgerMenu().contains("li", "Close").click()
if (options?.discardChanges) {
this.discardDocumentChanges()
}
},
getMenuBar() {
return cy.get('#codap-menu-bar-id')
Expand All @@ -24,9 +30,16 @@ export const CfmElements = {
getModalDialog() {
return cy.get('#codap-menu-bar-id .view .modal-dialog')
},
openExampleDocument(filename: string) {
discardDocumentChanges() {
this.getModalDialog().contains("Are you sure")
this.getModalDialog().find('button').contains("Yes").click()
},
openExampleDocument(filename: string, options?: IDocumentOptions) {
this.getHamburgerMenuButton().click()
this.getHamburgerMenu().find("li").contains("Open...").click()
if (options?.discardChanges) {
this.discardDocumentChanges()
}
this.getModalDialog().find(".selectable").contains(filename).eq(0).click()
this.getModalDialog().find("button").contains("Open").click()
},
Expand Down

0 comments on commit 611a2a2

Please sign in to comment.