2020-09-26 00:12:16 +12:00
|
|
|
context("Create a Table", () => {
|
|
|
|
before(() => {
|
2021-04-16 05:29:11 +12:00
|
|
|
cy.login()
|
2021-03-06 03:36:38 +13:00
|
|
|
cy.createTestApp()
|
2020-09-26 00:12:16 +12:00
|
|
|
})
|
|
|
|
|
|
|
|
it("should create a new Table", () => {
|
|
|
|
cy.createTable("dog")
|
2021-09-29 00:26:38 +13:00
|
|
|
cy.wait(1000)
|
2020-09-26 00:12:16 +12:00
|
|
|
// Check if Table exists
|
2020-10-28 04:26:07 +13:00
|
|
|
cy.get(".table-title h1").should("have.text", "dog")
|
2020-09-26 00:12:16 +12:00
|
|
|
})
|
|
|
|
|
|
|
|
it("adds a new column to the table", () => {
|
2020-10-05 23:13:09 +13:00
|
|
|
cy.addColumn("dog", "name", "Text")
|
2020-09-26 00:12:16 +12:00
|
|
|
cy.contains("name").should("be.visible")
|
|
|
|
})
|
|
|
|
|
2020-10-10 07:10:28 +13:00
|
|
|
it("creates a row in the table", () => {
|
|
|
|
cy.addRow(["Rover"])
|
2020-09-26 00:12:16 +12:00
|
|
|
cy.contains("Rover").should("be.visible")
|
|
|
|
})
|
|
|
|
|
|
|
|
it("updates a column on the table", () => {
|
2021-05-26 05:06:56 +12:00
|
|
|
cy.get(".title").click()
|
|
|
|
cy.get(".spectrum-Table-editIcon > use").click()
|
2021-10-02 01:58:15 +13:00
|
|
|
cy.get("input").eq(1).type("updated", { force: true })
|
2020-10-15 20:17:26 +13:00
|
|
|
// Unset table display column
|
2021-05-26 05:06:56 +12:00
|
|
|
cy.get(".spectrum-Switch-input").eq(1).click()
|
2020-09-26 00:12:16 +12:00
|
|
|
cy.contains("Save Column").click()
|
2021-05-26 05:06:56 +12:00
|
|
|
cy.contains("nameupdated ").should("contain", "nameupdated")
|
2020-09-26 00:12:16 +12:00
|
|
|
})
|
2021-10-15 04:45:27 +13:00
|
|
|
|
2020-10-10 07:10:28 +13:00
|
|
|
it("edits a row", () => {
|
2020-10-29 05:05:19 +13:00
|
|
|
cy.contains("button", "Edit").click({ force: true })
|
|
|
|
cy.wait(1000)
|
2021-09-29 23:27:58 +13:00
|
|
|
cy.get(".spectrum-Modal input").clear()
|
2021-10-13 01:02:08 +13:00
|
|
|
cy.get(".spectrum-Modal input").type("Updated")
|
2020-09-26 00:12:16 +12:00
|
|
|
cy.contains("Save").click()
|
2021-09-28 06:19:25 +13:00
|
|
|
cy.contains("Updated").should("have.text", "Updated")
|
2020-09-26 00:12:16 +12:00
|
|
|
})
|
2021-10-15 04:45:27 +13:00
|
|
|
|
2020-10-10 07:10:28 +13:00
|
|
|
it("deletes a row", () => {
|
2021-05-26 05:06:56 +12:00
|
|
|
cy.get(".spectrum-Checkbox-input").check({ force: true })
|
2020-10-28 05:01:27 +13:00
|
|
|
cy.contains("Delete 1 row(s)").click()
|
2021-10-02 01:58:15 +13:00
|
|
|
cy.get(".spectrum-Modal").contains("Delete").click()
|
2020-09-26 00:12:16 +12:00
|
|
|
cy.contains("RoverUpdated").should("not.exist")
|
|
|
|
})
|
2021-11-16 04:25:58 +13:00
|
|
|
|
|
|
|
it("Adds 15 rows and checks pagination", () => {
|
|
|
|
// 10 rows per page, 15 rows should create 2 pages within table
|
|
|
|
const totalRows = 16
|
|
|
|
for (let i = 1; i < totalRows; i++){
|
|
|
|
cy.addRow([i])
|
|
|
|
}
|
|
|
|
cy.wait(1000)
|
|
|
|
cy.get(".spectrum-Pagination").within(() => {
|
|
|
|
cy.get(".spectrum-ActionButton").eq(1).click()
|
|
|
|
})
|
|
|
|
cy.get(".spectrum-Pagination").within(() => {
|
|
|
|
cy.get(".spectrum-Body--secondary").contains("Page 2")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it("Deletes rows and checks pagination", () => {
|
|
|
|
// Delete rows, removing second page of rows from table
|
|
|
|
const deleteRows = 5
|
|
|
|
cy.get(".spectrum-Checkbox-input").check({ force: true })
|
|
|
|
cy.get(".spectrum-Table-body")
|
|
|
|
cy.contains("Delete 5 row(s)").click()
|
|
|
|
cy.get(".spectrum-Modal").contains("Delete").click()
|
|
|
|
cy.wait(1000)
|
|
|
|
|
|
|
|
// Confirm table only has one page
|
|
|
|
cy.get(".spectrum-Pagination").within(() => {
|
|
|
|
cy.get(".spectrum-ActionButton").eq(1).should('not.be.enabled')
|
|
|
|
})
|
|
|
|
})
|
2020-09-26 00:12:16 +12:00
|
|
|
|
|
|
|
it("deletes a column", () => {
|
2021-12-24 23:38:03 +13:00
|
|
|
const columnName = "nameupdated"
|
2021-05-26 05:06:56 +12:00
|
|
|
cy.get(".title").click()
|
|
|
|
cy.get(".spectrum-Table-editIcon > use").click()
|
2020-10-28 22:50:05 +13:00
|
|
|
cy.contains("Delete").click()
|
2021-12-24 23:38:03 +13:00
|
|
|
cy.get('[data-cy="delete-column-confirm"]').type(columnName)
|
2021-10-02 01:58:15 +13:00
|
|
|
cy.contains("Delete Column").click()
|
2020-09-26 00:12:16 +12:00
|
|
|
cy.contains("nameupdated").should("not.exist")
|
|
|
|
})
|
|
|
|
|
|
|
|
it("deletes a table", () => {
|
2021-10-02 01:58:15 +13:00
|
|
|
cy.get(".nav-item")
|
|
|
|
.contains("dog")
|
|
|
|
.parents(".nav-item")
|
|
|
|
.first()
|
|
|
|
.within(() => {
|
|
|
|
cy.get(".actions .spectrum-Icon").click({ force: true })
|
|
|
|
})
|
2021-06-02 23:32:07 +12:00
|
|
|
cy.get(".spectrum-Menu > :nth-child(2)").click()
|
2021-12-24 23:38:03 +13:00
|
|
|
cy.get('[data-cy="delete-table-confirm"]').type("dog")
|
2020-09-26 00:12:16 +12:00
|
|
|
cy.contains("Delete Table").click()
|
|
|
|
cy.contains("dog").should("not.exist")
|
|
|
|
})
|
2020-08-08 05:31:40 +12:00
|
|
|
})
|