2022-01-21 13:43:27 +01:00
|
|
|
import filterTests from "../support/filterTests"
|
2020-06-11 12:56:16 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
filterTests(['all'], () => {
|
2022-05-17 16:09:13 +02:00
|
|
|
context("Create Components", () => {
|
2022-01-21 13:43:27 +01:00
|
|
|
let headlineId
|
2021-03-05 14:52:26 +01:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
before(() => {
|
|
|
|
cy.login()
|
|
|
|
cy.createTestApp()
|
|
|
|
cy.createTable("dog")
|
|
|
|
cy.addColumn("dog", "name", "Text")
|
|
|
|
cy.addColumn("dog", "age", "Number")
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.addColumn("dog", "breed", "Options")
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.navigateToFrontend()
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.wait(1000) //allow the iframe some wiggle room
|
2021-03-05 14:52:26 +01:00
|
|
|
})
|
2020-06-11 12:56:16 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should add a container", () => {
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.addComponent("Layout", "Container").then(componentId => {
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.getComponent(componentId).should("exist")
|
|
|
|
})
|
|
|
|
})
|
2021-03-05 14:52:26 +01:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should add a headline", () => {
|
|
|
|
cy.addComponent("Elements", "Headline").then(componentId => {
|
|
|
|
headlineId = componentId
|
|
|
|
cy.getComponent(headlineId).should("exist")
|
|
|
|
})
|
|
|
|
})
|
2020-06-11 12:56:16 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should change the text of the headline", () => {
|
|
|
|
const text = "Lorem ipsum dolor sit amet."
|
|
|
|
cy.get("[data-cy=setting-text] input")
|
|
|
|
.type(text)
|
|
|
|
.blur()
|
|
|
|
cy.getComponent(headlineId).should("have.text", text)
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should change the size of the headline", () => {
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.get("[data-cy=setting-size]").scrollIntoView().click()
|
|
|
|
cy.get("[data-cy=setting-size]").within(() => {
|
|
|
|
cy.get(".spectrum-Form-item li.spectrum-Menu-item").contains("3XL").click()
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.getComponent(headlineId).within(() => {
|
|
|
|
cy.get(".spectrum-Heading").should("have.css", "font-size", "60px")
|
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it("should create a form and reset to match schema", () => {
|
|
|
|
cy.addComponent("Form", "Form").then(() => {
|
|
|
|
cy.get("[data-cy=setting-dataSource]")
|
2022-05-17 16:09:13 +02:00
|
|
|
.contains("Custom")
|
2022-01-21 13:43:27 +01:00
|
|
|
.click()
|
|
|
|
cy.get(".dropdown")
|
|
|
|
.contains("dog")
|
2021-03-05 14:52:26 +01:00
|
|
|
.click()
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.addComponent("Form", "Field Group").then(fieldGroupId => {
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.contains("Update form fields").click()
|
|
|
|
cy.get(".spectrum-Modal")
|
|
|
|
.get(".confirm-wrap .spectrum-Button")
|
2022-01-21 13:43:27 +01:00
|
|
|
.click()
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.wait(500)
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.getComponent(fieldGroupId).within(() => {
|
|
|
|
cy.contains("name").should("exist")
|
|
|
|
cy.contains("age").should("exist")
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.contains("breed").should("exist")
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
|
|
|
cy.getComponent(fieldGroupId)
|
|
|
|
.find("input")
|
|
|
|
.should("have.length", 2)
|
|
|
|
cy.getComponent(fieldGroupId)
|
|
|
|
.find(".spectrum-Picker")
|
|
|
|
.should("have.length", 1)
|
2021-03-05 14:52:26 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2021-03-08 12:57:56 +01:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("deletes a component", () => {
|
|
|
|
cy.addComponent("Elements", "Paragraph").then(componentId => {
|
|
|
|
cy.get("[data-cy=setting-_instanceName] input")
|
|
|
|
.type(componentId)
|
|
|
|
.blur()
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.get(".nav-items-container .nav-item.selected .actions > div > .icon").click({
|
2022-01-21 13:43:27 +01:00
|
|
|
force: true,
|
|
|
|
})
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.get(".spectrum-Popover.is-open li")
|
2022-01-21 13:43:27 +01:00
|
|
|
.contains("Delete")
|
|
|
|
.click()
|
2022-05-17 16:09:13 +02:00
|
|
|
cy.get(".spectrum-Modal button")
|
2022-01-21 13:43:27 +01:00
|
|
|
.contains("Delete Component")
|
2022-05-17 16:09:13 +02:00
|
|
|
.click({
|
|
|
|
force: true,
|
|
|
|
})
|
2022-01-21 13:43:27 +01:00
|
|
|
cy.getComponent(componentId).should("not.exist")
|
2021-03-08 12:57:56 +01:00
|
|
|
})
|
|
|
|
})
|
2022-05-17 16:09:13 +02:00
|
|
|
|
|
|
|
it("should set focus to the field setting when fields are added to a form", () => {
|
|
|
|
cy.addComponent("Form", "Form").then(() => {
|
|
|
|
cy.get("[data-cy=setting-dataSource]")
|
|
|
|
.contains("Custom")
|
|
|
|
.click()
|
|
|
|
cy.get(".dropdown")
|
|
|
|
.contains("dog")
|
|
|
|
.click()
|
|
|
|
|
|
|
|
const componentTypeLabels = ["Text Field", "Number Field", "Password Field",
|
|
|
|
"Options Picker", "Checkbox", "Long Form Field", "Date Picker", "Attachment",
|
|
|
|
"JSON Field", "Multi-select Picker", "Relationship Picker"]
|
|
|
|
|
|
|
|
const refocusTest = (componentId) => {
|
|
|
|
let inputClasses
|
|
|
|
|
|
|
|
cy.getComponent(componentId)
|
|
|
|
.find(".showMe").should("exist").click({ force: true })
|
|
|
|
|
|
|
|
cy.get("[data-cy=setting-field] .spectrum-InputGroup")
|
|
|
|
.should("have.class", "is-focused").within(() => {
|
|
|
|
cy.get("input").should(($input) => {
|
|
|
|
expect($input).to.have.length(1)
|
|
|
|
inputClasses = Cypress.$($input).attr('class')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.focused().then(($focused) => {
|
|
|
|
const focusedClasses = Cypress.$($focused).attr('class')
|
|
|
|
expect(inputClasses).to.equal(focusedClasses)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const testFieldFocusOnCreate = (componentLabel) => {
|
|
|
|
let inputClasses
|
|
|
|
|
|
|
|
cy.addComponent("Form", componentLabel).then((componentId) => {
|
|
|
|
|
|
|
|
refocusTest(componentId)
|
|
|
|
|
|
|
|
cy.get("[data-cy=setting-field] .spectrum-InputGroup")
|
|
|
|
.should("have.class", "is-focused").within(() => {
|
|
|
|
cy.get("input").should(($input) => {
|
|
|
|
expect($input).to.have.length(1)
|
|
|
|
inputClasses = Cypress.$($input).attr('class')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
cy.focused().then(($focused) => {
|
|
|
|
const focusedClasses = Cypress.$($focused).attr('class')
|
|
|
|
expect(inputClasses).to.equal(focusedClasses)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
componentTypeLabels.forEach( testFieldFocusOnCreate )
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
2021-03-08 12:57:56 +01:00
|
|
|
})
|
2020-06-11 12:56:16 +02:00
|
|
|
})
|