2022-01-21 13:43:27 +01:00
|
|
|
import filterTests from "../support/filterTests"
|
2022-06-08 16:05:08 +02:00
|
|
|
const interact = require('../support/interact')
|
2022-01-21 13:43:27 +01:00
|
|
|
|
|
|
|
filterTests(['smoke', 'all'], () => {
|
2022-02-17 15:06:17 +01:00
|
|
|
context("Create a View", () => {
|
2022-01-21 13:43:27 +01:00
|
|
|
before(() => {
|
|
|
|
cy.login()
|
2022-03-29 00:21:38 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.createTestApp()
|
|
|
|
cy.createTable("data")
|
|
|
|
cy.addColumn("data", "group", "Text")
|
|
|
|
cy.addColumn("data", "age", "Number")
|
|
|
|
cy.addColumn("data", "rating", "Number")
|
|
|
|
|
|
|
|
// 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-10-05 12:13:09 +02:00
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
|
|
|
|
it("creates a view", () => {
|
|
|
|
cy.contains("Create view").click()
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.MODAL_INNER_WRAPPER).within(() => {
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.get("input").type("Test View")
|
|
|
|
cy.get("button").contains("Create View").click({ force: true })
|
|
|
|
})
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.TABLE_TITLE_H1).contains("Test View")
|
|
|
|
cy.get(interact.TITLE).then($headers => {
|
2022-01-21 13:43:27 +01:00
|
|
|
expect($headers).to.have.length(3)
|
|
|
|
const headers = Array.from($headers).map(header =>
|
|
|
|
header.textContent.trim()
|
|
|
|
)
|
|
|
|
expect(removeSpacing(headers)).to.deep.eq(["group", "age", "rating"])
|
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
})
|
|
|
|
|
2022-01-21 13:43:27 +01: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
|
|
|
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.MODAL_INNER_WRAPPER).within(() => {
|
|
|
|
cy.get(interact.SPECTRUM_PICKER_LABEL).eq(0).click()
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.contains("age").click({ force: true })
|
2021-06-02 23:38:04 +02:00
|
|
|
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.SPECTRUM_PICKER_LABEL).eq(1).click()
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.contains("More Than").click({ force: true })
|
2021-06-02 20:20:28 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.get("input").type(18)
|
|
|
|
cy.contains("Save").click()
|
|
|
|
})
|
2021-06-02 20:20:28 +02:00
|
|
|
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE_ROW).get($values => {
|
2022-01-21 13:43:27 +01:00
|
|
|
expect($values).to.have.length(5)
|
|
|
|
})
|
2020-09-25 14:12:16 +02:00
|
|
|
})
|
2021-10-01 13:48:16 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("creates a stats calculation view based on age", () => {
|
|
|
|
cy.wait(1000)
|
|
|
|
cy.contains("Calculate").click()
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.MODAL_INNER_WRAPPER).within(() => {
|
|
|
|
cy.get(interact.SPECTRUM_PICKER_LABEL).eq(0).click()
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.contains("Statistics").click()
|
|
|
|
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.SPECTRUM_PICKER_LABEL).eq(1).click()
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.contains("age").click({ force: true })
|
|
|
|
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.SPECTRUM_BUTTON).contains("Save").click({ force: true })
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
|
|
|
|
2022-06-29 19:28:32 +02:00
|
|
|
cy.wait(1000)
|
|
|
|
cy.get(interact.TITLE).then($headers => {
|
2022-01-21 13:43:27 +01:00
|
|
|
expect($headers).to.have.length(7)
|
|
|
|
const headers = Array.from($headers).map(header =>
|
|
|
|
header.textContent.trim()
|
|
|
|
)
|
|
|
|
expect(removeSpacing(headers)).to.deep.eq([
|
|
|
|
"field",
|
|
|
|
"sum",
|
|
|
|
"min",
|
|
|
|
"max",
|
|
|
|
"count",
|
|
|
|
"sumsqr",
|
|
|
|
"avg",
|
|
|
|
])
|
|
|
|
})
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE_CELL).then($values => {
|
2022-01-21 13:43:27 +01:00
|
|
|
let values = Array.from($values).map(header => header.textContent.trim())
|
|
|
|
expect(values).to.deep.eq(["age", "155", "20", "49", "5", "5347", "31"])
|
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
})
|
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("groups the view by group", () => {
|
|
|
|
cy.contains("Group by").click()
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.MODAL_INNER_WRAPPER).within(() => {
|
|
|
|
cy.get(interact.SPECTRUM_PICKER_LABEL).eq(0).click()
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.contains("group").click()
|
|
|
|
cy.contains("Save").click()
|
|
|
|
})
|
|
|
|
cy.wait(1000)
|
|
|
|
cy.contains("Students").should("be.visible")
|
|
|
|
cy.contains("Teachers").should("be.visible")
|
|
|
|
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.SPECTRUM_TABLE_CELL).then($values => {
|
2022-01-21 13:43:27 +01:00
|
|
|
let values = Array.from($values).map(header => header.textContent.trim())
|
|
|
|
expect(values).to.deep.eq([
|
|
|
|
"Students",
|
|
|
|
"70",
|
|
|
|
"20",
|
|
|
|
"25",
|
|
|
|
"3",
|
|
|
|
"1650",
|
|
|
|
"23.333333333333332",
|
|
|
|
"Teachers",
|
|
|
|
"85",
|
|
|
|
"36",
|
|
|
|
"49",
|
|
|
|
"2",
|
|
|
|
"3697",
|
|
|
|
"42.5",
|
|
|
|
])
|
|
|
|
})
|
2021-06-02 23:38:04 +02:00
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("renames a view", () => {
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.contains(interact.NAV_ITEM, "Test View")
|
2022-04-26 13:04:07 +02:00
|
|
|
.find(".actions .icon.open-popover")
|
2022-01-21 13:43:27 +01:00
|
|
|
.click({ force: true })
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.get(interact.SPECTRUM_MENU_ITEM_LABEL).contains("Edit").click()
|
|
|
|
cy.get(interact.MODAL_INNER_WRAPPER).within(() => {
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.get("input").type(" Updated")
|
|
|
|
cy.contains("Save").click()
|
|
|
|
})
|
|
|
|
cy.wait(1000)
|
|
|
|
cy.contains("Test View Updated").should("be.visible")
|
2020-10-05 12:13:09 +02:00
|
|
|
})
|
2020-08-19 17:43:04 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("deletes a view", () => {
|
2022-06-08 16:05:08 +02:00
|
|
|
cy.contains(interact.NAV_ITEM, "Test View Updated")
|
2022-04-26 13:04:07 +02:00
|
|
|
.find(".actions .icon.open-popover")
|
2022-01-21 13:43:27 +01:00
|
|
|
.click({ force: true })
|
|
|
|
cy.contains("Delete").click()
|
|
|
|
cy.contains("Delete View").click()
|
|
|
|
cy.wait(500)
|
|
|
|
cy.contains("TestView Updated").should("not.exist")
|
|
|
|
})
|
2020-09-25 14:12:16 +02:00
|
|
|
})
|
2021-03-05 15:36:38 +01:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
function removeSpacing(headers) {
|
|
|
|
let newHeaders = []
|
|
|
|
for (let header of headers) {
|
|
|
|
newHeaders.push(header.replace(/\s\s+/g, " "))
|
|
|
|
}
|
|
|
|
return newHeaders
|
2021-03-05 15:36:38 +01:00
|
|
|
}
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|