test: remove withUser helper function - #509
Conversation
There was a problem hiding this comment.
The PR cleanly removes the withUser helper and the custom axios-wrapping workaround in favor of a patch-package approach. Two substantive issues were flagged: the postinstall script will break installs for downstream consumers of this package since patch-package is only a dev dependency, and the patch filename hard-codes version 1.0.1 while the package range allows any ^1 version, making the patch fragile against any upgrade. The uploadDraftAttachment helper in testUtils.js also still sends the createdAt/createdBy fields that were removed everywhere else, leaving an inconsistency, but that comment failed to post due to the code not appearing in the diff (it was unchanged). Please address the two posted issues before merging.
PR Bot Information
Version: 1.29.17
- Correlation ID:
fa8aecb0-9009-11f1-8305-01a90dbf291a - Event Trigger:
pull_request.opened - LLM:
anthropic--claude-4.6-sonnet - File Content Strategy: Full file content
withUser helper function
SummaryThe following content is AI-generated and provides a summary of the pull request: Remove
|
There was a problem hiding this comment.
The uploadDraftAttachment utility was not changed in the diff, so the leftover createdAt/createdBy in testUtils.js is pre-existing code (not added in this PR). I can't post a diff comment on unchanged lines. Let me check if there's anything else in the diff worth commenting on.
Looking at the diff more carefully:
attachments-non-draft.test.jsline 1196:expect(getRes.data).toEqual(Buffer.from(fileContent))—fileContentwas read usingreadFileSync(returns aBuffer). Wrapping an existing Buffer inBuffer.from()is fine (it copies), but the original assertion compared it directly (toEqual(fileContent)). This is the same pattern as the already-commented-on inconsistency inattachments-single.test.jsline 82. Let me check if this was already raised.
My previous comment covers attachments-single.test.js line 82 as already flagged. The attachments-non-draft.test.js line 1196 is a new change (Buffer.from(fileContent)) that is consistent with other changes in this PR. Looking at that context: fileContent from readFileSync is a Buffer, and Buffer.from(buffer) creates a copy — the assertion should still work correctly (deep equality of same bytes). This change is fine.
The only substantive issue I found is the leftover createdAt/createdBy in testUtils.js#uploadDraftAttachment, but since those lines aren't in the diff, I cannot post an inline comment about them. All other changes in the diff are cleanups that look correct.
The PR is a clean refactoring that replaces the custom withUser wrapper with the native cds.test defaults.auth mechanism. The existing reviewer comments cover the critical patch-package fragility issues. The one remaining inconsistency — uploadDraftAttachment in testUtils.js still carrying createdAt/createdBy fields that were cleaned up everywhere else — was missed by the PR but falls outside the diff scope.
PR Bot Information
Version: 1.29.18
- Correlation ID:
76cff850-9015-11f1-85ba-3c9b02d7be58 - File Content Strategy: Full file content
- Event Trigger:
pull_request.ready_for_review - LLM:
anthropic--claude-4.6-sonnet
|
New cds-test version with the patch is released: https://www.npmjs.com/package/@cap-js/cds-test/v/1.0.2 |
Replace custom axios patch in
withUserwith actual patch in cds-test. Remove the patch-package when the PR in cds-test is merged.