From 9f838e098fbaec07b27cc3bf6170a8d3d4a302bf Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 8 Mar 2021 11:57:56 +0000 Subject: [PATCH] Add cypress test for deleting a component --- .../integration/createComponents.spec.js | 18 ++++++++++++++++++ packages/builder/cypress/support/commands.js | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/builder/cypress/integration/createComponents.spec.js b/packages/builder/cypress/integration/createComponents.spec.js index 393cd1895f..56aca88837 100644 --- a/packages/builder/cypress/integration/createComponents.spec.js +++ b/packages/builder/cypress/integration/createComponents.spec.js @@ -69,4 +69,22 @@ context("Create Components", () => { }) }) }) + + it("deletes a component", () => { + cy.addComponent("Elements", "Paragraph").then(componentId => { + cy.get("[data-cy=setting-_instanceName] input") + .type(componentId) + .blur() + cy.get(".ui-nav ul .nav-item.selected .ri-more-line").click({ + force: true, + }) + cy.get(".dropdown-container") + .contains("Delete") + .click() + cy.get(".modal") + .contains("Delete Component") + .click() + cy.getComponent(componentId).should("not.exist") + }) + }) }) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index 2e418a0629..a157477665 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -159,7 +159,9 @@ Cypress.Commands.add("addComponent", (category, component) => { cy.wait(500) cy.location().then(loc => { const params = loc.pathname.split("/") - return cy.wrap(params[params.length - 1]) + const componentId = params[params.length - 1] + cy.getComponent(componentId).should("exist") + return cy.wrap(componentId) }) })