fix(#821): ignore deleted primary-contact ref in move-contacts - #824
fix(#821): ignore deleted primary-contact ref in move-contacts#824Hendrixx-RE wants to merge 3 commits into
Conversation
binokaryg
left a comment
There was a problem hiding this comment.
The tests are failing because of max-len. Please fix it.
There is one more inline comment about a test gap.
binokaryg
left a comment
There was a problem hiding this comment.
One small change request regarding stub restore. Apart from that, I think it's good.
| }); | ||
|
|
||
| it('no error when primary contact doc is deleted (404)', async () => { | ||
| const warnStub = sinon.stub(log, 'warn'); |
There was a problem hiding this comment.
sinon.stub(log, 'warn') mutates the shared log module object.
The repo convention is the stub in beforeEach and afterEach(() => sinon.restore()) at the describe level, which is more defensive. It should not affect if more tests are added in the future.
Example: validate-forms.js
There was a problem hiding this comment.
Hi @binokaryg, addressed the stub feedback here as we need this fix for the user management app
binokaryg
left a comment
There was a problem hiding this comment.
Thanks for addressing the change request. @freddieptf
Approving
Description
Wrap the db.get(sourcePrimaryContactId) call in a try/catch. A 404 (deleted or missing doc) is treated as "no primary contact" — a WARN is logged and the operation continues. Any other error is re-thrown unchanged.
medic/cht-conf #821
Code review items
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.