-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from aws-geospatial/main
Sync with main
- Loading branch information
Showing
22 changed files
with
787 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 16 additions & 64 deletions
80
cypress/e2e/userIsAbleToConnectAndDisconnectAwsAccount.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); |
Oops, something went wrong.