-
Notifications
You must be signed in to change notification settings - Fork 75
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
Refactoring entity tests and adding new entity update tests #1021
Conversation
- moved extra tests of streaming CSVs of entities from worker/entity test to datasets test (multi form and updated entities in particular) - removed redundant checks and tests from worker/entity test file - added entity update tests to relevant sections of entity API test file * returning current version and data of updated entity * audit log events for an entity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Liked this reorganization of tests
@@ -156,11 +157,14 @@ const _createEntity = (dataset, entityData, submissionId, submissionDef, submiss | |||
}; | |||
|
|||
const _updateEntity = (dataset, entityData, submissionId, submissionDef, submissionDefId, event) => async ({ Audits, Entities }) => { | |||
if (!(event.action === 'submission.create')) // only update on submission.create |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this condition be in _processSubmissionEvent
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I moved these lines into _createEntity
if ((dataset.approvalRequired && event.details.reviewState !== 'approved') ||
(!dataset.approvalRequired && event.action === 'submission.update'))
it felt reasonable to move this event action check into _updateEntity
Closes the following issues:
In particular:
commit 1
commit 2
worker/entity
test toapi/datasets
test (multi form and updated entities in particular)worker/entity
test fileapi/entities
API test filecommit 3
commit 4
commit 5
What has been done to verify that this works as intended?
it's mostly all tests!
Why is this the best possible solution? Were any other approaches considered?
Some of the tests got refactored. I moved tests that started in worker/entity but weren't really about the worker into other files, e.g. csv streaming of entities, which was one of the first tests about entities to exist.
Many tests about entity updates have an API endpoint that is most relevant, and it seems reasonable to move tests/parts of tests to those places.
I added one special section to the end of
integration/api/entities
for capturing update logic. There are some special sections at the bottom ofintegration/api/datasets
specifically for dataset scenarios.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
More reliable entity update behavior
Does this change require updates to the API documentation? If so, please update docs/api.md as part of this PR.
No
Before submitting this PR, please make sure you have:
make test-full
and confirmed all checks still pass OR confirm CircleCI build passes