refactoring test createTable
This commit is contained in:
parent
6db2a30e96
commit
b9b60cf2cd
|
@ -1,4 +1,5 @@
|
||||||
import filterTests from "../support/filterTests"
|
import filterTests from "../support/filterTests"
|
||||||
|
const interact = require('../support/interact')
|
||||||
|
|
||||||
filterTests(["smoke", "all"], () => {
|
filterTests(["smoke", "all"], () => {
|
||||||
context("Create a Table", () => {
|
context("Create a Table", () => {
|
||||||
|
@ -11,7 +12,7 @@ filterTests(["smoke", "all"], () => {
|
||||||
cy.createTable("dog")
|
cy.createTable("dog")
|
||||||
cy.wait(1000)
|
cy.wait(1000)
|
||||||
// Check if Table exists
|
// Check if Table exists
|
||||||
cy.get(".table-title h1").should("have.text", "dog")
|
cy.get(interact.TABLE_TITLE_H1).should("have.text", "dog")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adds a new column to the table", () => {
|
it("adds a new column to the table", () => {
|
||||||
|
@ -25,13 +26,13 @@ filterTests(["smoke", "all"], () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("updates a column on the table", () => {
|
it("updates a column on the table", () => {
|
||||||
cy.get(".title").click()
|
cy.get(interact.TABLE_TITLE).click()
|
||||||
cy.get(".spectrum-Table-editIcon > use").click()
|
cy.get(interact.SPECTRUM_TABLE_EDIT).click()
|
||||||
cy.get(".modal-inner-wrapper").within(() => {
|
cy.get(interact.MODAL_INNER_WRAPPER).within(() => {
|
||||||
|
|
||||||
cy.get("input").eq(0).type("updated", { force: true })
|
cy.get("input").eq(0).type("updated", { force: true })
|
||||||
// Unset table display column
|
// Unset table display column
|
||||||
cy.get(".spectrum-Switch-input").eq(1).click()
|
cy.get(interact.SPECTRUM_SWITCH_INPUT).eq(1).click()
|
||||||
cy.contains("Save Column").click()
|
cy.contains("Save Column").click()
|
||||||
})
|
})
|
||||||
cy.contains("nameupdated ").should("contain", "nameupdated")
|
cy.contains("nameupdated ").should("contain", "nameupdated")
|
||||||
|
@ -40,16 +41,16 @@ filterTests(["smoke", "all"], () => {
|
||||||
it("edits a row", () => {
|
it("edits a row", () => {
|
||||||
cy.contains("button", "Edit").click({ force: true })
|
cy.contains("button", "Edit").click({ force: true })
|
||||||
cy.wait(1000)
|
cy.wait(1000)
|
||||||
cy.get(".spectrum-Modal input").clear()
|
cy.get(interact.SPECTRUM_MODAL_INPUT).clear()
|
||||||
cy.get(".spectrum-Modal input").type("Updated")
|
cy.get(interact.SPECTRUM_MODAL_INPUT).type("Updated")
|
||||||
cy.contains("Save").click()
|
cy.contains("Save").click()
|
||||||
cy.contains("Updated").should("have.text", "Updated")
|
cy.contains("Updated").should("have.text", "Updated")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("deletes a row", () => {
|
it("deletes a row", () => {
|
||||||
cy.get(".spectrum-Checkbox-input").check({ force: true })
|
cy.get(interact.SPECTRUM_CHECKBOX_INPUT).check({ force: true })
|
||||||
cy.contains("Delete 1 row(s)").click()
|
cy.contains("Delete 1 row(s)").click()
|
||||||
cy.get(".spectrum-Modal").contains("Delete").click()
|
cy.get(interact.SPECTRUM_MODAL).contains("Delete").click()
|
||||||
cy.contains("RoverUpdated").should("not.exist")
|
cy.contains("RoverUpdated").should("not.exist")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -63,50 +64,50 @@ filterTests(["smoke", "all"], () => {
|
||||||
}
|
}
|
||||||
cy.reload()
|
cy.reload()
|
||||||
cy.wait(2000)
|
cy.wait(2000)
|
||||||
cy.get(".spectrum-Pagination").within(() => {
|
cy.get(interact.SPECTRUM_PAGINATION).within(() => {
|
||||||
cy.get(".spectrum-ActionButton").eq(1).click()
|
cy.get(interact.SPECTRUM_ACTION_BUTTON).eq(1).click()
|
||||||
})
|
})
|
||||||
cy.get(".spectrum-Pagination").within(() => {
|
cy.get(interact.SPECTRUM_PAGINATION).within(() => {
|
||||||
cy.get(".spectrum-Body--secondary").contains("Page 2")
|
cy.get(interact.SPECTRUM_BODY_SECOND).contains("Page 2")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
xit("Deletes rows and checks pagination", () => {
|
xit("Deletes rows and checks pagination", () => {
|
||||||
// Delete rows, removing second page from table
|
// Delete rows, removing second page from table
|
||||||
cy.get(".spectrum-Checkbox-input").check({ force: true })
|
cy.get(interact.SPECTRUM_CHECKBOX_INPUT).check({ force: true })
|
||||||
cy.get(".popovers").within(() => {
|
cy.get(interact.POPOVERS).within(() => {
|
||||||
cy.get(".spectrum-Button").click({ force: true })
|
cy.get(interact.SPECTRUM_BUTTON).click({ force: true })
|
||||||
})
|
})
|
||||||
cy.get(".spectrum-Dialog-grid").contains("Delete").click({ force: true })
|
cy.get(interact.SPECTRUM_DIALOG_GRID).contains("Delete").click({ force: true })
|
||||||
cy.wait(1000)
|
cy.wait(1000)
|
||||||
|
|
||||||
// Confirm table only has one page
|
// Confirm table only has one page
|
||||||
cy.get(".spectrum-Pagination").within(() => {
|
cy.get(interact.SPECTRUM_PAGINATION).within(() => {
|
||||||
cy.get(".spectrum-ActionButton").eq(1).should("not.be.enabled")
|
cy.get(interact.SPECTRUM_ACTION_BUTTON).eq(1).should("not.be.enabled")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
it("deletes a column", () => {
|
it("deletes a column", () => {
|
||||||
const columnName = "nameupdated"
|
const columnName = "nameupdated"
|
||||||
cy.get(".title").click()
|
cy.get(interact.TABLE_TITLE).click()
|
||||||
cy.get(".spectrum-Table-editIcon > use").click()
|
cy.get(interact.SPECTRUM_TABLE_EDIT).click()
|
||||||
cy.contains("Delete").click()
|
cy.contains("Delete").click()
|
||||||
cy.get('[data-cy="delete-column-confirm"]').type(columnName)
|
cy.get(interact.DELETE_COLUMN_CONFIRM).type(columnName)
|
||||||
cy.contains("Delete Column").click()
|
cy.contains("Delete Column").click()
|
||||||
cy.contains("nameupdated").should("not.exist")
|
cy.contains("nameupdated").should("not.exist")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("deletes a table", () => {
|
it("deletes a table", () => {
|
||||||
cy.get(".nav-item")
|
cy.get(interact.NAV_ITEM)
|
||||||
.contains("dog")
|
.contains("dog")
|
||||||
.parents(".nav-item")
|
.parents(interact.NAV_ITEM)
|
||||||
.first()
|
.first()
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.get(".actions .spectrum-Icon").click({ force: true })
|
cy.get(interact.ACTION_SPECTRUM_ICON).click({ force: true })
|
||||||
})
|
})
|
||||||
cy.get(".spectrum-Menu > :nth-child(2)").click()
|
cy.get(interact.SPECTRUM_MENU_CHILD2).click()
|
||||||
cy.get('[data-cy="delete-table-confirm"]').type("dog")
|
cy.get(interact.DELETE_TABLE_CONFIRM).type("dog")
|
||||||
cy.contains("Delete Table").click()
|
cy.contains("Delete Table").click()
|
||||||
cy.contains("dog").should("not.exist")
|
cy.contains("dog").should("not.exist")
|
||||||
})
|
})
|
||||||
|
|
|
@ -75,3 +75,20 @@ export const ADD_BUTTON_SPECTRUM = ".add-button .spectrum-Icon"
|
||||||
export const MODAL_INNER_WRAPPER = ".modal-inner-wrapper"
|
export const MODAL_INNER_WRAPPER = ".modal-inner-wrapper"
|
||||||
export const SPECTRUM_BUTTON_CTA = ".spectrum-Button--cta"
|
export const SPECTRUM_BUTTON_CTA = ".spectrum-Button--cta"
|
||||||
export const SPECTRUM_TEXTFIELD_INPUT = ".spectrum-Textfield-input"
|
export const SPECTRUM_TEXTFIELD_INPUT = ".spectrum-Textfield-input"
|
||||||
|
|
||||||
|
//createTable
|
||||||
|
export const TABLE_TITLE_H1 = ".table-title h1"
|
||||||
|
export const TABLE_TITLE = ".title"
|
||||||
|
export const SPECTRUM_TABLE_EDIT = ".spectrum-Table-editIcon > use"
|
||||||
|
export const SPECTRUM_SWITCH_INPUT = ".spectrum-Switch-input"
|
||||||
|
export const SPECTRUM_CHECKBOX_INPUT = ".spectrum-Checkbox-input"
|
||||||
|
export const SPECTRUM_PAGINATION = ".spectrum-Pagination"
|
||||||
|
export const SPECTRUM_ACTION_BUTTON = ".spectrum-ActionButton"
|
||||||
|
export const SPECTRUM_BODY_SECOND = ".spectrum-Body--secondary"
|
||||||
|
export const POPOVERS = ".popovers"
|
||||||
|
export const SPECTRUM_DIALOG_GRID = ".spectrum-Dialog-grid"
|
||||||
|
export const DELETE_COLUMN_CONFIRM = '[data-cy="delete-column-confirm"]'
|
||||||
|
export const NAV_ITEM = ".nav-item"
|
||||||
|
export const ACTION_SPECTRUM_ICON = ".actions .spectrum-Icon"
|
||||||
|
export const SPECTRUM_MENU_CHILD2 = ".spectrum-Menu > :nth-child(2)"
|
||||||
|
export const DELETE_TABLE_CONFIRM = '[data-cy="delete-table-confirm"]'
|
||||||
|
|
Loading…
Reference in New Issue