Merge pull request #3024 from Budibase/cypress-testing
New Tests & Command
This commit is contained in:
commit
2636dd67e5
|
@ -5,12 +5,12 @@ context("Custom Theming Properties", () => {
|
|||
cy.navigateToFrontend()
|
||||
})
|
||||
|
||||
// Default Values
|
||||
// Button roundness = Large
|
||||
// Accent colour = Blue 600
|
||||
// Accent colour (hover) = Blue 500
|
||||
// Navigation bar background colour = Gray 100
|
||||
// Navigation bar text colour = Gray 800
|
||||
/* Default Values:
|
||||
Button roundness = Large
|
||||
Accent colour = Blue 600
|
||||
Accent colour (hover) = Blue 500
|
||||
Navigation bar background colour = Gray 100
|
||||
Navigation bar text colour = Gray 800 */
|
||||
it("should reset the color property values", () => {
|
||||
// Open Theme modal and change colours
|
||||
cy.get(".spectrum-ActionButton-label").contains("Theme").click()
|
||||
|
@ -24,6 +24,29 @@ context("Custom Theming Properties", () => {
|
|||
checkThemeColorDefaults()
|
||||
})
|
||||
|
||||
/* Button Roundness Values:
|
||||
None = 0
|
||||
Small = 4px
|
||||
Medium = 8px
|
||||
Large = 16px */
|
||||
it.only("should test button roundness", () => {
|
||||
const buttonRoundnessValues = ["0", "4px", "8px", "16px"]
|
||||
cy.wait(1000)
|
||||
// Add button, change roundness and confirm value
|
||||
cy.addComponent("Button", null).then((componentId) => {
|
||||
buttonRoundnessValues.forEach(function (item, index){
|
||||
cy.get(".spectrum-ActionButton-label").contains("Theme").click()
|
||||
cy.get(".setting").contains("Button roundness").parent()
|
||||
.get(".select-wrapper").click()
|
||||
cy.get(".spectrum-Popover").find('li').eq(index).click()
|
||||
cy.get(".spectrum-Button").contains("View changes").click({force: true})
|
||||
cy.reload()
|
||||
cy.getComponent(componentId)
|
||||
.parents(".svelte-xiqd1c").eq(0).should('have.attr', 'style').and('contains', `--buttonBorderRadius:${item}`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const changeThemeColors = () => {
|
||||
// Changes the theme colours
|
||||
cy.get(".spectrum-FieldLabel").contains("Accent color")
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
context("Rename an App", () => {
|
||||
beforeEach(() => {
|
||||
cy.login()
|
||||
cy.createTestApp()
|
||||
})
|
||||
|
||||
it("should rename an unpublished application", () => {
|
||||
const appRename = "Cypress Renamed"
|
||||
// Rename app, Search for app, Confirm name was changed
|
||||
cy.get(".home-logo").click()
|
||||
renameApp(appRename)
|
||||
cy.searchForApplication(appRename)
|
||||
cy.get(".appGrid").find(".wrapper").should("have.length", 1)
|
||||
})
|
||||
|
||||
it("Should rename a published application", () => {
|
||||
// It is not possible to rename a published application
|
||||
const appRename = "Cypress Renamed"
|
||||
// Publish the app
|
||||
cy.get(".toprightnav")
|
||||
cy.get(".spectrum-Button").contains("Publish").click({force: true})
|
||||
cy.get(".spectrum-Dialog-grid")
|
||||
.within(() => {
|
||||
// Click publish again within the modal
|
||||
cy.get(".spectrum-Button").contains("Publish").click({force: true})
|
||||
})
|
||||
// Rename app, Search for app, Confirm name was changed
|
||||
cy.get(".home-logo").click()
|
||||
renameApp(appRename, true)
|
||||
cy.searchForApplication(appRename)
|
||||
cy.get(".appGrid").find(".wrapper").should("have.length", 1)
|
||||
})
|
||||
|
||||
it("Should try to rename an application to have no name", () => {
|
||||
cy.get(".home-logo").click()
|
||||
renameApp(" ", false, true)
|
||||
// Close modal and confirm name has not been changed
|
||||
cy.get(".spectrum-Dialog-grid").contains("Cancel").click()
|
||||
cy.searchForApplication("Cypress Tests")
|
||||
cy.get(".appGrid").find(".wrapper").should("have.length", 1)
|
||||
})
|
||||
|
||||
it("Should create two applications with the same name", () => {
|
||||
// It is not possible to have applications with the same name
|
||||
const appName = "Cypress Tests"
|
||||
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
|
||||
cy.wait(500)
|
||||
cy.get(".spectrum-Button").contains("Create app").click({force: true})
|
||||
cy.contains(/Start from scratch/).click()
|
||||
cy.get(".spectrum-Modal")
|
||||
.within(() => {
|
||||
cy.get("input").eq(0).type(appName)
|
||||
cy.get(".spectrum-ButtonGroup").contains("Create app").click({force: true})
|
||||
cy.get(".error").should("have.text", "Another app with the same name already exists")
|
||||
})
|
||||
})
|
||||
|
||||
it("should validate application names", () => {
|
||||
// App name must be letters, numbers and spaces only
|
||||
// This test checks numbers and special characters specifically
|
||||
const numberName = 12345
|
||||
const specialCharName = "£$%^"
|
||||
cy.get(".home-logo").click()
|
||||
renameApp(numberName)
|
||||
cy.searchForApplication(numberName)
|
||||
cy.get(".appGrid").find(".wrapper").should("have.length", 1)
|
||||
renameApp(specialCharName)
|
||||
cy.get(".error").should("have.text", "App name must be letters, numbers and spaces only")
|
||||
})
|
||||
|
||||
const renameApp = (appName, published, noName) => {
|
||||
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`)
|
||||
.its("body")
|
||||
.then(val => {
|
||||
if (val.length > 0) {
|
||||
cy.get(".title > :nth-child(3) > .spectrum-Icon").click()
|
||||
// Check for when an app is published
|
||||
if (published == true){
|
||||
// Should not have Edit as option, will unpublish app
|
||||
cy.should("not.have.value", "Edit")
|
||||
cy.get(".spectrum-Menu").contains("Unpublish").click()
|
||||
cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click()
|
||||
cy.get(".title > :nth-child(3) > .spectrum-Icon").click()
|
||||
}
|
||||
cy.contains("Edit").click()
|
||||
cy.get(".spectrum-Modal")
|
||||
.within(() => {
|
||||
if (noName == true){
|
||||
cy.get("input").clear()
|
||||
cy.get(".spectrum-Dialog-grid").click()
|
||||
.contains("App name must be letters, numbers and spaces only")
|
||||
return cy
|
||||
}
|
||||
cy.get("input").clear()
|
||||
cy.get("input").eq(0).type(appName).should("have.value", appName).blur()
|
||||
cy.get(".spectrum-ButtonGroup").contains("Save").click({force: true})
|
||||
cy.wait(500)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
|
@ -224,3 +224,9 @@ Cypress.Commands.add("addCustomSourceOptions", totalOptions => {
|
|||
cy.get(".spectrum-Button").contains("Save").click({ force: true })
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add("searchForApplication", appName => {
|
||||
cy.get(".spectrum-Textfield").within(() => {
|
||||
cy.get("input").eq(0).type(appName)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue