Skip to content

Commit 53ecf0e

Browse files
committed
Map: Mark route stops as TrunkLine stops on edit
1 parent fab76b8 commit 53ecf0e

5 files changed

Lines changed: 512 additions & 236 deletions

File tree

cypress/e2e/map/createRoute.cy.ts

Lines changed: 94 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import {
22
Priority,
3-
ReusableComponentsVehicleModeEnum,
43
RouteDirectionEnum,
4+
RouteTypeOfLineEnum,
5+
StopAreaInput,
6+
StopInsertInput,
7+
StopRegistryGeoJsonInput,
8+
StopRegistryGeoJsonType,
9+
StopRegistryTransportModeType,
510
} from '@hsl/jore4-test-db-manager/dist/CypressSpecExports';
611
import {
712
buildInfraLinksAlongRoute,
@@ -12,17 +17,50 @@ import {
1217
} from '../../datasets/base';
1318
import { Tag } from '../../enums';
1419
import {
15-
FilterPanel,
1620
LineChangeHistory,
1721
LineDetailsPage,
1822
MapFooter,
1923
MapPage,
2024
RouteStopsOverlay,
2125
RouteStopsOverlayRow,
26+
StopsNeedingUpdateModal,
2227
Toast,
2328
} from '../../pageObjects';
2429
import { UUID } from '../../types';
25-
import { SupportedResources, insertToDbHelper } from '../../utils';
30+
import { SupportedResources, insertToDbHelper, mapAt } from '../../utils';
31+
import { InsertedStopRegistryIds } from '../utils';
32+
33+
const baseDbResources = getClonedBaseDbResources();
34+
35+
function constructStopRegistryEntriesForBaseDbResourceStopPoints(
36+
stopPoints: ReadonlyArray<StopInsertInput> = [],
37+
) {
38+
return stopPoints.map<StopAreaInput>(
39+
({ label, measured_location: location }) => {
40+
const geometry: StopRegistryGeoJsonInput = {
41+
coordinates: location.coordinates.slice(0, 2),
42+
type: StopRegistryGeoJsonType.Point,
43+
};
44+
45+
return {
46+
organisations: null,
47+
StopArea: {
48+
name: { value: label, lang: 'fin' },
49+
privateCode: { value: `A-${label}`, type: 'HSL/TEST' },
50+
geometry,
51+
transportMode: StopRegistryTransportModeType.Bus,
52+
quays: [
53+
{
54+
privateCode: { value: label, type: 'HSL/TEST' },
55+
publicCode: label,
56+
geometry,
57+
},
58+
],
59+
},
60+
};
61+
},
62+
);
63+
}
2664

2765
const rootOpts: Cypress.SuiteConfigOverrides = {
2866
tags: [Tag.Routes, Tag.Map],
@@ -31,7 +69,6 @@ const rootOpts: Cypress.SuiteConfigOverrides = {
3169
describe('Route creation', rootOpts, () => {
3270
let dbResources: SupportedResources;
3371

34-
const baseDbResources = getClonedBaseDbResources();
3572
// Location where all test stops and routes are visible.
3673
const mapLocation = {
3774
lng: 24.929689228090112,
@@ -50,6 +87,11 @@ describe('Route creation', rootOpts, () => {
5087

5188
dbResources = {
5289
...baseDbResources,
90+
// Change the 901 line to be a Trunk Line
91+
lines: mapAt(baseDbResources.lines, 0, (line) => ({
92+
...line,
93+
type_of_line: RouteTypeOfLineEnum.ExpressBusService,
94+
})),
5395
stops,
5496
infraLinksAlongRoute,
5597
};
@@ -60,6 +102,12 @@ describe('Route creation', rootOpts, () => {
60102
cy.task('resetDbs');
61103

62104
insertToDbHelper(dbResources);
105+
cy.task<InsertedStopRegistryIds>('insertStopRegistryData', {
106+
stopPlaces: constructStopRegistryEntriesForBaseDbResourceStopPoints(
107+
dbResources.stops,
108+
),
109+
});
110+
63111
cy.setupTests();
64112
cy.mockLogin();
65113
});
@@ -73,8 +121,6 @@ describe('Route creation', rootOpts, () => {
73121
const versionComment = 'E2E create route reason';
74122

75123
MapPage.map.visit(mapLocation);
76-
77-
FilterPanel.toggleShowStops(ReusableComponentsVehicleModeEnum.Bus);
78124
MapPage.map.waitForLoadToComplete();
79125

80126
MapFooter.getCreateRouteButton().click();
@@ -129,10 +175,17 @@ describe('Route creation', rootOpts, () => {
129175
stopCoordinatesByLabel.E2E005[1],
130176
);
131177

178+
MapFooter.save();
179+
180+
StopsNeedingUpdateModal.getModal().shouldBeVisible();
181+
['E2E001', 'E2E003', 'E2E004', 'E2E005']
182+
.map(StopsNeedingUpdateModal.getStopLink)
183+
.forEach((link) => link.shouldBeVisible());
184+
StopsNeedingUpdateModal.getConfirmButton().click();
185+
132186
MapPage.map.getLoader().should('exist');
133187
MapPage.map.getLoader().should('not.exist');
134188

135-
MapFooter.save();
136189
Toast.expectSuccessToast('Reitti tallennettu');
137190

138191
// Check from routeStopsOverlay that everything is correct
@@ -145,16 +198,16 @@ describe('Route creation', rootOpts, () => {
145198
).shouldBeVisible();
146199
RouteStopsOverlay.getRouteStopsOverlayRows().should('have.length', 4);
147200
RouteStopsOverlay.getNthRouteStopsOverlayRow(0).shouldHaveText(
148-
'E2E001 -',
201+
'E2E001 E2E001',
149202
);
150203
RouteStopsOverlay.getNthRouteStopsOverlayRow(1).shouldHaveText(
151-
'E2E003 -',
204+
'E2E003 E2E003',
152205
);
153206
RouteStopsOverlay.getNthRouteStopsOverlayRow(2).shouldHaveText(
154-
'E2E004 -',
207+
'E2E004 E2E004',
155208
);
156209
RouteStopsOverlay.getNthRouteStopsOverlayRow(3).shouldHaveText(
157-
'E2E005 -',
210+
'E2E005 E2E005',
158211
);
159212

160213
LineDetailsPage.visit(baseDbResources.lines[0].line_id);
@@ -208,7 +261,6 @@ describe('Route creation', rootOpts, () => {
208261
() => {
209262
MapPage.map.visit(mapLocation);
210263

211-
FilterPanel.toggleShowStops(ReusableComponentsVehicleModeEnum.Bus);
212264
MapPage.map.waitForLoadToComplete();
213265
MapFooter.getCreateRouteButton().click();
214266
MapPage.routePropertiesForm.fillRouteProperties({
@@ -257,19 +309,19 @@ describe('Route creation', rootOpts, () => {
257309

258310
RouteStopsOverlay.getRouteStopsOverlayRows().should('have.length', 4);
259311
RouteStopsOverlay.getNthRouteStopsOverlayRow(0).shouldHaveText(
260-
'E2E001 -',
312+
'E2E001 E2E001',
261313
);
262314
RouteStopsOverlay.getNthRouteStopsOverlayRow(1).shouldHaveText(
263-
'E2E002 -',
315+
'E2E002 E2E002',
264316
);
265317
RouteStopsOverlay.getNthRouteStopsOverlayRow(2).shouldHaveText(
266-
'E2E003 -',
318+
'E2E003 E2E003',
267319
);
268320
RouteStopsOverlay.getNthRouteStopsOverlayRow(3).shouldHaveText(
269-
'E2E004 -',
321+
'E2E004 E2E004',
270322
);
271323

272-
// Remove one stop from the journey pattern
324+
// Remove one stop (E2E003) from the journey pattern
273325
RouteStopsOverlay.getNthRouteStopsOverlayRow(2).within(() =>
274326
RouteStopsOverlayRow.getMenuButton().click(),
275327
);
@@ -278,20 +330,28 @@ describe('Route creation', rootOpts, () => {
278330
.click();
279331

280332
MapFooter.save();
333+
334+
StopsNeedingUpdateModal.getModal().shouldBeVisible();
335+
['E2E001', 'E2E002', 'E2E004']
336+
.map(StopsNeedingUpdateModal.getStopLink)
337+
.forEach((link) => link.shouldBeVisible());
338+
StopsNeedingUpdateModal.getStopLink('E2E003').should('not.exist');
339+
StopsNeedingUpdateModal.getConfirmButton().click();
340+
281341
Toast.expectSuccessToast('Reitti tallennettu');
282342

283343
RouteStopsOverlay.getHeader()
284344
.should('contain', '901X')
285345
.and('contain', 'Test route');
286346
RouteStopsOverlay.getRouteStopsOverlayRows().should('have.length', 3);
287347
RouteStopsOverlay.getNthRouteStopsOverlayRow(0).shouldHaveText(
288-
'E2E001 -',
348+
'E2E001 E2E001',
289349
);
290350
RouteStopsOverlay.getNthRouteStopsOverlayRow(1).shouldHaveText(
291-
'E2E002 -',
351+
'E2E002 E2E002',
292352
);
293353
RouteStopsOverlay.getNthRouteStopsOverlayRow(2).shouldHaveText(
294-
'E2E004 -',
354+
'E2E004 E2E004',
295355
);
296356
},
297357
);
@@ -302,7 +362,6 @@ describe('Route creation', rootOpts, () => {
302362
() => {
303363
MapPage.map.visit(mapLocation);
304364

305-
FilterPanel.toggleShowStops(ReusableComponentsVehicleModeEnum.Bus);
306365
MapPage.map.waitForLoadToComplete();
307366

308367
MapFooter.getCreateRouteButton().click();
@@ -348,10 +407,10 @@ describe('Route creation', rootOpts, () => {
348407

349408
RouteStopsOverlay.getRouteStopsOverlayRows().should('have.length', 2);
350409
RouteStopsOverlay.getNthRouteStopsOverlayRow(0).shouldHaveText(
351-
'E2E001 -',
410+
'E2E001 E2E001',
352411
);
353412
RouteStopsOverlay.getNthRouteStopsOverlayRow(1).shouldHaveText(
354-
'E2E002 -',
413+
'E2E002 E2E002',
355414
);
356415

357416
// Remove the other stop from the journey pattern
@@ -375,7 +434,6 @@ describe('Route creation', rootOpts, () => {
375434
() => {
376435
MapPage.map.visit(mapLocation);
377436

378-
FilterPanel.toggleShowStops(ReusableComponentsVehicleModeEnum.Bus);
379437
MapPage.map.waitForLoadToComplete();
380438

381439
MapFooter.getCreateRouteButton().click();
@@ -420,10 +478,13 @@ describe('Route creation', rootOpts, () => {
420478
stopCoordinatesByLabel.E2E002[1],
421479
);
422480

481+
MapFooter.save();
482+
483+
StopsNeedingUpdateModal.getConfirmButton().click();
484+
423485
MapPage.map.getLoader().should('exist');
424486
MapPage.map.getLoader().should('not.exist');
425487

426-
MapFooter.save();
427488
Toast.expectSuccessToast('Reitti tallennettu');
428489
},
429490
);
@@ -434,7 +495,6 @@ describe('Route creation', rootOpts, () => {
434495
() => {
435496
MapPage.map.visit(mapLocation);
436497

437-
FilterPanel.toggleShowStops(ReusableComponentsVehicleModeEnum.Bus);
438498
MapPage.map.waitForLoadToComplete();
439499

440500
MapFooter.getCreateRouteButton().click();
@@ -469,29 +529,31 @@ describe('Route creation', rootOpts, () => {
469529
});
470530

471531
MapPage.editRouteModal.save();
532+
MapFooter.save();
533+
534+
StopsNeedingUpdateModal.getConfirmButton().click();
472535

473536
MapPage.map.getLoader().should('exist');
474537
MapPage.map.getLoader().should('not.exist');
475-
MapFooter.save();
476538

477539
RouteStopsOverlay.getHeader()
478540
.should('contain', '901T')
479541
.and('contain', 'Based on template test route');
480542
RouteStopsOverlay.getRouteStopsOverlayRows().should('have.length', 5);
481543
RouteStopsOverlay.getNthRouteStopsOverlayRow(0).shouldHaveText(
482-
'E2E001 -',
544+
'E2E001 E2E001',
483545
);
484546
RouteStopsOverlay.getNthRouteStopsOverlayRow(1).shouldHaveText(
485-
'E2E002 -',
547+
'E2E002 E2E002',
486548
);
487549
RouteStopsOverlay.getNthRouteStopsOverlayRow(2).shouldHaveText(
488-
'E2E003 -',
550+
'E2E003 E2E003',
489551
);
490552
RouteStopsOverlay.getNthRouteStopsOverlayRow(3).shouldHaveText(
491-
'E2E004 -',
553+
'E2E004 E2E004',
492554
);
493555
RouteStopsOverlay.getNthRouteStopsOverlayRow(4).shouldHaveText(
494-
'E2E005 -',
556+
'E2E005 E2E005',
495557
);
496558
},
497559
);

0 commit comments

Comments
 (0)