Skip to content

Commit

Permalink
Merge pull request #1813 from rodekruis/feat.add-e2e-test-for-flood-e…
Browse files Browse the repository at this point in the history
…xtent-legend

Add e2e test for flood extent present in the legend
  • Loading branch information
Piotrk39 authored Dec 3, 2024
2 parents 695f6c0 + 6848977 commit 5bdc2cf
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/e2e/testData/testData.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ export enum NoTriggerDataSet {
firstName = 'Uganda',
lastName = 'Manager',
}

export enum TriggerDataSet {
TriggerScenario = 'trigger',
CountryCode = 'UGA',
CountryName = 'Uganda',
UserMail = '[email protected]',
UserPassword = 'password',
firstName = 'Uganda',
lastName = 'Manager',
}
60 changes: 60 additions & 0 deletions tests/e2e/tests/Map/FloodExtentVisibleInLegend.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { test } from '@playwright/test';
import DashboardPage from 'Pages/DashboardPage';
import MapComponent from 'Pages/MapComponent';
import UserStateComponent from 'Pages/UserStateComponent';
import { qase } from 'playwright-qase-reporter';
import { TriggerDataSet } from 'testData/testData.enum';

import { FloodsScenario } from '../../../../services/API-service/src/scripts/enum/mock-scenario.enum';
import {
getAccessToken,
mockFloods,
resetDB,
} from '../../helpers/utility.helper';
import LoginPage from '../../Pages/LoginPage';

let accessToken: string;

test.beforeEach(async ({ page }) => {
// Login
const loginPage = new LoginPage(page);
accessToken = await getAccessToken();
await resetDB(accessToken);

// We should maybe create one mock for all different disaster types for now we can just use floods
await mockFloods(
FloodsScenario.Trigger,
TriggerDataSet.CountryCode,
accessToken,
);

await page.goto('/');
await loginPage.login(TriggerDataSet.UserMail, TriggerDataSet.UserPassword);
});
// https://app.qase.io/project/IBF?previewMode=side&suite=3&tab=&case=35
test(
qase(
35,
'[Trigger] Flood extent legend is visible when flood extent layer is active',
),
async ({ page }) => {
const dashboard = new DashboardPage(page);
const userState = new UserStateComponent(page);
const map = new MapComponent(page);

// Navigate to disaster type the data was mocked for
await dashboard.navigateToFloodDisasterType();
// Assertions
await userState.headerComponentIsVisible({
countryName: TriggerDataSet.CountryName,
});
// Wait for the page to load
await dashboard.waitForLoaderToDisappear();

await map.mapComponentIsVisible();
await map.isLegendOpen({ legendOpen: true });
await map.assertLegendElementIsVisible({
legendComponentName: 'Flood extent',
});
},
);

0 comments on commit 5bdc2cf

Please sign in to comment.