feat(content-uploader): pass version_number to modernized uploader items list#4623
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR adjusts PlainUpload to consistently apply field query parameters to all upload URLs, and extends UploadItem mapping to extract version numbers from legacy file objects, with corresponding test coverage. ChangesUpload Handling and Item Mapping Enhancements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/api/uploads/__tests__/PlainUpload.test.js (1)
177-196: ⚡ Quick winConsider adding a test for fields with preflight-provided
upload_url.The new test correctly verifies that
fieldsare appended when the upload URL is constructed internally. However, the PR objective states that fields should be appended "regardless of whether the upload URL is provided initially or returned by preflight." Consider adding a complementary test case wheredata.upload_urlis provided to ensure complete coverage of both code paths.🧪 Suggested additional test case
+ test('should append fields query parameter when upload URL is provided by preflight', () => { + const preflightUploadUrl = 'https://upload.box.com/api/2.0/files/content'; + upload.isDestroyed = jest.fn().mockReturnValueOnce(false); + upload.computeSHA1 = jest.fn().mockReturnValueOnce(Promise.resolve('somehash')); + upload.file = { + name: 'warlock', + }; + upload.folderId = '123'; + upload.fields = ['content_created_at', 'version_number']; + upload.xhr = { + uploadFile: jest.fn(), + }; + + return upload.preflightSuccessHandler({ data: { upload_url: preflightUploadUrl } }).then(() => { + expect(upload.xhr.uploadFile).toHaveBeenCalledWith( + expect.objectContaining({ + url: `${preflightUploadUrl}?fields=content_created_at%2Cversion_number`, + }), + ); + }); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/api/uploads/__tests__/PlainUpload.test.js` around lines 177 - 196, Add a complementary unit test to verify that when preflight returns an upload_url the upload.fields are still appended to that URL; specifically, create a test that sets upload.fields (e.g., ['content_created_at','version_number']), mocks upload.isDestroyed and computeSHA1, sets upload.file/folderId and upload.xhr.uploadFile, calls upload.preflightSuccessHandler({ data: { upload_url: 'https://host/some/path' } }) and asserts upload.xhr.uploadFile was called with an object whose url equals the provided upload_url plus the query parameter ?fields=content_created_at%2Cversion_number; this ensures both code paths (constructed URL and preflight-provided upload_url) handle upload.fields correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Line 150: Verify that bumping `@box/uploads-manager` to 1.17.2 doesn’t introduce
breaking API/type changes by auditing uses of UploadItemStatus, UploadItem, and
UploadsManager in the repo: search for references to those symbols, update any
call sites or type annotations to match the new package typings if they changed,
and run the content-uploader test suite (unit and integration) to catch
runtime/type regressions; if tests fail, pin the dependency back or apply
necessary code changes to adapt to the new API.
---
Nitpick comments:
In `@src/api/uploads/__tests__/PlainUpload.test.js`:
- Around line 177-196: Add a complementary unit test to verify that when
preflight returns an upload_url the upload.fields are still appended to that
URL; specifically, create a test that sets upload.fields (e.g.,
['content_created_at','version_number']), mocks upload.isDestroyed and
computeSHA1, sets upload.file/folderId and upload.xhr.uploadFile, calls
upload.preflightSuccessHandler({ data: { upload_url: 'https://host/some/path' }
}) and asserts upload.xhr.uploadFile was called with an object whose url equals
the provided upload_url plus the query parameter
?fields=content_created_at%2Cversion_number; this ensures both code paths
(constructed URL and preflight-provided upload_url) handle upload.fields
correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aee7135a-79ca-41b0-87ab-fe599be9ee22
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (5)
package.jsonsrc/api/uploads/PlainUpload.jssrc/api/uploads/__tests__/PlainUpload.test.jssrc/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.tssrc/elements/content-uploader/utils/mapToModernizedUploadItem.ts
abd1679 to
e27735e
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package.json (1)
307-307:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winCritical: Update
@box/item-iconversion in peerDependencies to match devDependencies.Line 139 bumps
@box/item-iconto^2.37.5indevDependencies, but Line 307 still declares^2.32.14inpeerDependencies. All other upgraded dependencies (@box/activity-feed,@box/blueprint-web,@box/blueprint-web-assets,@box/collaboration-popover,@box/readable-time,@box/threaded-annotations,@box/user-selector,@box/uploads-manager) maintain consistent versions across both sections. This mismatch will cause peer dependency resolution warnings or errors for consumers of this package.🔧 Proposed fix
- "`@box/item-icon`": "^2.32.14", + "`@box/item-icon`": "^2.37.5",🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@package.json` at line 307, Update the version of the `@box/item-icon` dependency in the peerDependencies section to match the version specified in devDependencies. The peerDependencies entry for `@box/item-icon` is currently pinned to ^2.32.14 while devDependencies has been updated to ^2.37.5. Change the peerDependencies version of `@box/item-icon` from ^2.32.14 to ^2.37.5 to maintain consistency with other upgraded dependencies and prevent peer dependency resolution warnings for package consumers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@package.json`:
- Line 307: Update the version of the `@box/item-icon` dependency in the
peerDependencies section to match the version specified in devDependencies. The
peerDependencies entry for `@box/item-icon` is currently pinned to ^2.32.14 while
devDependencies has been updated to ^2.37.5. Change the peerDependencies version
of `@box/item-icon` from ^2.32.14 to ^2.37.5 to maintain consistency with other
upgraded dependencies and prevent peer dependency resolution warnings for
package consumers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 00016147-dac4-4e1d-b6ef-675976a2af08
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (5)
package.jsonsrc/api/uploads/PlainUpload.jssrc/api/uploads/__tests__/PlainUpload.test.jssrc/elements/content-uploader/utils/__tests__/mapToModernizedUploadItem.test.tssrc/elements/content-uploader/utils/mapToModernizedUploadItem.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/elements/content-uploader/utils/tests/mapToModernizedUploadItem.test.ts
- src/elements/content-uploader/utils/mapToModernizedUploadItem.ts
- src/api/uploads/PlainUpload.js
Merge Queue Status
This pull request spent 1 minute 19 seconds in the queue, including 21 seconds running CI. Required conditions to merge
|
…ems list (box#4623) * feat(content-uploader): pass version_number to modernized uploader items list * feat: bump uploads-manager package * feat: bump @box/item-icon version * feat: bump @box/item-icon version * fix: bump @box/item-icon version
Summary
version_numberto the modernized upload items listversion_numberquery param to the upload url outside ofif (!uploadUrl)so that it can be called when we receive a url from preflight requestSummary by CodeRabbit
Chores
Bug Fixes
fieldsquery parameter is consistently included, even when the upload URL is constructed internally.Features
versionNumberto modernized upload item mapping, sourced from legacy file data when available.Tests
fieldsURL inclusion andversionNumbermapping behavior.