createView test green

This commit is contained in:
Martin McKeaveney 2021-06-02 22:38:04 +01:00
parent 2fbb9cdad0
commit 2b1b434aa8
1 changed files with 59 additions and 67 deletions

View File

@ -40,114 +40,106 @@ context("Create a View", () => {
cy.contains("Filter").click() cy.contains("Filter").click()
cy.contains("Add Filter").click() cy.contains("Add Filter").click()
cy.get(".spectrum-Picker-label").eq(0).click() cy.get(".modal-inner-wrapper").within(() => {
cy.contains("age").click() cy.get(".spectrum-Picker-label").eq(0).click()
cy.contains("age").click({ force: true })
cy.get(".spectrum-Picker-label").eq(1).click() cy.get(".spectrum-Picker-label").eq(1).click()
cy.contains("More Than").click() cy.contains("More Than").click({ force: true })
cy.get(".spectrum-Picker-label").eq(2).click() cy.get("input").type(18)
cy.contains("More Than").click() cy.contains("Save").click()
// cy.get(".menu-container") })
// .find("select")
// .first() cy.get(".spectrum-Table-row").get($values => {
// .select("age")
// cy.get(".menu-container")
// .find("select")
// .eq(1)
// .select("More Than")
cy.get(".modal-inner-wrapper")
.find("input")
.type(18)
cy.contains("Save").click()
cy.get("[role=rowgroup] .ag-row").get($values => {
expect($values).to.have.length(5) expect($values).to.have.length(5)
}) })
}) })
it("creates a stats calculation view based on age", () => { it("creates a stats calculation view based on age", () => {
// Required due to responsive bug with ag grid in cypress
cy.viewport("macbook-15")
cy.contains("Calculate").click() cy.contains("Calculate").click()
cy.get(".spectrum-Picker-label").eq(0).click() cy.get(".modal-inner-wrapper").within(() => {
cy.contains("Statistics").click() cy.get(".spectrum-Picker-label").eq(0).click()
cy.contains("Statistics").click()
cy.get(".spectrum-Picker-label").eq(1).click() cy.get(".spectrum-Picker-label").eq(1).click()
cy.contains("age").click() cy.contains("age").click({ force: true })
cy.contains("Save").click() cy.contains("Save").click()
})
cy.wait(1000) cy.wait(1000)
cy.get(".ag-center-cols-viewport").scrollTo("100%")
cy.get("[data-cy=table-header]").then($headers => { cy.get(".title").then($headers => {
expect($headers).to.have.length(7) expect($headers).to.have.length(7)
const headers = Array.from($headers).map(header => const headers = Array.from($headers).map(header =>
header.textContent.trim() header.textContent.trim()
) )
expect(removeSpacing(headers)).to.deep.eq([ expect(removeSpacing(headers)).to.deep.eq([
"avg Number", "field",
"sumsqr Number", "sum",
"count Number", "min",
"max Number", "max",
"min Number", "count",
"sum Number", "sumsqr",
"field Text", "avg",
]) ])
}) })
cy.get(".ag-cell").then($values => { cy.get(".spectrum-Table-cell").then($values => {
let values = Array.from($values).map(header => header.textContent.trim()) let values = Array.from($values).map(header => header.textContent.trim())
expect(values).to.deep.eq(["31", "5347", "5", "49", "20", "155", "age"]) expect(values).to.deep.eq(["age", "155", "20", "49", "5", "5347", "31"])
}) })
}) })
it("groups the view by group", () => { it("groups the view by group", () => {
// Required due to responsive bug with ag grid in cypress cy.contains("Group by").click()
cy.viewport("macbook-15") cy.get(".modal-inner-wrapper").within(() => {
cy.get(".spectrum-Picker-label").eq(0).click()
cy.contains("Group By").click() cy.contains("group").click()
cy.get("select").select("group") cy.contains("Save").click()
cy.contains("Save").click() })
cy.wait(1000) cy.wait(1000)
cy.get(".ag-center-cols-viewport").scrollTo("100%")
cy.contains("Students").should("be.visible") cy.contains("Students").should("be.visible")
cy.contains("Teachers").should("be.visible") cy.contains("Teachers").should("be.visible")
cy.get(".ag-row[row-index=0]") cy.get(".spectrum-Table-cell").then($values => {
.find(".ag-cell") let values = Array.from($values).map(header => header.textContent.trim())
.then($values => { expect(values).to.deep.eq([
const values = Array.from($values).map(value => value.textContent)
expect(values.sort()).to.deep.eq(
[
"Students", "Students",
"23.333333333333332",
"1650",
"3",
"25",
"20",
"70", "70",
].sort() "20",
) "25",
}) "3",
"1650",
"23.333333333333332",
"Teachers",
"85",
"36",
"49",
"2",
"3697",
"42.5",
])
})
}) })
it("renames a view", () => { it("renames a view", () => {
cy.contains(".nav-item", "Test view") cy.contains(".nav-item", "Test View")
.find(".ri-more-line") .find(".actions .icon")
.click({ force: true }) .click({ force: true })
cy.get("[data-cy=edit-view]").click() cy.contains("Edit").click()
cy.get(".modal-inner-wrapper").within(() => { cy.get(".modal-inner-wrapper").within(() => {
cy.get("input").type(" Updated") cy.get("input").type(" Updated")
cy.contains("Save").click() cy.contains("Save").click()
}) })
cy.wait(1000) cy.wait(1000)
cy.contains("Test view Updated").should("be.visible") cy.contains("Test View Updated").should("be.visible")
}) })
it("deletes a view", () => { it("deletes a view", () => {
cy.contains(".nav-item", "Test view Updated") cy.contains(".nav-item", "Test View Updated")
.find(".ri-more-line") .find(".actions .icon")
.click({ force: true }) .click({ force: true })
cy.get("[data-cy=delete-view]").click() cy.contains("Delete").click()
cy.contains("Delete View").click() cy.contains("Delete View").click()
cy.wait(1000) cy.wait(1000)
cy.contains("TestView Updated").should("not.be.visible") cy.contains("TestView Updated").should("not.be.visible")