Updated deleteApp function
Added a check for app name, function returns if app does not exist, rather than trying to delete
This commit is contained in:
parent
4340a46fe7
commit
87ac25bcea
|
@ -60,44 +60,50 @@ Cypress.Commands.add("deleteApp", name => {
|
||||||
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
|
cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
|
||||||
.its("body")
|
.its("body")
|
||||||
.then(val => {
|
.then(val => {
|
||||||
if (val.length > 0) {
|
const findAppName = val.some(val => val.name == name)
|
||||||
if (Cypress.env("TEST_ENV")) {
|
if (findAppName) {
|
||||||
cy.searchForApplication(name)
|
if (val.length > 0) {
|
||||||
cy.get(".appTable").within(() => {
|
if (Cypress.env("TEST_ENV")) {
|
||||||
cy.get(".spectrum-Icon").eq(1).click()
|
cy.searchForApplication(name)
|
||||||
|
cy.get(".appTable").within(() => {
|
||||||
|
cy.get(".spectrum-Icon").eq(1).click()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const appId = val.reduce((acc, app) => {
|
||||||
|
if (name === app.name) {
|
||||||
|
acc = app.appId
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, "")
|
||||||
|
|
||||||
|
if (appId == "") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const appIdParsed = appId.split("_").pop()
|
||||||
|
const actionEleId = `[data-cy=row_actions_${appIdParsed}]`
|
||||||
|
cy.get(actionEleId).within(() => {
|
||||||
|
cy.get(".spectrum-Icon").eq(0).click()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.get(".spectrum-Menu").then($menu => {
|
||||||
|
if ($menu.text().includes("Unpublish")) {
|
||||||
|
cy.get(".spectrum-Menu").contains("Unpublish").click()
|
||||||
|
cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click()
|
||||||
|
} else {
|
||||||
|
cy.get(".spectrum-Menu").contains("Delete").click()
|
||||||
|
cy.get(".spectrum-Dialog-grid").within(() => {
|
||||||
|
cy.get("input").type(name)
|
||||||
|
})
|
||||||
|
cy.get(".spectrum-Button--warning").click()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const appId = val.reduce((acc, app) => {
|
return
|
||||||
if (name === app.name) {
|
|
||||||
acc = app.appId
|
|
||||||
}
|
|
||||||
return acc
|
|
||||||
}, "")
|
|
||||||
|
|
||||||
if (appId == "") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const appIdParsed = appId.split("_").pop()
|
|
||||||
const actionEleId = `[data-cy=row_actions_${appIdParsed}]`
|
|
||||||
cy.get(actionEleId).within(() => {
|
|
||||||
cy.get(".spectrum-Icon").eq(0).click()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cy.get(".spectrum-Menu").then($menu => {
|
else {
|
||||||
if ($menu.text().includes("Unpublish")) {
|
|
||||||
cy.get(".spectrum-Menu").contains("Unpublish").click()
|
|
||||||
cy.get(".spectrum-Dialog-grid").contains("Unpublish app").click()
|
|
||||||
} else {
|
|
||||||
cy.get(".spectrum-Menu").contains("Delete").click()
|
|
||||||
cy.get(".spectrum-Dialog-grid").within(() => {
|
|
||||||
cy.get("input").type(name)
|
|
||||||
})
|
|
||||||
cy.get(".spectrum-Button--warning").click()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue