1
0
Fork 0
mirror of synced 2024-07-07 23:35:49 +12:00
budibase/packages/builder/cypress/integration/createView.spec.js

138 lines
3.8 KiB
JavaScript
Raw Normal View History

2020-09-26 00:12:16 +12:00
context("Create a View", () => {
before(() => {
cy.visit("localhost:4001/_builder")
cy.createApp("View App", "View App Description")
cy.createTable("data")
cy.addColumn("data", "group", "Text")
2020-09-26 00:12:16 +12:00
cy.addColumn("data", "age", "Number")
cy.addColumn("data", "rating", "Number")
2020-08-25 02:48:34 +12: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-26 00:12:16 +12:00
})
2020-08-20 03:43:04 +12:00
2020-09-26 00:12:16 +12:00
it("creates a view", () => {
cy.contains("Create New View").click()
cy.get(".menu-container").within(() => {
cy.get("input").type("Test View")
cy.contains("Save View").click()
})
2020-09-26 00:12:16 +12:00
cy.get(".title").contains("Test View")
2020-10-28 05:01:27 +13:00
cy.get("[data-cy=table-header]").then($headers => {
2020-09-26 00:12:16 +12:00
expect($headers).to.have.length(3)
2020-10-28 05:01:27 +13:00
// const headers = $headers.map(header => header.text())
// expect(headers).to.deep.eq(["group", "age", "rating"])
2020-08-20 03:43:04 +12:00
})
2020-09-26 00:12:16 +12:00
})
2020-08-20 03:43:04 +12:00
2020-10-28 05:01:27 +13:00
xit("filters the view by age over 10", () => {
2020-09-26 00:12:16 +12:00
cy.contains("Filter").click()
cy.contains("Add Filter").click()
cy.get(".menu-container")
.find("select")
.first()
.select("age")
cy.get(".menu-container")
.find("select")
.eq(1)
.select("More Than")
2020-10-28 05:01:27 +13:00
cy.get(".menu-container").find("input").type(18)
2020-09-26 00:12:16 +12:00
cy.contains("Save").click()
2020-10-28 05:01:27 +13:00
cy.get(".ag-center-cols-container > div.ag-row").get($values => {
2020-09-26 00:12:16 +12:00
expect($values).to.have.length(5)
})
})
2020-08-25 02:48:34 +12:00
2020-10-28 05:01:27 +13:00
xit("creates a stats calculation view based on age", () => {
2020-09-26 00:12:16 +12:00
cy.contains("Calculate").click()
cy.get(".menu-container")
.find("select")
.eq(0)
2020-10-16 10:21:08 +13:00
.select("Statistics")
cy.wait(50)
cy.get(".menu-container")
.find("select")
.eq(1)
2020-09-26 00:12:16 +12:00
.select("age")
cy.contains("Save").click()
2020-10-28 05:01:27 +13:00
cy.get("[data-cy=table-header] span").then($headers => {
cy.log($headers)
2020-09-26 00:12:16 +12:00
expect($headers).to.have.length(7)
2020-10-28 05:01:27 +13:00
const headers = $headers.map(header => header.textContent)
cy.log(headers)
expect(headers).to.deep.eq([
2020-09-26 00:12:16 +12:00
"field",
"sum",
"min",
"max",
"count",
"sumsqr",
"avg",
])
2020-08-20 03:43:04 +12:00
})
2020-10-28 05:01:27 +13:00
// cy.get("tbody td").then($values => {
// const values = $values.map((i, value) => Cypress.$(value).text())
// expect(values.get()).to.deep.eq([
// "age",
// "155",
// "20",
// "49",
// "5",
// "5347",
// "31",
// ])
// })
2020-09-26 00:12:16 +12:00
})
2020-08-20 03:43:04 +12:00
2020-10-28 05:01:27 +13:00
xit("groups the view by group", () => {
2020-09-26 00:12:16 +12:00
cy.contains("Group By").click()
cy.get("select").select("group")
cy.contains("Save").click()
cy.contains("Students").should("be.visible")
cy.contains("Teachers").should("be.visible")
2020-08-20 03:43:04 +12:00
2020-10-28 05:01:27 +13:00
cy.get(".ag-center-cols-container > div.ag-row")
2020-09-26 00:12:16 +12:00
.first()
2020-10-28 05:01:27 +13:00
.find(".ag-cell")
.then($values => {
const values = $values.map(value => value.textContent)
expect(values).to.deep.eq([
2020-08-20 03:43:04 +12:00
"Students",
2020-08-25 02:48:34 +12:00
"70",
"20",
2020-08-20 03:43:04 +12:00
"25",
2020-08-25 02:48:34 +12:00
"3",
"1650",
2020-09-26 00:12:16 +12:00
"23.333333333333332",
2020-08-20 03:43:04 +12:00
])
})
2020-09-26 00:12:16 +12:00
})
2020-08-20 03:43:04 +12:00
2020-09-26 00:12:16 +12:00
it("renames a view", () => {
cy.contains("[data-cy=table-nav-item]", "Test View")
2020-09-26 00:12:16 +12:00
.find(".ri-more-line")
.click()
cy.contains("Edit").click()
cy.get(".menu-container").within(() => {
cy.get("input").type(" Updated")
cy.contains("Save").click()
})
2020-09-26 00:12:16 +12:00
cy.contains("Test View Updated").should("be.visible")
})
2020-08-20 03:43:04 +12:00
2020-09-26 00:12:16 +12:00
it("deletes a view", () => {
cy.contains("[data-cy=table-nav-item]", "Test View Updated").click()
cy.contains("[data-cy=table-nav-item]", "Test View Updated")
2020-09-26 00:12:16 +12:00
.find(".ri-more-line")
.click()
cy.contains("Delete").click()
cy.contains("Delete View").click()
cy.contains("TestView Updated").should("not.be.visible")
})
2020-08-20 03:43:04 +12:00
})