2020-09-25 14:12:16 +02:00
|
|
|
context("Create a View", () => {
|
|
|
|
before(() => {
|
2021-04-15 19:29:11 +02:00
|
|
|
cy.login()
|
2021-03-05 15:36:38 +01:00
|
|
|
cy.createTestApp()
|
2020-09-25 14:12:16 +02:00
|
|
|
cy.createTable("data")
|
2020-10-05 12:13:09 +02:00
|
|
|
cy.addColumn("data", "group", "Text")
|
2020-09-25 14:12:16 +02:00
|
|
|
cy.addColumn("data", "age", "Number")
|
|
|
|
cy.addColumn("data", "rating", "Number")
|
2020-08-24 16:48:34 +02:00
|
|
|
|
2020-10-09 20:10:28 +02:00
|
|
|
// 6 Rows
|
|
|
|
cy.addRow(["Students", 25, 1])
|
|
|
|
cy.addRow(["Students", 20, 3])
|
|
|
|
cy.addRow(["Students", 18, 6])
|
|
|
|
cy.addRow(["Students", 25, 2])
|
|
|
|
cy.addRow(["Teachers", 49, 5])
|
|
|
|
cy.addRow(["Teachers", 36, 3])
|
2020-09-25 14:12:16 +02:00
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
|
2020-09-25 14:12:16 +02:00
|
|
|
it("creates a view", () => {
|
2021-06-02 19:28:05 +02:00
|
|
|
cy.contains("Create view").click()
|
2021-06-02 20:21:55 +02:00
|
|
|
cy.get(".modal-inner-wrapper").within(() => {
|
|
|
|
cy.get("input").type("Test View")
|
|
|
|
cy.get("button").contains("Create View").click({ force: true })
|
2020-10-05 12:13:09 +02:00
|
|
|
})
|
2021-06-02 20:21:55 +02:00
|
|
|
cy.get(".table-title h1").contains("Test View")
|
|
|
|
cy.get(".title").then($headers => {
|
2020-09-25 14:12:16 +02:00
|
|
|
expect($headers).to.have.length(3)
|
2020-10-28 16:20:56 +01:00
|
|
|
const headers = Array.from($headers).map(header =>
|
|
|
|
header.textContent.trim()
|
|
|
|
)
|
2021-03-05 15:36:38 +01:00
|
|
|
expect(removeSpacing(headers)).to.deep.eq([
|
2021-06-02 20:21:55 +02:00
|
|
|
"group",
|
|
|
|
"age",
|
|
|
|
"rating",
|
2021-03-05 15:36:38 +01:00
|
|
|
])
|
2020-08-19 17:43:04 +02:00
|
|
|
})
|
2020-09-25 14:12:16 +02:00
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
|
2020-09-25 14:12:16 +02:00
|
|
|
it("filters the view by age over 10", () => {
|
|
|
|
cy.contains("Filter").click()
|
|
|
|
cy.contains("Add Filter").click()
|
2021-06-02 20:20:28 +02:00
|
|
|
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.get(".modal-inner-wrapper").within(() => {
|
|
|
|
cy.get(".spectrum-Picker-label").eq(0).click()
|
|
|
|
cy.contains("age").click({ force: true })
|
|
|
|
|
|
|
|
cy.get(".spectrum-Picker-label").eq(1).click()
|
|
|
|
cy.contains("More Than").click({ force: true })
|
2021-06-02 20:20:28 +02:00
|
|
|
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.get("input").type(18)
|
|
|
|
cy.contains("Save").click()
|
|
|
|
})
|
2021-06-02 20:20:28 +02:00
|
|
|
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.get(".spectrum-Table-row").get($values => {
|
2020-09-25 14:12:16 +02:00
|
|
|
expect($values).to.have.length(5)
|
|
|
|
})
|
|
|
|
})
|
2020-08-24 16:48:34 +02:00
|
|
|
|
2020-09-25 14:12:16 +02:00
|
|
|
it("creates a stats calculation view based on age", () => {
|
|
|
|
cy.contains("Calculate").click()
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.get(".modal-inner-wrapper").within(() => {
|
|
|
|
cy.get(".spectrum-Picker-label").eq(0).click()
|
|
|
|
cy.contains("Statistics").click()
|
|
|
|
|
|
|
|
cy.get(".spectrum-Picker-label").eq(1).click()
|
|
|
|
cy.contains("age").click({ force: true })
|
2021-06-02 20:20:28 +02:00
|
|
|
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.contains("Save").click()
|
|
|
|
})
|
2021-04-01 13:56:27 +02:00
|
|
|
cy.wait(1000)
|
2021-06-02 23:38:04 +02:00
|
|
|
|
|
|
|
cy.get(".title").then($headers => {
|
2020-09-25 14:12:16 +02:00
|
|
|
expect($headers).to.have.length(7)
|
2020-10-28 16:20:56 +01:00
|
|
|
const headers = Array.from($headers).map(header =>
|
|
|
|
header.textContent.trim()
|
|
|
|
)
|
2021-03-05 15:36:38 +01:00
|
|
|
expect(removeSpacing(headers)).to.deep.eq([
|
2021-06-02 23:38:04 +02:00
|
|
|
"field",
|
|
|
|
"sum",
|
|
|
|
"min",
|
|
|
|
"max",
|
|
|
|
"count",
|
|
|
|
"sumsqr",
|
|
|
|
"avg",
|
2021-03-05 15:36:38 +01:00
|
|
|
])
|
2020-08-19 17:43:04 +02:00
|
|
|
})
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.get(".spectrum-Table-cell").then($values => {
|
2021-03-05 15:36:38 +01:00
|
|
|
let values = Array.from($values).map(header => header.textContent.trim())
|
2021-06-02 23:38:04 +02:00
|
|
|
expect(values).to.deep.eq(["age", "155", "20", "49", "5", "5347", "31"])
|
2020-09-25 14:12:16 +02:00
|
|
|
})
|
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
|
2020-09-25 14:12:16 +02:00
|
|
|
it("groups the view by group", () => {
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.contains("Group by").click()
|
|
|
|
cy.get(".modal-inner-wrapper").within(() => {
|
|
|
|
cy.get(".spectrum-Picker-label").eq(0).click()
|
|
|
|
cy.contains("group").click()
|
|
|
|
cy.contains("Save").click()
|
|
|
|
})
|
2021-04-01 14:10:58 +02:00
|
|
|
cy.wait(1000)
|
2020-09-25 14:12:16 +02:00
|
|
|
cy.contains("Students").should("be.visible")
|
|
|
|
cy.contains("Teachers").should("be.visible")
|
2020-08-19 17:43:04 +02:00
|
|
|
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.get(".spectrum-Table-cell").then($values => {
|
|
|
|
let values = Array.from($values).map(header => header.textContent.trim())
|
|
|
|
expect(values).to.deep.eq([
|
2021-04-07 14:46:26 +02:00
|
|
|
"Students",
|
|
|
|
"70",
|
2021-06-02 23:38:04 +02:00
|
|
|
"20",
|
|
|
|
"25",
|
|
|
|
"3",
|
|
|
|
"1650",
|
|
|
|
"23.333333333333332",
|
|
|
|
"Teachers",
|
|
|
|
"85",
|
|
|
|
"36",
|
|
|
|
"49",
|
|
|
|
"2",
|
|
|
|
"3697",
|
|
|
|
"42.5",
|
|
|
|
])
|
|
|
|
})
|
2020-09-25 14:12:16 +02:00
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
|
2020-09-25 14:12:16 +02:00
|
|
|
it("renames a view", () => {
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.contains(".nav-item", "Test View")
|
|
|
|
.find(".actions .icon")
|
2021-02-06 23:41:27 +01:00
|
|
|
.click({ force: true })
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.contains("Edit").click()
|
2021-06-02 20:21:55 +02:00
|
|
|
cy.get(".modal-inner-wrapper").within(() => {
|
2020-10-05 12:13:09 +02:00
|
|
|
cy.get("input").type(" Updated")
|
|
|
|
cy.contains("Save").click()
|
|
|
|
})
|
2021-04-01 14:10:58 +02:00
|
|
|
cy.wait(1000)
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.contains("Test View Updated").should("be.visible")
|
2020-09-25 14:12:16 +02:00
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
|
2020-09-25 14:12:16 +02:00
|
|
|
it("deletes a view", () => {
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.contains(".nav-item", "Test View Updated")
|
|
|
|
.find(".actions .icon")
|
2021-02-06 23:41:27 +01:00
|
|
|
.click({ force: true })
|
2021-06-02 23:38:04 +02:00
|
|
|
cy.contains("Delete").click()
|
2020-09-25 14:12:16 +02:00
|
|
|
cy.contains("Delete View").click()
|
2021-04-01 14:10:58 +02:00
|
|
|
cy.wait(1000)
|
2020-09-25 14:12:16 +02:00
|
|
|
cy.contains("TestView Updated").should("not.be.visible")
|
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
})
|
2021-03-05 15:36:38 +01:00
|
|
|
|
|
|
|
function removeSpacing(headers) {
|
|
|
|
let newHeaders = []
|
|
|
|
for (let header of headers) {
|
|
|
|
newHeaders.push(header.replace(/\s\s+/g, " "))
|
|
|
|
}
|
|
|
|
return newHeaders
|
|
|
|
}
|