Skip to content

Commit

Permalink
Merge pull request #193 from aws-geospatial/main
Browse files Browse the repository at this point in the history
Sync with main
  • Loading branch information
wadhawh authored Jun 11, 2024
2 parents 0ecdbaf + bde90b9 commit 9d2efb3
Show file tree
Hide file tree
Showing 22 changed files with 787 additions and 551 deletions.
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
88 changes: 39 additions & 49 deletions cypress/e2e/pinpointAnalytics.cy.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,49 @@
/* 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", () => {
beforeEach(() => {
cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`);
});
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("PPA-001 - should successfully send correct user event to pinpoint", () => {
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"];
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 });
context("Responsive view", () => {
beforeEach(() => {
cy.visitDomainInResponsiveView(`${Cypress.env("WEB_DOMAIN")}/demo`);
});

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("PPA-003 - should successfully send correct user event to pinpoint", () => {
cy.sendCorrectEventToPinpoint(Viewport.RESPONSIVE);
});
});
});
20 changes: 16 additions & 4 deletions cypress/e2e/unauthUserCanAccessLimitedFunctionality.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
/* 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");
let awsAccountButtonLocator = '[data-testid="connect-aws-account-button"]';

context("Desktop view", () => {
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(awsAccountButtonLocator).should("exist");
});
});

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.get(awsAccountButtonLocator).should("exist");
});
});
});
47 changes: 18 additions & 29 deletions cypress/e2e/unauthUserCanAccessSimulation.cy.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. */
/* SPDX-License-Identifier: MIT-0 */

import { Viewport } from "../support/constants";

describe("Unauth Simulation", () => {
beforeEach(() => {
cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`);
context("Desktop view", () => {
beforeEach(() => {
cy.visitDomain(`${Cypress.env("WEB_DOMAIN")}/demo`);
});

it("US-001 - should allow user to use unauth simulation", () => {
cy.useUnauthSimulation(Viewport.DESKTOP);
});
});

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("US-002 - should allow user to use unauth simulation", () => {
cy.useUnauthSimulation(Viewport.RESPONSIVE);
});
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/userCanViewTheirCurrentLocation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/userCanZoomInAndOut.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
80 changes: 16 additions & 64 deletions cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js
Original file line number Diff line number Diff line change
@@ -1,76 +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", () => {
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(Viewport.DESKTOP);
});
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("CDAA-001 - should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => {
cy.signOutAndDisconnectFromAwsAccount(Viewport.DESKTOP);
});
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.connectAwsAccount(Viewport.RESPONSIVE);
});

it("CDAA-002 - should allow user to connect, sign-in, sign-out and disconnect AWS account from sidebar", () => {
cy.signOutAndDisconnectFromAwsAccount(Viewport.RESPONSIVE);
});
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");
});
});
Loading

0 comments on commit 9d2efb3

Please sign in to comment.