budibase/packages/builder/cypress/integration/revertApp.spec.js

76 lines
3.4 KiB
JavaScript
Raw Normal View History

import filterTests from "../support/filterTests"
2022-06-08 16:29:12 +02:00
const interact = require('../support/interact')
filterTests(['smoke', 'all'], () => {
xcontext("Revert apps", () => {
before(() => {
cy.login()
cy.createTestApp()
})
it("should try to revert an unpublished app", () => {
// Click revert icon
2022-06-08 16:29:12 +02:00
cy.get(interact.TOP_RIGHT_NAV).within(() => {
2022-06-13 12:10:11 +02:00
cy.get(interact.AREA_LABEL_REVERT).click({ force: true })
})
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_MODAL).within(() => {
// Enter app name before revert
cy.get(interact.SPECTRUM_TEXTFIELD_INPUT).type("Cypress Tests")
cy.intercept('**/revert').as('revertApp')
// Click Revert
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_BUTTON).contains("Revert").click({ force: true })
// Intercept Request after button click & apply assertions
cy.wait("@revertApp")
cy.get("@revertApp").its('response.body').should('have.property', 'message', "App has not yet been deployed")
cy.get("@revertApp").its('response.body').should('have.property', 'status', 400)
})
})
it("should revert a published app", () => {
2022-05-10 23:40:27 +02:00
cy.navigateToFrontend()
// Add initial component - Paragraph
cy.searchAndAddComponent("Paragraph")
// Publish app
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_BUTTON).contains("Publish").click({ force: true })
cy.get(interact.SPECTRUM_BUTTON_GROUP).within(() => {
cy.get(interact.SPECTRUM_BUTTON).contains("Publish").click({ force: true })
})
cy.wait(1000) // Wait for next modal to finish loading
cy.get(interact.SPECTRUM_BUTTON_GROUP, { timeout: 1000 }).within(() => {
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_BUTTON).contains("Done").click({ force: true })
})
2022-05-10 23:40:27 +02:00
// Add second component - Button
cy.searchAndAddComponent("Button")
// Click Revert
2022-06-08 16:29:12 +02:00
cy.get(interact.TOP_RIGHT_NAV).within(() => {
2022-06-13 12:10:11 +02:00
cy.get(interact.AREA_LABEL_REVERT).click({ force: true })
})
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
cy.get("input").type("Cypress Tests")
// Click Revert
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_BUTTON).contains("Revert").click({ force: true })
cy.wait(2000) // Wait for app to finish reverting
})
// Confirm Paragraph component is still visible
cy.get(interact.ROOT, { timeout: 1000 }).contains("New Paragraph")
// Confirm Button component is not visible
cy.get(interact.ROOT, { timeout: 1000 }).should("not.have.text", "New Button")
})
it("should enter incorrect app name when reverting", () => {
// Click Revert
cy.get(interact.TOP_RIGHT_NAV, { timeout: 1000 }).within(() => {
2022-06-13 12:10:11 +02:00
cy.get(interact.AREA_LABEL_REVERT).click({ force: true })
})
// Enter incorrect app name
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
cy.get("input").type("Cypress Tests")
// Revert button within modal should be disabled
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_BUTTON).eq(1).should('be.disabled')
})
})
})
2021-12-24 11:40:57 +01:00
})