Skip to content

Conversation

@Math-R
Copy link

@Math-R Math-R commented Nov 19, 2025

Description

This PR updates unit tests to accommodate the changes made to TrainrunSectionViewObject in the collapsed nodes feature implementation.

Changes

Modified Test Files

  • trainrunsections.view.spec.ts: Updated tests for methods that now expect TrainrunSectionViewObject instead of TrainrunSection:

    • getPosition() - 2 tests updated
    • enforceStartTextAnchor() - 8 tests updated
    • getAdditionTextCloseToNodePositioningValue() - 4 tests updated
    • getTrainrunSectionNextAndDestinationNodeToShow() - 1 test updated
  • data.view.spec.ts:

    • Updated TrainrunSectionViewObject constructor call to use array of sections ([ts] instead of ts)
    • Updated expected key value to reflect new key generation logic

Key Changes

The main model change was:

  • TrainrunSectionViewObject.trainrunSection: TrainrunSectionTrainrunSectionViewObject.trainrunSections: TrainrunSection[]

This change supports grouping multiple sections together when intermediate nodes are collapsed, allowing the view layer to render direct paths between expanded nodes.

Test Pattern

All updated tests now follow this pattern:

const ts = trainrunSectionService.getTrainrunSectionFromId(id);
const viewObj = new TrainrunSectionViewObject(
  editorView, 
  [ts],  // Array instead of single section
  false, false, false, false, false, false, false, false
);
// Use viewObj instead of ts in method calls

Test Results
✅ All 514 tests passing
✅ No TypeScript compilation errors

Issues
Related to #554 - Part of the collapsed nodes feature implementation

Checklist
This PR contains a description of the changes I'm making
I've read the Contribution Guidelines
I've added tests for changes or features I've introduced (updated existing tests to match new signatures)
I documented any high-level concepts I'm introducing in documentation (test updates don't require documentation)
CI is currently green and this is ready for review

@Math-R Math-R requested a review from aiAdrian as a code owner November 19, 2025 10:01
@Math-R Math-R requested review from aiAdrian, emersion and louisgreiner and removed request for aiAdrian November 19, 2025 10:01
@Math-R Math-R force-pushed the mrd/modify-node-display branch from f01f31b to 2ae95ab Compare November 19, 2025 16:05
…pec accordingly to the isCollapsed's model change
@Math-R Math-R force-pushed the mrd/fix-tests-after-model-change branch from 08ccae5 to 6068eef Compare November 20, 2025 12:25
@louisgreiner
Copy link
Contributor

Does these changes are aligned with #596?

Comment on lines +1562 to +1568
// Create a minimal ViewObject without triggering side effects
const viewObject = {
trainrunSections: [trainrunSection],
getTrainrun: () => trainrunSection.getTrainrun(),
getTravelTime: () => trainrunSection.getTravelTime(),
getPath: () => trainrunSection.getPath(),
} as TrainrunSectionViewObject;
Copy link
Member

Choose a reason for hiding this comment

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

Why can't we create a regular TrainrunSectionViewObject here?

Comment on lines +87 to +89
// After PR #554, trainrunSections with numberOfStops > 0 are expanded into
// intermediate nodes and sections. Calculate expected expansion dynamically
// so the test will automatically adapt when numberOfStops is removed.
Copy link
Member

@emersion emersion Nov 21, 2025

Choose a reason for hiding this comment

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

As far as I understand this test is supposed to check that an up-to-date input DTO isn't mutated when loaded. We have another check below for numberOfStops migration.

Can we update the input to reset numberOfStops and create collapsed nodes, instead of updating the test check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants