diff --git a/tests/e2e/testData/testData.enum.ts b/tests/e2e/testData/testData.enum.ts index 936a1d09d..9e23e6edd 100644 --- a/tests/e2e/testData/testData.enum.ts +++ b/tests/e2e/testData/testData.enum.ts @@ -7,3 +7,13 @@ export enum NoTriggerDataSet { firstName = 'Uganda', lastName = 'Manager', } + +export enum TriggerDataSet { + TriggerScenario = 'trigger', + CountryCode = 'UGA', + CountryName = 'Uganda', + UserMail = 'uganda@redcross.nl', + UserPassword = 'password', + firstName = 'Uganda', + lastName = 'Manager', +} diff --git a/tests/e2e/tests/Map/NoAlertThresholdIsVisibleInLegend.spec.ts b/tests/e2e/tests/Map/AlertThresholdIsVisibleInLegend.spec.ts similarity index 100% rename from tests/e2e/tests/Map/NoAlertThresholdIsVisibleInLegend.spec.ts rename to tests/e2e/tests/Map/AlertThresholdIsVisibleInLegend.spec.ts diff --git a/tests/e2e/tests/Map/FloodExtentVisibleInLegend.spec.ts b/tests/e2e/tests/Map/FloodExtentVisibleInLegend.spec.ts new file mode 100644 index 000000000..1e7257c62 --- /dev/null +++ b/tests/e2e/tests/Map/FloodExtentVisibleInLegend.spec.ts @@ -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', + }); + }, +);