Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front: harmonize timesstops component name in scenario #9832

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions front/src/modules/timesStops/TimesStops.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { useTranslation } from 'react-i18next';

import { Loader } from 'common/Loaders/Loader';

import { useTimeStopsColumns } from './hooks/useTimeStopsColumns';
import { type TableType, type TimeStopsRow } from './types';
import { useTimesStopsColumns } from './hooks/useTimesStopsColumns';
import { type TableType, type TimesStopsRow } from './types';

type TimesStopsProps<T extends TimeStopsRow> = {
type TimesStopsProps<T extends TimesStopsRow> = {
rows: T[];
tableType: TableType;
cellClassName?: DataSheetGridProps['cellClassName'];
Expand All @@ -18,7 +18,7 @@ type TimesStopsProps<T extends TimeStopsRow> = {
dataIsLoading: boolean;
};

const TimesStops = <T extends TimeStopsRow>({
const TimesStops = <T extends TimesStopsRow>({
rows,
tableType,
cellClassName,
Expand All @@ -29,7 +29,7 @@ const TimesStops = <T extends TimeStopsRow>({
}: TimesStopsProps<T>) => {
const { t } = useTranslation('timesStops');

const columns = useTimeStopsColumns(tableType, rows);
const columns = useTimesStopsColumns(tableType, rows);

if (dataIsLoading) {
return (
Expand Down
4 changes: 2 additions & 2 deletions front/src/modules/timesStops/TimesStopsOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { NO_BREAK_SPACE } from 'utils/strings';

import useOutputTableData from './hooks/useOutputTableData';
import TimesStops from './TimesStops';
import { TableType, type TimeStopsRow } from './types';
import { TableType, type TimesStopsRow } from './types';

type TimesStopsOutputProps = {
simulatedTrain: SimulationResponseSuccess;
Expand Down Expand Up @@ -41,7 +41,7 @@ const TimesStopsOutput = ({
rows={enrichedOperationalPoints}
tableType={TableType.Output}
cellClassName={({ rowData: rowData_, columnId }) => {
const rowData = rowData_ as TimeStopsRow;
const rowData = rowData_ as TimesStopsRow;
const arrivalScheduleNotRespected = rowData.arrival?.time
? rowData.calculatedArrival !== rowData.arrival.time
: false;
Expand Down
6 changes: 3 additions & 3 deletions front/src/modules/timesStops/hooks/useOutputTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ import { ARRIVAL_TIME_ACCEPTABLE_ERROR_MS } from '../consts';
import { computeInputDatetimes } from '../helpers/arrivalTime';
import computeMargins, { getTheoreticalMargins } from '../helpers/computeMargins';
import { formatSchedule } from '../helpers/scheduleData';
import { type ScheduleEntry, type TimeStopsRow } from '../types';
import { type ScheduleEntry, type TimesStopsRow } from '../types';

const useOutputTableData = (
{ final_output: simulatedTrain }: SimulationResponseSuccess,
trainSummary?: TrainScheduleWithDetails,
operationalPoints?: PathPropertiesFormatted['operationalPoints'],
selectedTrainSchedule?: TrainScheduleResult,
path?: PathfindingResultSuccess
): TimeStopsRow[] => {
): TimesStopsRow[] => {
const { t } = useTranslation('timesStops');
const { getTrackSectionsByIds } = useScenarioContext();

const [rows, setRows] = useState<TimeStopsRow[]>([]);
const [rows, setRows] = useState<TimesStopsRow[]>([]);

const scheduleByAt: Record<string, ScheduleEntry> = keyBy(selectedTrainSchedule?.schedule, 'at');
const theoreticalMargins = selectedTrainSchedule && getTheoreticalMargins(selectedTrainSchedule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { marginRegExValidation } from '../consts';
import { disabledTextColumn } from '../helpers/utils';
import ReadOnlyTime from '../ReadOnlyTime';
import TimeInput from '../TimeInput';
import { TableType, type TimeExtraDays, type TimeStopsRow } from '../types';
import { TableType, type TimeExtraDays, type TimesStopsRow } from '../types';

const timeColumn = (isOutputTable: boolean) =>
({
Expand All @@ -33,7 +33,7 @@ function headerWithTitleTagIfShortened(shortenedHeader: string, fullHeader: stri
return <span title={fullHeader}> {shortenedHeader} </span>;
}

export const useTimeStopsColumns = <T extends TimeStopsRow>(
export const useTimesStopsColumns = <T extends TimesStopsRow>(
tableType: TableType,
allWaypoints: T[] = []
) => {
Expand Down
4 changes: 2 additions & 2 deletions front/src/modules/timesStops/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type TimeExtraDays = {
dayDisplayed?: boolean;
};

export type TimeStopsRow = {
export type TimesStopsRow = {
opId: string;
name?: string;
ch?: string;
Expand All @@ -33,7 +33,7 @@ export type TimeStopsRow = {
isMarginValid?: boolean;
};

export type TimesStopsInputRow = Omit<SuggestedOP, 'arrival' | 'departure'> & TimeStopsRow;
export type TimesStopsInputRow = Omit<SuggestedOP, 'arrival' | 'departure'> & TimesStopsRow;

export enum TableType {
Input = 'Input',
Expand Down
2 changes: 1 addition & 1 deletion front/tests/011-op-times-and-stops-tab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ test.describe('Times and Stops Tab Verification', () => {
// Add train schedule, verify results and output table data
await operationalStudiesPage.addTrainSchedule();
await operationalStudiesPage.returnSimulationResult();
await opOutputTablePage.verifyTimeStopsDataSheetVisibility();
await opOutputTablePage.verifyTimesStopsDataSheetVisibility();

// Scroll and extract output table data for verification
await scrollContainer(page, '.time-stop-outputs .time-stops-datasheet .dsg-container');
Expand Down
14 changes: 7 additions & 7 deletions front/tests/012-op-simulation-settings-tab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ test.describe('Simulation Settings Tab Verification', () => {
await operationalStudiesPage.returnSimulationResult();
await opTimetablePage.getTrainArrivalTime('11:53');
await opTimetablePage.clickOnScenarioCollapseButton();
await opOutputTablePage.verifyTimeStopsDataSheetVisibility();
await opOutputTablePage.verifyTimesStopsDataSheetVisibility();
await scrollContainer(page, '.time-stop-outputs .time-stops-datasheet .dsg-container');
await opOutputTablePage.getOutputTableData(expectedCellDataElectricalProfileON, OSRDLanguage);
await opTimetablePage.clickOnTimetableCollapseButton();
Expand All @@ -178,7 +178,7 @@ test.describe('Simulation Settings Tab Verification', () => {
await page.waitForTimeout(stabilityTimeout); // Waiting for the timetable to update due to a slight latency
await opTimetablePage.getTrainArrivalTime('11:52');
await opTimetablePage.clickOnScenarioCollapseButton();
await opOutputTablePage.verifyTimeStopsDataSheetVisibility();
await opOutputTablePage.verifyTimesStopsDataSheetVisibility();
await opOutputTablePage.getOutputTableData(expectedCellDataElectricalProfileOFF, OSRDLanguage);
});
test('Activate composition code', async ({ page }) => {
Expand Down Expand Up @@ -220,7 +220,7 @@ test.describe('Simulation Settings Tab Verification', () => {
await operationalStudiesPage.returnSimulationResult();
await opTimetablePage.getTrainArrivalTime('12:03');
await opTimetablePage.clickOnScenarioCollapseButton();
await opOutputTablePage.verifyTimeStopsDataSheetVisibility();
await opOutputTablePage.verifyTimesStopsDataSheetVisibility();
await scrollContainer(page, '.time-stop-outputs .time-stops-datasheet .dsg-container');
await opOutputTablePage.getOutputTableData(expectedCellDataCodeCompoON, OSRDLanguage);
await opTimetablePage.clickOnTimetableCollapseButton();
Expand All @@ -232,7 +232,7 @@ test.describe('Simulation Settings Tab Verification', () => {
await page.waitForTimeout(stabilityTimeout);
await opTimetablePage.getTrainArrivalTime('11:52');
await opTimetablePage.clickOnScenarioCollapseButton();
await opOutputTablePage.verifyTimeStopsDataSheetVisibility();
await opOutputTablePage.verifyTimesStopsDataSheetVisibility();
await opOutputTablePage.getOutputTableData(expectedCellDataCodeCompoOFF, OSRDLanguage);
});
test('Activate linear and mareco margin', async ({ page }) => {
Expand Down Expand Up @@ -283,7 +283,7 @@ test.describe('Simulation Settings Tab Verification', () => {
await operationalStudiesPage.returnSimulationResult();
await opTimetablePage.getTrainArrivalTime('11:54');
await opTimetablePage.clickOnScenarioCollapseButton();
await opOutputTablePage.verifyTimeStopsDataSheetVisibility();
await opOutputTablePage.verifyTimesStopsDataSheetVisibility();
await scrollContainer(page, '.time-stop-outputs .time-stops-datasheet .dsg-container');
await opOutputTablePage.getOutputTableData(expectedCellDataLinearMargin, OSRDLanguage);
await opTimetablePage.clickOnTimetableCollapseButton();
Expand All @@ -295,7 +295,7 @@ test.describe('Simulation Settings Tab Verification', () => {
await page.waitForTimeout(stabilityTimeout);
await opTimetablePage.getTrainArrivalTime('11:54');
await opTimetablePage.clickOnScenarioCollapseButton();
await opOutputTablePage.verifyTimeStopsDataSheetVisibility();
await opOutputTablePage.verifyTimesStopsDataSheetVisibility();
await opOutputTablePage.getOutputTableData(expectedCellDataMarecoMargin, OSRDLanguage);
});
test('Add all the simulation settings', async ({ page }) => {
Expand Down Expand Up @@ -347,7 +347,7 @@ test.describe('Simulation Settings Tab Verification', () => {
await operationalStudiesPage.returnSimulationResult();
await opTimetablePage.getTrainArrivalTime('12:06');
await opTimetablePage.clickOnScenarioCollapseButton();
await opOutputTablePage.verifyTimeStopsDataSheetVisibility();
await opOutputTablePage.verifyTimesStopsDataSheetVisibility();
await scrollContainer(page, '.time-stop-outputs .time-stops-datasheet .dsg-container');
await opOutputTablePage.getOutputTableData(expectedCellDataForAllSettings, OSRDLanguage);
});
Expand Down
6 changes: 3 additions & 3 deletions front/tests/pages/op-output-table-page-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ class OperationalStudiesOutputTablePage extends OperationalStudiesTimetablePage
}

// Wait for the Times and Stops simulation data sheet to be fully loaded with a specified timeout (default: 60 seconds)
async verifyTimeStopsDataSheetVisibility(timeout = 60 * 1000): Promise<void> {
await this.timeStopsDataSheet.waitFor({ state: 'visible', timeout });
async verifyTimesStopsDataSheetVisibility(timeout = 60 * 1000): Promise<void> {
await this.timesStopsDataSheet.waitFor({ state: 'visible', timeout });
await this.page.waitForTimeout(100); // Short delay for stabilization
await this.timeStopsDataSheet.scrollIntoViewIfNeeded({ timeout });
await this.timesStopsDataSheet.scrollIntoViewIfNeeded({ timeout });
}
}

Expand Down
12 changes: 6 additions & 6 deletions front/tests/pages/op-timetable-page-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OperationalStudiesTimetablePage {

readonly speedSpaceChart: Locator;

readonly timeStopsDataSheet: Locator;
readonly timesStopsDataSheet: Locator;

readonly simulationMap: Locator;

Expand Down Expand Up @@ -52,7 +52,7 @@ class OperationalStudiesTimetablePage {
this.manchetteSpaceTimeChart = page.locator('.manchette-space-time-chart-wrapper');
this.speedSpaceChart = page.locator('#container-SpeedSpaceChart');
this.spaceTimeChart = page.locator('.space-time-chart-container');
this.timeStopsDataSheet = page.locator('.time-stops-datasheet');
this.timesStopsDataSheet = page.locator('.time-stops-datasheet');
this.simulationMap = page.locator('.simulation-map');
this.timetableFilterButton = page.getByTestId('timetable-filter-button');
this.timetableFilterButtonClose = page.getByTestId('timetable-filter-button-close');
Expand Down Expand Up @@ -104,7 +104,7 @@ class OperationalStudiesTimetablePage {
this.speedSpaceChart,
this.spaceTimeChart,
this.simulationMap,
this.timeStopsDataSheet,
this.timesStopsDataSheet,
];
await Promise.all(
simulationResultsLocators.map((simulationResultsLocator) =>
Expand Down Expand Up @@ -211,10 +211,10 @@ class OperationalStudiesTimetablePage {
}
}

async verifyTimeStopsDataSheetVisibility(timeout = 60 * 1000): Promise<void> {
async verifyTimesStopsDataSheetVisibility(timeout = 60 * 1000): Promise<void> {
// Wait for the Times and Stops simulation dataSheet to be fully loaded with a specified timeout (default: 60 seconds)
await expect(this.timeStopsDataSheet).toBeVisible({ timeout });
await this.timeStopsDataSheet.scrollIntoViewIfNeeded();
await expect(this.timesStopsDataSheet).toBeVisible({ timeout });
await this.timesStopsDataSheet.scrollIntoViewIfNeeded();
}

async clickOnEditTrain() {
Expand Down
Loading