From 8d0ee5091f524ccb0a299c255def2723af7a346f Mon Sep 17 00:00:00 2001 From: Jesse Jaara Date: Thu, 31 Oct 2024 12:26:27 +0200 Subject: [PATCH] E2E: Add generic test data for Stop Areas --- cypress/datasets/stopRegistry.ts | 35 ++++++++++++++++++- .../e2e/stop-registry/stopAreaDetails.cy.ts | 31 +++++----------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/cypress/datasets/stopRegistry.ts b/cypress/datasets/stopRegistry.ts index f7e55b111..68f50d573 100644 --- a/cypress/datasets/stopRegistry.ts +++ b/cypress/datasets/stopRegistry.ts @@ -5,6 +5,7 @@ import { StopRegistryNameType, } from '@hsl/jore4-test-db-manager'; import cloneDeep from 'lodash/cloneDeep'; +import { DateTime } from 'luxon'; import { stopCoordinatesByLabel } from './base'; const coordinatesToStopRegistryGeoJSON = ( @@ -134,9 +135,41 @@ const stopPlaceData: Array = [ }, ]; +export const stopAreaX0003 = { + memberLabels: ['E2E001', 'E2E009'], + stopArea: { + name: { lang: 'fin', value: 'X0003' }, + description: { lang: 'fin', value: 'Annankatu 15' }, + validBetween: { + fromDate: DateTime.fromISO('2020-01-01T00:00:00.001'), + toDate: DateTime.fromISO('2050-01-01T00:00:00.001'), + }, + geometry: { + coordinates: [24.938927, 60.165433], + type: StopRegistryGeoJsonType.Point, + }, + }, +}; + +export const stopAreaX0004 = { + memberLabels: ['E2E003', 'E2E006'], + stopArea: { + name: { lang: 'fin', value: 'X0004' }, + description: { lang: 'fin', value: 'Kalevankatu 32' }, + validBetween: { + fromDate: DateTime.fromISO('2020-01-01T00:00:00.001'), + toDate: DateTime.fromISO('2050-01-01T00:00:00.001'), + }, + geometry: { + coordinates: [24.932914978884, 60.165538996581], + type: StopRegistryGeoJsonType.Point, + }, + }, +}; + const baseStopRegistryData = { organisations: [], - stopAreas: [], + stopAreas: [stopAreaX0003, stopAreaX0004], stopPlaces: stopPlaceData, }; diff --git a/cypress/e2e/stop-registry/stopAreaDetails.cy.ts b/cypress/e2e/stop-registry/stopAreaDetails.cy.ts index 8eb870aa4..7cd165dcd 100644 --- a/cypress/e2e/stop-registry/stopAreaDetails.cy.ts +++ b/cypress/e2e/stop-registry/stopAreaDetails.cy.ts @@ -9,7 +9,10 @@ import { getClonedBaseDbResources, testInfraLinkExternalIds, } from '../../datasets/base'; -import { getClonedBaseStopRegistryData } from '../../datasets/stopRegistry'; +import { + getClonedBaseStopRegistryData, + stopAreaX0003, +} from '../../datasets/stopRegistry'; import { SelectMemberStopsDropdown, StopAreaDetailsPage, @@ -49,23 +52,7 @@ describe('Stop area details', () => { const baseDbResources = getClonedBaseDbResources(); const baseStopRegistryData = getClonedBaseStopRegistryData(); - const testStopArea = { - memberLabels: ['E2E001', 'E2E009'], - stopArea: { - name: { lang: 'fin', value: 'X0003' }, - description: { lang: 'fin', value: 'Annankatu 15' }, - validBetween: { - fromDate: DateTime.fromISO('2020-01-01T00:00:00.001'), - toDate: DateTime.fromISO('2050-01-01T00:00:00.001'), - }, - geometry: { - coordinates: [24.938927, 60.165433], - type: StopRegistryGeoJsonType.Point, - }, - }, - }; - - const stopAreaData: Array = [testStopArea]; + const testStopArea = { ...stopAreaX0003 }; const testAreaExpectedBasicDetails: ExpectedBasicDetails = { name: testStopArea.stopArea.name.value, @@ -100,10 +87,10 @@ describe('Stop area details', () => { insertToDbHelper(dbResources); - cy.task('insertStopRegistryData', { - ...baseStopRegistryData, - stopAreas: stopAreaData, - }).then((data) => { + cy.task( + 'insertStopRegistryData', + baseStopRegistryData, + ).then((data) => { const id = data.stopAreaIdsByName.X0003; cy.setupTests();