Skip to content

Commit

Permalink
fixup! front: add stdcm simulation sheet e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Maymanaf committed Jan 15, 2025
1 parent 4a0d5cb commit e08bd03
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 126 deletions.
2 changes: 1 addition & 1 deletion front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"maplibre-gl": "^4.0.0",
"openapi-typescript-codegen": "^0.29.0",
"party-js": "^2.2.0",
"pdf-parse": "^1.1.1",
"prop-types": "^15.8.1",
"rc-slider": "^11.1.8",
"react": "^18.2.0",
Expand Down Expand Up @@ -142,6 +141,7 @@
"json-key-path-list": "^2.0.3",
"license-checker-rseidelsohn": "^4.4.2",
"openapi-types": "^12.1.3",
"pdf-parse": "^1.1.1",
"prettier": "^3.4.2",
"sass": "^1.83.1",
"ts-node": "^10.9.2",
Expand Down
3 changes: 2 additions & 1 deletion front/tests/013-stdcm-simulation-sheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import STDCMPage, { type ConsistFields } from './pages/stdcm-page-model';
import test from './test-logger';
import { waitForInfraStateToBeCached } from './utils';
import { getInfra } from './utils/api-setup';
import { findFirstPdf, verifySimulationContent, type Simulation } from './utils/simulationSheet';
import { findFirstPdf, verifySimulationContent } from './utils/simulationSheet';
import type { Simulation } from './utils/types';

test.use({
launchOptions: {
Expand Down
2 changes: 1 addition & 1 deletion front/tests/assets/simulation-sheet-const.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import enTranslations from '../../public/locales/en/stdcm-simulation-report-sheet.json';
import frTranslations from '../../public/locales/fr/stdcm-simulation-report-sheet.json';
import { getLocalizedDateString } from '../utils/date';
import type { Simulation } from '../utils/simulationSheet';
import type { Simulation } from '../utils/types';

const simulationSheetDetails = (selectedLanguage: string): Simulation => {
const translations = selectedLanguage === 'English' ? enTranslations : frTranslations;
Expand Down
125 changes: 3 additions & 122 deletions front/tests/utils/simulationSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,129 +3,10 @@ import path from 'path';

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

export interface Simulation {
header: {
toolDescription: string;
documentTitle: string;
};
applicationDate: string;
applicationDateValue: string;
trainDetails: {
compositionCode: string;
compositionCodeValue: string;
towedMaterial: string;
towedMaterialValue: string;
maxSpeed: string;
maxSpeedValue: string;
maxTonnage: string;
maxTonnageValue: string;
referenceEngine: string;
referenceEngineValue: string;
maxLength: string;
maxLengthValue: string;
};
requestedRoute: {
station1: {
name: string;
ch: string;
arrivalTime?: string | null;
plusTolerance?: string | null;
minusTolerance?: string | null;
stop?: string | null;
departureTime?: string | null;
reason: string;
};
station2: {
name: string;
ch: string;
arrivalTime?: string | null;
plusTolerance?: string | null;
minusTolerance?: string | null;
stop?: string | null;
departureTime?: string | null;
reason: string;
};
station3: {
name: string;
ch: string;
arrivalTime?: string | null;
plusTolerance?: string | null;
minusTolerance?: string | null;
stop?: string | null;
departureTime?: string | null;
reason: string;
};
};
simulationDetails: {
totalDistance: string;
simulationRoute: {
station1: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
station2: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
station3: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
station4: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
station5: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
};
disclaimer: string;
};
}
import type { Simulation } from './types';

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

/**
* Verifies the PDF content against the expected simulation.
* Verify the PDF content against the expected simulation.
* @param pdfText The text extracted from the PDF.
* @param expectedSimulation The expected simulation data.
*/
Expand Down
120 changes: 120 additions & 0 deletions front/tests/utils/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
export type Simulation = {
header: {
toolDescription: string;
documentTitle: string;
};
applicationDate: string;
applicationDateValue: string;
trainDetails: {
compositionCode: string;
compositionCodeValue: string;
towedMaterial: string;
towedMaterialValue: string;
maxSpeed: string;
maxSpeedValue: string;
maxTonnage: string;
maxTonnageValue: string;
referenceEngine: string;
referenceEngineValue: string;
maxLength: string;
maxLengthValue: string;
};
requestedRoute: {
station1: {
name: string;
ch: string;
arrivalTime?: string | null;
plusTolerance?: string | null;
minusTolerance?: string | null;
stop?: string | null;
departureTime?: string | null;
reason: string;
};
station2: {
name: string;
ch: string;
arrivalTime?: string | null;
plusTolerance?: string | null;
minusTolerance?: string | null;
stop?: string | null;
departureTime?: string | null;
reason: string;
};
station3: {
name: string;
ch: string;
arrivalTime?: string | null;
plusTolerance?: string | null;
minusTolerance?: string | null;
stop?: string | null;
departureTime?: string | null;
reason: string;
};
};
simulationDetails: {
totalDistance: string;
simulationRoute: {
station1: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
station2: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
station3: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
station4: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
station5: {
name: string;
ch: string;
track: string;
arrivalTime?: string | null;
passageTime?: string | null;
departureTime?: string | null;
tonnage: string;
length: string;
referenceEngine?: string | null;
stopType?: string | null;
};
};
disclaimer: string;
};
};

0 comments on commit e08bd03

Please sign in to comment.