Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove request NONE id schemes [DHIS2-18013] #98

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

tomzemp
Copy link
Member

@tomzemp tomzemp commented Sep 6, 2024

This fixes a bug whereby ID Schemes for requests were being sent to the backend with "NONE" values (https://dhis2.atlassian.net/jira/software/c/projects/DHIS2/issues/DHIS2-18013). The backend excepted these "NONE" types and then the exchange wouldn't run.

The app was supposed to be filtering out "NONE" values, but I had the wrong ID scheme names defined, so this failed.

The requests were also being posted to the backend with some additional properties (e.g. dxInfo that contains metadata about the dx selected). These extra properties were ignored, but it made interpreting the payload a bit difficult, so I've updated the logic to filter out properties that are only relevant for the app.

I've added some unit tests and modified an existing add-page test to partly cover this. I think it would be good to add some additional dedicated tests for add page, edit page around request ID schemes, but I've created a separate ticket for that (https://dhis2.atlassian.net/browse/DHIS2-18015) as I wanted to prioritize fixing the bug here.

@tomzemp tomzemp requested review from a team as code owners September 6, 2024 08:43
'dataElementIdScheme',
'orgUnitIdScheme',
'categoryOptionComboIdScheme',
'outputDataElementIdScheme',
Copy link
Member Author

Choose a reason for hiding this comment

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

this was the source of the error before. I had the wrong names for the ID schemes relevant for requests.

@@ -32,20 +32,24 @@ jest.mock('@dhis2/analytics', () => ({
DataDimension: ({ onSelect }) => (
<input
data-test="fake-data-selector"
onInput={(e) => onSelect({ items: [e.target.value] })}
onInput={(e) =>
onSelect({ items: [{ id: 'anIdDe', name: e.target.value }] })
Copy link
Member Author

Choose a reason for hiding this comment

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

I've modified these, so that they produce a more realistic payload when saving.

@dhis2-bot
Copy link
Contributor

dhis2-bot commented Sep 6, 2024

🚀 Deployed on https://pr-98--dhis2-data-exchange.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify September 6, 2024 08:46 Inactive
}

expect(createExchangeMock).toHaveBeenCalled()
expect(createExchangeMock).toHaveBeenCalledWith(expectedPayload)
Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated this test to check the payload being sent on save (which seems reasonable in general), and also has the benefit of confirming that the "NONE" ID Schemes that are selected by default get filtered out.

@flaminic
Copy link
Contributor

Thank you @tomzemp . Looks great and thanks for adding tests to it!!!

@flaminic flaminic closed this Sep 10, 2024
@flaminic flaminic reopened this Sep 10, 2024
@dhis2-bot dhis2-bot temporarily deployed to netlify September 10, 2024 16:32 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify September 11, 2024 15:01 Inactive
@tomzemp tomzemp merged commit 307d522 into master Sep 11, 2024
8 checks passed
dhis2-bot added a commit that referenced this pull request Sep 11, 2024
## [100.9.4](v100.9.3...v100.9.4) (2024-09-11)

### Bug Fixes

* remove request NONE id schemes [DHIS2-18013] ([#98](#98)) ([307d522](307d522))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 100.9.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants