Skip to content

Commit

Permalink
front: harmonize timesstops component name
Browse files Browse the repository at this point in the history
Signed-off-by: Alice Khoudli <[email protected]>
  • Loading branch information
Synar committed Nov 28, 2024
1 parent 2520f67 commit 9723f76
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
10 changes: 5 additions & 5 deletions front/src/modules/timesStops/TimesStops.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { DynamicDataSheetGrid, type DataSheetGridProps } from 'react-datasheet-g
import type { Operation } from 'react-datasheet-grid/dist/types';
import { useTranslation } from 'react-i18next';

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 @@ -15,7 +15,7 @@ type TimesStopsProps<T extends TimeStopsRow> = {
onChange?: (newRows: T[], operation: Operation) => void;
};

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

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

if (!rows) {
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 @@ -11,7 +11,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 @@ -51,7 +51,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 @@ -17,15 +17,15 @@ 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 scheduleByAt: Record<string, ScheduleEntry> = keyBy(selectedTrainSchedule?.schedule, 'at');
Expand Down Expand Up @@ -103,7 +103,7 @@ const useOutputTableData = (
});
}, [selectedTrainSchedule, path, trainSummary?.pathItemTimes, startDatetime]);

const rows: TimeStopsRow[] = useMemo(() => {
const rows: TimesStopsRow[] = useMemo(() => {
if (!operationalPoints || !startDatetime) return [];

return operationalPoints.map((op) => {
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 @@ -32,7 +32,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 @@ -172,7 +172,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 @@ -137,10 +137,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

0 comments on commit 9723f76

Please sign in to comment.