From 17736d55055f5f84a029706ca45c10fc9c4c7397 Mon Sep 17 00:00:00 2001 From: Ahmad Azizi <91204996+its-aazizi@users.noreply.github.com> Date: Fri, 25 Aug 2023 14:57:15 +0500 Subject: [PATCH] fixed failing E2E tests --- .../e2e/unauthUserCanAccessSimulation.cy.js | 4 +- ...AbleToConnectAndDisconnectAwsAccount.cy.js | 20 +++++++++ cypress/e2e/userIsAbleToUseTracker.cy.js | 44 ++++++++++++------- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/cypress/e2e/unauthUserCanAccessSimulation.cy.js b/cypress/e2e/unauthUserCanAccessSimulation.cy.js index 53287928..5b4cd650 100644 --- a/cypress/e2e/unauthUserCanAccessSimulation.cy.js +++ b/cypress/e2e/unauthUserCanAccessSimulation.cy.js @@ -20,13 +20,13 @@ describe("Unauth Simulation", () => { { timeout: 20000 } ) .should("be.visible") - .click({ multiple: true }); + .click({ multiple: true, force: true }); cy.get( '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click exit-geofence"]', { timeout: 20000 } ) .should("be.visible") - .click({ multiple: true }); + .click({ multiple: true, force: true }); cy.wait(2000); cy.get('[data-testid="pause-button"]').click(); cy.wait(2000); diff --git a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js index b1dc78e1..d89d8f9c 100644 --- a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js +++ b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js @@ -36,9 +36,29 @@ describe("Connecting and Disconnecting AWS account", () => { }); }); cy.wait(5000); + cy.get('[data-testid="hamburger-menu"]').click(); + + cy.get("#root").then($root => { + const root = $root.find('[class="amplify-button amplify-field-group__control amplify-button--primary"]'); + root.length && root[0].innerText === "Sign in" + ? root[0].click() + : cy.get('[data-testid="hamburger-menu"]').click(); + }); + cy.wait(5000); + cy.get('[data-testid="hamburger-menu"]').click(); cy.get('[data-testid="sign-out-button"]').click(); cy.wait(5000); + cy.get('[data-testid="hamburger-menu"]').click(); + + cy.get("#root").then($root => { + const root = $root.find('[class="amplify-button amplify-field-group__control amplify-button--primary"]'); + root.length && root[0].innerText === "Sign out" + ? root[0].click() + : cy.get('[data-testid="hamburger-menu"]').click(); + }); + cy.wait(5000); + cy.get('[data-testid="hamburger-menu"]').click(); cy.get('[data-testid="disconnect-aws-account-button"]').click(); cy.wait(10000); diff --git a/cypress/e2e/userIsAbleToUseTracker.cy.js b/cypress/e2e/userIsAbleToUseTracker.cy.js index a2edcfbf..e2f51e0b 100644 --- a/cypress/e2e/userIsAbleToUseTracker.cy.js +++ b/cypress/e2e/userIsAbleToUseTracker.cy.js @@ -54,21 +54,11 @@ describe("Tracker", () => { }); it("should allow user to add a tracker and the user should see the notifications for Geofence enter and exit events", () => { - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(2000); - - cy.contains("Tracker").click(); - cy.wait(2000); - - cy.contains("Continue").click(); - cy.wait(2000); - cy.get('[class="amplify-flex geofence-button"]').click(); cy.wait(4000); - - cy.get('[placeholder="Enter address or coordinates"]').type("Rio Tinto Perth Western Australia"); + cy.get('[placeholder="Enter address or coordinates"]').type("Empire State Building"); cy.wait(4000); - cy.contains("Rio Tinto Operations Centre").click(); + cy.contains("Empire State Building").click(); cy.wait(2000); cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}`); cy.wait(2000); @@ -79,16 +69,20 @@ describe("Tracker", () => { cy.get('[class="amplify-flex geofence-card-close"]').click(); cy.wait(500); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(2000); + cy.contains("Tracker").click(); + cy.wait(2000); + cy.contains("Continue").click(); + cy.wait(2000); cy.get('[class="mapboxgl-canvas"]').click("left", { force: true }); cy.wait(2000); cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); cy.wait(2000); cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); cy.wait(2000); - cy.contains("Save").click(); cy.wait(2000); - cy.get('[class="amplify-button amplify-field-group__control amplify-button--primary play-pause-button"]').click(); cy.wait(2000); @@ -97,19 +91,37 @@ describe("Tracker", () => { { timeout: 50000 } ) .should("be.visible") - .click({ multiple: true }); + .click({ multiple: true, force: true }); cy.get( '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click exit-geofence"]', { timeout: 50000 } ) .should("be.visible") - .click({ multiple: true }); + .click({ multiple: true, force: true }); cy.wait(2000); cy.get('[data-testid="auth-tracker-box-close"]').click(); + + cy.get('[class="amplify-flex geofence-button"]').click(); + cy.wait(2000); + cy.contains("Go Back").click(); + cy.wait(2000); + cy.get(`[data-testid="icon-trash-${geofenceName}"]`).click({ force: true }); + cy.get('[class="amplify-flex geofence-card-close"]').click(); + cy.get('[data-testid="hamburger-menu"]').click(); cy.get('[data-testid="sign-out-button"]').click(); + cy.get('[data-testid="hamburger-menu"]').click(); + + cy.get("#root").then($root => { + const root = $root.find('[class="amplify-button amplify-field-group__control amplify-button--primary"]'); + root.length && root[0].innerText === "Sign out" + ? root[0].click() + : cy.get('[data-testid="hamburger-menu"]').click(); + }); + cy.wait(5000); + cy.get('[data-testid="hamburger-menu"]').click(); cy.get('[data-testid="disconnect-aws-account-button"]').click(); });