From dfffd0c1a82cfb6b7e53f6ef318753f98869d5f2 Mon Sep 17 00:00:00 2001 From: Ahmad Azizi <91204996+its-aazizi@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:43:59 +0500 Subject: [PATCH 1/4] updated automatic map unit to be set based on country code --- src/core/constants/appConfig.ts | 2 +- src/hooks/useAmplifyMap.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/constants/appConfig.ts b/src/core/constants/appConfig.ts index 5385439e..e632a049 100644 --- a/src/core/constants/appConfig.ts +++ b/src/core/constants/appConfig.ts @@ -110,7 +110,7 @@ const appConfig = { NL_TOGGLE: "nl" }, MAP_RESOURCES: { - IMPERIAL_COUNTRIES: ["US", "GB", "LR", "MM"], + IMPERIAL_COUNTRIES: ["US", "LR", "MM"], GRAB_SUPPORTED_AWS_REGIONS: ["ap-southeast-1"], AMAZON_HQ: { US: { longitude: -122.3408586, latitude: 47.6149975 }, diff --git a/src/hooks/useAmplifyMap.ts b/src/hooks/useAmplifyMap.ts index aa6221cd..aafe887d 100644 --- a/src/hooks/useAmplifyMap.ts +++ b/src/hooks/useAmplifyMap.ts @@ -17,6 +17,7 @@ import { } from "@demo/types"; import { OpenDataMapEnum } from "@demo/types/Enums"; +import { getCountryCode } from "@demo/utils/countryUtil"; import { errorHandler } from "@demo/utils/errorHandler"; import { useTranslation } from "react-i18next"; @@ -59,9 +60,10 @@ const useAmplifyMap = () => { setIsAutomaticMapUnit: (selected: boolean) => { setState(s => ({ autoMapUnit: { ...s.autoMapUnit, selected } })); }, - setAutomaticMapUnit: () => { - const isMetric = !IMPERIAL_COUNTRIES.includes(navigator.language.split("-")[1]); - const mapUnit = isMetric ? METRIC : IMPERIAL; + setAutomaticMapUnit: async () => { + const countryCode = await getCountryCode(); + const isImperial = !!countryCode && IMPERIAL_COUNTRIES.includes(countryCode); + const mapUnit = isImperial ? IMPERIAL : METRIC; setState(s => ({ autoMapUnit: { ...s.autoMapUnit, system: mapUnit }, mapUnit })); }, setMapUnit: (mapUnit: MapUnitEnum) => { From 32a93ba6aa9ae55cec21cba6dffe8e68c3bb3a2a Mon Sep 17 00:00:00 2001 From: Ahmad Azizi <91204996+its-aazizi@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:47:42 +0500 Subject: [PATCH 2/4] updated setupTests with updated imperial countries list --- src/setupTests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setupTests.ts b/src/setupTests.ts index 76b66f70..afc6e48c 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -87,7 +87,7 @@ jest.mock("@demo/core/constants/appConfig", () => ({ NL_TOGGLE: "nl" }, MAP_RESOURCES: { - IMPERIAL_COUNTRIES: ["US", "GB", "LR", "MM"], + IMPERIAL_COUNTRIES: ["US", "LR", "MM"], GRAB_SUPPORTED_AWS_REGIONS: ["ap-southeast-1"], AMAZON_HQ: { US: { longitude: -122.3408586, latitude: 47.6149975 }, From 89a308f17ad686f30541667b70d161e4a477da76 Mon Sep 17 00:00:00 2001 From: Ahmad Azizi <91204996+its-aazizi@users.noreply.github.com> Date: Mon, 22 Jul 2024 23:29:03 +0500 Subject: [PATCH 3/4] added GB to the list of imperial countries --- src/core/constants/appConfig.ts | 2 +- src/setupTests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/constants/appConfig.ts b/src/core/constants/appConfig.ts index e632a049..5385439e 100644 --- a/src/core/constants/appConfig.ts +++ b/src/core/constants/appConfig.ts @@ -110,7 +110,7 @@ const appConfig = { NL_TOGGLE: "nl" }, MAP_RESOURCES: { - IMPERIAL_COUNTRIES: ["US", "LR", "MM"], + IMPERIAL_COUNTRIES: ["US", "GB", "LR", "MM"], GRAB_SUPPORTED_AWS_REGIONS: ["ap-southeast-1"], AMAZON_HQ: { US: { longitude: -122.3408586, latitude: 47.6149975 }, diff --git a/src/setupTests.ts b/src/setupTests.ts index afc6e48c..76b66f70 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -87,7 +87,7 @@ jest.mock("@demo/core/constants/appConfig", () => ({ NL_TOGGLE: "nl" }, MAP_RESOURCES: { - IMPERIAL_COUNTRIES: ["US", "LR", "MM"], + IMPERIAL_COUNTRIES: ["US", "GB", "LR", "MM"], GRAB_SUPPORTED_AWS_REGIONS: ["ap-southeast-1"], AMAZON_HQ: { US: { longitude: -122.3408586, latitude: 47.6149975 }, From e9f147f2c306acd3b6a4a80c2ce7b3330adf8a97 Mon Sep 17 00:00:00 2001 From: Ahmad Azizi <91204996+its-aazizi@users.noreply.github.com> Date: Tue, 23 Jul 2024 05:24:44 +0500 Subject: [PATCH 4/4] updated tracker test as per responsiveness --- cypress/support/commands.js | 4 +++- cypress/support/trackerAndGeofenceSupport.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index bd5ca47c..08dfe896 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -62,7 +62,9 @@ Cypress.Commands.add("connectAwsAccount", isResponsive => { 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(); + isResponsive + ? cy.get('[data-testid="sign-in-button"]').first().click() + : cy.get('[data-testid="sign-in-button"]').click(); cy.wait(5000); cy.origin(`${Cypress.env("USER_DOMAIN")}`, { args: { isResponsive } }, ({ isResponsive }) => { isResponsive diff --git a/cypress/support/trackerAndGeofenceSupport.js b/cypress/support/trackerAndGeofenceSupport.js index 8046065b..76936ae7 100644 --- a/cypress/support/trackerAndGeofenceSupport.js +++ b/cypress/support/trackerAndGeofenceSupport.js @@ -38,7 +38,6 @@ Cypress.Commands.add("addTrackerAndGeofenceEnterExit", (isResponsive, geofenceNa 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('[data-testid="hamburger-menu"]').click(); @@ -50,7 +49,9 @@ Cypress.Commands.add("addTrackerAndGeofenceEnterExit", (isResponsive, geofenceNa cy.wait(5000); cy.get('[class="mapboxgl-canvas"]').click("left", { force: true }); cy.wait(5000); - cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); + isResponsive + ? cy.get('[class="mapboxgl-canvas"]').click(200, 200, { force: true }) + : cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); cy.wait(5000); cy.get('[class="mapboxgl-canvas"]').click("right", { force: true }); cy.wait(5000);