Browse Source

Update commands.js

master
Mitch-Budibase 5 years ago
parent
commit
417826ffed
  1. 95
      packages/builder/cypress/support/commands.js

95
packages/builder/cypress/support/commands.js

@ -101,29 +101,32 @@ Cypress.Commands.add("createTable", tableName => {
cy.contains(tableName).should("be.visible") cy.contains(tableName).should("be.visible")
}) })
Cypress.Commands.add("addColumn", (tableName, columnName, type, multiOptions = null) => { Cypress.Commands.add(
// Select Table "addColumn",
cy.selectTable(tableName) (tableName, columnName, type, multiOptions = null) => {
cy.contains(".nav-item", tableName).click() // Select Table
cy.contains("Create column").click() cy.selectTable(tableName)
cy.contains(".nav-item", tableName).click()
// Configure column cy.contains("Create column").click()
cy.get(".spectrum-Modal").within(() => {
cy.get("input").first().type(columnName).blur() // Configure column
cy.get(".spectrum-Modal").within(() => {
// Unset table display column cy.get("input").first().type(columnName).blur()
cy.contains("display column").click({ force: true })
cy.get(".spectrum-Picker-label").click() // Unset table display column
cy.contains(type).click() cy.contains("display column").click({ force: true })
cy.get(".spectrum-Picker-label").click()
// Add options for Multi-select Type cy.contains(type).click()
if(multiOptions !== null){
cy.get(".spectrum-Textfield-input").eq(1).type(multiOptions) // Add options for Multi-select Type
} if (multiOptions !== null) {
cy.get(".spectrum-Textfield-input").eq(1).type(multiOptions)
}
cy.contains("Save Column").click() cy.contains("Save Column").click()
}) })
}) }
)
Cypress.Commands.add("addRow", values => { Cypress.Commands.add("addRow", values => {
cy.contains("Create row").click() cy.contains("Create row").click()
@ -137,15 +140,17 @@ Cypress.Commands.add("addRow", values => {
Cypress.Commands.add("addRowMultiValue", values => { Cypress.Commands.add("addRowMultiValue", values => {
cy.contains("Create row").click() cy.contains("Create row").click()
cy.get(".spectrum-Form-itemField").click().then(() => { cy.get(".spectrum-Form-itemField")
cy.get(".spectrum-Popover").within(() => { .click()
for (let i = 0; i < values.length; i++) { .then(() => {
cy.get(".spectrum-Menu-item").eq(i).click() cy.get(".spectrum-Popover").within(() => {
} for (let i = 0; i < values.length; i++) {
cy.get(".spectrum-Menu-item").eq(i).click()
}
})
cy.get(".spectrum-Dialog-grid").click("top")
cy.get(".spectrum-ButtonGroup").contains("Create").click()
}) })
cy.get(".spectrum-Dialog-grid").click('top')
cy.get(".spectrum-ButtonGroup").contains("Create").click()
})
}) })
Cypress.Commands.add("createUser", email => { Cypress.Commands.add("createUser", email => {
@ -166,7 +171,7 @@ Cypress.Commands.add("addComponent", (category, component) => {
if (category) { if (category) {
cy.get(`[data-cy="category-${category}"]`).click() cy.get(`[data-cy="category-${category}"]`).click()
} }
if (component){ if (component) {
cy.get(`[data-cy="component-${component}"]`).click() cy.get(`[data-cy="component-${component}"]`).click()
} }
cy.wait(1000) cy.wait(1000)
@ -219,16 +224,22 @@ Cypress.Commands.add("selectTable", tableName => {
}) })
Cypress.Commands.add("addCustomSourceOptions", totalOptions => { Cypress.Commands.add("addCustomSourceOptions", totalOptions => {
cy.get(".spectrum-ActionButton").contains("Define Options").click().then(() => { cy.get(".spectrum-ActionButton")
for (let i = 0; i < totalOptions; i++) { .contains("Define Options")
// Add radio button options .click()
cy.get(".spectrum-Button").contains("Add Option").click({force: true}).then(() => { .then(() => {
cy.wait(500) for (let i = 0; i < totalOptions; i++) {
cy.get("[placeholder='Label']").eq(i).type(i) // Add radio button options
cy.get("[placeholder='Value']").eq(i).type(i) cy.get(".spectrum-Button")
.contains("Add Option")
.click({ force: true })
.then(() => {
cy.wait(500)
cy.get("[placeholder='Label']").eq(i).type(i)
cy.get("[placeholder='Value']").eq(i).type(i)
})
}
// Save options
cy.get(".spectrum-Button").contains("Save").click({ force: true })
}) })
}
// Save options
cy.get(".spectrum-Button").contains("Save").click({force: true})
})
}) })

Loading…
Cancel
Save