Skip to content

Commit 41f05bc

Browse files
committed
fixup! front: fix allowances do not reset when changing the path
1 parent 2708b5e commit 41f05bc

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardButtons.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,13 @@ const RollingStockCardButtons = ({
3030
const rollingStockComfort = useSelector(getRollingStockComfort);
3131
const [comfort, setComfort] = useState('STANDARD');
3232

33-
const {
34-
updatePathfindingID,
35-
updatePowerRestrictionRanges,
36-
updateRollingStockComfort,
37-
updateRollingStockID,
38-
} = useOsrdConfActions();
33+
const { updatePathfindingID, updateRollingStockComfort, updateRollingStockID } =
34+
useOsrdConfActions();
3935

4036
const selectRollingStock = () => {
4137
setOpenedRollingStockCardId(undefined);
4238
dispatch(updateRollingStockComfort(comfort as RollingStockComfortType));
4339
dispatch(updateRollingStockID(id));
44-
dispatch(updatePowerRestrictionRanges([]));
4540
dispatch(updatePathfindingID(undefined));
4641
closeModal();
4742
};

front/tests/005-operational-studies.spec.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ test.describe('Testing if all mandatory elements simulation configuration are lo
7474
await playwrightRollingstockModalPage.getRollingStockInfoComfort().textContent()
7575
).toMatch(/ConfortSStandard/i);
7676

77+
// ***************** Test choice Origin/Destination *****************
78+
await scenarioPage.openTabByDataId('tab-pathfinding');
79+
const itinerary = scenarioPage.getItineraryModule;
80+
await expect(itinerary).toBeVisible();
81+
82+
await scenarioPage.getPathfindingByTriGramSearch('MWS', 'NES');
83+
84+
await scenarioPage.checkPathfindingDistance('33.950 km');
85+
7786
// TODO: move this test in his own file
7887
// ***************** Test Composition Code *****************
7988
await scenarioPage.openTabByDataId('tab-simulation-settings');
@@ -87,19 +96,10 @@ test.describe('Testing if all mandatory elements simulation configuration are lo
8796
/Voyageurs - Automoteurs - E32C/i
8897
);
8998

90-
// ***************** Test choice Origin/Destination *****************
91-
await scenarioPage.openTabByDataId('tab-pathfinding');
92-
const itinerary = scenarioPage.getItineraryModule;
93-
await expect(itinerary).toBeVisible();
94-
95-
await scenarioPage.getPathfindingByTriGramSearch('MWS', 'NES');
96-
97-
await scenarioPage.checkPathfindingDistance('33.950 km');
98-
9999
// ***************** Test Add Train Schedule *****************
100100
await scenarioPage.addTrainSchedule();
101101
await scenarioPage.page.waitForSelector('.dots-loader', { state: 'hidden' });
102-
await scenarioPage.checkToastSNCFTitle();
102+
await scenarioPage.checkTrainHasBeenAdded();
103103
await scenarioPage.returnSimulationResult();
104104
await scenarioPage.checkNumberOfTrains(Number(trainCount));
105105
});

front/tests/assets/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default async function createCompleteScenario(
136136
// ***************** Create train *****************
137137
await scenarioPage.addTrainSchedule();
138138
await scenarioPage.page.waitForSelector('.dots-loader', { state: 'hidden' });
139-
await scenarioPage.checkToastSNCFTitle();
139+
await scenarioPage.checkTrainHasBeenAdded();
140140
await scenarioPage.returnSimulationResult();
141141
}
142142

front/tests/pages/base-page.ts

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

33
export default class BasePage {
44
public page: Page;
@@ -7,11 +7,14 @@ export default class BasePage {
77

88
protected viteOverlay: Locator;
99

10+
readonly lastToast: Locator;
11+
1012
constructor(page: Page) {
1113
this.page = page;
1214

1315
this.backToHomePageButton = page.locator('.mastheader-logo');
1416
this.viteOverlay = page.locator('vite-plugin-checker-error-overlay');
17+
this.lastToast = page.getByTestId('toast-SNCF').last();
1518
}
1619

1720
// Completly remove VITE button & sign
@@ -24,4 +27,12 @@ export default class BasePage {
2427
async backToHomePage() {
2528
await this.backToHomePageButton.click();
2629
}
30+
31+
async checkLastToastBody(text: string | RegExp) {
32+
await expect(this.lastToast.locator('.toast-body')).toHaveText(text);
33+
}
34+
35+
async checkLastToastTitle(text: string | RegExp) {
36+
await expect(this.lastToast.getByTestId('toast-SNCF-title')).toHaveText(text);
37+
}
2738
}

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

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

3-
class PlaywrightScenarioPage {
3+
import BasePage from './base-page';
4+
import manageTrainScheduleTranslation from '../../public/locales/fr/operationalStudies/manageTrainSchedule.json';
5+
6+
const trainAddedTranslation = manageTrainScheduleTranslation.trainAdded;
7+
8+
class PlaywrightScenarioPage extends BasePage {
49
readonly getScenarioUpdateBtn: Locator;
510

611
readonly getScenarioDeleteConfirmBtn: Locator;
@@ -57,10 +62,6 @@ class PlaywrightScenarioPage {
5762

5863
readonly getReturnSimulationResultBtn: Locator;
5964

60-
readonly getToastSNCF: Locator;
61-
62-
readonly getToastSNCFTitle: Locator;
63-
6465
readonly getPathfindingState: Locator;
6566

6667
readonly getSearchByTrigramButton: Locator;
@@ -92,6 +93,8 @@ class PlaywrightScenarioPage {
9293
readonly getSuccessBtn: Locator;
9394

9495
constructor(readonly page: Page) {
96+
super(page);
97+
9598
this.getRollingStockSelector = page.getByTestId('rollingstock-selector-empty');
9699
this.getScenarioUpdateBtn = page.getByTitle('Modifier le scénario');
97100
this.getScenarioDeleteConfirmBtn = page
@@ -134,8 +137,6 @@ class PlaywrightScenarioPage {
134137
.locator('.scenario-timetable-trains')
135138
.locator('.scenario-timetable-train');
136139
this.getReturnSimulationResultBtn = page.getByTestId('return-simulation-result');
137-
this.getToastSNCF = page.getByTestId('toast-SNCF');
138-
this.getToastSNCFTitle = this.getToastSNCF.getByTestId('toast-SNCF-title');
139140
this.getPathfindingState = page.locator('.pathfinding-state-main-container');
140141
this.getTimetableList = page.locator('.scenario-timetable-train-with-right-bar');
141142
this.getTrainEditBtn = page.locator('.scenario-timetable-train-buttons-update');
@@ -241,12 +242,8 @@ class PlaywrightScenarioPage {
241242
await this.getReturnSimulationResultBtn.click();
242243
}
243244

244-
async checkToastSNCFTitle() {
245-
await expect(this.getToastSNCFTitle).not.toBeEmpty();
246-
}
247-
248-
async checkToastSNCFBody(text: string | RegExp) {
249-
await expect(this.getToastSNCF.locator('.toast-body')).toHaveText(text);
245+
async checkTrainHasBeenAdded() {
246+
this.checkLastToastTitle(trainAddedTranslation);
250247
}
251248

252249
getBtnByName(name: string | RegExp) {

0 commit comments

Comments
 (0)