-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
Refactor Enketo service code to allow for reuse by test harness #7567
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…straint when it is done loading doc fields.
# Conflicts: # config/standard/forms/app/immunization_visit.xlsx
# Conflicts: # api/package-lock.json
# Conflicts: # webapp/src/ts/modules/contacts/contacts-edit.component.ts # webapp/src/ts/services/contact-save.service.ts # webapp/tests/karma/ts/modules/contacts/contacts-edit.component.spec.ts
# Conflicts: # api/src/services/generate-xform.js # api/tests/mocha/services/generate-xform.spec.js # package.json # webapp/src/ts/services/enketo.service.ts # webapp/tests/karma/ts/services/enketo.service.spec.ts
# Conflicts: # api/server.js # api/src/services/config-watcher.js # api/src/services/generate-xform.js # api/tests/mocha/services/generate-xform.spec.js # package.json # shared-libs/rules-engine/package-lock.json # shared-libs/rules-engine/package.json # webapp/src/ts/services/enketo-translation.service.ts # webapp/src/ts/services/enketo.service.ts # webapp/tests/karma/js/enketo/enketo-data-translator.spec.ts # webapp/tests/karma/ts/services/enketo.service.spec.ts
This PR will not be merged, but this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactors code for Enketo forms to allow for reuse by https://github.com/medic/cht-conf-test-harness. The goal of these changes is to minimize the amount of duplicate code required in the test harness for working with Enketo forms. This should make it easier to maintain the test harness going forwards (simplifying the process of uplifting to new versions of Enketo/cht-core).
@kennsippell has been working on integrating the test harness with this refactored code in https://github.com/medic/cht-conf-test-harness/tree/enketo-uplift.
Changelist:
generate-xform
service contained logic both for generating the xForm html files and for updating the forms stored on the client when one changed. This update logic was discrete from the generation logic and had some dependencies that caused issues for the test harness code when trying to consume the generation logic. So, I have refactored the update logic into a newupdate-xform
service.enketo
Angular service is the main bit that we want to be able to reuse in the test harness. To do this, I had to decouple it from all the Angular-specific code and services. I created theenketo-form-manager.js
which contains the refactored logic and can be pulled in by both the test harness and theenketo
service.enketo-prepopulation-data
service was only used by theenketo
service, so I have refactored it into theenketo-data-prepopulator.js
that is consumed directly byenketo-form-manager
.xpath-element-path
provider was only used by theenketo
service, so I have refactored it intoxpath-element-path.js
that is consumed directly byenketo-form-manager
.contact-save
service is also needed by the test harness (to save their contact forms). So, I have refactored this logic intocontact-saver.js
.EnketoFormManager
exposes thecontact-saver
functionality via thesaveContactForm
method to give a single point of reference for rendering and saving all Enketo forms.enketo
service to have asaveContactForm
method that can be used by thecontacts-edit
component to save the contact form (instead of using the (now removed)contact-save
service).enketo-translation
service was only being used by code that is now centralized in theenketo-form-manager
. I have refactored that logic into aenketo-data-translator.js
which is referenced directly by enketo logic.#7462
Code review checklist
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.