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); 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) => {