@@ -3,41 +3,41 @@ import { v4 as uuidv4 } from 'uuid';
3
3
import type { Project , Study } from 'common/api/osrdEditoastApi' ;
4
4
5
5
import studyData from './assets/operationStudies/study.json' ;
6
- import HomePage from './pages/home-page-model ' ;
6
+ import test from './logging-fixture ' ;
7
7
import StudyPage from './pages/study-page-model' ;
8
- import test from './test-logger' ;
9
- import { formatDateToDayMonthYear , generateUniqueName } from './utils' ;
8
+ import { formatDateToDayMonthYear , generateUniqueName , getTranslations } from './utils' ;
10
9
import { getProject } from './utils/api-setup' ;
11
10
import { createStudy } from './utils/setup-utils' ;
12
11
import { deleteStudy } from './utils/teardown-utils' ;
13
12
import enTranslations from '../public/locales/en/operationalStudies/study.json' ;
14
13
import frTranslations from '../public/locales/fr/operationalStudies/study.json' ;
15
14
16
15
test . describe ( 'Validate the Study creation workflow' , ( ) => {
16
+ let studyPage : StudyPage ;
17
17
let project : Project ;
18
18
let study : Study ;
19
- let OSRDLanguage : string ;
20
- test . beforeAll ( ' Retrieve a project' , async ( ) => {
19
+ let translations : typeof enTranslations | typeof frTranslations ;
20
+ let PROJECT_LANGUAGE : string ;
21
+ test . beforeAll ( ' Retrieve a project and the translation' , async ( ) => {
21
22
project = await getProject ( ) ;
23
+ PROJECT_LANGUAGE = process . env . PROJECT_LANGUAGE || '' ;
24
+ translations = getTranslations ( PROJECT_LANGUAGE , {
25
+ en : enTranslations ,
26
+ fr : frTranslations ,
27
+ } ) ;
22
28
} ) ;
23
-
24
- test . beforeEach ( 'Create a new study linked to the project' , async ( { page } ) => {
25
- const homePage = new HomePage ( page ) ;
26
- await homePage . goToHomePage ( ) ;
27
- OSRDLanguage = await homePage . getOSRDLanguage ( ) ;
29
+ test . beforeEach ( async ( { page } ) => {
30
+ studyPage = new StudyPage ( page ) ;
28
31
} ) ;
29
32
30
33
/** *************** Test 1 **************** */
31
34
test ( 'Create a new study' , async ( { page } ) => {
32
- const studyPage = new StudyPage ( page ) ;
33
35
// Navigate to project page
34
36
await page . goto ( `/operational-studies/projects/${ project . id } ` ) ;
35
-
36
37
// Set translations based on the language
37
- const translations = OSRDLanguage === 'English' ? enTranslations : frTranslations ;
38
38
const studyName = `${ studyData . name } ${ uuidv4 ( ) } ` ; // Unique study name
39
39
const todayDateISO = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ; // Get today's date in ISO format
40
- const expectedDate = formatDateToDayMonthYear ( todayDateISO , OSRDLanguage ) ;
40
+ const expectedDate = formatDateToDayMonthYear ( todayDateISO , PROJECT_LANGUAGE ) ;
41
41
// Create a new study using the study page model
42
42
await studyPage . createStudy ( {
43
43
name : studyName ,
@@ -72,14 +72,12 @@ test.describe('Validate the Study creation workflow', () => {
72
72
73
73
/** *************** Test 2 **************** */
74
74
test ( 'Update an existing study' , async ( { page } ) => {
75
- const studyPage = new StudyPage ( page ) ;
76
75
// Create a study
77
76
study = await createStudy ( project . id , generateUniqueName ( studyData . name ) ) ;
78
77
// Navigate to study page
79
78
await page . goto ( `/operational-studies/projects/${ project . id } /studies/${ study . id } ` ) ;
80
- const translations = OSRDLanguage === 'English' ? enTranslations : frTranslations ;
81
79
const tomorrowDateISO = new Date ( Date . now ( ) + 86400000 ) . toISOString ( ) . split ( 'T' ) [ 0 ] ; // Get tomorrow's date in ISO format
82
- const expectedDate = formatDateToDayMonthYear ( tomorrowDateISO , OSRDLanguage ) ;
80
+ const expectedDate = formatDateToDayMonthYear ( tomorrowDateISO , PROJECT_LANGUAGE ) ;
83
81
// Update the study with new values
84
82
await studyPage . updateStudy ( {
85
83
name : `${ study . name } (updated)` ,
@@ -122,8 +120,6 @@ test.describe('Validate the Study creation workflow', () => {
122
120
// Create a study
123
121
study = await createStudy ( project . id , generateUniqueName ( studyData . name ) ) ;
124
122
125
- const studyPage = new StudyPage ( page ) ;
126
-
127
123
// Navigate to the list of studies for the project
128
124
await page . goto ( `/operational-studies/projects/${ project . id } ` ) ;
129
125
0 commit comments