Skip to content

(test) O3-3926 Add test coverage for the InlineDateAdapter#422

Closed
suubi-joshua wants to merge 1 commit intoopenmrs:mainfrom
suubi-joshua:O3-3926
Closed

(test) O3-3926 Add test coverage for the InlineDateAdapter#422
suubi-joshua wants to merge 1 commit intoopenmrs:mainfrom
suubi-joshua:O3-3926

Conversation

@suubi-joshua
Copy link

@suubi-joshua suubi-joshua commented Nov 7, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR introduces test coverage for the InlineDateAdapter to ensure robust handling of date transformations within form fields. Key scenarios tested include:

Updating Observation Dates: Tests confirm that when a new date is provided, the adapter correctly updates the obsDatetime field in the target field’s submission, ensuring accuracy in new entries.

Editing Dates in Edit Mode: Verifies that the adapter updates dates accurately when modified in edit mode, supporting seamless updates to existing records.

Conditional Side-Effects: Tests check that side-effects only trigger when there’s an actual change in the date value, avoiding redundant updates.

Commitment on Value Presence: Ensures side-effects are committed if the target field holds a value or has an existing submission, facilitating reliable updates when data is available.

Initial Value Extraction: Confirms that the adapter retrieves initial observation dates correctly from the previous value, essential for accurate pre-filling.

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-3926

Other

@suubi-joshua
Copy link
Author

suubi-joshua commented Nov 7, 2024

@samuelmale @pirupius is this the right approach

@pirupius pirupius changed the title (test) O3-3926-Add test coverage for the InlineDateAdapter (test) O3-3926 Add test coverage for the InlineDateAdapter Dec 2, 2024
Copy link
Member

@samuelmale samuelmale left a comment

Choose a reason for hiding this comment

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

@suubi-joshua can you resolve the merge conflicts?

Comment on lines +72 to +74
targetField.meta.previousValue = {
value: '36'
};
Copy link
Member

Choose a reason for hiding this comment

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

A more explicit way of testing this is by making sure that the target field has no value (neither the previous nor the current); in that case, we assert:

expect(targetField.meta.submission.newValue).toBeUndefined();

@suubi-joshua suubi-joshua deleted the O3-3926 branch January 28, 2026 13:53
@suubi-joshua
Copy link
Author

New PR #674

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.

2 participants