Merge pull request #5371 from Budibase/cypress-testing

Smoke Build Test Changes
This commit is contained in:
Mitch-Budibase 2022-04-13 12:15:02 +01:00 committed by GitHub
commit 0c880dd714
3 changed files with 53 additions and 43 deletions

View File

@ -25,9 +25,13 @@ filterTests(['smoke', 'all'], () => {
cy.visit(`${Cypress.config().baseUrl}/builder`) cy.visit(`${Cypress.config().baseUrl}/builder`)
cy.wait(500) cy.wait(500)
if (Cypress.env("TEST_ENV")) { cy.request(`${Cypress.config().baseUrl}/api/applications?status=all`)
cy.get(".spectrum-Button").contains("Templates").click({force: true}) .its("body")
} .then(val => {
if (val.length > 0) {
cy.get(".spectrum-Button").contains("Templates").click({force: true})
}
})
cy.get(".template-category-filters").should("exist") cy.get(".template-category-filters").should("exist")
cy.get(".template-categories").should("exist") cy.get(".template-categories").should("exist")

View File

@ -61,7 +61,8 @@ filterTests(["smoke", "all"], () => {
for (let i = 1; i < totalRows; i++) { for (let i = 1; i < totalRows; i++) {
cy.addRow([i]) cy.addRow([i])
} }
cy.wait(1000) cy.reload()
cy.wait(2000)
cy.get(".spectrum-Pagination").within(() => { cy.get(".spectrum-Pagination").within(() => {
cy.get(".spectrum-ActionButton").eq(1).click() cy.get(".spectrum-ActionButton").eq(1).click()
}) })
@ -71,12 +72,12 @@ filterTests(["smoke", "all"], () => {
}) })
it("Deletes rows and checks pagination", () => { it("Deletes rows and checks pagination", () => {
// Delete rows, removing second page of rows from table // Delete rows, removing second page from table
const deleteRows = 5
cy.get(".spectrum-Checkbox-input").check({ force: true }) cy.get(".spectrum-Checkbox-input").check({ force: true })
cy.get(".spectrum-Table") cy.get(".popovers").within(() => {
cy.contains("Delete 5 row(s)").click() cy.get(".spectrum-Button").click({ force: true })
cy.get(".spectrum-Modal").contains("Delete").click() })
cy.get(".spectrum-Dialog-grid").contains("Delete").click({ force: true })
cy.wait(1000) cy.wait(1000)
// Confirm table only has one page // Confirm table only has one page

View File

@ -60,43 +60,48 @@ 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 => {
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 {
return return
} }