Refactoring test revertApp
This commit is contained in:
parent
d8f18dfd44
commit
e35c353295
|
@ -1,4 +1,5 @@
|
||||||
import filterTests from "../support/filterTests"
|
import filterTests from "../support/filterTests"
|
||||||
|
const interact = require('../support/interact')
|
||||||
|
|
||||||
filterTests(['smoke', 'all'], () => {
|
filterTests(['smoke', 'all'], () => {
|
||||||
context("Revert apps", () => {
|
context("Revert apps", () => {
|
||||||
|
@ -9,15 +10,15 @@ filterTests(['smoke', 'all'], () => {
|
||||||
|
|
||||||
it("should try to revert an unpublished app", () => {
|
it("should try to revert an unpublished app", () => {
|
||||||
// Click revert icon
|
// Click revert icon
|
||||||
cy.get(".toprightnav").within(() => {
|
cy.get(interact.TOP_RIGHT_NAV).within(() => {
|
||||||
cy.get("[aria-label='Revert']").click({ force: true })
|
cy.get("[aria-label='Revert']").click({ force: true })
|
||||||
})
|
})
|
||||||
cy.get(".spectrum-Modal").within(() => {
|
cy.get(interact.SPECTRUM_MODAL).within(() => {
|
||||||
// Enter app name before revert
|
// Enter app name before revert
|
||||||
cy.get("input").type("Cypress Tests")
|
cy.get("input").type("Cypress Tests")
|
||||||
cy.intercept('**/revert').as('revertApp')
|
cy.intercept('**/revert').as('revertApp')
|
||||||
// Click Revert
|
// Click Revert
|
||||||
cy.get(".spectrum-Button").contains("Revert").click({ force: true })
|
cy.get(interact.SPECTRUM_BUTTON).contains("Revert").click({ force: true })
|
||||||
// Intercept Request after button click & apply assertions
|
// Intercept Request after button click & apply assertions
|
||||||
cy.wait("@revertApp")
|
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', 'message', "App has not yet been deployed")
|
||||||
|
@ -31,30 +32,30 @@ filterTests(['smoke', 'all'], () => {
|
||||||
// Add initial component - Paragraph
|
// Add initial component - Paragraph
|
||||||
cy.addComponent("Elements", "Paragraph")
|
cy.addComponent("Elements", "Paragraph")
|
||||||
// Publish app
|
// Publish app
|
||||||
cy.get(".spectrum-Button").contains("Publish").click({ force: true })
|
cy.get(interact.SPECTRUM_BUTTON).contains("Publish").click({ force: true })
|
||||||
cy.get(".spectrum-ButtonGroup").within(() => {
|
cy.get(interact.SPECTRUM_BUTTON_GROUP).within(() => {
|
||||||
cy.get(".spectrum-Button").contains("Publish").click({ force: true })
|
cy.get(interact.SPECTRUM_BUTTON).contains("Publish").click({ force: true })
|
||||||
})
|
})
|
||||||
cy.wait(1000)
|
cy.wait(1000)
|
||||||
cy.get(".spectrum-ButtonGroup").within(() => {
|
cy.get(interact.SPECTRUM_BUTTON_GROUP).within(() => {
|
||||||
cy.get(".spectrum-Button").contains("Done").click({ force: true })
|
cy.get(interact.SPECTRUM_BUTTON).contains("Done").click({ force: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add second component - Button
|
// Add second component - Button
|
||||||
cy.addComponent("Elements", "Button")
|
cy.addComponent("Elements", "Button")
|
||||||
// Click Revert
|
// Click Revert
|
||||||
cy.get(".toprightnav").within(() => {
|
cy.get(interact.TOP_RIGHT_NAV).within(() => {
|
||||||
cy.get("[aria-label='Revert']").click({ force: true })
|
cy.get("[aria-label='Revert']").click({ force: true })
|
||||||
})
|
})
|
||||||
cy.get(".spectrum-Dialog-grid").within(() => {
|
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
|
||||||
// Click Revert
|
// Click Revert
|
||||||
cy.get(".spectrum-Button").contains("Revert").click({ force: true })
|
cy.get(interact.SPECTRUM_BUTTON).contains("Revert").click({ force: true })
|
||||||
cy.wait(1000)
|
cy.wait(1000)
|
||||||
})
|
})
|
||||||
// Confirm Paragraph component is still visible
|
// Confirm Paragraph component is still visible
|
||||||
cy.get(".root").contains("New Paragraph")
|
cy.get(interact.ROOT).contains("New Paragraph")
|
||||||
// Confirm Button component is not visible
|
// Confirm Button component is not visible
|
||||||
cy.get(".root").should("not.have.text", "New Button")
|
cy.get(interact.ROOT).should("not.have.text", "New Button")
|
||||||
cy.wait(500)
|
cy.wait(500)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -64,10 +65,10 @@ filterTests(['smoke', 'all'], () => {
|
||||||
cy.get("[aria-label='Revert']").click({ force: true })
|
cy.get("[aria-label='Revert']").click({ force: true })
|
||||||
})
|
})
|
||||||
// Enter incorrect app name
|
// Enter incorrect app name
|
||||||
cy.get(".spectrum-Dialog-grid").within(() => {
|
cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => {
|
||||||
cy.get("input").type("Cypress Tests")
|
cy.get("input").type("Cypress Tests")
|
||||||
// Revert button within modal should be disabled
|
// Revert button within modal should be disabled
|
||||||
cy.get(".spectrum-Button").eq(1).should('be.disabled')
|
cy.get(interact.SPECTRUM_BUTTON).eq(1).should('be.disabled')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -107,3 +107,8 @@ export const CONTAINER = ".container"
|
||||||
|
|
||||||
//createView
|
//createView
|
||||||
export const SPECTRUM_MENU_ITEM_LABEL = ".spectrum-Menu-itemLabel"
|
export const SPECTRUM_MENU_ITEM_LABEL = ".spectrum-Menu-itemLabel"
|
||||||
|
|
||||||
|
//revertApp
|
||||||
|
export const TOP_RIGHT_NAV = ".toprightnav"
|
||||||
|
export const AREA_LAVEL_REVERT = "[aria-label=Revert]"
|
||||||
|
export const ROOT = ".root"
|
||||||
|
|
Loading…
Reference in New Issue