Skip to content

Commit ddbef76

Browse files
committed
front: add JSON import attribute when importing locale files
Without this, imports fail in module packages: TypeError: Module "file:///app/front/public/locales/en/home/home.json" needs an import attribute of type "json" Signed-off-by: Simon Ser <[email protected]>
1 parent 161c395 commit ddbef76

16 files changed

+29
-29
lines changed

front/tests/001-home-page.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { expect } from '@playwright/test';
22

33
import HomePage from './pages/home-page-model';
44
import test from './test-logger';
5-
import enTranslations from '../public/locales/en/home/home.json';
6-
import frTranslations from '../public/locales/fr/home/home.json';
5+
import enTranslations from '../public/locales/en/home/home.json' with { type: 'json' };
6+
import frTranslations from '../public/locales/fr/home/home.json' with { type: 'json' };
77

88
test.describe('Home page OSRD', () => {
99
let homePage: HomePage;

front/tests/002-project-management.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Project } from 'common/api/osrdEditoastApi';
22

3-
import projectData from './assets/operationStudies/project.json';
3+
import projectData from './assets/operationStudies/project.json' with { type: 'json' };
44
import HomePage from './pages/home-page-model';
55
import ProjectPage from './pages/project-page-model';
66
import test from './test-logger';

front/tests/003-study-management.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import { v4 as uuidv4 } from 'uuid';
22

33
import type { Project, Study } from 'common/api/osrdEditoastApi';
44

5-
import studyData from './assets/operationStudies/study.json';
5+
import studyData from './assets/operationStudies/study.json' with { type: 'json' };
66
import HomePage from './pages/home-page-model';
77
import StudyPage from './pages/study-page-model';
88
import test from './test-logger';
99
import { formatDateToDayMonthYear, generateUniqueName } from './utils';
1010
import { getProject } from './utils/api-setup';
1111
import { createStudy } from './utils/setup-utils';
1212
import { deleteStudy } from './utils/teardown-utils';
13-
import enTranslations from '../public/locales/en/operationalStudies/study.json';
14-
import frTranslations from '../public/locales/fr/operationalStudies/study.json';
13+
import enTranslations from '../public/locales/en/operationalStudies/study.json' with { type: 'json' };
14+
import frTranslations from '../public/locales/fr/operationalStudies/study.json' with { type: 'json' };
1515

1616
test.describe('Validate the Study creation workflow', () => {
1717
let project: Project;

front/tests/004-scenario-management.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from '@playwright/test';
22

33
import type { ElectricalProfileSet, Project, Scenario, Study } from 'common/api/osrdEditoastApi';
44

5-
import scenarioData from './assets/operationStudies/scenario.json';
5+
import scenarioData from './assets/operationStudies/scenario.json' with { type: 'json' };
66
import { infrastructureName } from './assets/project-const';
77
import ScenarioPage from './pages/scenario-page-model';
88
import test from './test-logger';

front/tests/011-op-times-and-stops-tab.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import { cleanWhitespace, cleanWhitespaceInArray, type StationData } from './uti
1616
import createScenario from './utils/scenario';
1717
import scrollContainer from './utils/scrollHelper';
1818
import { deleteScenario } from './utils/teardown-utils';
19-
import enTranslations from '../public/locales/en/timesStops.json';
20-
import frTranslations from '../public/locales/fr/timesStops.json';
19+
import enTranslations from '../public/locales/en/timesStops.json' with { type: 'json' };
20+
import frTranslations from '../public/locales/fr/timesStops.json' with { type: 'json' };
2121

2222
test.describe('Times and Stops Tab Verification', () => {
2323
test.slow();

front/tests/012-op-simulation-settings-tab.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { cleanWhitespace, type StationData } from './utils/dataNormalizer';
2525
import createScenario from './utils/scenario';
2626
import scrollContainer from './utils/scrollHelper';
2727
import { deleteScenario } from './utils/teardown-utils';
28-
import enTranslations from '../public/locales/en/timesStops.json';
29-
import frTranslations from '../public/locales/fr/timesStops.json';
28+
import enTranslations from '../public/locales/en/timesStops.json' with { type: 'json' };
29+
import frTranslations from '../public/locales/fr/timesStops.json' with { type: 'json' };
3030

3131
test.describe('Simulation Settings Tab Verification', () => {
3232
test.slow();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import enTranslations from '../../public/locales/en/stdcm-simulation-report-sheet.json';
2-
import frTranslations from '../../public/locales/fr/stdcm-simulation-report-sheet.json';
1+
import enTranslations from '../../public/locales/en/stdcm-simulation-report-sheet.json' with { type: 'json' };
2+
import frTranslations from '../../public/locales/fr/stdcm-simulation-report-sheet.json' with { type: 'json' };
33
import { getLocalizedDateString } from '../utils/date';
44
import type { Simulation } from '../utils/types';
55

front/tests/pages/op-input-table-page-model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type Locator, type Page, expect } from '@playwright/test';
22

3-
import enTranslations from '../../public/locales/en/timesStops.json';
4-
import frTranslations from '../../public/locales/fr/timesStops.json';
3+
import enTranslations from '../../public/locales/en/timesStops.json' with { type: 'json' };
4+
import frTranslations from '../../public/locales/fr/timesStops.json' with { type: 'json' };
55
import { cleanWhitespace } from '../utils/dataNormalizer';
66

77
class OperationalStudiesInputTablePage {

front/tests/pages/op-output-table-page-model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { type Locator, type Page, expect } from '@playwright/test';
22

33
import OperationalStudiesTimetablePage from './op-timetable-page-model';
4-
import enTranslations from '../../public/locales/en/timesStops.json';
5-
import frTranslations from '../../public/locales/fr/timesStops.json';
4+
import enTranslations from '../../public/locales/en/timesStops.json' with { type: 'json' };
5+
import frTranslations from '../../public/locales/fr/timesStops.json' with { type: 'json' };
66
import { normalizeData, type StationData } from '../utils/dataNormalizer';
77

88
class OperationalStudiesOutputTablePage extends OperationalStudiesTimetablePage {

front/tests/pages/op-route-page-model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, type Locator, type Page } from '@playwright/test';
22

3-
import enTranslations from '../../public/locales/en/operationalStudies/manageTrainSchedule.json';
4-
import frTranslations from '../../public/locales/fr/operationalStudies/manageTrainSchedule.json';
3+
import enTranslations from '../../public/locales/en/operationalStudies/manageTrainSchedule.json' with { type: 'json' };
4+
import frTranslations from '../../public/locales/fr/operationalStudies/manageTrainSchedule.json' with { type: 'json' };
55
import { clickWithDelay } from '../utils';
66

77
class RoutePage {

front/tests/pages/op-timetable-page-model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type Locator, type Page, expect } from '@playwright/test';
22

3-
import enTranslations from '../../public/locales/en/operationalStudies/scenario.json';
4-
import frTranslations from '../../public/locales/fr/operationalStudies/scenario.json';
3+
import enTranslations from '../../public/locales/en/operationalStudies/scenario.json' with { type: 'json' };
4+
import frTranslations from '../../public/locales/fr/operationalStudies/scenario.json' with { type: 'json' };
55
import { clickWithDelay } from '../utils';
66
import CommonPage from './common-page-model';
77

front/tests/pages/operational-studies-page-model.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, type Locator, type Page } from '@playwright/test';
22

33
import CommonPage from './common-page-model';
4-
import manageTrainScheduleTranslation from '../../public/locales/fr/operationalStudies/manageTrainSchedule.json';
4+
import manageTrainScheduleTranslation from '../../public/locales/fr/operationalStudies/manageTrainSchedule.json' with { type: 'json' };
55

66
const trainAddedTranslation = manageTrainScheduleTranslation.trainAdded;
77

front/tests/pages/stdcm-page-model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import path from 'path';
33

44
import { expect, type Locator, type Page } from '@playwright/test';
55

6-
import enTranslations from '../../public/locales/en/stdcm.json';
7-
import frTranslations from '../../public/locales/fr/stdcm.json';
6+
import enTranslations from '../../public/locales/en/stdcm.json' with { type: 'json' };
7+
import frTranslations from '../../public/locales/fr/stdcm.json' with { type: 'json' };
88
import {
99
CI_SUGGESTIONS,
1010
DEFAULT_DETAILS,

front/tests/utils/api-setup.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import type {
2424
GetTowedRollingStockApiResponse,
2525
} from 'common/api/osrdEditoastApi';
2626

27-
import electricalProfileSet from '../assets/operationStudies/simulationSettings/electricalProfiles/electricalProfile.json';
27+
import electricalProfileSet from '../assets/operationStudies/simulationSettings/electricalProfiles/electricalProfile.json' with { type: 'json' };
2828
import { globalProjectName, globalStudyName, infrastructureName } from '../assets/project-const';
29-
import towedRollingStockData from '../assets/stdcm/towedRollingStock/towedRollingStock.json';
29+
import towedRollingStockData from '../assets/stdcm/towedRollingStock/towedRollingStock.json' with { type: 'json' };
3030
import { logger } from '../test-logger';
3131

3232
/**

front/tests/utils/scenario.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
33
import type { Infra, Project, Scenario, Study, TimetableResult } from 'common/api/osrdEditoastApi';
44

55
import { getInfra, getProject, getStudy, postApiRequest } from './api-setup';
6-
import scenarioData from '../assets/operationStudies/scenario.json';
6+
import scenarioData from '../assets/operationStudies/scenario.json' with { type: 'json' };
77

88
// Define the SetupResult interface to structure the returned setup data.
99
interface SetupResult {

front/tests/utils/setup-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { readJsonFile } from '.';
1313
import { getApiRequest, getInfra, postApiRequest, setStdcmEnvironment } from './api-setup';
1414
import createScenario from './scenario';
1515
import { sendTrainSchedules } from './trainSchedule';
16-
import projectData from '../assets/operationStudies/project.json';
17-
import studyData from '../assets/operationStudies/study.json';
16+
import projectData from '../assets/operationStudies/project.json' with { type: 'json' };
17+
import studyData from '../assets/operationStudies/study.json' with { type: 'json' };
1818
import {
1919
dualModeRollingStockName,
2020
electricRollingStockName,

0 commit comments

Comments
 (0)