From d6a49d3e1b5753a5dedeaae64fcd6a534953010d Mon Sep 17 00:00:00 2001 From: Ahmad Azizi <91204996+its-aazizi@users.noreply.github.com> Date: Fri, 31 May 2024 02:24:27 +0500 Subject: [PATCH] PR review - comments resolved --- cypress/e2e/pinpointAnalytics.cy.js | 17 +- ...uthUserCanAccessLimitedFunctionality.cy.js | 2 +- .../e2e/unauthUserCanAccessSimulation.cy.js | 12 +- ...AbleToConnectAndDisconnectAwsAccount.cy.js | 14 +- cypress/e2e/userIsAbleToSearch.cy.js | 48 ++--- cypress/e2e/userIsAbleToUseGeofence.cy.js | 14 +- cypress/e2e/userIsAbleToUseRoute.cy.js | 30 ++-- cypress/e2e/userIsAbleToUseSettings.cy.js | 26 +-- cypress/e2e/userIsAbleToUseTracker.cy.js | 15 +- ...serIsAbleUseMapDataAndStylesShortcut.cy.js | 26 ++- .../MapDataAndStylesShortcutSupport.js | 75 ++++---- cypress/support/commands.js | 126 +++++++------ cypress/support/constants.js | 4 + cypress/support/index.js | 2 +- cypress/support/routeSupport.js | 48 ++--- cypress/support/settingSupport.js | 34 ++-- cypress/support/trackerAndGeofenceSupport.js | 165 +++++++++--------- 17 files changed, 361 insertions(+), 297 deletions(-) create mode 100644 cypress/support/constants.js diff --git a/cypress/e2e/pinpointAnalytics.cy.js b/cypress/e2e/pinpointAnalytics.cy.js index f22fc15e..255f1d66 100644 --- a/cypress/e2e/pinpointAnalytics.cy.js +++ b/cypress/e2e/pinpointAnalytics.cy.js @@ -1,13 +1,18 @@ +/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. */ +/* SPDX-License-Identifier: MIT-0 */ + +import { Viewport } from "../support/constants"; + describe("Should record user events correctly", () => { context("Desktop view", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - + it("PPA-001 - should successfully send correct user event to pinpoint", () => { - cy.sendCorrectEventToPinpoint(false); + cy.sendCorrectEventToPinpoint(Viewport.DESKTOP); }); - + it("PPA-002 - should successfully create correct endpoint with the correct event to correct pinpoint application", () => { cy.getAllLocalStorage().then(result => { const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; @@ -20,7 +25,7 @@ describe("Should record user events correctly", () => { } }).then(result => { cy.task("log", { result }); - + if (result.stdout) { const response = JSON.parse(result.stdout); expect(response["$metadata"]["httpStatusCode"]).to.equal(200); @@ -36,9 +41,9 @@ describe("Should record user events correctly", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - + it("PPA-003 - should successfully send correct user event to pinpoint", () => { - cy.sendCorrectEventToPinpoint(true); + cy.sendCorrectEventToPinpoint(Viewport.RESPONSIVE); }); }); }); diff --git a/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js b/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js index b92a0b6b..6d1f9c64 100644 --- a/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js +++ b/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js @@ -15,7 +15,7 @@ describe("Unauthorized users have limited permissions", () => { context("Responsive view", () => { it("UULP-002 - shouldn't allow unauth users to use tracker and geofence", { scrollBehavior: false }, () => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.openResponsiveMenu('[data-testid="bottomsheet"]') + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); cy.get(awsAccountButtonLocator).should("exist"); }); }); diff --git a/cypress/e2e/unauthUserCanAccessSimulation.cy.js b/cypress/e2e/unauthUserCanAccessSimulation.cy.js index 30d53817..21e05ceb 100644 --- a/cypress/e2e/unauthUserCanAccessSimulation.cy.js +++ b/cypress/e2e/unauthUserCanAccessSimulation.cy.js @@ -1,14 +1,16 @@ /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. */ /* SPDX-License-Identifier: MIT-0 */ +import { Viewport } from "../support/constants"; + describe("Unauth Simulation", () => { context("Desktop view", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - + it("US-001 - should allow user to use unauth simulation", () => { - cy.useUnauthSimulation(false) + cy.useUnauthSimulation(Viewport.DESKTOP); }); }); @@ -16,9 +18,9 @@ describe("Unauth Simulation", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - + it("US-002 - should allow user to use unauth simulation", () => { - cy.useUnauthSimulation(true) + cy.useUnauthSimulation(Viewport.RESPONSIVE); }); }); -}); \ No newline at end of file +}); diff --git a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js index 12681e45..d7ea2d7d 100644 --- a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js +++ b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js @@ -1,26 +1,28 @@ /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. */ /* SPDX-License-Identifier: MIT-0 */ +import { Viewport } from "../support/constants"; + describe("Connecting and Disconnecting AWS account", () => { context("Desktop view", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.connectAwsAccount(false); + cy.connectAwsAccount(Viewport.DESKTOP); }); - + it("CDAA-001 - should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { - cy.signOutAndDisconnectFromAwsAccount(false); + cy.signOutAndDisconnectFromAwsAccount(Viewport.DESKTOP); }); }); context("Responsive view", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.connectAwsAccount(true); + cy.connectAwsAccount(Viewport.RESPONSIVE); }); - + it("CDAA-002 - should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { - cy.signOutAndDisconnectFromAwsAccount(true); + cy.signOutAndDisconnectFromAwsAccount(Viewport.RESPONSIVE); }); }); }); diff --git a/cypress/e2e/userIsAbleToSearch.cy.js b/cypress/e2e/userIsAbleToSearch.cy.js index f3637b98..964aa02a 100644 --- a/cypress/e2e/userIsAbleToSearch.cy.js +++ b/cypress/e2e/userIsAbleToSearch.cy.js @@ -7,12 +7,16 @@ describe("Search", () => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.get('[placeholder="Search"]').click(); }); - - it("DS-001 - should allow user to view the list of search results once search is performed", { scrollBehavior: false }, () => { - cy.get('[inputmode="search"]').type("gramercy park music school USA"); - cy.get('[class="amplify-scrollview amplify-autocomplete__menu" ]').should("be.visible"); - }); - + + it( + "DS-001 - should allow user to view the list of search results once search is performed", + { scrollBehavior: false }, + () => { + cy.get('[inputmode="search"]').type("gramercy park music school USA"); + cy.get('[class="amplify-scrollview amplify-autocomplete__menu" ]').should("be.visible"); + } + ); + it( "DS-002 - should allow user to search an address and view the information popup after selecting a suggestion", { scrollBehavior: false }, @@ -25,12 +29,12 @@ describe("Search", () => { cy.get('[class="mapboxgl-popup popup-container mapboxgl-popup-anchor-left"]').should("be.visible"); } ); - + it("DS-003 - should allow user to search by geocode", { scrollBehavior: false }, () => { cy.get('[inputmode="search"]').type("-31.9627092,115.9248736").wait(10000).type("{downArrow}").type("{enter}"); cy.get('[class="mapboxgl-popup popup-container mapboxgl-popup-anchor-left"]').should("be.visible"); }); - + it("DS-004 - should allow user to view the POIs after a search", { scrollBehavior: false }, () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars Cypress.on("uncaught:exception", (err, runnable) => { @@ -43,12 +47,12 @@ describe("Search", () => { cy.wait(2000); } }); - + it("DS-005 - should show user an error message when no search text is present", { scrollBehavior: false }, () => { cy.get('[inputmode="search"]').type("{enter}"); cy.get("div").should("contain", "Failed to search place by text, 'Text' must have length at least 1"); }); - + it.skip("should enable nl search and allow user to view POI after nl search", { scrollBehavior: false }, () => { cy.get('[id="nl-search"]').click(); cy.get('[placeholder="Search"]').click(); @@ -62,28 +66,32 @@ describe("Search", () => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.get('[placeholder="Search"]').click(); }); - - it("DS-006 - should allow user to view the list of search results once search is performed", { scrollBehavior: false }, () => { - cy.get('[data-testid="search-box-input"]').type("gramercy park music school USA"); - cy.get('[data-testid="search-suggestions"]').should("be.visible"); - }); - + + it( + "DS-006 - should allow user to view the list of search results once search is performed", + { scrollBehavior: false }, + () => { + cy.get('[data-testid="search-box-input"]').type("gramercy park music school USA"); + cy.get('[data-testid="search-suggestions"]').should("be.visible"); + } + ); + it( "DS-007 - should allow user to search an address and view the information popup after selecting a suggestion", { scrollBehavior: false }, () => { - cy.get('[data-testid="search-box-input"]').type("gramercy park music school USA") + cy.get('[data-testid="search-box-input"]').type("gramercy park music school USA"); cy.get('[data-testid="search-suggestions"]').click(); cy.get('[data-testid="poi-body"]').should("be.visible"); } ); - + it("DS-008 - should allow user to search by geocode", { scrollBehavior: false }, () => { cy.get('[data-testid="search-box-input"]').type("-31.9627092,115.9248736"); cy.get('[data-testid="search-suggestions"]').click(); cy.get('[data-testid="poi-body"]').should("be.visible"); }); - + it("DS-009 - should allow user to view the POIs after a search", { scrollBehavior: false }, () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars Cypress.on("uncaught:exception", (err, runnable) => { @@ -97,7 +105,7 @@ describe("Search", () => { cy.wait(2000); } }); - + it("DS-010 - should show user an error message when no search text is present", { scrollBehavior: false }, () => { cy.get('[data-testid="search-box-input"]').type("{enter}"); cy.get("div").should("contain", "Failed to search place by text, 'Text' must have length at least 1"); diff --git a/cypress/e2e/userIsAbleToUseGeofence.cy.js b/cypress/e2e/userIsAbleToUseGeofence.cy.js index c2034a55..71ec2539 100644 --- a/cypress/e2e/userIsAbleToUseGeofence.cy.js +++ b/cypress/e2e/userIsAbleToUseGeofence.cy.js @@ -3,17 +3,19 @@ import { faker } from "@faker-js/faker"; +import { Viewport } from "../support/constants"; + describe("Geofence", () => { context("Desktop view", () => { const geofenceName = faker.random.word(); beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.connectAwsAccount(false); + cy.connectAwsAccount(Viewport.DESKTOP); }); - + it("GF-001 - should allow user to add, edit and delete geofence", () => { - cy.addEditAndDeleteGeofence(false, geofenceName); + cy.addEditAndDeleteGeofence(Viewport.DESKTOP, geofenceName); }); }); @@ -22,11 +24,11 @@ describe("Geofence", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.connectAwsAccount(true,); + cy.connectAwsAccount(Viewport.RESPONSIVE); }); - + it("GF-002 - should allow user to add, edit and delete geofence", () => { - cy.addEditAndDeleteGeofence(true, geofenceName); + cy.addEditAndDeleteGeofence(Viewport.RESPONSIVE, geofenceName); }); }); }); diff --git a/cypress/e2e/userIsAbleToUseRoute.cy.js b/cypress/e2e/userIsAbleToUseRoute.cy.js index 849f1e6a..c3c2e8f8 100644 --- a/cypress/e2e/userIsAbleToUseRoute.cy.js +++ b/cypress/e2e/userIsAbleToUseRoute.cy.js @@ -1,6 +1,8 @@ /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. */ /* SPDX-License-Identifier: MIT-0 */ +import { Viewport } from "../support/constants"; + describe("Route", () => { context("Desktop view", () => { beforeEach(() => { @@ -8,7 +10,7 @@ describe("Route", () => { cy.get('[class="amplify-flex icon outter-end-component"]').click(); cy.wait(2000); }); - + it( "R-001 - should allow user to perform a route search and is able to select current location if enabled", { scrollBehavior: false }, @@ -16,21 +18,21 @@ describe("Route", () => { cy.searchRouteAndSelectCurrentLocation(); } ); - + it("R-002 - should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { cy.swapDepartureAndDestinationAddresses(); }); - + it("R-003 - should allow user to select any of the route modes from car, walk and truck", () => { cy.canSelectAnyRouteMode(); }); - + it("R-004 - should allow user to search for route with avoid toll route option", () => { - cy.searchRouteWithAvoidTollOption(false) + cy.searchRouteWithAvoidTollOption(Viewport.DESKTOP); }); - + it("R-005 - should allow user to search for route with avoid ferry option", () => { - cy.searchRouteWithAvoidFerryOption(false); + cy.searchRouteWithAvoidFerryOption(Viewport.DESKTOP); }); }); @@ -40,7 +42,7 @@ describe("Route", () => { cy.get('[data-testid="explore-button-container-Routes"]').click(); cy.wait(2000); }); - + it( "R-006 - should allow user to perform a route search and is able to select current location if enabled", { scrollBehavior: false }, @@ -48,21 +50,21 @@ describe("Route", () => { cy.searchRouteAndSelectCurrentLocation(); } ); - + it("R-007 - should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { cy.swapDepartureAndDestinationAddresses(); }); - + it("R-008 - should allow user to select any of the route modes from car, walk and truck", () => { cy.canSelectAnyRouteMode(); }); - + it("R-009 - should allow user to search for route with avoid toll route option", () => { - cy.searchRouteWithAvoidTollOption(true) + cy.searchRouteWithAvoidTollOption(Viewport.RESPONSIVE); }); - + it("R-010 - should allow user to search for route with avoid ferry option", () => { - cy.searchRouteWithAvoidFerryOption(true); + cy.searchRouteWithAvoidFerryOption(Viewport.RESPONSIVE); }); }); }); diff --git a/cypress/e2e/userIsAbleToUseSettings.cy.js b/cypress/e2e/userIsAbleToUseSettings.cy.js index 003b9316..51c046e1 100644 --- a/cypress/e2e/userIsAbleToUseSettings.cy.js +++ b/cypress/e2e/userIsAbleToUseSettings.cy.js @@ -1,6 +1,8 @@ /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. */ /* SPDX-License-Identifier: MIT-0 */ +import { Viewport } from "../support/constants"; + describe("Settings", () => { context("Desktop view", () => { beforeEach(() => { @@ -8,19 +10,19 @@ describe("Settings", () => { cy.get('[data-testid="hamburger-menu"]').click(); cy.contains("Settings").click(); }); - + it("ST-001 - should allow user toggle default units for map", { scrollBehavior: false }, () => { - cy.toggleDefaultUnitsForMap(false); + cy.toggleDefaultUnitsForMap(Viewport.DESKTOP); }); - + it("ST-002 - should allow user to select map data provider", { scrollBehavior: false }, () => { cy.selectMapDataProvider(); }); - + it("ST-003 - should allow user to select map style", { scrollBehavior: false }, () => { - cy.selectMapStyle(false); + cy.selectMapStyle(Viewport.DESKTOP); }); - + it("ST-004 - should allow user to set default route options from settings", { scrollBehavior: false }, () => { cy.checkDefaultRouteOptions(); }); @@ -32,19 +34,19 @@ describe("Settings", () => { cy.openResponsiveMenu('[data-testid="bottomsheet"]'); cy.contains("Settings").click(); }); - + it("ST-005 - should allow user toggle default units for map", { scrollBehavior: false }, () => { - cy.toggleDefaultUnitsForMap(true); + cy.toggleDefaultUnitsForMap(Viewport.RESPONSIVE); }); - + it("ST-006 - should allow user to select map data provider", { scrollBehavior: false }, () => { cy.selectMapDataProvider(); }); - + it("ST-007 - should allow user to select map style", { scrollBehavior: false }, () => { - cy.selectMapStyle(true); + cy.selectMapStyle(Viewport.RESPONSIVE); }); - + it("ST-008 - should allow user to set default route options from settings", { scrollBehavior: false }, () => { cy.checkDefaultRouteOptions(); }); diff --git a/cypress/e2e/userIsAbleToUseTracker.cy.js b/cypress/e2e/userIsAbleToUseTracker.cy.js index fc81b59c..da7fa8b1 100644 --- a/cypress/e2e/userIsAbleToUseTracker.cy.js +++ b/cypress/e2e/userIsAbleToUseTracker.cy.js @@ -1,29 +1,32 @@ /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. */ /* SPDX-License-Identifier: MIT-0 */ + import { faker } from "@faker-js/faker"; +import { Viewport } from "../support/constants"; + const geofenceName = faker.random.word(); describe("Tracker", () => { context("Desktop view", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.connectAwsAccount(false); + cy.connectAwsAccount(Viewport.DESKTOP); }); - + it("TR-001 - should allow user to add a tracker and the user should see the notifications for Geofence enter and exit events", () => { - cy.addTrackerAndGeofenceEnterExit(false, geofenceName); + cy.addTrackerAndGeofenceEnterExit(Viewport.DESKTOP, geofenceName); }); }); context("Responsive view", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.connectAwsAccount(true); + cy.connectAwsAccount(Viewport.RESPONSIVE); }); - + it("TR-002 - should allow user to add a tracker and the user should see the notifications for Geofence enter and exit events", () => { - cy.addTrackerAndGeofenceEnterExit(true, geofenceName) + cy.addTrackerAndGeofenceEnterExit(Viewport.RESPONSIVE, geofenceName); }); }); }); diff --git a/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js b/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js index 405500ca..43f3c8da 100644 --- a/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js +++ b/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js @@ -1,24 +1,34 @@ /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. */ /* SPDX-License-Identifier: MIT-0 */ +import { Viewport } from "../support/constants"; + describe("Switch data provider and map styles", () => { context("Desktop view", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - - it("MSS-001 - should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { - cy.switchBetweenMapStyles(false); - }); + + it( + "MSS-001 - should allow user to view and switch between map styles from right side menu", + { scrollBehavior: false }, + () => { + cy.switchBetweenMapStyles(Viewport.DESKTOP); + } + ); }); context("Responsive view", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - - it("MSS-002 - Should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { - cy.switchBetweenMapStyles(true); - }); + + it( + "MSS-002 - Should allow user to view and switch between map styles from right side menu", + { scrollBehavior: false }, + () => { + cy.switchBetweenMapStyles(Viewport.RESPONSIVE); + } + ); }); }); diff --git a/cypress/support/MapDataAndStylesShortcutSupport.js b/cypress/support/MapDataAndStylesShortcutSupport.js index 47b07ffe..91af63d7 100644 --- a/cypress/support/MapDataAndStylesShortcutSupport.js +++ b/cypress/support/MapDataAndStylesShortcutSupport.js @@ -1,47 +1,38 @@ -Cypress.Commands.add("switchBetweenMapStyles", (isResponsive) => { - - if(isResponsive){ - cy.get('[data-testid="explore-button-container-Map style"]').click(); - cy.get('[data-testid="map-styles-wrapper"]').should("exist"); - } - else{ - cy.get('[data-testid="map-styles-button"]').click(); - cy.get('[data-testid="map-styles-card"]').should("be.visible"); - } - +Cypress.Commands.add("switchBetweenMapStyles", isResponsive => { + if (isResponsive) { + cy.get('[data-testid="explore-button-container-Map style"]').click(); + cy.get('[data-testid="map-styles-wrapper"]').should("exist"); + } else { + cy.get('[data-testid="map-styles-button"]').click(); + cy.get('[data-testid="map-styles-card"]').should("be.visible"); + } - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.Esri.Light"]').should( - "have.class", - "mb-style-container selected" - ); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.Esri.Light"]').should( + "have.class", + "mb-style-container selected" + ); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click({ force: true }); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click({ force: true }); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').should( - "have.class", - "mb-style-container selected" - ); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click({ force: true }); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click({ force: true }); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').should( + "have.class", + "mb-style-container selected" + ); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.Grab.StandardLight"]').click({ force: true }); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.Grab.StandardLight"]').click({ force: true }); - cy.get('[data-testid="confirmation-button"]').click({ force: true }); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.Grab.StandardLight"]').should( - "have.class", - "mb-style-container selected" - ); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.Grab.StandardLight"]').click({ force: true }); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.Grab.StandardLight"]').click({ force: true }); + cy.get('[data-testid="confirmation-button"]').click({ force: true }); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.Grab.StandardLight"]').should( + "have.class", + "mb-style-container selected" + ); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').click({ force: true }); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').click({ force: true }); - cy.get('[data-testid="confirmation-button"]').click({ force: true }); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').should( - "have.class", - "mb-style-container selected" - ); + cy.wait(5000); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').click({ force: true }); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').click({ force: true }); + cy.get('[data-testid="confirmation-button"]').click({ force: true }); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').should( + "have.class", + "mb-style-container selected" + ); }); - - - - - - - \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 49b7d6b0..289f3a6d 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -26,24 +26,34 @@ Cypress.Commands.add("visitDomainInResponsiveView", domain => { cy.visitDomain(domain); }); -Cypress.Commands.add("openResponsiveMenu", (menuElement) => { +Cypress.Commands.add("openResponsiveMenu", menuElement => { cy.get(menuElement) - .invoke('removeAttr', 'class') - .invoke('attr', 'class', 'bottom-sheet mobile disable-body-scroll no-dragging') - .invoke('removeAttr', 'style') - .invoke('attr', 'style', '--rsbs-content-opacity: 1; --rsbs-backdrop-opacity: 1; --rsbs-antigap-scale-y: 0; --rsbs-overlay-translate-y: 0px; --rsbs-overlay-rounded: 10px; --rsbs-overlay-h: 730px; opacity: 1;'); + .invoke("removeAttr", "class") + .invoke("attr", "class", "bottom-sheet mobile disable-body-scroll no-dragging") + .invoke("removeAttr", "style") + .invoke( + "attr", + "style", + "--rsbs-content-opacity: 1; --rsbs-backdrop-opacity: 1; --rsbs-antigap-scale-y: 0; --rsbs-overlay-translate-y: 0px; --rsbs-overlay-rounded: 10px; --rsbs-overlay-h: 730px; opacity: 1;" + ); }); -Cypress.Commands.add("closeResponsiveMenu", (menuElement) => { +Cypress.Commands.add("closeResponsiveMenu", menuElement => { cy.get(menuElement) - .invoke('removeAttr', 'class') - .invoke('attr', 'class', 'bottom-sheet mobile add-overlay disable-body-scroll margin-top-from-header no-dragging') - .invoke('removeAttr', 'style') - .invoke('attr', 'style', '--rsbs-content-opacity: 1; --rsbs-backdrop-opacity: 1; --rsbs-antigap-scale-y: 0; --rsbs-overlay-translate-y: 0px; --rsbs-overlay-rounded: 10px; --rsbs-overlay-h: 238px; opacity: 1;'); + .invoke("removeAttr", "class") + .invoke("attr", "class", "bottom-sheet mobile add-overlay disable-body-scroll margin-top-from-header no-dragging") + .invoke("removeAttr", "style") + .invoke( + "attr", + "style", + "--rsbs-content-opacity: 1; --rsbs-backdrop-opacity: 1; --rsbs-antigap-scale-y: 0; --rsbs-overlay-translate-y: 0px; --rsbs-overlay-rounded: 10px; --rsbs-overlay-h: 238px; opacity: 1;" + ); }); -Cypress.Commands.add("connectAwsAccount", (isResponsive) => { - isResponsive ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); +Cypress.Commands.add("connectAwsAccount", isResponsive => { + isResponsive + ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); cy.get('[data-testid="connect-aws-account-button"]').click(); cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); @@ -51,68 +61,80 @@ Cypress.Commands.add("connectAwsAccount", (isResponsive) => { cy.get('[placeholder="Enter UserPoolId"]').type(`${Cypress.env("USER_POOL_ID")}`); cy.get('[placeholder="Enter WebSocketUrl"]').type(`${Cypress.env("WEB_SOCKET_URL")}`); cy.get('[data-testid="connect-button"]').click(); - cy.get('[data-testid="connect-aws-account-modal-container"]').should( - "contain", - "Your AWS account is now connected." - ); + cy.get('[data-testid="connect-aws-account-modal-container"]').should("contain", "Your AWS account is now connected."); cy.get('[data-testid="sign-in-button"]').click(); cy.wait(5000); cy.origin(`${Cypress.env("USER_DOMAIN")}`, { args: { isResponsive } }, ({ isResponsive }) => { - isResponsive ? - cy.get(".modal-content.background-customizable.modal-content-mobile.visible-md.visible-lg").then(els => { - [...els].forEach(el => { - cy.wrap(el) - .get('[placeholder="Username"]') - .first() - .type(`${Cypress.env("COGNITO_EMAIL")}`); - cy.wrap(el) - .get('[placeholder="Password"]') - .first() - .type(`${Cypress.env("COGNITO_PASSWORD")}`); - cy.wrap(el).get('[name="signInSubmitButton"]').first().click(); - }); - }) : - cy.get(".modal-content.background-customizable.modal-content-mobile.visible-md.visible-lg").then(els => { - [...els].forEach(el => { - cy.wrap(el) - .get('[placeholder="Username"]') - .eq(1) - .type(`${Cypress.env("COGNITO_EMAIL")}`); - cy.wrap(el) - .get('[placeholder="Password"]') - .eq(1) - .type(`${Cypress.env("COGNITO_PASSWORD")}`); - cy.wrap(el).get('[name="signInSubmitButton"]').eq(1).click(); - }); - }); + isResponsive + ? cy.get(".modal-content.background-customizable.modal-content-mobile.visible-md.visible-lg").then(els => { + [...els].forEach(el => { + cy.wrap(el) + .get('[placeholder="Username"]') + .first() + .type(`${Cypress.env("COGNITO_EMAIL")}`); + cy.wrap(el) + .get('[placeholder="Password"]') + .first() + .type(`${Cypress.env("COGNITO_PASSWORD")}`); + cy.wrap(el).get('[name="signInSubmitButton"]').first().click(); + }); + }) + : cy.get(".modal-content.background-customizable.modal-content-mobile.visible-md.visible-lg").then(els => { + [...els].forEach(el => { + cy.wrap(el) + .get('[placeholder="Username"]') + .eq(1) + .type(`${Cypress.env("COGNITO_EMAIL")}`); + cy.wrap(el) + .get('[placeholder="Password"]') + .eq(1) + .type(`${Cypress.env("COGNITO_PASSWORD")}`); + cy.wrap(el).get('[name="signInSubmitButton"]').eq(1).click(); + }); + }); }); cy.wait(5000); - isResponsive ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); + isResponsive + ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); cy.get("#root").then($root => { const asd = $root.find('[class="amplify-button amplify-field-group__control amplify-button--primary"]'); if (asd.length && asd[0].innerText === "Sign in") { asd[0].click(); } else { - isResponsive ? cy.closeResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); + isResponsive + ? cy.closeResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); } - }); + }); }); -Cypress.Commands.add("signOutAndDisconnectFromAwsAccount", (isResponsive) => { - isResponsive ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); +Cypress.Commands.add("signOutAndDisconnectFromAwsAccount", isResponsive => { + isResponsive + ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); cy.get('[data-testid="sign-out-button"]').click(); cy.wait(5000); - isResponsive ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); + isResponsive + ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') + : 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() - : isResponsive ? cy.closeResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); + : isResponsive + ? cy.closeResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); }); - isResponsive ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(5000); + isResponsive + ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); cy.get('[data-testid="disconnect-aws-account-button"]').click(); cy.get('[data-testid="welcome-modal-continue-button"]').click(); - isResponsive ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); + isResponsive + ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); cy.get('[data-testid="connect-aws-account-button"]').should("exist"); }); diff --git a/cypress/support/constants.js b/cypress/support/constants.js new file mode 100644 index 00000000..6f0a89ab --- /dev/null +++ b/cypress/support/constants.js @@ -0,0 +1,4 @@ +export const Viewport = { + DESKTOP: false, + RESPONSIVE: true +}; diff --git a/cypress/support/index.js b/cypress/support/index.js index 69033c7b..6da566c8 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -5,4 +5,4 @@ import "./commands"; import "./routeSupport"; import "./settingSupport"; import "./trackerAndGeofenceSupport"; -import "./MapDataAndStylesShortcutSupport"; \ No newline at end of file +import "./MapDataAndStylesShortcutSupport"; diff --git a/cypress/support/routeSupport.js b/cypress/support/routeSupport.js index 9acf7ce2..e40cd1f2 100644 --- a/cypress/support/routeSupport.js +++ b/cypress/support/routeSupport.js @@ -1,21 +1,21 @@ Cypress.Commands.add("searchRouteAndSelectCurrentLocation", () => { cy.get('[placeholder="From"]').click(); cy.get("div").should("contain", "Current location"); - cy.get('[placeholder="From"]').type("Empire State Building", {delay: 200}); - cy.contains("Empire State Building").click({force: true}); + cy.get('[placeholder="From"]').type("Empire State Building", { delay: 200 }); + cy.contains("Empire State Building").click({ force: true }); cy.wait(2000); - cy.get('[placeholder="To"]').click().type("Gramercy Park", {delay: 200}); - cy.contains("Gramercy Park").click({force: true}); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); + cy.get('[placeholder="To"]').click().type("Gramercy Park", { delay: 200 }); + cy.contains("Gramercy Park").click({ force: true }); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); }); Cypress.Commands.add("swapDepartureAndDestinationAddresses", () => { - cy.get('[placeholder="From"]').type("Empire State Building", {delay: 200}); - cy.contains("Empire State Building").click({force: true}); + cy.get('[placeholder="From"]').type("Empire State Building", { delay: 200 }); + cy.contains("Empire State Building").click({ force: true }); cy.wait(2000); - cy.get('[placeholder="To"]').click().type("Gramercy Park", {delay: 200}); - cy.contains("Gramercy Park").click({force: true}); + cy.get('[placeholder="To"]').click().type("Gramercy Park", { delay: 200 }); + cy.contains("Gramercy Park").click({ force: true }); cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); cy.get('[class="amplify-flex swap-icon-container"]').click(); @@ -25,28 +25,32 @@ Cypress.Commands.add("swapDepartureAndDestinationAddresses", () => { }); Cypress.Commands.add("canSelectAnyRouteMode", () => { - cy.get(".travel-mode").should("have.class", "selected"); + cy.get(".travel-mode").should("have.class", "selected"); cy.get(".travel-mode").should("exist").and("have.length", 3); }); -Cypress.Commands.add("searchRouteWithAvoidTollOption", (isResponsive) => { - cy.get('[placeholder="From"]').click().type("auburn sydney", {delay: 200}); - cy.contains("Auburn").click({force: true}); +Cypress.Commands.add("searchRouteWithAvoidTollOption", isResponsive => { + cy.get('[placeholder="From"]').click().type("auburn sydney", { delay: 200 }); + cy.contains("Auburn").click({ force: true }); cy.wait(2000); - cy.get('[placeholder="To"]').click().type("manly beach sydney", {delay: 200}); - cy.contains("Beach").click({force: true}); + cy.get('[placeholder="To"]').click().type("manly beach sydney", { delay: 200 }); + cy.contains("Beach").click({ force: true }); isResponsive ? cy.get('[data-testid="more-action-icon-container"]').click() : cy.contains("Route Options").click(); cy.contains("Avoid tolls").click(); - isResponsive ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() : cy.get('[class="route-card-close"]').click(); + isResponsive + ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() + : cy.get('[class="route-card-close"]').click(); }); -Cypress.Commands.add("searchRouteWithAvoidFerryOption", (isResponsive) => { - cy.get('[placeholder="From"]').click().type("port fouad", {delay: 200}); - cy.contains("Port Fouad").click({force: true}); +Cypress.Commands.add("searchRouteWithAvoidFerryOption", isResponsive => { + cy.get('[placeholder="From"]').click().type("port fouad", { delay: 200 }); + cy.contains("Port Fouad").click({ force: true }); cy.wait(2000); - cy.get('[placeholder="To"]').click().type("port said", {delay: 200}); + cy.get('[placeholder="To"]').click().type("port said", { delay: 200 }); cy.contains("Port Said").click(); isResponsive ? cy.get('[data-testid="more-action-icon-container"]').click() : cy.contains("Route Options").click(); cy.contains("Avoid ferries").click(); - isResponsive ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() : cy.get('[class="route-card-close"]').click(); -}); \ No newline at end of file + isResponsive + ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() + : cy.get('[class="route-card-close"]').click(); +}); diff --git a/cypress/support/settingSupport.js b/cypress/support/settingSupport.js index c1c47c4a..5c661eb2 100644 --- a/cypress/support/settingSupport.js +++ b/cypress/support/settingSupport.js @@ -1,39 +1,41 @@ -Cypress.Commands.add("toggleDefaultUnitsForMap", (isResponsive) => { - cy.get('[data-testid="option-item-Units"]').click(); +Cypress.Commands.add("toggleDefaultUnitsForMap", isResponsive => { + cy.get('[data-testid="option-item-Units"]').click(); cy.get('[data-testid="unit-imperial-radio"]').click({ force: true }); - if(isResponsive){ - cy.get('[class="grey-icon back-arrow"]').click(); - } + if (isResponsive) { + cy.get('[class="grey-icon back-arrow"]').click(); + } cy.get('[data-testid="option-item-Units"]').contains("Imperial"); }); Cypress.Commands.add("selectMapDataProvider", () => { - cy.get('[data-testid="option-item-Data provider"]').click(); + cy.get('[data-testid="option-item-Data provider"]').click(); cy.get('[data-testid="option-details-container"]').contains("Esri"); cy.get('[data-testid="option-details-container"]').contains("HERE"); cy.get('[data-testid="option-details-container"]').contains("GrabMaps"); cy.get('[data-testid="option-details-container"]').contains("OpenData"); }); -Cypress.Commands.add("selectMapStyle", (isResponsive) => { - cy.get('[data-testid="option-item-Map style"]').click(); +Cypress.Commands.add("selectMapStyle", isResponsive => { + cy.get('[data-testid="option-item-Map style"]').click(); cy.contains("Streets").click(); - if(isResponsive){ - cy.get('[class="grey-icon back-arrow"]').click(); - } + if (isResponsive) { + cy.get('[class="grey-icon back-arrow"]').click(); + } cy.get('[data-testid="option-item-Map style"]').contains("Streets"); }); Cypress.Commands.add("checkDefaultRouteOptions", () => { - cy.get('[data-testid="option-item-Default route options"]').click(); + cy.get('[data-testid="option-item-Default route options"]').click(); cy.get("div").should("contain", "Avoid tolls"); cy.get("div").should("contain", "Avoid ferries"); }); -Cypress.Commands.add("sendCorrectEventToPinpoint", (isResponsive) => { - cy.getAllLocalStorage().then(result => { +Cypress.Commands.add("sendCorrectEventToPinpoint", isResponsive => { + cy.getAllLocalStorage().then(result => { const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; - isResponsive ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click() + isResponsive + ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); cy.contains("Settings").click(); cy.intercept("POST", "**/events").as("postPinpointEvents"); cy.get('[data-testid="option-item-Map style"]').click(); @@ -54,4 +56,4 @@ Cypress.Commands.add("sendCorrectEventToPinpoint", (isResponsive) => { ); }); }); -}); \ No newline at end of file +}); diff --git a/cypress/support/trackerAndGeofenceSupport.js b/cypress/support/trackerAndGeofenceSupport.js index f1835817..74701d9e 100644 --- a/cypress/support/trackerAndGeofenceSupport.js +++ b/cypress/support/trackerAndGeofenceSupport.js @@ -1,85 +1,84 @@ Cypress.Commands.add("addTrackerAndGeofenceEnterExit", (isResponsive, geofenceName) => { - if(isResponsive){ - cy.get('[data-testid="explore-button-container-Geofences"]').click(); - cy.get('[data-testid="add-geofence-button-container-mobile"]').click() - } - else{ - cy.get('[class="amplify-flex geofence-button"]').click(); - } - cy.get('[placeholder="Enter address or coordinates"]').type("Empire State Building", {delay: 200}); - cy.contains("Empire State Building").click(); - cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}`, {force: true}); - cy.contains("Save").click(); - cy.wait(5000); - cy.get("div").should("contain", `${geofenceName}`); - if(isResponsive){ - cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); + if (isResponsive) { + cy.get('[data-testid="explore-button-container-Geofences"]').click(); + cy.get('[data-testid="add-geofence-button-container-mobile"]').click(); + } else { + cy.get('[class="amplify-flex geofence-button"]').click(); + } + cy.get('[placeholder="Enter address or coordinates"]').type("Empire State Building", { delay: 200 }); + cy.wait(5000); + cy.contains("Empire State Building").click(); + cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}`, { force: true }); + cy.contains("Save").click(); + cy.wait(5000); + cy.get("div").should("contain", `${geofenceName}`); + if (isResponsive) { + cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - } - else{ - // cy.get('[data-testid="auth-geofence-box-close-button"]').click(); - cy.get('[class="amplify-flex geofence-card-close "]').click(); // TODO: remove this after deployment - cy.get('[data-testid="hamburger-menu"]').click(); - } - cy.wait(5000); - cy.contains("Tracker").click(); - cy.contains("Continue").click(); - cy.wait(5000); - cy.get('[class="mapboxgl-canvas"]').click("left", { force: true }); - cy.wait(5000); - cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); - cy.wait(5000); - cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); - cy.wait(5000); - cy.contains("Save").click(); - cy.get('[class="amplify-button amplify-field-group__control amplify-button--primary play-pause-button"]').click(); - if(isResponsive){ - cy.closeResponsiveMenu('[data-testid="bottomsheet"]'); - } - cy.get( - '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click enter-geofence"]', - { timeout: 50000 } - ) - .should("be.visible") - .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, force: true }); - cy.wait(5000); - if(isResponsive){ - cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); + } else { + // cy.get('[data-testid="auth-geofence-box-close-button"]').click(); + cy.get('[class="amplify-flex geofence-card-close "]').click(); // TODO: remove this after deployment + cy.get('[data-testid="hamburger-menu"]').click(); + } + cy.wait(5000); + cy.contains("Tracker").click(); + cy.contains("Continue").click(); + cy.wait(5000); + cy.get('[class="mapboxgl-canvas"]').click("left", { force: true }); + cy.wait(5000); + cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); + cy.wait(5000); + cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); + cy.wait(5000); + cy.contains("Save").click(); + cy.get('[class="amplify-button amplify-field-group__control amplify-button--primary play-pause-button"]').click(); + if (isResponsive) { + cy.closeResponsiveMenu('[data-testid="bottomsheet"]'); + } + cy.get( + '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click enter-geofence"]', + { timeout: 50000 } + ) + .should("be.visible") + .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, force: true }); + cy.wait(5000); + if (isResponsive) { + cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); cy.get('[data-testid="explore-button-container-Geofences"]').click(); - } - else{ - cy.get('[data-testid="auth-tracker-box-close"]').click(); - cy.wait(5000); - cy.get('[class="amplify-flex geofence-button"]').click(); - cy.wait(5000); - cy.contains("Go Back").click(); - } - cy.wait(5000); - cy.get(`[data-testid="icon-trash-${geofenceName}"]`).click({ force: true }); - cy.wait(5000); - cy.get('[data-testid="geofences-list-container"]').should("not.contain", `${geofenceName}`); - cy.wait(5000); - isResponsive ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() : cy.get('[data-testid="auth-geofence-box-close-button"]').click(); - cy.wait(5000); - cy.signOutAndDisconnectFromAwsAccount(isResponsive); + } else { + cy.get('[data-testid="auth-tracker-box-close"]').click(); + cy.wait(5000); + cy.get('[class="amplify-flex geofence-button"]').click(); + cy.wait(5000); + cy.contains("Go Back").click(); + } + cy.wait(5000); + cy.get(`[data-testid="icon-trash-${geofenceName}"]`).click({ force: true }); + cy.wait(5000); + cy.get('[data-testid="geofences-list-container"]').should("not.contain", `${geofenceName}`); + cy.wait(5000); + isResponsive + ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() + : cy.get('[data-testid="auth-geofence-box-close-button"]').click(); + cy.wait(5000); + cy.signOutAndDisconnectFromAwsAccount(isResponsive); }); Cypress.Commands.add("addEditAndDeleteGeofence", (isResponsive, geofenceName) => { - if(isResponsive){ - cy.get('[data-testid="explore-button-container-Geofences"]').click() - cy.get('[data-testid="add-geofence-button-container-mobile"]').click() + if (isResponsive) { + cy.get('[data-testid="explore-button-container-Geofences"]').click(); + cy.get('[data-testid="add-geofence-button-container-mobile"]').click(); + } else { + cy.get('[class="amplify-flex geofence-button"]').click(); + cy.get('[class="amplify-loader"]').should("not.exist"); } - else{ - cy.get('[class="amplify-flex geofence-button"]').click() - cy.get('[class="amplify-loader"]').should('not.exist'); - } - cy.get('[placeholder="Enter address or coordinates"]').type("Rio Tinto Perth Western Australia", {delay: 200}); + cy.get('[placeholder="Enter address or coordinates"]').type("Rio Tinto Perth Western Australia", { delay: 200 }); cy.wait(4000); isResponsive ? cy.get('[class="amplify-flex suggestion border-top"]').click() : cy.contains("Rio Tinto").click(); cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}`); @@ -92,12 +91,16 @@ Cypress.Commands.add("addEditAndDeleteGeofence", (isResponsive, geofenceName) => isResponsive ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() : cy.contains("Go Back").click(); cy.get(`[data-testid="icon-trash-${geofenceName}"]`).click({ force: true }); cy.get('[data-testid="geofences-list-container"]').should("not.contain", `${geofenceName}`); - isResponsive ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() : cy.get('[data-testid="auth-geofence-box-close-button"]').click(); + isResponsive + ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() + : cy.get('[data-testid="auth-geofence-box-close-button"]').click(); cy.signOutAndDisconnectFromAwsAccount(isResponsive); }); -Cypress.Commands.add("useUnauthSimulation", (isResponsive) => { - isResponsive ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') : cy.get('[data-testid="hamburger-menu"]').click(); +Cypress.Commands.add("useUnauthSimulation", isResponsive => { + isResponsive + ? cy.openResponsiveMenu('[data-testid="bottomsheet"]') + : cy.get('[data-testid="hamburger-menu"]').click(); cy.contains("Geofence").click(); cy.get('[data-testid="unauth-simulation-cta"]').click(); cy.get('[data-testid="start-simulation-btn"]').click(); @@ -114,6 +117,8 @@ Cypress.Commands.add("useUnauthSimulation", (isResponsive) => { .should("be.visible") .click({ multiple: true, force: true }); cy.get('[data-testid="pause-button"]').click(); - isResponsive ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() : cy.get('[data-testid="unauth-simulation-back-arrow"]').click(); + isResponsive + ? cy.get('[data-testid="bottomsheet-header-close-icon"]').click() + : cy.get('[data-testid="unauth-simulation-back-arrow"]').click(); cy.get('[data-testid="confirmation-cancel-button"]').click(); -}); \ No newline at end of file +});