Skip to content

Commit e08bd03

Browse files
committed
fixup! front: add stdcm simulation sheet e2e test
1 parent 4a0d5cb commit e08bd03

6 files changed

+128
-126
lines changed

front/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"maplibre-gl": "^4.0.0",
7070
"openapi-typescript-codegen": "^0.29.0",
7171
"party-js": "^2.2.0",
72-
"pdf-parse": "^1.1.1",
7372
"prop-types": "^15.8.1",
7473
"rc-slider": "^11.1.8",
7574
"react": "^18.2.0",
@@ -142,6 +141,7 @@
142141
"json-key-path-list": "^2.0.3",
143142
"license-checker-rseidelsohn": "^4.4.2",
144143
"openapi-types": "^12.1.3",
144+
"pdf-parse": "^1.1.1",
145145
"prettier": "^3.4.2",
146146
"sass": "^1.83.1",
147147
"ts-node": "^10.9.2",

front/tests/013-stdcm-simulation-sheet.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import STDCMPage, { type ConsistFields } from './pages/stdcm-page-model';
1111
import test from './test-logger';
1212
import { waitForInfraStateToBeCached } from './utils';
1313
import { getInfra } from './utils/api-setup';
14-
import { findFirstPdf, verifySimulationContent, type Simulation } from './utils/simulationSheet';
14+
import { findFirstPdf, verifySimulationContent } from './utils/simulationSheet';
15+
import type { Simulation } from './utils/types';
1516

1617
test.use({
1718
launchOptions: {

front/tests/assets/simulation-sheet-const.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import enTranslations from '../../public/locales/en/stdcm-simulation-report-sheet.json';
22
import frTranslations from '../../public/locales/fr/stdcm-simulation-report-sheet.json';
33
import { getLocalizedDateString } from '../utils/date';
4-
import type { Simulation } from '../utils/simulationSheet';
4+
import type { Simulation } from '../utils/types';
55

66
const simulationSheetDetails = (selectedLanguage: string): Simulation => {
77
const translations = selectedLanguage === 'English' ? enTranslations : frTranslations;

front/tests/utils/simulationSheet.ts

+3-122
Original file line numberDiff line numberDiff line change
@@ -3,129 +3,10 @@ import path from 'path';
33

44
import { expect } from '@playwright/test';
55

6-
export interface Simulation {
7-
header: {
8-
toolDescription: string;
9-
documentTitle: string;
10-
};
11-
applicationDate: string;
12-
applicationDateValue: string;
13-
trainDetails: {
14-
compositionCode: string;
15-
compositionCodeValue: string;
16-
towedMaterial: string;
17-
towedMaterialValue: string;
18-
maxSpeed: string;
19-
maxSpeedValue: string;
20-
maxTonnage: string;
21-
maxTonnageValue: string;
22-
referenceEngine: string;
23-
referenceEngineValue: string;
24-
maxLength: string;
25-
maxLengthValue: string;
26-
};
27-
requestedRoute: {
28-
station1: {
29-
name: string;
30-
ch: string;
31-
arrivalTime?: string | null;
32-
plusTolerance?: string | null;
33-
minusTolerance?: string | null;
34-
stop?: string | null;
35-
departureTime?: string | null;
36-
reason: string;
37-
};
38-
station2: {
39-
name: string;
40-
ch: string;
41-
arrivalTime?: string | null;
42-
plusTolerance?: string | null;
43-
minusTolerance?: string | null;
44-
stop?: string | null;
45-
departureTime?: string | null;
46-
reason: string;
47-
};
48-
station3: {
49-
name: string;
50-
ch: string;
51-
arrivalTime?: string | null;
52-
plusTolerance?: string | null;
53-
minusTolerance?: string | null;
54-
stop?: string | null;
55-
departureTime?: string | null;
56-
reason: string;
57-
};
58-
};
59-
simulationDetails: {
60-
totalDistance: string;
61-
simulationRoute: {
62-
station1: {
63-
name: string;
64-
ch: string;
65-
track: string;
66-
arrivalTime?: string | null;
67-
passageTime?: string | null;
68-
departureTime?: string | null;
69-
tonnage: string;
70-
length: string;
71-
referenceEngine?: string | null;
72-
stopType?: string | null;
73-
};
74-
station2: {
75-
name: string;
76-
ch: string;
77-
track: string;
78-
arrivalTime?: string | null;
79-
passageTime?: string | null;
80-
departureTime?: string | null;
81-
tonnage: string;
82-
length: string;
83-
referenceEngine?: string | null;
84-
stopType?: string | null;
85-
};
86-
station3: {
87-
name: string;
88-
ch: string;
89-
track: string;
90-
arrivalTime?: string | null;
91-
passageTime?: string | null;
92-
departureTime?: string | null;
93-
tonnage: string;
94-
length: string;
95-
referenceEngine?: string | null;
96-
stopType?: string | null;
97-
};
98-
station4: {
99-
name: string;
100-
ch: string;
101-
track: string;
102-
arrivalTime?: string | null;
103-
passageTime?: string | null;
104-
departureTime?: string | null;
105-
tonnage: string;
106-
length: string;
107-
referenceEngine?: string | null;
108-
stopType?: string | null;
109-
};
110-
station5: {
111-
name: string;
112-
ch: string;
113-
track: string;
114-
arrivalTime?: string | null;
115-
passageTime?: string | null;
116-
departureTime?: string | null;
117-
tonnage: string;
118-
length: string;
119-
referenceEngine?: string | null;
120-
stopType?: string | null;
121-
};
122-
};
123-
disclaimer: string;
124-
};
125-
}
6+
import type { Simulation } from './types';
1267

1278
/**
128-
* Finds the first PDF file in a directory.
9+
* Find the first PDF file in a directory.
12910
* @param directory - The directory to search in.
13011
* @returns The absolute path to the PDF file, or `null` if no PDF file is found.
13112
*/
@@ -139,7 +20,7 @@ export function findFirstPdf(directory: string): string | null {
13920
}
14021

14122
/**
142-
* Verifies the PDF content against the expected simulation.
23+
* Verify the PDF content against the expected simulation.
14324
* @param pdfText The text extracted from the PDF.
14425
* @param expectedSimulation The expected simulation data.
14526
*/

front/tests/utils/types.ts

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
export type Simulation = {
2+
header: {
3+
toolDescription: string;
4+
documentTitle: string;
5+
};
6+
applicationDate: string;
7+
applicationDateValue: string;
8+
trainDetails: {
9+
compositionCode: string;
10+
compositionCodeValue: string;
11+
towedMaterial: string;
12+
towedMaterialValue: string;
13+
maxSpeed: string;
14+
maxSpeedValue: string;
15+
maxTonnage: string;
16+
maxTonnageValue: string;
17+
referenceEngine: string;
18+
referenceEngineValue: string;
19+
maxLength: string;
20+
maxLengthValue: string;
21+
};
22+
requestedRoute: {
23+
station1: {
24+
name: string;
25+
ch: string;
26+
arrivalTime?: string | null;
27+
plusTolerance?: string | null;
28+
minusTolerance?: string | null;
29+
stop?: string | null;
30+
departureTime?: string | null;
31+
reason: string;
32+
};
33+
station2: {
34+
name: string;
35+
ch: string;
36+
arrivalTime?: string | null;
37+
plusTolerance?: string | null;
38+
minusTolerance?: string | null;
39+
stop?: string | null;
40+
departureTime?: string | null;
41+
reason: string;
42+
};
43+
station3: {
44+
name: string;
45+
ch: string;
46+
arrivalTime?: string | null;
47+
plusTolerance?: string | null;
48+
minusTolerance?: string | null;
49+
stop?: string | null;
50+
departureTime?: string | null;
51+
reason: string;
52+
};
53+
};
54+
simulationDetails: {
55+
totalDistance: string;
56+
simulationRoute: {
57+
station1: {
58+
name: string;
59+
ch: string;
60+
track: string;
61+
arrivalTime?: string | null;
62+
passageTime?: string | null;
63+
departureTime?: string | null;
64+
tonnage: string;
65+
length: string;
66+
referenceEngine?: string | null;
67+
stopType?: string | null;
68+
};
69+
station2: {
70+
name: string;
71+
ch: string;
72+
track: string;
73+
arrivalTime?: string | null;
74+
passageTime?: string | null;
75+
departureTime?: string | null;
76+
tonnage: string;
77+
length: string;
78+
referenceEngine?: string | null;
79+
stopType?: string | null;
80+
};
81+
station3: {
82+
name: string;
83+
ch: string;
84+
track: string;
85+
arrivalTime?: string | null;
86+
passageTime?: string | null;
87+
departureTime?: string | null;
88+
tonnage: string;
89+
length: string;
90+
referenceEngine?: string | null;
91+
stopType?: string | null;
92+
};
93+
station4: {
94+
name: string;
95+
ch: string;
96+
track: string;
97+
arrivalTime?: string | null;
98+
passageTime?: string | null;
99+
departureTime?: string | null;
100+
tonnage: string;
101+
length: string;
102+
referenceEngine?: string | null;
103+
stopType?: string | null;
104+
};
105+
station5: {
106+
name: string;
107+
ch: string;
108+
track: string;
109+
arrivalTime?: string | null;
110+
passageTime?: string | null;
111+
departureTime?: string | null;
112+
tonnage: string;
113+
length: string;
114+
referenceEngine?: string | null;
115+
stopType?: string | null;
116+
};
117+
};
118+
disclaimer: string;
119+
};
120+
};

0 commit comments

Comments
 (0)