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

76 lines
3.2 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'], () => {
context("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("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.addComponent("Elements", "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)
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_BUTTON_GROUP).within(() => {
cy.get(interact.SPECTRUM_BUTTON).contains("Done").click({ force: true })
})
2022-05-10 23:40:27 +02:00
// Add second component - Button
cy.addComponent("Elements", "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(() => {
// Click Revert
2022-06-08 16:29:12 +02:00
cy.get(interact.SPECTRUM_BUTTON).contains("Revert").click({ force: true })
cy.wait(1000)
})
// Confirm Paragraph component is still visible
2022-06-08 16:29:12 +02:00
cy.get(interact.ROOT).contains("New Paragraph")
// Confirm Button component is not visible
2022-06-08 16:29:12 +02:00
cy.get(interact.ROOT).should("not.have.text", "New Button")
cy.wait(500)
})
it("should enter incorrect app name when reverting", () => {
// Click Revert
2022-06-13 12:10:11 +02:00
cy.get(interact.TOP_RIGHT_NAV).within(() => {
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
})