Skip to content

Commit

Permalink
E2E: Add generic test data for Stop Areas
Browse files Browse the repository at this point in the history
  • Loading branch information
Huulivoide committed Oct 31, 2024
1 parent 3bb4d10 commit 8d0ee50
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
35 changes: 34 additions & 1 deletion cypress/datasets/stopRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -134,9 +135,41 @@ const stopPlaceData: Array<StopPlaceInput> = [
},
];

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,
};

Expand Down
31 changes: 9 additions & 22 deletions cypress/e2e/stop-registry/stopAreaDetails.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
getClonedBaseDbResources,
testInfraLinkExternalIds,
} from '../../datasets/base';
import { getClonedBaseStopRegistryData } from '../../datasets/stopRegistry';
import {
getClonedBaseStopRegistryData,
stopAreaX0003,
} from '../../datasets/stopRegistry';
import {
SelectMemberStopsDropdown,
StopAreaDetailsPage,
Expand Down Expand Up @@ -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<StopAreaInput> = [testStopArea];
const testStopArea = { ...stopAreaX0003 };

const testAreaExpectedBasicDetails: ExpectedBasicDetails = {
name: testStopArea.stopArea.name.value,
Expand Down Expand Up @@ -100,10 +87,10 @@ describe('Stop area details', () => {

insertToDbHelper(dbResources);

cy.task<InsertedStopRegistryIds>('insertStopRegistryData', {
...baseStopRegistryData,
stopAreas: stopAreaData,
}).then((data) => {
cy.task<InsertedStopRegistryIds>(
'insertStopRegistryData',
baseStopRegistryData,
).then((data) => {
const id = data.stopAreaIdsByName.X0003;

cy.setupTests();
Expand Down

0 comments on commit 8d0ee50

Please sign in to comment.