1
0
Fork 0
mirror of synced 2024-09-28 07:11:40 +12:00

Changing test structure when searching for applications

Search functionality is not available when only 1 app exists - Updating to reflect this
This commit is contained in:
Mitch-Budibase 2022-04-01 14:37:11 +01:00
parent 9ffd278d80
commit db0b6f8441
2 changed files with 46 additions and 42 deletions

View file

@ -79,7 +79,8 @@ filterTests(['all'], () => {
const appName = "Cypress Tests" const appName = "Cypress Tests"
const numberName = 12345 const numberName = 12345
const specialCharName = "£$%^" const specialCharName = "£$%^"
cy.get(".home-logo").click() cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(500)
renameApp(appName, numberName) renameApp(appName, numberName)
cy.reload() cy.reload()
cy.wait(1000) cy.wait(1000)
@ -95,41 +96,33 @@ filterTests(['all'], () => {
}) })
const renameApp = (originalName, changedName, published, noName) => { const renameApp = (originalName, changedName, published, noName) => {
cy.wait(2000)
cy.searchForApplication(originalName) cy.searchForApplication(originalName)
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`) cy.get(".appTable")
.its("body") .within(() => {
.then(val => { cy.get(".spectrum-Icon").eq(1).click()
if (val.length > 0) { })
cy.get(".appTable") // Check for when an app is published
.within(() => { if (published == true) {
cy.get(".spectrum-Icon").eq(1).click() // Should not have Edit as option, will unpublish app
}) cy.should("not.have.value", "Edit")
// Check for when an app is published cy.get(".spectrum-Menu").contains("Unpublish").click()
if (published == true) { cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click()
// Should not have Edit as option, will unpublish app cy.get(".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon").click()
cy.should("not.have.value", "Edit") }
cy.get(".spectrum-Menu").contains("Unpublish").click() cy.contains("Edit").click()
cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click() cy.get(".spectrum-Modal")
cy.get(".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon").click() .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.contains("Edit").click() cy.get("input").clear()
cy.get(".spectrum-Modal") cy.get("input").eq(0).type(changedName).should("have.value", changedName).blur()
.within(() => { cy.get(".spectrum-ButtonGroup").contains("Save").click({ force: true })
if (noName == true) { cy.wait(500)
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(changedName).should("have.value", changedName).blur()
cy.get(".spectrum-ButtonGroup").contains("Save").click({ force: true })
cy.wait(500)
})
}
})
}
})
}) })

View file

@ -344,14 +344,25 @@ Cypress.Commands.add("addCustomSourceOptions", totalOptions => {
Cypress.Commands.add("searchForApplication", appName => { Cypress.Commands.add("searchForApplication", appName => {
cy.visit(`${Cypress.config().baseUrl}/builder`) cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(2000) cy.wait(2000)
// Searches for the app
cy.get(".filter").then(() => { // No app filter functionality if only 1 app exists
cy.get(".spectrum-Textfield").within(() => { cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
cy.get("input").eq(0).clear() .its("body")
cy.get("input").eq(0).type(appName) .then(val => {
if (val.length < 2) {
return
}
else {
// Searches for the app
cy.get(".filter").then(() => {
cy.get(".spectrum-Textfield").within(() => {
cy.get("input").eq(0).clear()
cy.get("input").eq(0).type(appName)
})
})
}
}) })
}) })
})
//Assumes there are no others //Assumes there are no others
Cypress.Commands.add("applicationInAppTable", appName => { Cypress.Commands.add("applicationInAppTable", appName => {