From c55388b2d58efd788d64f745560c4b37c5d227e9 Mon Sep 17 00:00:00 2001 From: u216993 Date: Mon, 4 Nov 2024 16:09:17 +0100 Subject: [PATCH] fix: While combining two trainruns the first trainrun will "survive" and the second one will be deleted. If the trainrun which will be deleted consists of more than one trainrun segment (connected paths) the reported issue will be generated. (Test added) --- .../services/data/trainrun.service.spec.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/app/services/data/trainrun.service.spec.ts b/src/app/services/data/trainrun.service.spec.ts index 01307136..07b9c004 100644 --- a/src/app/services/data/trainrun.service.spec.ts +++ b/src/app/services/data/trainrun.service.spec.ts @@ -367,6 +367,46 @@ describe("TrainrunService", () => { expect(trainrunSections4.length).toBe(2); }); + it("combineTwoTrainruns - 002 - two trainrun segments tests", () => { + dataService.loadNetzgrafikDto( + NetzgrafikUnitTesting.getUnitTestNetzgrafik(), + ); + + trainrunSectionService.deleteTrainrunSection(4); + + const ts5: TrainrunSection = + trainrunSectionService.getTrainrunSectionFromId(5); + const ts7: TrainrunSection = + trainrunSectionService.getTrainrunSectionFromId(7); + + const node2: Node = nodeService.getNodeFromId(2); + + const trainrunSections5 = + trainrunSectionService.getAllTrainrunSectionsForTrainrun( + ts5.getTrainrunId(), + ); + const trainrunSections7 = + trainrunSectionService.getAllTrainrunSectionsForTrainrun( + ts7.getTrainrunId(), + ); + + trainrunService.combineTwoTrainruns( + node2, + node2.getPortOfTrainrunSection(7), + node2.getPortOfTrainrunSection(5), + ); + + const trainrunSections75 = + trainrunSectionService.getAllTrainrunSectionsForTrainrun( + ts7.getTrainrunId(), + ); + + expect(trainrunSections75.length).toBe( + trainrunSections5.length + + trainrunSections7.length); + expect(trainrunSections75.length).toBe(3); + }); + it("getRootIterators", () => { dataService.loadNetzgrafikDto( NetzgrafikUnitTesting.getUnitTestNetzgrafik(),