Browse Source

Fix cypress test

master
Andrew Kingston 6 years ago
parent
commit
d0806b2924
  1. 130
      packages/builder/cypress/integration/createTable.spec.js
  2. 204
      packages/builder/cypress/integration/createView.spec.js

130
packages/builder/cypress/integration/createTable.spec.js

@ -1,70 +1,62 @@
context('Create a Table', () => { context("Create a Table", () => {
before(() => { before(() => {
cy.visit('localhost:4001/_builder') cy.visit("localhost:4001/_builder")
cy.createApp('Table App', 'Table App Description') cy.createApp("Table App", "Table App Description")
}) })
it('should create a new Table', () => { it("should create a new Table", () => {
cy.createTable('dog') cy.createTable("dog")
// Check if Table exists // Check if Table exists
cy.get('.title').should('have.text', 'dog') cy.get(".title").should("have.text", "dog")
}) })
it('adds a new column to the table', () => { it("adds a new column to the table", () => {
cy.addColumn('dog', 'name', 'Plain Text') cy.addColumn("dog", "name", "Plain Text")
cy.contains("name").should("be.visible")
cy.contains('name').should("be.visible") })
})
it("creates a record in the table", () => {
it('creates a record in the table', () => { cy.addRecord(["Rover"])
cy.addRecord(["Rover"]) cy.contains("Rover").should("be.visible")
})
cy.contains('Rover').should("be.visible")
}) it("updates a column on the table", () => {
cy.contains("name").click()
it('updates a column on the table', () => { cy.get("[data-cy='edit-column-header']").click()
cy.contains("name").click() cy.get("[placeholder=Name]").type("updated")
cy.get("[data-cy='edit-column-header']").click() cy.get("select").select("Plain Text")
cy.contains("Save Column").click()
cy.get("[placeholder=Name]").type("updated") cy.contains("nameupdated").should("have.text", "nameupdated ")
cy.get("select").select("Plain Text") })
cy.contains("Save Column").click() it("edits a record", () => {
cy.get("tbody .ri-more-line").click()
cy.contains('nameupdated').should('have.text', 'nameupdated ') cy.get("[data-cy=edit-row]").click()
}) cy.get(".actions input").type("Updated")
cy.contains("Save").click()
it('edits a record', () => { cy.contains("RoverUpdated").should("have.text", "RoverUpdated")
cy.get("tbody .ri-more-line").click() })
cy.get("[data-cy=edit-row]").click()
cy.get(".actions input").type("Updated") it("deletes a record", () => {
cy.contains("Save").click() cy.get("tbody .ri-more-line").click()
cy.get("[data-cy=delete-row]").click()
cy.contains('RoverUpdated').should('have.text', 'RoverUpdated') cy.contains("Delete Row").click()
}) cy.contains("RoverUpdated").should("not.exist")
})
it('deletes a record', () => {
cy.get("tbody .ri-more-line").click() it("deletes a column", () => {
cy.get("[data-cy=delete-row]").click() cy.contains("name").click()
cy.get(".modal-actions").contains("Delete").click() cy.get("[data-cy='delete-column-header']").click()
cy.contains("nameupdated").should("not.exist")
cy.contains('RoverUpdated').should('not.exist') })
})
it("deletes a table", () => {
it('deletes a column', () => { cy.contains("div", "dog")
cy.contains("name").click() .get(".ri-more-line")
cy.get("[data-cy='delete-column-header']").click() .click()
cy.get("[data-cy=delete-table]").click()
cy.contains('nameupdated').should('not.exist') cy.contains("Delete Table").click()
}) cy.contains("dog").should("not.exist")
})
it('deletes a table', () => {
cy.contains("div", "dog").get(".ri-more-line").click()
cy.get("[data-cy=delete-table]").click()
cy.get(".modal-actions").contains("Delete").click()
cy.contains('dog').should('not.exist')
})
}) })

204
packages/builder/cypress/integration/createView.spec.js

@ -1,90 +1,100 @@
context("Create a View", () => {
before(() => {
cy.visit("localhost:4001/_builder")
cy.createApp("View App", "View App Description")
cy.createTable("data")
cy.addColumn("data", "group", "Plain Text")
cy.addColumn("data", "age", "Number")
cy.addColumn("data", "rating", "Number")
context('Create a View', () => { // 6 Records
before(() => { cy.addRecord(["Students", 25, 1])
cy.visit('localhost:4001/_builder') cy.addRecord(["Students", 20, 3])
cy.createApp('View App', 'View App Description') cy.addRecord(["Students", 18, 6])
cy.createTable('data') cy.addRecord(["Students", 25, 2])
cy.addColumn('data', 'group', 'Plain Text') cy.addRecord(["Teachers", 49, 5])
cy.addColumn('data', 'age', 'Number') cy.addRecord(["Teachers", 36, 3])
cy.addColumn('data', 'rating', 'Number') })
// 6 Records it("creates a view", () => {
cy.addRecord(["Students", 25, 1]) cy.contains("Create New View").click()
cy.addRecord(["Students", 20, 3]) cy.get("[placeholder='View Name']").type("Test View")
cy.addRecord(["Students", 18, 6]) cy.contains("Save View").click()
cy.addRecord(["Students", 25, 2]) cy.get(".title").contains("Test View")
cy.addRecord(["Teachers", 49, 5]) cy.get("thead th").should($headers => {
cy.addRecord(["Teachers", 36, 3]) expect($headers).to.have.length(3)
const headers = $headers.map((i, header) => Cypress.$(header).text())
expect(headers.get()).to.deep.eq(["group", "age", "rating"])
}) })
})
it('creates a view', () => { it("filters the view by age over 10", () => {
cy.contains("Create New View").click() cy.contains("Filter").click()
cy.get("[placeholder='View Name']").type("Test View") cy.contains("Add Filter").click()
cy.contains("Save View").click() cy.get(".menu-container")
cy.get(".title").contains("Test View") .find("select")
cy.get("thead th").should(($headers) => { .first()
expect($headers).to.have.length(3) .select("age")
const headers = $headers.map((i, header) => Cypress.$(header).text()) cy.get(".menu-container")
expect(headers.get()).to.deep.eq([ .find("select")
"group", .eq(1)
"age", .select("More Than")
"rating" cy.get("input[placeholder='age']").type(18)
]) cy.contains("Save").click()
}) cy.get("tbody tr").should($values => {
}); expect($values).to.have.length(5)
})
it('filters the view by age over 10', () => { })
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")
cy.get("input[placeholder='age']").type(18)
cy.contains("Save").click()
cy.get("tbody tr").should(($values) => {
expect($values).to.have.length(5)
})
});
it('creates a stats calculation view based on age', () => { it("creates a stats calculation view based on age", () => {
cy.contains("Calculate").click() cy.contains("Calculate").click()
cy.get(".menu-container").find("select").first().select("Statistics") cy.get(".menu-container")
cy.get(".menu-container").find("select").eq(1).select("age") .find("select")
cy.contains("Save").click() .first()
cy.get("thead th").should(($headers) => { .select("Statistics")
expect($headers).to.have.length(7) cy.get(".menu-container")
const headers = $headers.map((i, header) => Cypress.$(header).text()) .find("select")
expect(headers.get()).to.deep.eq([ .eq(1)
"field", .select("age")
"sum", cy.contains("Save").click()
"min", cy.get("thead th").should($headers => {
"max", expect($headers).to.have.length(7)
"count", const headers = $headers.map((i, header) => Cypress.$(header).text())
"sumsqr", expect(headers.get()).to.deep.eq([
"avg", "field",
]) "sum",
}) "min",
cy.get("tbody td").should(($values) => { "max",
const values = $values.map((i, value) => Cypress.$(value).text()) "count",
expect(values.get()).to.deep.eq([ "sumsqr",
"age", "avg",
"155", ])
"20",
"49",
"5",
"5347",
"31"
])
})
}) })
cy.get("tbody td").should($values => {
const values = $values.map((i, value) => Cypress.$(value).text())
expect(values.get()).to.deep.eq([
"age",
"155",
"20",
"49",
"5",
"5347",
"31",
])
})
})
it('groups the view by group', () => { it("groups the view by group", () => {
cy.contains("Group By").click() cy.contains("Group By").click()
cy.get("select").select("group") cy.get("select").select("group")
cy.contains("Save").click() cy.contains("Save").click()
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("tbody tr").first().find("td").should(($values) => { cy.get("tbody tr")
.first()
.find("td")
.should($values => {
const values = $values.map((i, value) => Cypress.$(value).text()) const values = $values.map((i, value) => Cypress.$(value).text())
expect(values.get()).to.deep.eq([ expect(values.get()).to.deep.eq([
"Students", "Students",
@ -93,24 +103,28 @@ context('Create a View', () => {
"25", "25",
"3", "3",
"1650", "1650",
"23.333333333333332" "23.333333333333332",
]) ])
}) })
}) })
it('renames a view', () => { it("renames a view", () => {
cy.contains("[data-cy=model-nav-item]", "Test View").find(".ri-more-line").click() cy.contains("[data-cy=model-nav-item]", "Test View")
cy.contains("Edit").click() .find(".ri-more-line")
cy.get("[placeholder='View Name']").type(" Updated") .click()
cy.contains("Save").click() cy.contains("Edit").click()
cy.contains("Test View Updated").should("be.visible") cy.get("[placeholder='View Name']").type(" Updated")
}) cy.contains("Save").click()
cy.contains("Test View Updated").should("be.visible")
})
it('deletes a view', () => { it("deletes a view", () => {
cy.contains("[data-cy=model-nav-item]", "Test View Updated").click() cy.contains("[data-cy=model-nav-item]", "Test View Updated").click()
cy.contains("[data-cy=model-nav-item]", "Test View Updated").find(".ri-more-line").click() cy.contains("[data-cy=model-nav-item]", "Test View Updated")
cy.contains("Delete").click() .find(".ri-more-line")
cy.get(".content").contains("button", "Delete").click() .click()
cy.contains("TestView Updated").should("not.be.visible") cy.contains("Delete").click()
}) cy.contains("Delete View").click()
cy.contains("TestView Updated").should("not.be.visible")
})
}) })

Loading…
Cancel
Save