From 11beb999ddc8344e274763b77e1553d0be6dbb9c Mon Sep 17 00:00:00 2001 From: MihailHadzhiev2022 Date: Wed, 8 Jun 2022 17:29:12 +0300 Subject: [PATCH] Refactoring test revertApp --- .../cypress/integration/revertApp.spec.js | 31 ++++++++++--------- packages/builder/cypress/support/interact.js | 5 +++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/builder/cypress/integration/revertApp.spec.js b/packages/builder/cypress/integration/revertApp.spec.js index 01d5a04981..58d51fa5b9 100644 --- a/packages/builder/cypress/integration/revertApp.spec.js +++ b/packages/builder/cypress/integration/revertApp.spec.js @@ -1,4 +1,5 @@ import filterTests from "../support/filterTests" +const interact = require('../support/interact') filterTests(['smoke', 'all'], () => { context("Revert apps", () => { @@ -9,15 +10,15 @@ filterTests(['smoke', 'all'], () => { it("should try to revert an unpublished app", () => { // Click revert icon - cy.get(".toprightnav").within(() => { + cy.get(interact.TOP_RIGHT_NAV).within(() => { cy.get("[aria-label='Revert']").click({ force: true }) }) - cy.get(".spectrum-Modal").within(() => { + cy.get(interact.SPECTRUM_MODAL).within(() => { // Enter app name before revert cy.get("input").type("Cypress Tests") cy.intercept('**/revert').as('revertApp') // 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 cy.wait("@revertApp") 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 cy.addComponent("Elements", "Paragraph") // Publish app - cy.get(".spectrum-Button").contains("Publish").click({ force: true }) - cy.get(".spectrum-ButtonGroup").within(() => { - cy.get(".spectrum-Button").contains("Publish").click({ force: true }) + 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) - cy.get(".spectrum-ButtonGroup").within(() => { - cy.get(".spectrum-Button").contains("Done").click({ force: true }) + cy.get(interact.SPECTRUM_BUTTON_GROUP).within(() => { + cy.get(interact.SPECTRUM_BUTTON).contains("Done").click({ force: true }) }) // Add second component - Button cy.addComponent("Elements", "Button") // Click Revert - cy.get(".toprightnav").within(() => { + cy.get(interact.TOP_RIGHT_NAV).within(() => { cy.get("[aria-label='Revert']").click({ force: true }) }) - cy.get(".spectrum-Dialog-grid").within(() => { + cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => { // Click Revert - cy.get(".spectrum-Button").contains("Revert").click({ force: true }) + cy.get(interact.SPECTRUM_BUTTON).contains("Revert").click({ force: true }) cy.wait(1000) }) // 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 - cy.get(".root").should("not.have.text", "New Button") + cy.get(interact.ROOT).should("not.have.text", "New Button") cy.wait(500) }) @@ -64,10 +65,10 @@ filterTests(['smoke', 'all'], () => { cy.get("[aria-label='Revert']").click({ force: true }) }) // Enter incorrect app name - cy.get(".spectrum-Dialog-grid").within(() => { + cy.get(interact.SPECTRUM_DIALOG_GRID).within(() => { cy.get("input").type("Cypress Tests") // 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') }) }) }) diff --git a/packages/builder/cypress/support/interact.js b/packages/builder/cypress/support/interact.js index 7ac2d8853d..49595e572a 100644 --- a/packages/builder/cypress/support/interact.js +++ b/packages/builder/cypress/support/interact.js @@ -107,3 +107,8 @@ export const CONTAINER = ".container" //createView 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"