From 972d8464395160910b8962062c1bf8ca7682d7fd Mon Sep 17 00:00:00 2001 From: maymanaf Date: Mon, 6 Jan 2025 15:01:54 +0100 Subject: [PATCH] front: fix missing await statements for asynchronous calls Signed-off-by: maymanaf --- front/.eslintrc | 6 ++++++ front/tests/004-scenario-management.spec.ts | 2 +- front/tests/pages/op-simulation-settings-page-model.ts | 2 +- front/tests/pages/op-timetable-page-model.ts | 2 +- front/tests/pages/operational-studies-page-model.ts | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/front/.eslintrc b/front/.eslintrc index a8d736ad852..9ceed07f589 100644 --- a/front/.eslintrc +++ b/front/.eslintrc @@ -154,6 +154,12 @@ "rules": { "@typescript-eslint/no-explicit-any": ["error", { "fixToUnknown": true }] } + }, + { + "files": ["tests/**/*.ts", "tests/**/*.tsx"], + "rules": { + "@typescript-eslint/no-floating-promises": "error" + } } ] } diff --git a/front/tests/004-scenario-management.spec.ts b/front/tests/004-scenario-management.spec.ts index 447d51c9590..21e5895bd90 100644 --- a/front/tests/004-scenario-management.spec.ts +++ b/front/tests/004-scenario-management.spec.ts @@ -24,7 +24,7 @@ test.describe('Validate the Scenario creation workflow', () => { }); test.afterAll('Delete the electrical profile', async () => { - deleteApiRequest(`/api/electrical_profile_set/${electricalProfileSet.id}/`); + await deleteApiRequest(`/api/electrical_profile_set/${electricalProfileSet.id}/`); }); /** *************** Test 1 **************** */ diff --git a/front/tests/pages/op-simulation-settings-page-model.ts b/front/tests/pages/op-simulation-settings-page-model.ts index 740c4965532..4ff1d493401 100644 --- a/front/tests/pages/op-simulation-settings-page-model.ts +++ b/front/tests/pages/op-simulation-settings-page-model.ts @@ -28,7 +28,7 @@ class OperationalStudiesSimulationSettingsPage { // Deactivate electrical profiles switch async deactivateElectricalProfile() { await this.electricalProfilesSwitch.setChecked(false, { force: true }); - expect(this.electricalProfilesSwitch).not.toBeChecked(); + await expect(this.electricalProfilesSwitch).not.toBeChecked(); } async activateLinearMargin() { diff --git a/front/tests/pages/op-timetable-page-model.ts b/front/tests/pages/op-timetable-page-model.ts index 66c19a12ac2..2b9433a458a 100644 --- a/front/tests/pages/op-timetable-page-model.ts +++ b/front/tests/pages/op-timetable-page-model.ts @@ -152,7 +152,7 @@ class OperationalStudiesTimetablePage extends CommonPage { // Verify that the imported train number is correct async verifyTrainCount(trainCount: number): Promise { await this.page.waitForLoadState('networkidle'); - expect(this.timetableTrains).toHaveCount(trainCount); + await expect(this.timetableTrains).toHaveCount(trainCount); } // Filter trains validity and verify their count diff --git a/front/tests/pages/operational-studies-page-model.ts b/front/tests/pages/operational-studies-page-model.ts index 62a480eafda..af358675d6b 100644 --- a/front/tests/pages/operational-studies-page-model.ts +++ b/front/tests/pages/operational-studies-page-model.ts @@ -99,7 +99,7 @@ class OperationalStudiesPage extends CommonPage { } async checkTrainHasBeenAdded() { - this.checkLastToastTitle(trainAddedTranslation); + await this.checkLastToastTitle(trainAddedTranslation); } async returnSimulationResult() {