2022-01-21 13:43:27 +01:00
|
|
|
import filterTests from "../support/filterTests"
|
2021-10-15 18:36:10 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
filterTests(['all'], () => {
|
2022-03-29 00:21:38 +02:00
|
|
|
context("Rename an App", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.login()
|
|
|
|
cy.createTestApp()
|
|
|
|
})
|
2021-10-15 18:36:10 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("should rename an unpublished application", () => {
|
2022-03-29 00:21:38 +02:00
|
|
|
const appName = "Cypress Tests"
|
|
|
|
const appRename = "Cypress Renamed"
|
|
|
|
// Rename app, Search for app, Confirm name was changed
|
2022-04-01 14:15:06 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.wait(500)
|
2022-03-29 00:21:38 +02:00
|
|
|
renameApp(appName, appRename)
|
|
|
|
cy.reload()
|
|
|
|
cy.wait(1000)
|
2022-04-01 12:31:18 +02:00
|
|
|
cy.searchForApplication(appRename)
|
2022-03-29 00:21:38 +02:00
|
|
|
cy.get(".appTable").find(".title").should("have.length", 1)
|
|
|
|
cy.applicationInAppTable(appRename)
|
|
|
|
// Set app name back to Cypress Tests
|
|
|
|
cy.reload()
|
|
|
|
cy.wait(1000)
|
|
|
|
renameApp(appRename, appName)
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
2022-03-29 00:21:38 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
xit("Should rename a published application", () => {
|
2022-03-29 00:21:38 +02:00
|
|
|
// It is not possible to rename a published application
|
|
|
|
const appName = "Cypress Tests"
|
|
|
|
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
|
2022-04-01 14:15:06 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.wait(500)
|
2022-03-29 00:21:38 +02:00
|
|
|
renameApp(appName, appRename, true)
|
|
|
|
cy.get(".appTable").find(".wrapper").should("have.length", 1)
|
|
|
|
cy.applicationInAppTable(appRename)
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
2021-10-15 18:36:10 +02:00
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
it("Should try to rename an application to have no name", () => {
|
2022-03-29 00:21:38 +02:00
|
|
|
const appName = "Cypress Tests"
|
2022-04-01 14:15:06 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.wait(500)
|
2022-03-29 00:21:38 +02:00
|
|
|
renameApp(appName, " ", false, true)
|
|
|
|
cy.wait(500)
|
|
|
|
// Close modal and confirm name has not been changed
|
|
|
|
cy.get(".spectrum-Dialog-grid").contains("Cancel").click()
|
|
|
|
cy.reload()
|
|
|
|
cy.wait(1000)
|
|
|
|
cy.applicationInAppTable(appName)
|
2021-10-15 18:36:10 +02:00
|
|
|
})
|
|
|
|
|
2022-01-21 13:43:27 +01:00
|
|
|
xit("Should create two applications with the same name", () => {
|
2022-03-29 00:21:38 +02:00
|
|
|
// It is not possible to have applications with the same name
|
|
|
|
const appName = "Cypress Tests"
|
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.wait(500)
|
|
|
|
cy.get(".spectrum-Button").contains("Create app").click({ force: true })
|
|
|
|
cy.contains(/Start from scratch/).click()
|
|
|
|
cy.get(".spectrum-Modal")
|
2022-01-21 13:43:27 +01:00
|
|
|
.within(() => {
|
2022-03-29 00:21:38 +02:00
|
|
|
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")
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should validate application names", () => {
|
2022-03-29 00:21:38 +02:00
|
|
|
// App name must be letters, numbers and spaces only
|
|
|
|
// This test checks numbers and special characters specifically
|
|
|
|
const appName = "Cypress Tests"
|
|
|
|
const numberName = 12345
|
|
|
|
const specialCharName = "£$%^"
|
2022-04-01 15:37:11 +02:00
|
|
|
cy.visit(`${Cypress.config().baseUrl}/builder`)
|
|
|
|
cy.wait(500)
|
2022-03-29 00:21:38 +02:00
|
|
|
renameApp(appName, numberName)
|
|
|
|
cy.reload()
|
|
|
|
cy.wait(1000)
|
|
|
|
cy.applicationInAppTable(numberName)
|
|
|
|
cy.reload()
|
|
|
|
cy.wait(1000)
|
|
|
|
renameApp(numberName, specialCharName)
|
|
|
|
cy.get(".error").should("have.text", "App name must be letters, numbers and spaces only")
|
|
|
|
// Set app name back to Cypress Tests
|
|
|
|
cy.reload()
|
|
|
|
cy.wait(1000)
|
|
|
|
renameApp(numberName, appName)
|
2022-01-21 13:43:27 +01:00
|
|
|
})
|
2022-03-29 00:21:38 +02:00
|
|
|
|
|
|
|
const renameApp = (originalName, changedName, published, noName) => {
|
2022-04-01 12:31:18 +02:00
|
|
|
cy.searchForApplication(originalName)
|
2022-04-01 15:37:11 +02:00
|
|
|
cy.get(".appTable")
|
|
|
|
.within(() => {
|
2022-04-26 13:04:07 +02:00
|
|
|
cy.get("[aria-label='More']").eq(0).click()
|
2022-04-20 10:17:01 +02:00
|
|
|
})
|
|
|
|
// 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(".appTable > :nth-child(5) > :nth-child(2) > .spectrum-Icon").click()
|
|
|
|
}
|
2022-04-20 13:51:44 +02:00
|
|
|
cy.get("[data-cy='app-row-actions-menu-popover']").eq(0).within(() => {
|
|
|
|
cy.get(".spectrum-Menu-item").contains("Edit").click({ force: true })
|
2022-04-20 10:17:01 +02:00
|
|
|
})
|
|
|
|
cy.get(".spectrum-Modal")
|
|
|
|
.within(() => {
|
|
|
|
if (noName == true) {
|
2022-04-01 15:37:11 +02:00
|
|
|
cy.get("input").clear()
|
2022-04-20 10:17:01 +02:00
|
|
|
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)
|
|
|
|
})
|
|
|
|
}
|
2022-04-01 15:37:11 +02:00
|
|
|
})
|
2021-10-15 18:36:10 +02:00
|
|
|
})
|