Skip to content

Commit 54fc6d2

Browse files
committed
fixup! front: improve page object structure and optimize project language handling for e2e tests
1 parent 768ae4a commit 54fc6d2

6 files changed

+21
-15
lines changed

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

+15-7
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ test.describe('Validate the Operational Study Project workflow', () => {
1111
let project: Project;
1212
let projectPage: ProjectPage;
1313

14-
test.beforeEach('Navigate to the projects page', async ({ page }) => {
14+
test.beforeEach(async ({ page }) => {
1515
projectPage = new ProjectPage(page);
16-
// Create a project
17-
project = await createProject(generateUniqueName(projectData.name));
18-
await page.goto('/operational-studies/projects');
1916
});
2017

2118
/** *************** Test 1 **************** */
22-
test('Create a new project', async () => {
19+
test('Create a new project', async ({ page }) => {
20+
// Go to projects page
21+
await page.goto('/operational-studies/projects');
22+
2323
// Define a unique project name for the test
2424
const projectName = generateUniqueName(projectData.name);
2525

@@ -48,7 +48,11 @@ test.describe('Validate the Operational Study Project workflow', () => {
4848
});
4949

5050
/** *************** Test 2 **************** */
51-
test('Update an existing project', async () => {
51+
test('Update an existing project', async ({ page }) => {
52+
// Create a project
53+
project = await createProject(generateUniqueName(projectData.name));
54+
await page.goto('/operational-studies/projects');
55+
5256
// Open the created project by name using the project page model
5357
await projectPage.openProjectByTestId(project.name);
5458

@@ -81,7 +85,11 @@ test.describe('Validate the Operational Study Project workflow', () => {
8185
});
8286

8387
/** *************** Test 3 **************** */
84-
test('Delete a project', async () => {
88+
test('Delete a project', async ({ page }) => {
89+
// Create a project
90+
project = await createProject(generateUniqueName(projectData.name));
91+
await page.goto('/operational-studies/projects');
92+
8593
// Find the project by name and delete it using the page model
8694
await projectPage.openProjectByTestId(project.name);
8795
await projectPage.deleteProject(project.name);

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

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ test.describe('Validate the Study creation workflow', () => {
3434
test('Create a new study', async ({ page }) => {
3535
// Navigate to project page
3636
await page.goto(`/operational-studies/projects/${project.id}`);
37-
// Set translations based on the language
3837
const studyName = `${studyData.name} ${uuidv4()}`; // Unique study name
3938
const todayDateISO = new Date().toISOString().split('T')[0]; // Get today's date in ISO format
4039
const expectedDate = formatDateToDayMonthYear(todayDateISO);

front/tests/006-stdcm.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ test.describe('Verify stdcm simulation page', () => {
4848
});
4949

5050
test.beforeEach('Navigate to the STDCM page', async ({ page }) => {
51-
// Retrieve OSRD language and navigate to STDCM page
5251
[stdcmPage, stdcmLinkedTrainPage] = [new STDCMPage(page), new STDCMLinkedTrainPage(page)];
5352
await page.goto('/stdcm');
5453
await page.waitForLoadState('networkidle');

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

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ test.describe('Verify stdcm simulation page', () => {
3939
});
4040

4141
test.beforeEach('Navigate to the STDCM page', async ({ page }) => {
42-
// Retrieve OSRD language and navigate to STDCM page
4342
stdcmPage = new STDCMPage(page);
4443
await page.goto('/stdcm');
4544
await page.waitForLoadState('networkidle');

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class RoutePage {
156156
await this.deleteItineraryButton.click();
157157
}
158158

159-
// Verify that no route is selected and displays appropriate messages based on language.
159+
// Verify that no route is selected and displays appropriate messages.
160160
async verifyNoSelectedRoute() {
161161
const translations = getTranslations({
162162
en: enTranslations,

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ class STDCMPage extends HomePage {
499499
await expect(this.toleranceOriginArrival).not.toBeVisible();
500500
}
501501

502-
// Fill and verify destination details based on selected language
502+
// Fill and verify destination details
503503
async fillAndVerifyDestinationDetails() {
504504
const {
505505
input,
@@ -594,15 +594,16 @@ class STDCMPage extends HomePage {
594594
async fillAndVerifyViaDetails({
595595
viaNumber,
596596
ciSearchText,
597-
language,
598597
}: {
599598
viaNumber: number;
600599
ciSearchText: string;
601-
language?: string;
602600
}): Promise<void> {
603601
const { PASSAGE_TIME, SERVICE_STOP, DRIVER_SWITCH } = VIA_STOP_TYPES;
604602
const { serviceStop, driverSwitch } = VIA_STOP_TIMES;
605-
const translations = language === 'English' ? enTranslations : frTranslations;
603+
const translations = getTranslations({
604+
en: enTranslations,
605+
fr: frTranslations,
606+
});
606607
const warning = this.getViaWarning(viaNumber);
607608
// Helper function to fill common fields
608609
const fillVia = async (selectedSuggestion: Locator) => {

0 commit comments

Comments
 (0)