Skip to content

Conversation

@mariadenis
Copy link

Description

This PR introduces a unit test suite for the Note.mustHandleConflict method (located in packages/lib/models/Note.ts), which previously had no dedicated test coverage.

What this PR does:

This PR follows the contribution guidelines by adding automated tests for existing business logic.

The mustHandleConflict method is responsible for critical business logic during synchronization, deciding when a note conflict should be created. The lack of tests represented a risk of regression.

Explanation of Changes:

  1. MC/DC Test Creation: Six new test cases were created in a separate file (NoteConflict.test.js) to ensure compatibility with the @joplin/lib sub-package's test environment.
  2. Logic Coverage: The tests cover all 4 decisions within the method, including the independence pairs for the multi-condition decision (line 981), as required by the MC/DC criterion.
  3. Focus: This PR is focused on this single issue, as guided by the contribution rules.

Manual Testing Plan (for the reviewer):

While the automated tests validate the logic, the following manual steps can be used to confirm execution:

  1. Verify Test Execution:

    Run the command:

    yarn workspace @joplin/lib test -- --coverage NoteConflict.test.js

    Expected Result: All 6 tests should pass successfully.

  2. Verify Coverage:

    Open the generated coverage report at packages/lib/coverage/lcov-report/index.html.

    Navigate to packages/lib/models/Note.ts.

    Expected Result: A measurable increase in the "Branches" and "Functions" coverage percentages for the Note.ts file will be visible, proving the effectiveness of the new tests.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@mariadenis
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Oct 31, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for the pull request!

Feedback:

@personalizedrefrigerator personalizedrefrigerator changed the title Desktop, Mobile: Add test coverage (MC/DC) for Note.mustHandleConflict Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants