Skip to content

front: add useSimulationResults hook tests#16004

Merged
Maymanaf merged 1 commit into
devfrom
aba/useSimulationResults-hook-test
Jun 9, 2026
Merged

front: add useSimulationResults hook tests#16004
Maymanaf merged 1 commit into
devfrom
aba/useSimulationResults-hook-test

Conversation

@Maymanaf

@Maymanaf Maymanaf commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

closes #16668
Critical behaviors covered:

  • no resolved train -> returns undefined results
  • complete data -> returns a valid simulation result
  • partial or incomplete data -> returns an invalid result
  • paced occurrences -> rebuilds the selected train correctly
  • loading -> returns loading=true when any dependency is fetching

@github-actions github-actions Bot added the area:front Work on Standard OSRD Interface modules label Mar 30, 2026
@Maymanaf Maymanaf force-pushed the aba/useSimulationResults-hook-test branch from ee8ede1 to 6b73724 Compare March 30, 2026 13:11
@Maymanaf Maymanaf force-pushed the aba/useSimulationResults-hook-test branch from 6b73724 to 5c62125 Compare April 13, 2026 13:18
@Maymanaf Maymanaf marked this pull request as ready for review April 13, 2026 13:26
@Maymanaf Maymanaf requested a review from a team as a code owner April 13, 2026 13:26
@Maymanaf Maymanaf force-pushed the aba/useSimulationResults-hook-test branch from 5c62125 to c940591 Compare April 13, 2026 13:39
@Maymanaf Maymanaf marked this pull request as draft April 13, 2026 14:00
@Maymanaf Maymanaf marked this pull request as ready for review April 13, 2026 14:15

@kmer2016 kmer2016 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on the test coverage! I had a thought about the mock setup.

I think we should only mock the 5 actual I/O dependencies (React, Redux, RTK endpoints). The other 9 are pure functions, so mocking them adds a lot of setup without giving us much assertions end up checking that mocks were called rather than what the hook actually produces.

Also, the useMemo that builds the effective train (useSimulationResults.ts:42-72) is pure domain logic. We could extract it as a buildEffectiveTrain(selectedTrainId, timetableItem) function. Tthat way we can unit-test the occurrence/exception resolution with zero mocks.

Together with the mock cleanup above, this would simplify the hook tests a lot. Happy to handle it in a follow-up PR.

Comment thread front/src/applications/operationalStudies/__tests__/useSimulationResults.spec.ts Outdated
@Maymanaf Maymanaf marked this pull request as draft April 20, 2026 13:10
@Maymanaf Maymanaf moved this to In Progress in Board PI 20 May 6, 2026
@Maymanaf Maymanaf self-assigned this May 6, 2026
@Maymanaf Maymanaf force-pushed the aba/useSimulationResults-hook-test branch from c940591 to 008ad99 Compare May 29, 2026 14:19
@Maymanaf Maymanaf marked this pull request as ready for review June 1, 2026 08:08
@Maymanaf Maymanaf marked this pull request as draft June 1, 2026 08:09
@Maymanaf Maymanaf marked this pull request as ready for review June 1, 2026 08:15
@Maymanaf Maymanaf requested review from SarahBellaha and kmer2016 June 1, 2026 08:15
@Maymanaf Maymanaf moved this from In Progress to Awaiting merge in Board PI 20 Jun 1, 2026

@Yohh Yohh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

this test is set in front/src/applications/operationalStudies/__tests__/, could you set it closer in front/src/applications/operationalStudies/hooks/__tests__/?

need more time to review deeper

Comment thread front/src/applications/operationalStudies/__tests__/useSimulationResults.spec.ts Outdated
Comment thread front/src/applications/operationalStudies/__tests__/useSimulationResults.spec.ts Outdated
Comment thread front/src/applications/operationalStudies/__tests__/useSimulationResults.spec.ts Outdated
Comment thread front/src/applications/operationalStudies/__tests__/useSimulationResults.spec.ts Outdated
Comment thread front/src/applications/operationalStudies/__tests__/useSimulationResults.spec.ts Outdated
@Maymanaf Maymanaf force-pushed the aba/useSimulationResults-hook-test branch from 008ad99 to 4c59910 Compare June 2, 2026 13:13
@Maymanaf Maymanaf requested a review from Yohh June 2, 2026 13:14
@Maymanaf Maymanaf force-pushed the aba/useSimulationResults-hook-test branch 2 times, most recently from 53a3404 to 5e3a9ab Compare June 8, 2026 08:46
@Maymanaf Maymanaf force-pushed the aba/useSimulationResults-hook-test branch from 5e3a9ab to 9c84bc4 Compare June 9, 2026 08:57
@Yohh Yohh requested a review from Math-R June 9, 2026 12:19
@Maymanaf Maymanaf requested a review from Yohh June 9, 2026 12:22

@Math-R Math-R left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Signed-off-by: Maymanaf <med.aymen.naf@gmail.com>
@Maymanaf Maymanaf force-pushed the aba/useSimulationResults-hook-test branch from 9c84bc4 to 8c3a39c Compare June 9, 2026 15:03
@Maymanaf Maymanaf enabled auto-merge June 9, 2026 15:03
@Maymanaf Maymanaf added this pull request to the merge queue Jun 9, 2026
Merged via the queue into dev with commit d5053f8 Jun 9, 2026
31 checks passed
@Maymanaf Maymanaf deleted the aba/useSimulationResults-hook-test branch June 9, 2026 15:55
@github-project-automation github-project-automation Bot moved this from Awaiting merge to Awaiting Validation in Board PI 20 Jun 9, 2026
@louisgreiner louisgreiner moved this from Awaiting Validation to Done in Board PI 20 Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:front Work on Standard OSRD Interface modules

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

front: test useSimulationResults

6 participants