Skip to content

Commit

Permalink
Add threshold lines test
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrk39 committed Nov 11, 2024
1 parent dee0b79 commit 3c23386
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 16 additions & 0 deletions tests/e2e/Pages/MapComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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() {
Expand Down Expand Up @@ -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"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
},
);

0 comments on commit 3c23386

Please sign in to comment.