diff --git a/tests/e2e/Pages/MapComponent.ts b/tests/e2e/Pages/MapComponent.ts index e4e3acf27..ce62d37cd 100644 --- a/tests/e2e/Pages/MapComponent.ts +++ b/tests/e2e/Pages/MapComponent.ts @@ -20,6 +20,7 @@ class MapComponent extends DashboardPage { readonly layerMenuToggle: Locator; readonly redCrossMarker: Locator; readonly gloFASMarker: Locator; + readonly alerThresholdLines: Locator; constructor(page: Page) { super(page); @@ -46,6 +47,9 @@ class MapComponent extends DashboardPage { this.layerMenuToggle = this.page.getByTestId('layer-menu-toggle-button'); this.redCrossMarker = this.page.getByAltText('red-cross-branch-marker'); this.gloFASMarker = this.page.getByAltText('glofas-station-marker'); + this.alerThresholdLines = this.page.locator( + '[stroke="var(--ion-color-ibf-outline-red)"]', + ); } async mapComponentIsVisible() { @@ -199,6 +203,18 @@ class MapComponent extends DashboardPage { await expect(legendComponent).toBeHidden(); } + async assertAlertThresholdLines({ visible = false }: { visible: boolean }) { + if (visible === true) { + const alertThresholdLinesCount = await this.alerThresholdLines.count(); + const nthSelector = this.getRandomInt(1, alertThresholdLinesCount); + // Assert that the number of alerThresholdLines is greater than 0 and randomly select one to be visible + expect(alertThresholdLinesCount).toBeGreaterThan(0); + await expect(this.alerThresholdLines.nth(nthSelector)).toBeVisible(); + } else { + await expect(this.alerThresholdLines).toBeHidden(); + } + } + async redCrossMarkersAreVisible() { // Wait for the page to load await this.page.waitForSelector('[alt="red-cross-branch-marker"]'); diff --git a/tests/e2e/tests/Map/AlertThresholdLinesAreNotVisibleNoTrigger.spec.ts b/tests/e2e/tests/Map/AlertThresholdLinesAreNotVisibleNoTrigger.spec.ts index 1745922d8..bc36c047b 100644 --- a/tests/e2e/tests/Map/AlertThresholdLinesAreNotVisibleNoTrigger.spec.ts +++ b/tests/e2e/tests/Map/AlertThresholdLinesAreNotVisibleNoTrigger.spec.ts @@ -53,8 +53,6 @@ test( await map.mapComponentIsVisible(); await map.isLegendOpen({ legendOpen: true }); - await map.assertLegendElementIsNotVisible({ - legendComponentName: 'Alert Threshold Reached', - }); + await map.assertAlertThresholdLines({ visible: false }); }, );