From 893034ff999c8d2784482bc04108ee1430f5a995 Mon Sep 17 00:00:00 2001 From: Hamza Godil Date: Thu, 23 May 2024 20:27:45 +0500 Subject: [PATCH 1/7] Reponsive Demo Cases Added --- cypress/e2e/pinpointAnalytics.cy.js | 135 ++++++---- ...uthUserCanAccessLimitedFunctionality.cy.js | 18 +- .../e2e/unauthUserCanAccessSimulation.cy.js | 94 ++++--- ...AbleToConnectAndDisconnectAwsAccount.cy.js | 202 ++++++++++----- cypress/e2e/userIsAbleToSearch.cy.js | 188 +++++++++----- cypress/e2e/userIsAbleToUseGeofence.cy.js | 236 ++++++++++++------ cypress/e2e/userIsAbleToUseRoute.cy.js | 235 +++++++++++------ cypress/e2e/userIsAbleToUseTheSidebar.cy.js | 48 ++-- cypress/support/commands.js | 38 +++ 9 files changed, 824 insertions(+), 370 deletions(-) diff --git a/cypress/e2e/pinpointAnalytics.cy.js b/cypress/e2e/pinpointAnalytics.cy.js index ecc613cf..c1a93fb6 100644 --- a/cypress/e2e/pinpointAnalytics.cy.js +++ b/cypress/e2e/pinpointAnalytics.cy.js @@ -1,58 +1,93 @@ describe("Should record user events correctly", () => { - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - }); - - it("should successfully send correct user event to pinpoint", () => { - cy.wait(10000); - cy.getAllLocalStorage().then(result => { - const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(2000); - cy.contains("Settings").click(); - cy.intercept("POST", "**/events").as("postPinpointEvents"); - cy.get('[data-testid="option-item-Map style"]').click(); - cy.wait(2000); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click(); - cy.wait(2000); - cy.wait("@postPinpointEvents").then(intercepted => { - const requestBody = intercepted.request.body; - const responseBody = intercepted.response.body; - expect(Object.values(requestBody["BatchItem"][analyticsEndpointId]["Events"])[0].EventType).to.equal( - "MAP_STYLE_CHANGE" - ); - expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.Message).to.equal("Accepted"); - expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.StatusCode).to.equal(202); - expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].Message).to.equal( - "Accepted" - ); - expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].StatusCode).to.equal( - 202 - ); + context("Desktop view", () => { + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + }); + + it("should successfully send correct user event to pinpoint", () => { + cy.wait(10000); + cy.getAllLocalStorage().then(result => { + const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; + cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(2000); + cy.contains("Settings").click(); + cy.intercept("POST", "**/events").as("postPinpointEvents"); + cy.get('[data-testid="option-item-Map style"]').click(); + cy.wait(2000); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click(); + cy.wait(2000); + cy.wait("@postPinpointEvents").then(intercepted => { + const requestBody = intercepted.request.body; + const responseBody = intercepted.response.body; + expect(Object.values(requestBody["BatchItem"][analyticsEndpointId]["Events"])[0].EventType).to.equal( + "MAP_STYLE_CHANGE" + ); + expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.Message).to.equal("Accepted"); + expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.StatusCode).to.equal(202); + expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].Message).to.equal( + "Accepted" + ); + expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].StatusCode).to.equal( + 202 + ); + }); + }); + }); + + it("should successfully create correct endpoint with the correct event to correct pinpoint application", () => { + cy.wait(10000); + cy.getAllLocalStorage().then(result => { + const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; + cy.exec("node extra/fetch-pinpoint-analytics-events/index.js", { + failOnNonZeroExit: false, + env: { + PINPOINT_IDENTITY_POOL_ID: Cypress.env("PINPOINT_IDENTITY_POOL_ID"), + PINPOINT_APPLICATION_ID: Cypress.env("PINPOINT_APPLICATION_ID"), + ANALYTICS_ENDPOINT_ID: analyticsEndpointId + } + }).then(result => { + cy.task("log", { result }); + + if (result.stdout) { + const response = JSON.parse(result.stdout); + expect(response["$metadata"]["httpStatusCode"]).to.equal(200); + expect(response["EndpointResponse"]["Id"]).to.equal(analyticsEndpointId); + expect(response["EndpointResponse"]["User"]["UserId"]).to.equal(`AnonymousUser:${analyticsEndpointId}`); + } + }); }); }); }); - it("should successfully create correct endpoint with the correct event to correct pinpoint application", () => { - cy.wait(10000); - cy.getAllLocalStorage().then(result => { - const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; - cy.exec("node extra/fetch-pinpoint-analytics-events/index.js", { - failOnNonZeroExit: false, - env: { - PINPOINT_IDENTITY_POOL_ID: Cypress.env("PINPOINT_IDENTITY_POOL_ID"), - PINPOINT_APPLICATION_ID: Cypress.env("PINPOINT_APPLICATION_ID"), - ANALYTICS_ENDPOINT_ID: analyticsEndpointId - } - }).then(result => { - cy.task("log", { result }); - - if (result.stdout) { - const response = JSON.parse(result.stdout); - expect(response["$metadata"]["httpStatusCode"]).to.equal(200); - expect(response["EndpointResponse"]["Id"]).to.equal(analyticsEndpointId); - expect(response["EndpointResponse"]["User"]["UserId"]).to.equal(`AnonymousUser:${analyticsEndpointId}`); - } + context("Responsive view", () => { + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + }); + + it("should successfully send correct user event to pinpoint", () => { + cy.wait(10000); + cy.getAllLocalStorage().then(result => { + const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.contains("Settings").click(); + cy.intercept("POST", "**/events").as("postPinpointEvents"); + cy.get('[data-testid="option-item-Map style"]').click(); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click(); + cy.wait("@postPinpointEvents").then(intercepted => { + const requestBody = intercepted.request.body; + const responseBody = intercepted.response.body; + expect(Object.values(requestBody["BatchItem"][analyticsEndpointId]["Events"])[0].EventType).to.equal( + "MAP_STYLE_CHANGE" + ); + expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.Message).to.equal("Accepted"); + expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.StatusCode).to.equal(202); + expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].Message).to.equal( + "Accepted" + ); + expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].StatusCode).to.equal( + 202 + ); + }); }); }); }); diff --git a/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js b/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js index 4f439fe5..8337b9c1 100644 --- a/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js +++ b/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js @@ -2,9 +2,19 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Unauthorized users have limited permissions", () => { - it("shouldn't allow unauth users to user tracker and geofence", { scrollBehavior: false }, () => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').should("exist"); + context("Desktop view", () => { + it("shouldn't allow unauth users to user tracker and geofence", { scrollBehavior: false }, () => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.get('[data-testid="connect-aws-account-button"]').should("exist"); + }); + }); + + context("Responsive view", () => { + it("shouldn't allow unauth users to user tracker and geofence", { scrollBehavior: false }, () => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.openResponsiveMenu('[data-testid="bottomsheet"]') + cy.get('[data-testid="connect-aws-account-button"]').should("exist"); + }); }); }); diff --git a/cypress/e2e/unauthUserCanAccessSimulation.cy.js b/cypress/e2e/unauthUserCanAccessSimulation.cy.js index 5b4cd650..7577fa5c 100644 --- a/cypress/e2e/unauthUserCanAccessSimulation.cy.js +++ b/cypress/e2e/unauthUserCanAccessSimulation.cy.js @@ -2,36 +2,72 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Unauth Simulation", () => { - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + context("Desktop view", () => { + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + }); + + it("should allow user to use unauth simulation", () => { + cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(2000); + cy.contains("Geofence").click(); + cy.wait(2000); + cy.get('[data-testid="unauth-simulation-cta"]').click(); + cy.wait(2000); + cy.get('[data-testid="start-simulation-btn"]').click(); + cy.wait(2000); + cy.get( + '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click enter-geofence"]', + { timeout: 20000 } + ) + .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: 20000 } + ) + .should("be.visible") + .click({ multiple: true, force: true }); + cy.wait(2000); + cy.get('[data-testid="pause-button"]').click(); + cy.wait(2000); + cy.get('[data-testid="unauth-simulation-back-arrow"]').click(); + cy.wait(2000); + cy.get('[data-testid="confirmation-cancel-button"]').click(); + }); }); - it("should allow user to use unauth simulation", () => { - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(2000); - cy.contains("Geofence").click(); - cy.wait(2000); - cy.get('[data-testid="unauth-simulation-cta"]').click(); - cy.wait(2000); - cy.get('[data-testid="start-simulation-btn"]').click(); - cy.wait(2000); - cy.get( - '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click enter-geofence"]', - { timeout: 20000 } - ) - .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: 20000 } - ) - .should("be.visible") - .click({ multiple: true, force: true }); - cy.wait(2000); - cy.get('[data-testid="pause-button"]').click(); - cy.wait(2000); - cy.get('[data-testid="unauth-simulation-back-arrow"]').click(); - cy.wait(2000); - cy.get('[data-testid="confirmation-cancel-button"]').click(); + context("Responsive view", () => { + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + }); + + it("should allow user to use unauth simulation", () => { + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.contains("Geofence").click(); + cy.wait(2000); + cy.get('[data-testid="unauth-simulation-cta"]').click(); + cy.wait(2000); + cy.get('[data-testid="start-simulation-btn"]').click(); + cy.wait(2000); + cy.get( + '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click enter-geofence"]', + { timeout: 20000 } + ) + .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: 20000 } + ) + .should("be.visible") + .click({ multiple: true, force: true }); + cy.wait(2000); + cy.get('[data-testid="pause-button"]').click(); + cy.wait(2000); + cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); + cy.wait(2000); + cy.get('[data-testid="confirmation-cancel-button"]').click(); + }); }); }); diff --git a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js index 333d2f6d..bc6acf7b 100644 --- a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js +++ b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js @@ -2,75 +2,151 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Connecting and Disconnecting AWS account", () => { - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').first().click(); - cy.wait(5000); - cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); - cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); - cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); - 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.wait(5000); - cy.get('[data-testid="connect-aws-account-modal-container"]').should( - "contain", - "Your AWS account is now connected." - ); - cy.wait(5000); - cy.get('[data-testid="sign-in-button"]').click(); - cy.wait(5000); - cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { - 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(); + context("Desktop view", () => { + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.get('[data-testid="connect-aws-account-button"]').first().click(); + cy.wait(5000); + cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); + cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); + cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); + 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.wait(5000); + cy.get('[data-testid="connect-aws-account-modal-container"]').should( + "contain", + "Your AWS account is now connected." + ); + cy.wait(5000); + cy.get('[data-testid="sign-in-button"]').click(); + cy.wait(5000); + cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { + 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); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(5000); + 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 { + cy.get('[data-testid="hamburger-menu"]').click(); + } + }); + cy.wait(5000); }); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - 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 { - cy.get('[data-testid="hamburger-menu"]').click(); - } + + it("should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { + cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(5000); + 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.wait(5000); + cy.get('[data-testid="disconnect-aws-account-button"]').click(); + cy.wait(10000); + cy.get('[data-testid="welcome-modal-continue-button"]').click(); + cy.wait(5000); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.get('[data-testid="connect-aws-account-button"]').should("exist"); }); - cy.wait(5000); }); - it("should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - 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(); + context("Responsive view", () => { + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.get('[data-testid="connect-aws-account-button"]').first().click(); + cy.wait(5000); + cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); + cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); + cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); + 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.wait(5000); + cy.get('[data-testid="connect-aws-account-modal-container"]').should( + "contain", + "Your AWS account is now connected." + ); + cy.wait(5000); + cy.get('[data-testid="sign-in-button"]').first().click(); + cy.wait(5000); + cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { + 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.wait(5000); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.wait(5000); + 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 { + cy.closeResponsiveMenu('[data-testid="bottomsheet"]'); + } + }); + cy.wait(5000); + }); + + it("should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.wait(5000); + cy.get('[data-testid="sign-out-button"]').click(); + cy.wait(5000); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + 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.closeResponsiveMenu('[data-testid="bottomsheet"]'); + }); + cy.wait(5000); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.wait(5000); + cy.get('[data-testid="disconnect-aws-account-button"]').click(); + cy.wait(10000); + cy.get('[data-testid="welcome-modal-continue-button"]').click(); + cy.wait(5000); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.get('[data-testid="connect-aws-account-button"]').should("exist"); }); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - cy.get('[data-testid="disconnect-aws-account-button"]').click(); - cy.wait(10000); - cy.get('[data-testid="welcome-modal-continue-button"]').click(); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').should("exist"); }); }); diff --git a/cypress/e2e/userIsAbleToSearch.cy.js b/cypress/e2e/userIsAbleToSearch.cy.js index 76788967..e2c72554 100644 --- a/cypress/e2e/userIsAbleToSearch.cy.js +++ b/cypress/e2e/userIsAbleToSearch.cy.js @@ -2,74 +2,142 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Search", () => { - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.wait(5000); - }); - - it("should allow user to view the list of search results once search is performed", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); - cy.get('[inputmode="search"]').type("gramercy park music school USA"); - cy.wait(10000); - cy.get('[class="amplify-scrollview amplify-autocomplete__menu" ]').should("be.visible"); - }); - - it( - "should allow user to search an address and view the information popup after selecting a suggestion", - { scrollBehavior: false }, - () => { + context("Desktop view", () => { + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.wait(5000); + }); + + it("should allow user to view the list of search results once search is performed", { scrollBehavior: false }, () => { cy.get('[placeholder="Search"]').click(); cy.wait(2000); - cy.get('[inputmode="search"]') - .type("gramercy park music school USA") - .wait(10000) - .type("{downArrow}") - .type("{enter}"); + cy.get('[inputmode="search"]').type("gramercy park music school USA"); + cy.wait(10000); + cy.get('[class="amplify-scrollview amplify-autocomplete__menu" ]').should("be.visible"); + }); + + it( + "should allow user to search an address and view the information popup after selecting a suggestion", + { scrollBehavior: false }, + () => { + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[inputmode="search"]') + .type("gramercy park music school USA") + .wait(10000) + .type("{downArrow}") + .type("{enter}"); + cy.wait(2000); + cy.get('[class="mapboxgl-popup popup-container mapboxgl-popup-anchor-left"]').should("be.visible"); + } + ); + + it("should allow user to search by geocode", { scrollBehavior: false }, () => { + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[inputmode="search"]').type("-31.9627092,115.9248736").wait(10000).type("{downArrow}").type("{enter}"); cy.wait(2000); cy.get('[class="mapboxgl-popup popup-container mapboxgl-popup-anchor-left"]').should("be.visible"); - } - ); - - it("should allow user to search by geocode", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); - cy.get('[inputmode="search"]').type("-31.9627092,115.9248736").wait(10000).type("{downArrow}").type("{enter}"); - cy.wait(2000); - cy.get('[class="mapboxgl-popup popup-container mapboxgl-popup-anchor-left"]').should("be.visible"); - }); - - it("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) => { - return false; }); - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); - cy.get('[inputmode="search"]').type("Rio tinto").wait(10000).type("{enter}"); - cy.wait(2000); - cy.get("div").should("contain", "Rio Tinto"); - cy.wait(2000); - for (let i = 0; i < 10; i++) { + + it("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) => { + return false; + }); + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[inputmode="search"]').type("Rio tinto").wait(10000).type("{enter}"); + cy.wait(2000); cy.get("div").should("contain", "Rio Tinto"); cy.wait(2000); - } - }); - - it("should show user an error message when no search text is present", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); - cy.get('[inputmode="search"]').type("{enter}"); - cy.wait(2000); - cy.get("div").should("contain", "Failed to search place by text, 'Text' must have length at least 1"); + for (let i = 0; i < 10; i++) { + cy.get("div").should("contain", "Rio Tinto"); + cy.wait(2000); + } + }); + + it("should show user an error message when no search text is present", { scrollBehavior: false }, () => { + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[inputmode="search"]').type("{enter}"); + cy.wait(2000); + 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(); + cy.wait(2000); + cy.get('[inputmode="search"]').type("Find me one starbucks in Vancouver?").wait(5000).type("{enter}"); + cy.wait(15000); + cy.get("div").invoke("text").should("have.length.gt", 0); + }); }); - 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(); - cy.wait(2000); - cy.get('[inputmode="search"]').type("Find me one starbucks in Vancouver?").wait(5000).type("{enter}"); - cy.wait(15000); - cy.get("div").invoke("text").should("have.length.gt", 0); + context("Responsive view", () => { + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.wait(5000); + }); + + it("should allow user to view the list of search results once search is performed", { scrollBehavior: false }, () => { + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[data-testid="search-box-input"]').type("gramercy park music school USA"); + cy.wait(10000); + cy.get('[data-testid="search-suggestions"]').should("be.visible"); + }); + + it( + "should allow user to search an address and view the information popup after selecting a suggestion", + { scrollBehavior: false }, + () => { + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[data-testid="search-box-input"]').type("gramercy park music school USA") + cy.wait(10000) + cy.get('[data-testid="search-suggestions"]').click(); + cy.wait(2000); + cy.get('[data-testid="poi-body"]').should("be.visible"); + } + ); + + it("should allow user to search by geocode", { scrollBehavior: false }, () => { + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[data-testid="search-box-input"]').type("-31.9627092,115.9248736"); + cy.wait(10000); + cy.get('[data-testid="search-suggestions"]').click(); + cy.wait(2000); + cy.get('[data-testid="poi-body"]').should("be.visible"); + }); + + it("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) => { + return false; + }); + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[data-testid="search-box-input"]').type("Rio tinto"); + cy.wait(10000); + cy.get('[data-testid="search-suggestions"]').first().click(); + cy.wait(2000); + cy.get("div").should("contain", "Rio Tinto"); + cy.wait(2000); + for (let i = 0; i < 10; i++) { + cy.get("div").should("contain", "Rio Tinto"); + cy.wait(2000); + } + }); + + it("should show user an error message when no search text is present", { scrollBehavior: false }, () => { + cy.get('[placeholder="Search"]').click(); + cy.wait(2000); + cy.get('[data-testid="search-box-input"]').type("{enter}"); + cy.wait(2000); + 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 e92fd623..51b3a690 100644 --- a/cypress/e2e/userIsAbleToUseGeofence.cy.js +++ b/cypress/e2e/userIsAbleToUseGeofence.cy.js @@ -4,86 +4,174 @@ import { faker } from "@faker-js/faker"; describe("Geofence", () => { - const geofenceName = faker.random.word(); + context("Desktop view", () => { + const geofenceName = faker.random.word(); - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').first().click(); - cy.wait(5000); - cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); - cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); - cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); - 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.wait(5000); - cy.get('[data-testid="connect-aws-account-modal-container"]').should( - "contain", - "Your AWS account is now connected." - ); - cy.wait(5000); - cy.get('[data-testid="sign-in-button"]').click(); - cy.wait(5000); - cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { - 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(); + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.get('[data-testid="connect-aws-account-button"]').first().click(); + cy.wait(5000); + cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); + cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); + cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); + 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.wait(5000); + cy.get('[data-testid="connect-aws-account-modal-container"]').should( + "contain", + "Your AWS account is now connected." + ); + cy.wait(5000); + cy.get('[data-testid="sign-in-button"]').click(); + cy.wait(5000); + cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { + 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); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(5000); + 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 { + cy.get('[data-testid="hamburger-menu"]').click(); + } + }); + cy.wait(5000); }); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - 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 { - cy.get('[data-testid="hamburger-menu"]').click(); - } + + it("should allow user to add, edit and delete geofence", () => { + cy.get('[class="amplify-flex geofence-button"]').click(); + cy.get('[placeholder="Enter address or coordinates"]').type("Rio Tinto Perth Western Australia"); + cy.wait(4000); + cy.contains("Rio Tinto").click(); + cy.wait(5000); + cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}`); + cy.wait(5000); + cy.contains("Save").click(); + cy.wait(5000); + cy.get("div").should("contain", `${geofenceName}`); + cy.wait(5000); + cy.contains(`${geofenceName}`).click({ force: true }); + cy.wait(5000); + cy.contains("Save").should("be.disabled"); + 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); + cy.get('[data-testid="auth-geofence-box-close-button"]').click(); + cy.wait(5000); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(5000); + cy.get('[data-testid="sign-out-button"]').click(); + cy.wait(30000); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.wait(5000); + cy.get('[data-testid="disconnect-aws-account-button"]').click(); }); - cy.wait(5000); }); - it("should allow user to add, edit and delete geofence", () => { - cy.get('[class="amplify-flex geofence-button"]').click(); - cy.get('[placeholder="Enter address or coordinates"]').type("Rio Tinto Perth Western Australia"); - cy.wait(4000); - cy.contains("Rio Tinto").click(); - cy.wait(5000); - cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}`); - cy.wait(5000); - cy.contains("Save").click(); - cy.wait(5000); - cy.get("div").should("contain", `${geofenceName}`); - cy.wait(5000); - cy.contains(`${geofenceName}`).click({ force: true }); - cy.wait(5000); - cy.contains("Save").should("be.disabled"); - 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); - cy.get('[data-testid="auth-geofence-box-close-button"]').click(); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - cy.get('[data-testid="sign-out-button"]').click(); - cy.wait(30000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - cy.get('[data-testid="disconnect-aws-account-button"]').click(); + context("Responsive view", () => { + const geofenceName = faker.random.word(); + + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.get('[data-testid="connect-aws-account-button"]').first().click(); + cy.wait(5000); + cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); + cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); + cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); + 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.wait(5000); + cy.get('[data-testid="connect-aws-account-modal-container"]').should( + "contain", + "Your AWS account is now connected." + ); + cy.wait(5000); + cy.get('[data-testid="sign-in-button"]').first().click(); + cy.wait(5000); + cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { + 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.wait(5000); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.wait(5000); + 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 { + cy.closeResponsiveMenu('[data-testid="bottomsheet"]'); + } + }); + cy.wait(5000); + }); + + it("should allow user to add, edit and delete geofence", () => { + cy.get('[data-testid="explore-button-container-Geofences"]').click(); + cy.get('[data-testid="add-geofence-button-container-mobile"]').click(); + cy.get('[placeholder="Enter address or coordinates"]').type("Rio Tinto Perth Western Australia"); + cy.wait(4000); + cy.get('[class="amplify-flex suggestion border-top"]').click(); + cy.wait(5000); + cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}{enter}`); + cy.wait(5000); + cy.contains("Save").click(); + cy.wait(5000); + cy.get("div").should("contain", `${geofenceName}`); + cy.wait(5000); + cy.contains(`${geofenceName}`).click({ force: true }); + cy.wait(5000); + cy.contains("Save").should("be.disabled"); + cy.get('[data-testid="bottomsheet-header-close-icon"]').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); + cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); + cy.wait(5000); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.wait(5000); + cy.get('[data-testid="sign-out-button"]').click(); + cy.wait(30000); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.wait(5000); + cy.get('[data-testid="disconnect-aws-account-button"]').click(); + }); }); }); diff --git a/cypress/e2e/userIsAbleToUseRoute.cy.js b/cypress/e2e/userIsAbleToUseRoute.cy.js index fb8c166d..086bdcf7 100644 --- a/cypress/e2e/userIsAbleToUseRoute.cy.js +++ b/cypress/e2e/userIsAbleToUseRoute.cy.js @@ -2,18 +2,34 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Route", () => { - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[class="amplify-flex icon outter-end-component"]').click(); - cy.wait(2000); - }); - - it( - "should allow user to perform a route search and is able to select current location if enabled", - { scrollBehavior: false }, - () => { - cy.get('[placeholder="From"]').click(); - cy.get("div").should("contain", "Current location"); + context("Desktop view", () => { + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.get('[class="amplify-flex icon outter-end-component"]').click(); + cy.wait(2000); + }); + + it( + "should allow user to perform a route search and is able to select current location if enabled", + { scrollBehavior: false }, + () => { + cy.get('[placeholder="From"]').click(); + cy.get("div").should("contain", "Current location"); + cy.get('[placeholder="From"]').type("Empire State Building"); + cy.wait(2000); + cy.contains("Empire State Building").click(); + cy.wait(2000); + cy.get('[placeholder="To"]').click().type("Gramercy Park"); + cy.wait(2000); + cy.contains("Gramercy Park").click(); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); + } + ); + + it("should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { cy.get('[placeholder="From"]').type("Empire State Building"); cy.wait(2000); cy.contains("Empire State Building").click(); @@ -25,67 +41,142 @@ describe("Route", () => { cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); cy.wait(2000); cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); - } - ); - - it("should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { - cy.get('[placeholder="From"]').type("Empire State Building"); - cy.wait(2000); - cy.contains("Empire State Building").click(); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("Gramercy Park"); - cy.wait(2000); - cy.contains("Gramercy Park").click(); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); - cy.wait(2000); - cy.get('[class="amplify-flex swap-icon-container"]').click(); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); - cy.wait(2000); - cy.get('[class="amplify-flex swap-icon-container"]').click(); - }); - - it("should allow user to select any of the route modes from car, walk and truck", () => { - cy.get(".travel-mode").should("have.class", "selected"); - cy.get(".travel-mode").should("exist").and("have.length", 3); - }); - - it("should allow user to search for route with avoid toll route option", () => { - cy.get('[placeholder="From"]').click().type("auburn sydney"); - cy.wait(4000); - cy.contains("Auburn").click(); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("manly beach sydney"); - cy.wait(4000); - cy.contains("Beach").click(); - cy.wait(2000); - cy.contains("Route Options").click(); - cy.wait(2000); - cy.contains("Avoid tolls").click(); - cy.wait(2000); - cy.get('[class="route-card-close"]').click(); - cy.wait(3000); + cy.wait(2000); + cy.get('[class="amplify-flex swap-icon-container"]').click(); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); + cy.wait(2000); + cy.get('[class="amplify-flex swap-icon-container"]').click(); + }); + + it("should allow user to select any of the route modes from car, walk and truck", () => { + cy.get(".travel-mode").should("have.class", "selected"); + cy.get(".travel-mode").should("exist").and("have.length", 3); + }); + + it("should allow user to search for route with avoid toll route option", () => { + cy.get('[placeholder="From"]').click().type("auburn sydney"); + cy.wait(4000); + cy.contains("Auburn").click(); + cy.wait(2000); + cy.get('[placeholder="To"]').click().type("manly beach sydney"); + cy.wait(4000); + cy.contains("Beach").click(); + cy.wait(2000); + cy.contains("Route Options").click(); + cy.wait(2000); + cy.contains("Avoid tolls").click(); + cy.wait(2000); + cy.get('[class="route-card-close"]').click(); + cy.wait(3000); + }); + + it("should allow user to search for route with avoid ferry option", () => { + cy.get('[placeholder="From"]').click().type("port fouad"); + cy.wait(2000); + cy.contains("Port Fouad").click(); + cy.wait(2000); + cy.get('[placeholder="To"]').click().type("port said"); + cy.wait(2000); + cy.contains("Port Said").click(); + cy.wait(2000); + cy.contains("Route Options").click(); + cy.wait(2000); + cy.contains("Avoid ferries").click(); + cy.wait(2000); + cy.get('[class="route-card-close"]').click(); + cy.wait(2000); + }); }); - it("should allow user to search for route with avoid ferry option", () => { - cy.get('[placeholder="From"]').click().type("port fouad"); - cy.wait(2000); - cy.contains("Port Fouad").click(); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("port said"); - cy.wait(2000); - cy.contains("Port Said").click(); - cy.wait(2000); - cy.contains("Route Options").click(); - cy.wait(2000); - cy.contains("Avoid ferries").click(); - cy.wait(2000); - cy.get('[class="route-card-close"]').click(); - cy.wait(2000); + context("Responsive view", () => { + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.get('[data-testid="explore-button-container-Routes"]').click(); + cy.wait(2000); + }); + + it( + "should allow user to perform a route search and is able to select current location if enabled", + { scrollBehavior: false }, + () => { + cy.get('[placeholder="From"]').click(); + cy.get("div").should("contain", "Current location"); + cy.get('[placeholder="From"]').type("Empire State Building"); + cy.wait(2000); + cy.contains("Empire State Building").click({force: true}); + cy.wait(2000); + cy.get('[placeholder="To"]').click().type("Gramercy Park"); + cy.wait(2000); + cy.contains("Gramercy Park").click({force: true}); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); + } + ); + + it("should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { + cy.get('[placeholder="From"]').type("Empire State Building"); + cy.wait(2000); + cy.contains("Empire State Building").click({force: true}); + cy.wait(2000); + cy.get('[placeholder="To"]').click().type("Gramercy Park"); + cy.wait(2000); + cy.contains("Gramercy Park").click({force: true}); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); + cy.wait(2000); + cy.get('[class="amplify-flex swap-icon-container"]').click(); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); + cy.wait(2000); + cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); + cy.wait(2000); + cy.get('[class="amplify-flex swap-icon-container"]').click(); + }); + + it("should allow user to select any of the route modes from car, walk and truck", () => { + cy.get(".travel-mode").should("have.class", "selected"); + cy.get(".travel-mode").should("exist").and("have.length", 3); + }); + + it("should allow user to search for route with avoid toll route option", () => { + cy.get('[placeholder="From"]').click().type("auburn sydney"); + cy.wait(4000); + cy.contains("Auburn").click({force: true}); + cy.wait(2000); + cy.get('[placeholder="To"]').click().type("manly beach sydney"); + cy.wait(4000); + cy.contains("Beach").click({force: true}); + cy.wait(2000); + cy.get('[data-testid="more-action-icon-container"]').click(); + cy.wait(2000); + cy.contains("Avoid tolls").click(); + cy.wait(2000); + cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); + cy.wait(3000); + }); + + it("should allow user to search for route with avoid ferry option", () => { + cy.get('[placeholder="From"]').click().type("port fouad"); + cy.wait(2000); + cy.contains("Port Fouad").click({force: true}); + cy.wait(2000); + cy.get('[placeholder="To"]').click().type("port said"); + cy.wait(2000); + cy.contains("Port Said").click({force: true}); + cy.wait(2000); + cy.get('[data-testid="more-action-icon-container"]').click(); + cy.wait(2000); + cy.contains("Avoid ferries").click(); + cy.wait(2000); + cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); + cy.wait(2000); + }); }); }); diff --git a/cypress/e2e/userIsAbleToUseTheSidebar.cy.js b/cypress/e2e/userIsAbleToUseTheSidebar.cy.js index adae3fc4..54688f7f 100644 --- a/cypress/e2e/userIsAbleToUseTheSidebar.cy.js +++ b/cypress/e2e/userIsAbleToUseTheSidebar.cy.js @@ -2,23 +2,35 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Sidebar", () => { - it("should allow user to access the sidebar via hamburger menu", { scrollBehavior: false }, () => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(2000); - cy.get("div").should("contain", "Demo"); - cy.wait(500); - cy.get("div").should("contain", "Geofence"); - cy.wait(500); - cy.get("div").should("contain", "Tracker"); - cy.wait(500); - cy.get("div").should("contain", "Settings"); - cy.wait(500); - cy.get("div").should("contain", "About"); - cy.wait(500); - cy.get("div").should("contain", "Overview"); - cy.wait(500); - cy.get("div").should("contain", "Samples"); - cy.wait(2000); + context("Desktop view", () => { + it("should allow user to access the sidebar via hamburger menu", { scrollBehavior: false }, () => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.get("div").should("contain", "Demo") + .and("contain", "Geofence") + .and("contain", "Tracker") + .and("contain", "Settings") + .and("contain", "Overview") + .and("contain", "Samples"); + }); + }); + + context("Responsive view", () => { + it("should allow user to access the Bottom Sheet (sidebar) in responsive menu", { scrollBehavior: false }, () => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.get('[data-testid="explore-button-container-Map style"]').should("contain", "Map style"); + cy.get('[data-testid="explore-button-container-Routes"]').should("contain", "Routes"); + cy.get('[data-testid="explore-button-container-Geofences"]').should("contain", "Geofences"); + cy.get('[data-testid="explore-button-container-Trackers"]').should("contain", "Tracker"); + cy.get('[data-testid="iconic-info-card-title"]') + .should("contain", "Overview") + .and("contain", "Samples") + .and("contain", "Migration") + .and("contain", "Pricing") + .and("contain", "Settings") + .and("contain", "About") + .and("contain", "Provide Feedback") + }); }); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 18aea6e3..f0771e01 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -20,3 +20,41 @@ Cypress.Commands.add("visitDomain", domain => { cy.get('[data-testid="welcome-modal-continue-button"]').click(); } }); + +Cypress.Commands.add("visitDomainInResponsiveView", domain => { + Cypress.on("uncaught:exception", () => { + return false; + }); + + cy.viewport(400, 733); + + if (typeof domain === "string") { + domain.includes("dev") + ? cy.visit(domain, { + auth: { + username: Cypress.env("WEB_DOMAIN_USERNAME"), + password: Cypress.env("WEB_DOMAIN_PASSWORD") + } + }) + : cy.visit(domain); + + cy.wait(20000); + cy.get('[data-testid="welcome-modal-continue-button"]').click(); + } +}); + +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;'); +}); + +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;'); +}); From 277ac773ff9f29df6575f84644f58e0aa0435061 Mon Sep 17 00:00:00 2001 From: Hamza Godil Date: Thu, 23 May 2024 21:25:25 +0500 Subject: [PATCH 2/7] Style Responsive Cases Added --- ...serIsAbleUseMapDataAndStylesShortcut.cy.js | 116 ++++++++++++------ 1 file changed, 80 insertions(+), 36 deletions(-) diff --git a/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js b/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js index d8b04d41..2ab79f29 100644 --- a/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js +++ b/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js @@ -2,43 +2,87 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Switch data provider and map styles", () => { - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + context("Desktop view", () => { + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + }); + + it("should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { + 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.HERE.Explore"]').click({ force: true }); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click({ force: true }); + cy.wait(5000); + 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.wait(5000); + 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.wait(5000); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').should( + "have.class", + "mb-style-container selected" + ); + }); }); - it("should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { - 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.HERE.Explore"]').click({ force: true }); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click({ force: true }); - cy.wait(5000); - 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.wait(5000); - 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.wait(5000); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').should( - "have.class", - "mb-style-container selected" - ); + context("Responsive view", () => { + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + }); + + it("should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { + cy.get('[data-testid="explore-button-container-Map style"]').click(); + cy.get('[data-testid="map-styles-wrapper"]').should("exist"); + + 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.wait(5000); + 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.wait(5000); + 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.wait(5000); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').should( + "have.class", + "mb-style-container selected" + ); + }); }); }); From 76bfff3ba906f5e39f58f23395598ac0173006a2 Mon Sep 17 00:00:00 2001 From: Hamza Godil Date: Fri, 24 May 2024 06:38:35 +0500 Subject: [PATCH 3/7] Setting cases add --- ...AbleToConnectAndDisconnectAwsAccount.cy.js | 4 +- cypress/e2e/userIsAbleToUseSettings.cy.js | 98 +++++++++++++------ 2 files changed, 68 insertions(+), 34 deletions(-) diff --git a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js index bc6acf7b..f4dd6ba1 100644 --- a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js +++ b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js @@ -6,7 +6,7 @@ describe("Connecting and Disconnecting AWS account", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').first().click(); + cy.get('[data-testid="connect-aws-account-button"]').click(); cy.wait(5000); cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); @@ -80,7 +80,7 @@ describe("Connecting and Disconnecting AWS account", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.get('[data-testid="connect-aws-account-button"]').first().click(); + cy.get('[data-testid="connect-aws-account-button"]').click(); cy.wait(5000); cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); diff --git a/cypress/e2e/userIsAbleToUseSettings.cy.js b/cypress/e2e/userIsAbleToUseSettings.cy.js index 7e22fa82..e45c8c53 100644 --- a/cypress/e2e/userIsAbleToUseSettings.cy.js +++ b/cypress/e2e/userIsAbleToUseSettings.cy.js @@ -2,39 +2,73 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Settings", () => { - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.contains("Settings").click(); + context("Desktop view", () => { + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.get('[data-testid="hamburger-menu"]').click(); + cy.contains("Settings").click(); + }); + + it("should allow user toggle default units for map", { scrollBehavior: false }, () => { + cy.get('[data-testid="option-item-Units"]').click(); + cy.get('[data-testid="unit-imperial-radio"]').click({ force: true }); + cy.get('[data-testid="option-item-Units"]').contains("Imperial"); + }); + + it("should allow user to select map data provider", { scrollBehavior: false }, () => { + 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"); + }); + + it("should allow user to select map style", { scrollBehavior: false }, () => { + cy.get('[data-testid="option-item-Map style"]').click(); + cy.contains("Streets").click(); + cy.get('[data-testid="option-item-Map style"]').contains("Streets"); + }); + + it("should allow user to set default route options from settings", { scrollBehavior: false }, () => { + cy.get('[data-testid="option-item-Default route options"]').click(); + cy.get("div").should("contain", "Avoid tolls"); + cy.get("div").should("contain", "Avoid ferries"); + }); }); - it("should allow user toggle default units for map", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Units"]').click(); - cy.get('[data-testid="unit-imperial-radio"]').click({ force: true }); - cy.get('[data-testid="option-item-Units"]').contains("Imperial"); - }); - - it.only("should allow user to select map data provider", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Data provider"]').click(); - cy.get('[class="amplify-flex option-details-container"]').contains("Esri"); - cy.get('[class="amplify-flex option-details-container"]').contains("HERE"); - cy.get('[class="amplify-flex option-details-container"]').contains("GrabMaps"); - cy.get('[class="amplify-flex option-details-container"]').contains("OpenData"); - // 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"); - }); - - it("should allow user to select map style", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Map style"]').click(); - cy.contains("Streets").click(); - cy.get('[data-testid="option-item-Map style"]').contains("Streets"); - }); - - it("should allow user to set default route options from settings", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Default route options"]').click(); - cy.get("div").should("contain", "Avoid tolls"); - cy.get("div").should("contain", "Avoid ferries"); + context("Responsive view", () => { + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.openResponsiveMenu('[data-testid="bottomsheet"]'); + cy.contains("Settings").click(); + }); + + it("should allow user toggle default units for map", { scrollBehavior: false }, () => { + cy.get('[data-testid="option-item-Units"]').click(); + cy.get('[data-testid="unit-imperial-radio"]').click({ force: true }); + cy.get('[class="grey-icon back-arrow"]').click(); + cy.get('[data-testid="option-item-Units"]').contains("Imperial"); + }); + + it("should allow user to select map data provider", { scrollBehavior: false }, () => { + 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"); + }); + + it("should allow user to select map style", { scrollBehavior: false }, () => { + cy.get('[data-testid="option-item-Map style"]').click(); + cy.contains("Streets").click(); + cy.get('[class="grey-icon back-arrow"]').click(); + cy.get('[data-testid="option-item-Map style"]').contains("Streets"); + }); + + it("should allow user to set default route options from settings", { scrollBehavior: false }, () => { + cy.get('[data-testid="option-item-Default route options"]').click(); + cy.get("div").should("contain", "Avoid tolls"); + cy.get("div").should("contain", "Avoid ferries"); + }); }); }); From 36a79f16dc9955886bb9e7c0a94d2bb12502d59a Mon Sep 17 00:00:00 2001 From: Hamza Godil Date: Thu, 30 May 2024 13:42:17 +0500 Subject: [PATCH 4/7] Waits Removed and code cleaned --- cypress.config.ts | 1 + cypress/e2e/pinpointAnalytics.cy.js | 60 +------ ...uthUserCanAccessLimitedFunctionality.cy.js | 10 +- .../e2e/unauthUserCanAccessSimulation.cy.js | 59 +------ .../e2e/userCanViewTheirCurrentLocation.cy.js | 2 +- cypress/e2e/userCanZoomInAndOut.cy.js | 2 +- ...AbleToConnectAndDisconnectAwsAccount.cy.js | 138 +-------------- cypress/e2e/userIsAbleToSearch.cy.js | 61 ++----- cypress/e2e/userIsAbleToUseGeofence.cy.js | 157 +----------------- cypress/e2e/userIsAbleToUseRoute.cy.js | 154 +++-------------- cypress/e2e/userIsAbleToUseSettings.cy.js | 54 ++---- cypress/e2e/userIsAbleToUseTheSidebar.cy.js | 4 +- cypress/e2e/userIsAbleToUseTracker.cy.js | 125 ++------------ ...serIsAbleUseMapDataAndStylesShortcut.cy.js | 72 +------- .../MapDataAndStylesShortcutSupport.js | 47 ++++++ cypress/support/commands.js | 94 +++++++++-- cypress/support/index.js | 4 + cypress/support/routeSupport.js | 52 ++++++ cypress/support/settingSupport.js | 57 +++++++ cypress/support/trackerAndGeofenceSupport.js | 119 +++++++++++++ 20 files changed, 456 insertions(+), 816 deletions(-) create mode 100644 cypress/support/MapDataAndStylesShortcutSupport.js create mode 100644 cypress/support/routeSupport.js create mode 100644 cypress/support/settingSupport.js create mode 100644 cypress/support/trackerAndGeofenceSupport.js diff --git a/cypress.config.ts b/cypress.config.ts index dbf8b617..4a9065ec 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -3,6 +3,7 @@ import { cypressBrowserPermissionsPlugin } from "cypress-browser-permissions"; import { afterRunHook, beforeRunHook } from "cypress-mochawesome-reporter/lib"; export default defineConfig({ + defaultCommandTimeout: 20000, viewportWidth: 1024, viewportHeight: 733, retries: 2, diff --git a/cypress/e2e/pinpointAnalytics.cy.js b/cypress/e2e/pinpointAnalytics.cy.js index c1a93fb6..f22fc15e 100644 --- a/cypress/e2e/pinpointAnalytics.cy.js +++ b/cypress/e2e/pinpointAnalytics.cy.js @@ -4,38 +4,11 @@ describe("Should record user events correctly", () => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - it("should successfully send correct user event to pinpoint", () => { - cy.wait(10000); - cy.getAllLocalStorage().then(result => { - const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(2000); - cy.contains("Settings").click(); - cy.intercept("POST", "**/events").as("postPinpointEvents"); - cy.get('[data-testid="option-item-Map style"]').click(); - cy.wait(2000); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click(); - cy.wait(2000); - cy.wait("@postPinpointEvents").then(intercepted => { - const requestBody = intercepted.request.body; - const responseBody = intercepted.response.body; - expect(Object.values(requestBody["BatchItem"][analyticsEndpointId]["Events"])[0].EventType).to.equal( - "MAP_STYLE_CHANGE" - ); - expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.Message).to.equal("Accepted"); - expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.StatusCode).to.equal(202); - expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].Message).to.equal( - "Accepted" - ); - expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].StatusCode).to.equal( - 202 - ); - }); - }); + it("PPA-001 - should successfully send correct user event to pinpoint", () => { + cy.sendCorrectEventToPinpoint(false); }); - it("should successfully create correct endpoint with the correct event to correct pinpoint application", () => { - cy.wait(10000); + 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"]; cy.exec("node extra/fetch-pinpoint-analytics-events/index.js", { @@ -64,31 +37,8 @@ describe("Should record user events correctly", () => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - it("should successfully send correct user event to pinpoint", () => { - cy.wait(10000); - cy.getAllLocalStorage().then(result => { - const analyticsEndpointId = result[`${Cypress.env("WEB_DOMAIN")}`]["amazon-location_analyticsEndpointId"]; - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.contains("Settings").click(); - cy.intercept("POST", "**/events").as("postPinpointEvents"); - cy.get('[data-testid="option-item-Map style"]').click(); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click(); - cy.wait("@postPinpointEvents").then(intercepted => { - const requestBody = intercepted.request.body; - const responseBody = intercepted.response.body; - expect(Object.values(requestBody["BatchItem"][analyticsEndpointId]["Events"])[0].EventType).to.equal( - "MAP_STYLE_CHANGE" - ); - expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.Message).to.equal("Accepted"); - expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.StatusCode).to.equal(202); - expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].Message).to.equal( - "Accepted" - ); - expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].StatusCode).to.equal( - 202 - ); - }); - }); + it("PPA-003 - should successfully send correct user event to pinpoint", () => { + cy.sendCorrectEventToPinpoint(true); }); }); }); diff --git a/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js b/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js index 8337b9c1..b92a0b6b 100644 --- a/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js +++ b/cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js @@ -2,19 +2,21 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Unauthorized users have limited permissions", () => { + let awsAccountButtonLocator = '[data-testid="connect-aws-account-button"]'; + context("Desktop view", () => { - it("shouldn't allow unauth users to user tracker and geofence", { scrollBehavior: false }, () => { + it("UULP-001 - shouldn't allow unauth users to use tracker and geofence", { scrollBehavior: false }, () => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').should("exist"); + cy.get(awsAccountButtonLocator).should("exist"); }); }); context("Responsive view", () => { - it("shouldn't allow unauth users to user tracker and geofence", { scrollBehavior: false }, () => { + 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.get('[data-testid="connect-aws-account-button"]').should("exist"); + cy.get(awsAccountButtonLocator).should("exist"); }); }); }); diff --git a/cypress/e2e/unauthUserCanAccessSimulation.cy.js b/cypress/e2e/unauthUserCanAccessSimulation.cy.js index 7577fa5c..30d53817 100644 --- a/cypress/e2e/unauthUserCanAccessSimulation.cy.js +++ b/cypress/e2e/unauthUserCanAccessSimulation.cy.js @@ -7,33 +7,8 @@ describe("Unauth Simulation", () => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - it("should allow user to use unauth simulation", () => { - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(2000); - cy.contains("Geofence").click(); - cy.wait(2000); - cy.get('[data-testid="unauth-simulation-cta"]').click(); - cy.wait(2000); - cy.get('[data-testid="start-simulation-btn"]').click(); - cy.wait(2000); - cy.get( - '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click enter-geofence"]', - { timeout: 20000 } - ) - .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: 20000 } - ) - .should("be.visible") - .click({ multiple: true, force: true }); - cy.wait(2000); - cy.get('[data-testid="pause-button"]').click(); - cy.wait(2000); - cy.get('[data-testid="unauth-simulation-back-arrow"]').click(); - cy.wait(2000); - cy.get('[data-testid="confirmation-cancel-button"]').click(); + it("US-001 - should allow user to use unauth simulation", () => { + cy.useUnauthSimulation(false) }); }); @@ -42,32 +17,8 @@ describe("Unauth Simulation", () => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - it("should allow user to use unauth simulation", () => { - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.contains("Geofence").click(); - cy.wait(2000); - cy.get('[data-testid="unauth-simulation-cta"]').click(); - cy.wait(2000); - cy.get('[data-testid="start-simulation-btn"]').click(); - cy.wait(2000); - cy.get( - '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click enter-geofence"]', - { timeout: 20000 } - ) - .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: 20000 } - ) - .should("be.visible") - .click({ multiple: true, force: true }); - cy.wait(2000); - cy.get('[data-testid="pause-button"]').click(); - cy.wait(2000); - cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); - cy.wait(2000); - cy.get('[data-testid="confirmation-cancel-button"]').click(); + it("US-002 - should allow user to use unauth simulation", () => { + cy.useUnauthSimulation(true) }); }); -}); +}); \ No newline at end of file diff --git a/cypress/e2e/userCanViewTheirCurrentLocation.cy.js b/cypress/e2e/userCanViewTheirCurrentLocation.cy.js index b92d25ce..d3858904 100644 --- a/cypress/e2e/userCanViewTheirCurrentLocation.cy.js +++ b/cypress/e2e/userCanViewTheirCurrentLocation.cy.js @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Current location", () => { - it("should allow user to see their current location", { scrollBehavior: false }, () => { + it("CL-001 - should allow user to see their current location", { scrollBehavior: false }, () => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.get('[class="mapboxgl-user-location-dot mapboxgl-marker mapboxgl-marker-anchor-center"]').should("be.visible"); }); diff --git a/cypress/e2e/userCanZoomInAndOut.cy.js b/cypress/e2e/userCanZoomInAndOut.cy.js index 33a5d05b..6a91ae32 100644 --- a/cypress/e2e/userCanZoomInAndOut.cy.js +++ b/cypress/e2e/userCanZoomInAndOut.cy.js @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT-0 */ describe("Map zoom in/out", () => { - it("should allow user to be able to zoom the map in and out", { scrollBehavior: false }, () => { + it("ZIO-001 - should allow user to be able to zoom the map in and out", { scrollBehavior: false }, () => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); for (let i = 0; i < 3; i++) { diff --git a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js index f4dd6ba1..12681e45 100644 --- a/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js +++ b/cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js @@ -5,148 +5,22 @@ describe("Connecting and Disconnecting AWS account", () => { context("Desktop view", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').click(); - cy.wait(5000); - cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); - cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); - cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); - 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.wait(5000); - cy.get('[data-testid="connect-aws-account-modal-container"]').should( - "contain", - "Your AWS account is now connected." - ); - cy.wait(5000); - cy.get('[data-testid="sign-in-button"]').click(); - cy.wait(5000); - cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { - 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); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - 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 { - cy.get('[data-testid="hamburger-menu"]').click(); - } - }); - cy.wait(5000); + cy.connectAwsAccount(false); }); - it("should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - 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.wait(5000); - cy.get('[data-testid="disconnect-aws-account-button"]').click(); - cy.wait(10000); - cy.get('[data-testid="welcome-modal-continue-button"]').click(); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').should("exist"); + it("CDAA-001 - should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { + cy.signOutAndDisconnectFromAwsAccount(false); }); }); context("Responsive view", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.get('[data-testid="connect-aws-account-button"]').click(); - cy.wait(5000); - cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); - cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); - cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); - 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.wait(5000); - cy.get('[data-testid="connect-aws-account-modal-container"]').should( - "contain", - "Your AWS account is now connected." - ); - cy.wait(5000); - cy.get('[data-testid="sign-in-button"]').first().click(); - cy.wait(5000); - cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { - 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.wait(5000); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.wait(5000); - 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 { - cy.closeResponsiveMenu('[data-testid="bottomsheet"]'); - } - }); - cy.wait(5000); + cy.connectAwsAccount(true); }); - it("should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.wait(5000); - cy.get('[data-testid="sign-out-button"]').click(); - cy.wait(5000); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - 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.closeResponsiveMenu('[data-testid="bottomsheet"]'); - }); - cy.wait(5000); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.wait(5000); - cy.get('[data-testid="disconnect-aws-account-button"]').click(); - cy.wait(10000); - cy.get('[data-testid="welcome-modal-continue-button"]').click(); - cy.wait(5000); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.get('[data-testid="connect-aws-account-button"]').should("exist"); + it("CDAA-002 - should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => { + cy.signOutAndDisconnectFromAwsAccount(true); }); }); }); diff --git a/cypress/e2e/userIsAbleToSearch.cy.js b/cypress/e2e/userIsAbleToSearch.cy.js index e2c72554..f3637b98 100644 --- a/cypress/e2e/userIsAbleToSearch.cy.js +++ b/cypress/e2e/userIsAbleToSearch.cy.js @@ -5,72 +5,54 @@ describe("Search", () => { context("Desktop view", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.wait(5000); + cy.get('[placeholder="Search"]').click(); }); - it("should allow user to view the list of search results once search is performed", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); + 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.wait(10000); cy.get('[class="amplify-scrollview amplify-autocomplete__menu" ]').should("be.visible"); }); it( - "should allow user to search an address and view the information popup after selecting a suggestion", + "DS-002 - should allow user to search an address and view the information popup after selecting a suggestion", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); cy.get('[inputmode="search"]') .type("gramercy park music school USA") .wait(10000) .type("{downArrow}") .type("{enter}"); - cy.wait(2000); cy.get('[class="mapboxgl-popup popup-container mapboxgl-popup-anchor-left"]').should("be.visible"); } ); - it("should allow user to search by geocode", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); + 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.wait(2000); cy.get('[class="mapboxgl-popup popup-container mapboxgl-popup-anchor-left"]').should("be.visible"); }); - it("should allow user to view the POIs after a search", { scrollBehavior: false }, () => { + 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) => { return false; }); - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); cy.get('[inputmode="search"]').type("Rio tinto").wait(10000).type("{enter}"); - cy.wait(2000); cy.get("div").should("contain", "Rio Tinto"); - cy.wait(2000); for (let i = 0; i < 10; i++) { cy.get("div").should("contain", "Rio Tinto"); cy.wait(2000); } }); - it("should show user an error message when no search text is present", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - 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.wait(2000); 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(); - cy.wait(2000); cy.get('[inputmode="search"]').type("Find me one starbucks in Vancouver?").wait(5000).type("{enter}"); - cy.wait(15000); cy.get("div").invoke("text").should("have.length.gt", 0); }); }); @@ -78,65 +60,46 @@ describe("Search", () => { context("Responsive view", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.wait(5000); + cy.get('[placeholder="Search"]').click(); }); - it("should allow user to view the list of search results once search is performed", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); + 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.wait(10000); cy.get('[data-testid="search-suggestions"]').should("be.visible"); }); it( - "should allow user to search an address and view the information popup after selecting a suggestion", + "DS-007 - should allow user to search an address and view the information popup after selecting a suggestion", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); cy.get('[data-testid="search-box-input"]').type("gramercy park music school USA") - cy.wait(10000) cy.get('[data-testid="search-suggestions"]').click(); - cy.wait(2000); cy.get('[data-testid="poi-body"]').should("be.visible"); } ); - it("should allow user to search by geocode", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); + 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.wait(10000); cy.get('[data-testid="search-suggestions"]').click(); - cy.wait(2000); cy.get('[data-testid="poi-body"]').should("be.visible"); }); - it("should allow user to view the POIs after a search", { scrollBehavior: false }, () => { + 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) => { return false; }); - cy.get('[placeholder="Search"]').click(); - cy.wait(2000); cy.get('[data-testid="search-box-input"]').type("Rio tinto"); - cy.wait(10000); cy.get('[data-testid="search-suggestions"]').first().click(); - cy.wait(2000); cy.get("div").should("contain", "Rio Tinto"); - cy.wait(2000); for (let i = 0; i < 10; i++) { cy.get("div").should("contain", "Rio Tinto"); cy.wait(2000); } }); - it("should show user an error message when no search text is present", { scrollBehavior: false }, () => { - cy.get('[placeholder="Search"]').click(); - 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.wait(2000); 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 51b3a690..c2034a55 100644 --- a/cypress/e2e/userIsAbleToUseGeofence.cy.js +++ b/cypress/e2e/userIsAbleToUseGeofence.cy.js @@ -9,83 +9,11 @@ describe("Geofence", () => { beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').first().click(); - cy.wait(5000); - cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); - cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); - cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); - 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.wait(5000); - cy.get('[data-testid="connect-aws-account-modal-container"]').should( - "contain", - "Your AWS account is now connected." - ); - cy.wait(5000); - cy.get('[data-testid="sign-in-button"]').click(); - cy.wait(5000); - cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { - 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); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - 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 { - cy.get('[data-testid="hamburger-menu"]').click(); - } - }); - cy.wait(5000); + cy.connectAwsAccount(false); }); - it("should allow user to add, edit and delete geofence", () => { - cy.get('[class="amplify-flex geofence-button"]').click(); - cy.get('[placeholder="Enter address or coordinates"]').type("Rio Tinto Perth Western Australia"); - cy.wait(4000); - cy.contains("Rio Tinto").click(); - cy.wait(5000); - cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}`); - cy.wait(5000); - cy.contains("Save").click(); - cy.wait(5000); - cy.get("div").should("contain", `${geofenceName}`); - cy.wait(5000); - cy.contains(`${geofenceName}`).click({ force: true }); - cy.wait(5000); - cy.contains("Save").should("be.disabled"); - 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); - cy.get('[data-testid="auth-geofence-box-close-button"]').click(); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - cy.get('[data-testid="sign-out-button"]').click(); - cy.wait(30000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - cy.get('[data-testid="disconnect-aws-account-button"]').click(); + it("GF-001 - should allow user to add, edit and delete geofence", () => { + cy.addEditAndDeleteGeofence(false, geofenceName); }); }); @@ -94,84 +22,11 @@ describe("Geofence", () => { beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.get('[data-testid="connect-aws-account-button"]').first().click(); - cy.wait(5000); - cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); - cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); - cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); - 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.wait(5000); - cy.get('[data-testid="connect-aws-account-modal-container"]').should( - "contain", - "Your AWS account is now connected." - ); - cy.wait(5000); - cy.get('[data-testid="sign-in-button"]').first().click(); - cy.wait(5000); - cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { - 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.wait(5000); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.wait(5000); - 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 { - cy.closeResponsiveMenu('[data-testid="bottomsheet"]'); - } - }); - cy.wait(5000); + cy.connectAwsAccount(true,); }); - it("should allow user to add, edit and delete geofence", () => { - cy.get('[data-testid="explore-button-container-Geofences"]').click(); - cy.get('[data-testid="add-geofence-button-container-mobile"]').click(); - cy.get('[placeholder="Enter address or coordinates"]').type("Rio Tinto Perth Western Australia"); - cy.wait(4000); - cy.get('[class="amplify-flex suggestion border-top"]').click(); - cy.wait(5000); - cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}{enter}`); - cy.wait(5000); - cy.contains("Save").click(); - cy.wait(5000); - cy.get("div").should("contain", `${geofenceName}`); - cy.wait(5000); - cy.contains(`${geofenceName}`).click({ force: true }); - cy.wait(5000); - cy.contains("Save").should("be.disabled"); - cy.get('[data-testid="bottomsheet-header-close-icon"]').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); - cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); - cy.wait(5000); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.wait(5000); - cy.get('[data-testid="sign-out-button"]').click(); - cy.wait(30000); - cy.openResponsiveMenu('[data-testid="bottomsheet"]'); - cy.wait(5000); - cy.get('[data-testid="disconnect-aws-account-button"]').click(); + it("GF-002 - should allow user to add, edit and delete geofence", () => { + cy.addEditAndDeleteGeofence(true, geofenceName); }); }); }); diff --git a/cypress/e2e/userIsAbleToUseRoute.cy.js b/cypress/e2e/userIsAbleToUseRoute.cy.js index 086bdcf7..849f1e6a 100644 --- a/cypress/e2e/userIsAbleToUseRoute.cy.js +++ b/cypress/e2e/userIsAbleToUseRoute.cy.js @@ -10,84 +10,27 @@ describe("Route", () => { }); it( - "should allow user to perform a route search and is able to select current location if enabled", + "R-001 - should allow user to perform a route search and is able to select current location if enabled", { scrollBehavior: false }, () => { - cy.get('[placeholder="From"]').click(); - cy.get("div").should("contain", "Current location"); - cy.get('[placeholder="From"]').type("Empire State Building"); - cy.wait(2000); - cy.contains("Empire State Building").click(); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("Gramercy Park"); - cy.wait(2000); - cy.contains("Gramercy Park").click(); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); + cy.searchRouteAndSelectCurrentLocation(); } ); - it("should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { - cy.get('[placeholder="From"]').type("Empire State Building"); - cy.wait(2000); - cy.contains("Empire State Building").click(); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("Gramercy Park"); - cy.wait(2000); - cy.contains("Gramercy Park").click(); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); - cy.wait(2000); - cy.get('[class="amplify-flex swap-icon-container"]').click(); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); - cy.wait(2000); - cy.get('[class="amplify-flex swap-icon-container"]').click(); + it("R-002 - should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { + cy.swapDepartureAndDestinationAddresses(); }); - it("should allow user to select any of the route modes from car, walk and truck", () => { - cy.get(".travel-mode").should("have.class", "selected"); - cy.get(".travel-mode").should("exist").and("have.length", 3); + it("R-003 - should allow user to select any of the route modes from car, walk and truck", () => { + cy.canSelectAnyRouteMode(); }); - it("should allow user to search for route with avoid toll route option", () => { - cy.get('[placeholder="From"]').click().type("auburn sydney"); - cy.wait(4000); - cy.contains("Auburn").click(); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("manly beach sydney"); - cy.wait(4000); - cy.contains("Beach").click(); - cy.wait(2000); - cy.contains("Route Options").click(); - cy.wait(2000); - cy.contains("Avoid tolls").click(); - cy.wait(2000); - cy.get('[class="route-card-close"]').click(); - cy.wait(3000); + it("R-004 - should allow user to search for route with avoid toll route option", () => { + cy.searchRouteWithAvoidTollOption(false) }); - it("should allow user to search for route with avoid ferry option", () => { - cy.get('[placeholder="From"]').click().type("port fouad"); - cy.wait(2000); - cy.contains("Port Fouad").click(); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("port said"); - cy.wait(2000); - cy.contains("Port Said").click(); - cy.wait(2000); - cy.contains("Route Options").click(); - cy.wait(2000); - cy.contains("Avoid ferries").click(); - cy.wait(2000); - cy.get('[class="route-card-close"]').click(); - cy.wait(2000); + it("R-005 - should allow user to search for route with avoid ferry option", () => { + cy.searchRouteWithAvoidFerryOption(false); }); }); @@ -99,84 +42,27 @@ describe("Route", () => { }); it( - "should allow user to perform a route search and is able to select current location if enabled", + "R-006 - should allow user to perform a route search and is able to select current location if enabled", { scrollBehavior: false }, () => { - cy.get('[placeholder="From"]').click(); - cy.get("div").should("contain", "Current location"); - cy.get('[placeholder="From"]').type("Empire State Building"); - cy.wait(2000); - cy.contains("Empire State Building").click({force: true}); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("Gramercy Park"); - cy.wait(2000); - cy.contains("Gramercy Park").click({force: true}); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); + cy.searchRouteAndSelectCurrentLocation(); } ); - it("should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { - cy.get('[placeholder="From"]').type("Empire State Building"); - cy.wait(2000); - cy.contains("Empire State Building").click({force: true}); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("Gramercy Park"); - cy.wait(2000); - cy.contains("Gramercy Park").click({force: true}); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); - cy.wait(2000); - cy.get('[class="amplify-flex swap-icon-container"]').click(); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(0).should("be.visible"); - cy.wait(2000); - cy.get('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); - cy.wait(2000); - cy.get('[class="amplify-flex swap-icon-container"]').click(); + it("R-007 - should allow user to swap the departure and destination addresses", { scrollBehavior: false }, () => { + cy.swapDepartureAndDestinationAddresses(); }); - it("should allow user to select any of the route modes from car, walk and truck", () => { - cy.get(".travel-mode").should("have.class", "selected"); - cy.get(".travel-mode").should("exist").and("have.length", 3); + it("R-008 - should allow user to select any of the route modes from car, walk and truck", () => { + cy.canSelectAnyRouteMode(); }); - it("should allow user to search for route with avoid toll route option", () => { - cy.get('[placeholder="From"]').click().type("auburn sydney"); - cy.wait(4000); - cy.contains("Auburn").click({force: true}); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("manly beach sydney"); - cy.wait(4000); - cy.contains("Beach").click({force: true}); - cy.wait(2000); - cy.get('[data-testid="more-action-icon-container"]').click(); - cy.wait(2000); - cy.contains("Avoid tolls").click(); - cy.wait(2000); - cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); - cy.wait(3000); + it("R-009 - should allow user to search for route with avoid toll route option", () => { + cy.searchRouteWithAvoidTollOption(true) }); - it("should allow user to search for route with avoid ferry option", () => { - cy.get('[placeholder="From"]').click().type("port fouad"); - cy.wait(2000); - cy.contains("Port Fouad").click({force: true}); - cy.wait(2000); - cy.get('[placeholder="To"]').click().type("port said"); - cy.wait(2000); - cy.contains("Port Said").click({force: true}); - cy.wait(2000); - cy.get('[data-testid="more-action-icon-container"]').click(); - cy.wait(2000); - cy.contains("Avoid ferries").click(); - cy.wait(2000); - cy.get('[data-testid="bottomsheet-header-close-icon"]').click(); - cy.wait(2000); + it("R-010 - should allow user to search for route with avoid ferry option", () => { + cy.searchRouteWithAvoidFerryOption(true); }); }); }); diff --git a/cypress/e2e/userIsAbleToUseSettings.cy.js b/cypress/e2e/userIsAbleToUseSettings.cy.js index e45c8c53..003b9316 100644 --- a/cypress/e2e/userIsAbleToUseSettings.cy.js +++ b/cypress/e2e/userIsAbleToUseSettings.cy.js @@ -9,30 +9,20 @@ describe("Settings", () => { cy.contains("Settings").click(); }); - it("should allow user toggle default units for map", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Units"]').click(); - cy.get('[data-testid="unit-imperial-radio"]').click({ force: true }); - cy.get('[data-testid="option-item-Units"]').contains("Imperial"); + it("ST-001 - should allow user toggle default units for map", { scrollBehavior: false }, () => { + cy.toggleDefaultUnitsForMap(false); }); - it("should allow user to select map data provider", { scrollBehavior: false }, () => { - 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"); + it("ST-002 - should allow user to select map data provider", { scrollBehavior: false }, () => { + cy.selectMapDataProvider(); }); - it("should allow user to select map style", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Map style"]').click(); - cy.contains("Streets").click(); - cy.get('[data-testid="option-item-Map style"]').contains("Streets"); + it("ST-003 - should allow user to select map style", { scrollBehavior: false }, () => { + cy.selectMapStyle(false); }); - it("should allow user to set default route options from settings", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Default route options"]').click(); - cy.get("div").should("contain", "Avoid tolls"); - cy.get("div").should("contain", "Avoid ferries"); + it("ST-004 - should allow user to set default route options from settings", { scrollBehavior: false }, () => { + cy.checkDefaultRouteOptions(); }); }); @@ -43,32 +33,20 @@ describe("Settings", () => { cy.contains("Settings").click(); }); - it("should allow user toggle default units for map", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Units"]').click(); - cy.get('[data-testid="unit-imperial-radio"]').click({ force: true }); - cy.get('[class="grey-icon back-arrow"]').click(); - cy.get('[data-testid="option-item-Units"]').contains("Imperial"); + it("ST-005 - should allow user toggle default units for map", { scrollBehavior: false }, () => { + cy.toggleDefaultUnitsForMap(true); }); - it("should allow user to select map data provider", { scrollBehavior: false }, () => { - 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"); + it("ST-006 - should allow user to select map data provider", { scrollBehavior: false }, () => { + cy.selectMapDataProvider(); }); - it("should allow user to select map style", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Map style"]').click(); - cy.contains("Streets").click(); - cy.get('[class="grey-icon back-arrow"]').click(); - cy.get('[data-testid="option-item-Map style"]').contains("Streets"); + it("ST-007 - should allow user to select map style", { scrollBehavior: false }, () => { + cy.selectMapStyle(true); }); - it("should allow user to set default route options from settings", { scrollBehavior: false }, () => { - cy.get('[data-testid="option-item-Default route options"]').click(); - cy.get("div").should("contain", "Avoid tolls"); - cy.get("div").should("contain", "Avoid ferries"); + it("ST-008 - should allow user to set default route options from settings", { scrollBehavior: false }, () => { + cy.checkDefaultRouteOptions(); }); }); }); diff --git a/cypress/e2e/userIsAbleToUseTheSidebar.cy.js b/cypress/e2e/userIsAbleToUseTheSidebar.cy.js index 54688f7f..eba24d4a 100644 --- a/cypress/e2e/userIsAbleToUseTheSidebar.cy.js +++ b/cypress/e2e/userIsAbleToUseTheSidebar.cy.js @@ -3,7 +3,7 @@ describe("Sidebar", () => { context("Desktop view", () => { - it("should allow user to access the sidebar via hamburger menu", { scrollBehavior: false }, () => { + it("SB-001 - should allow user to access the sidebar via hamburger menu", { scrollBehavior: false }, () => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.get('[data-testid="hamburger-menu"]').click(); cy.get("div").should("contain", "Demo") @@ -16,7 +16,7 @@ describe("Sidebar", () => { }); context("Responsive view", () => { - it("should allow user to access the Bottom Sheet (sidebar) in responsive menu", { scrollBehavior: false }, () => { + it("SB-002 - should allow user to access the Bottom Sheet (sidebar) in responsive menu", { scrollBehavior: false }, () => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.openResponsiveMenu('[data-testid="bottomsheet"]'); cy.get('[data-testid="explore-button-container-Map style"]').should("contain", "Map style"); diff --git a/cypress/e2e/userIsAbleToUseTracker.cy.js b/cypress/e2e/userIsAbleToUseTracker.cy.js index 0d2d4585..fc81b59c 100644 --- a/cypress/e2e/userIsAbleToUseTracker.cy.js +++ b/cypress/e2e/userIsAbleToUseTracker.cy.js @@ -5,118 +5,25 @@ import { faker } from "@faker-js/faker"; const geofenceName = faker.random.word(); describe("Tracker", () => { - beforeEach(() => { - cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.get('[data-testid="connect-aws-account-button"]').first().click(); - cy.wait(5000); - cy.get('[placeholder="Enter IdentityPoolId"]').type(`${Cypress.env("IDENTITY_POOL_ID")}`); - cy.get('[placeholder="Enter UserDomain"]').type(`${Cypress.env("USER_DOMAIN")}`); - cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); - 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.wait(5000); - cy.get('[data-testid="connect-aws-account-modal-container"]').should( - "contain", - "Your AWS account is now connected." - ); - cy.wait(5000); - cy.get('[data-testid="sign-in-button"]').click(); - cy.wait(5000); - cy.origin(`${Cypress.env("USER_DOMAIN")}`, () => { - 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(); - }); - }); + context("Desktop view", () => { + beforeEach(() => { + cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.connectAwsAccount(false); }); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - 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 { - cy.get('[data-testid="hamburger-menu"]').click(); - } + + 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.wait(5000); }); - it("should allow user to add a tracker and the user should see the notifications for Geofence enter and exit events", () => { - cy.get('[class="amplify-flex geofence-button"]').click(); - cy.wait(5000); - cy.get('[placeholder="Enter address or coordinates"]').type("Empire State Building"); - cy.wait(5000); - cy.contains("Empire State Building").click(); - cy.wait(5000); - cy.get('[placeholder="Type unique Geofence Name"]').type(`${geofenceName}`); - cy.wait(5000); - cy.contains("Save").click(); - cy.wait(5000); - cy.get("div").should("contain", `${geofenceName}`); - cy.wait(1000); - // 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.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - cy.contains("Tracker").click(); - cy.wait(5000); - 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.wait(5000); - cy.get('[class="amplify-button amplify-field-group__control amplify-button--primary play-pause-button"]').click(); - cy.wait(5000); - 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); - 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); - cy.get('[data-testid="auth-geofence-box-close-button"]').click(); - cy.wait(5000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - cy.get('[data-testid="sign-out-button"]').click(); - cy.wait(30000); - cy.get('[data-testid="hamburger-menu"]').click(); - cy.wait(5000); - cy.get('[data-testid="disconnect-aws-account-button"]').click(); + context("Responsive view", () => { + beforeEach(() => { + cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); + cy.connectAwsAccount(true); + }); + + 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) + }); }); }); diff --git a/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js b/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js index 2ab79f29..405500ca 100644 --- a/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js +++ b/cypress/e2e/userIsAbleUseMapDataAndStylesShortcut.cy.js @@ -7,40 +7,8 @@ describe("Switch data provider and map styles", () => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - it("should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { - 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.HERE.Explore"]').click({ force: true }); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click({ force: true }); - cy.wait(5000); - 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.wait(5000); - 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.wait(5000); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').should( - "have.class", - "mb-style-container selected" - ); + it("MSS-001 - should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { + cy.switchBetweenMapStyles(false); }); }); @@ -49,40 +17,8 @@ describe("Switch data provider and map styles", () => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); }); - it("should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { - cy.get('[data-testid="explore-button-container-Map style"]').click(); - cy.get('[data-testid="map-styles-wrapper"]').should("exist"); - - 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.wait(5000); - 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.wait(5000); - 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.wait(5000); - cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.OpenData.StandardLight"]').should( - "have.class", - "mb-style-container selected" - ); + it("MSS-002 - Should allow user to view and switch between map styles from right side menu", { scrollBehavior: false }, () => { + cy.switchBetweenMapStyles(true); }); }); }); diff --git a/cypress/support/MapDataAndStylesShortcutSupport.js b/cypress/support/MapDataAndStylesShortcutSupport.js new file mode 100644 index 00000000..47b07ffe --- /dev/null +++ b/cypress/support/MapDataAndStylesShortcutSupport.js @@ -0,0 +1,47 @@ +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.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.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 f0771e01..49b7d6b0 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -22,25 +22,8 @@ Cypress.Commands.add("visitDomain", domain => { }); Cypress.Commands.add("visitDomainInResponsiveView", domain => { - Cypress.on("uncaught:exception", () => { - return false; - }); - cy.viewport(400, 733); - - if (typeof domain === "string") { - domain.includes("dev") - ? cy.visit(domain, { - auth: { - username: Cypress.env("WEB_DOMAIN_USERNAME"), - password: Cypress.env("WEB_DOMAIN_PASSWORD") - } - }) - : cy.visit(domain); - - cy.wait(20000); - cy.get('[data-testid="welcome-modal-continue-button"]').click(); - } + cy.visitDomain(domain); }); Cypress.Commands.add("openResponsiveMenu", (menuElement) => { @@ -58,3 +41,78 @@ Cypress.Commands.add("closeResponsiveMenu", (menuElement) => { .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(); + 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")}`); + cy.get('[placeholder="Enter UserPoolClientId"]').type(`${Cypress.env("USER_POOL_CLIENT_ID")}`); + 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="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(); + }); + }); + }); + cy.wait(5000); + 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(); + } + }); +}); + +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(); + 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.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(); + cy.get('[data-testid="connect-aws-account-button"]').should("exist"); +}); diff --git a/cypress/support/index.js b/cypress/support/index.js index 05cb5fb6..69033c7b 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -2,3 +2,7 @@ /* SPDX-License-Identifier: MIT-0 */ import "./commands"; +import "./routeSupport"; +import "./settingSupport"; +import "./trackerAndGeofenceSupport"; +import "./MapDataAndStylesShortcutSupport"; \ No newline at end of file diff --git a/cypress/support/routeSupport.js b/cypress/support/routeSupport.js new file mode 100644 index 00000000..9acf7ce2 --- /dev/null +++ b/cypress/support/routeSupport.js @@ -0,0 +1,52 @@ +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.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('[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.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('[class="mapboxgl-marker mapboxgl-marker-anchor-center"]').eq(1).should("be.visible"); + cy.get('[class="amplify-flex swap-icon-container"]').click(); + 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(); +}); + +Cypress.Commands.add("canSelectAnyRouteMode", () => { + 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}); + cy.wait(2000); + 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(); +}); + +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.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 diff --git a/cypress/support/settingSupport.js b/cypress/support/settingSupport.js new file mode 100644 index 00000000..c1c47c4a --- /dev/null +++ b/cypress/support/settingSupport.js @@ -0,0 +1,57 @@ +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(); + } + 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-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(); + cy.contains("Streets").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("div").should("contain", "Avoid tolls"); + cy.get("div").should("contain", "Avoid ferries"); +}); + +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() + cy.contains("Settings").click(); + cy.intercept("POST", "**/events").as("postPinpointEvents"); + cy.get('[data-testid="option-item-Map style"]').click(); + cy.get('[data-testid="map-style-item-location.aws.com.demo.maps.HERE.Explore"]').click(); + cy.wait("@postPinpointEvents").then(intercepted => { + const requestBody = intercepted.request.body; + const responseBody = intercepted.response.body; + expect(Object.values(requestBody["BatchItem"][analyticsEndpointId]["Events"])[0].EventType).to.equal( + "MAP_STYLE_CHANGE" + ); + expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.Message).to.equal("Accepted"); + expect(responseBody["Results"][analyticsEndpointId].EndpointItemResponse.StatusCode).to.equal(202); + expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].Message).to.equal( + "Accepted" + ); + expect(Object.values(responseBody["Results"][analyticsEndpointId].EventsItemResponse)[0].StatusCode).to.equal( + 202 + ); + }); + }); +}); \ No newline at end of file diff --git a/cypress/support/trackerAndGeofenceSupport.js b/cypress/support/trackerAndGeofenceSupport.js new file mode 100644 index 00000000..f1835817 --- /dev/null +++ b/cypress/support/trackerAndGeofenceSupport.js @@ -0,0 +1,119 @@ +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(); + 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(); + 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); +}); + +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() + } + 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.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}`); + cy.wait(5000); + cy.contains("Save").click(); + cy.wait(5000); + cy.get("div").should("contain", `${geofenceName}`); + cy.contains(`${geofenceName}`).click({ force: true }); + cy.contains("Save").should("be.disabled"); + 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(); + cy.signOutAndDisconnectFromAwsAccount(isResponsive); +}); + +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(); + cy.get( + '[class="Toastify__toast Toastify__toast-theme--dark Toastify__toast--info Toastify__toast--close-on-click enter-geofence"]', + { timeout: 20000 } + ) + .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: 20000 } + ) + .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(); + cy.get('[data-testid="confirmation-cancel-button"]').click(); +}); \ No newline at end of file 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 5/7] 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 +}); From eab912bf0d6e4b71417a7f1d2149188b78b194ef Mon Sep 17 00:00:00 2001 From: Hamza Godil Date: Mon, 10 Jun 2024 20:22:40 +0500 Subject: [PATCH 6/7] CI/CD fails fix --- cypress/e2e/userIsAbleToUseTracker.cy.js | 6 ++++-- cypress/support/routeSupport.js | 2 ++ cypress/support/trackerAndGeofenceSupport.js | 3 --- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/userIsAbleToUseTracker.cy.js b/cypress/e2e/userIsAbleToUseTracker.cy.js index da7fa8b1..f50442bb 100644 --- a/cypress/e2e/userIsAbleToUseTracker.cy.js +++ b/cypress/e2e/userIsAbleToUseTracker.cy.js @@ -5,10 +5,10 @@ import { faker } from "@faker-js/faker"; import { Viewport } from "../support/constants"; -const geofenceName = faker.random.word(); - describe("Tracker", () => { context("Desktop view", () => { + const geofenceName = faker.random.word(); + beforeEach(() => { cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.connectAwsAccount(Viewport.DESKTOP); @@ -20,6 +20,8 @@ describe("Tracker", () => { }); context("Responsive view", () => { + const geofenceName = faker.random.word(); + beforeEach(() => { cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`); cy.connectAwsAccount(Viewport.RESPONSIVE); diff --git a/cypress/support/routeSupport.js b/cypress/support/routeSupport.js index e40cd1f2..468be1e3 100644 --- a/cypress/support/routeSupport.js +++ b/cypress/support/routeSupport.js @@ -1,4 +1,5 @@ Cypress.Commands.add("searchRouteAndSelectCurrentLocation", () => { + cy.wait(20000); cy.get('[placeholder="From"]').click(); cy.get("div").should("contain", "Current location"); cy.get('[placeholder="From"]').type("Empire State Building", { delay: 200 }); @@ -16,6 +17,7 @@ Cypress.Commands.add("swapDepartureAndDestinationAddresses", () => { cy.wait(2000); cy.get('[placeholder="To"]').click().type("Gramercy Park", { delay: 200 }); cy.contains("Gramercy Park").click({ force: true }); + cy.wait(10000); 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(); diff --git a/cypress/support/trackerAndGeofenceSupport.js b/cypress/support/trackerAndGeofenceSupport.js index 74701d9e..d08b51a1 100644 --- a/cypress/support/trackerAndGeofenceSupport.js +++ b/cypress/support/trackerAndGeofenceSupport.js @@ -32,9 +32,6 @@ Cypress.Commands.add("addTrackerAndGeofenceEnterExit", (isResponsive, geofenceNa 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 } From 23081f7bcda9cc2ba5db93f8f5f9498287c5fbf3 Mon Sep 17 00:00:00 2001 From: Rahul Bajaj Date: Mon, 10 Jun 2024 11:25:37 -0700 Subject: [PATCH 7/7] feedback remove nl search category (#119) --- src/atomicui/molecules/FeedbackModal/FeedbackModal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/atomicui/molecules/FeedbackModal/FeedbackModal.tsx b/src/atomicui/molecules/FeedbackModal/FeedbackModal.tsx index 41525866..1efdaafa 100644 --- a/src/atomicui/molecules/FeedbackModal/FeedbackModal.tsx +++ b/src/atomicui/molecules/FeedbackModal/FeedbackModal.tsx @@ -18,7 +18,6 @@ import "./styles.scss"; const feedbackCategories = [ { id: "General", label: "General" }, { id: "Places", label: "Places" }, - { id: "NaturalLanguageSearch", label: "Natural Language Search" }, { id: "Maps", label: "Maps" }, { id: "Routes", label: "Routes" }, { id: "TrackingGeofencing", label: "Tracking & Geofencing" }