[test]: Import multiple image file types into a WorkBench data set - #8352
Conversation
|
Warning One or more dependencies are approaching or past End-of-Life. |
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughChangesWorkBench attachment import tests
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
specifyweb/frontend/js_src/lib/components/WbImportAttachments/__tests__/WbImportAttachments.test.tsx (2)
157-219: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a failure-path test for the import flow.
All three tests exercise the happy path only. Given
uploadFile/dataset creation are chained network calls, a test that mocksAttachments.uploadFile(or one of the ajax overrides) to reject and asserts the UI surfaces an error instead of silently navigating would strengthen coverage of this critical import flow.🤖 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 `@specifyweb/frontend/js_src/lib/components/WbImportAttachments/__tests__/WbImportAttachments.test.tsx` around lines 157 - 219, Extend the WbImportAttachmentsView import-flow tests with a failure-path case by making Attachments.uploadFile or a dataset-request mock reject, then assert that the UI displays the error and does not navigate to the WorkBench data-set route. Keep the existing successful import assertions unchanged.
71-88: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract shared mount + file-input lookup into a helper.
The mount-with-router +
querySelector('input[type="file"]')+ null-check block is duplicated near-verbatim across all three tests. A small helper (e.g.renderWbImportAttachments()returning{ container, getByRole, findByText, user, input }) would cut this boilerplate and keep future edits (e.g. router setup changes) in one place.♻️ Sketch of a shared helper
+function renderWbImportAttachments({ withRoutes = false } = {}) { + const { container, getByRole, findByText, user } = mount( + <Router.MemoryRouter + initialEntries={['/']} + future={{ v7_relativeSplatPath: true, v7_startTransition: true }} + > + {withRoutes ? ( + <UnloadProtectsContext.Provider value={[]}> + <Router.Routes> + <Router.Route + path="/" + element={ + <SetMenuContext.Provider value={jest.fn()}> + <WbImportAttachmentsView /> + </SetMenuContext.Provider> + } + /> + <Router.Route + path="/specify/workbench/plan/:dataSetId/" + element={<div>WorkBench data set created</div>} + /> + </Router.Routes> + </UnloadProtectsContext.Provider> + ) : ( + <SetMenuContext.Provider value={jest.fn()}> + <WbImportAttachmentsView /> + </SetMenuContext.Provider> + )} + </Router.MemoryRouter> + ); + const input = container.querySelector<HTMLInputElement>('input[type="file"]'); + if (input === null) { + throw new Error('Unable to find the attachment file picker'); + } + return { container, getByRole, findByText, user, input }; +}Also applies to: 110-127, 162-193
🤖 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 `@specifyweb/frontend/js_src/lib/components/WbImportAttachments/__tests__/WbImportAttachments.test.tsx` around lines 71 - 88, Extract the duplicated Router.MemoryRouter mount and file-input lookup from the three tests into a shared helper, such as renderWbImportAttachments. Have the helper provide the existing test utilities and validated input element, then update each test near WbImportAttachmentsView to use it while preserving their current assertions and behavior.
🤖 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.
Nitpick comments:
In
`@specifyweb/frontend/js_src/lib/components/WbImportAttachments/__tests__/WbImportAttachments.test.tsx`:
- Around line 157-219: Extend the WbImportAttachmentsView import-flow tests with
a failure-path case by making Attachments.uploadFile or a dataset-request mock
reject, then assert that the UI displays the error and does not navigate to the
WorkBench data-set route. Keep the existing successful import assertions
unchanged.
- Around line 71-88: Extract the duplicated Router.MemoryRouter mount and
file-input lookup from the three tests into a shared helper, such as
renderWbImportAttachments. Have the helper provide the existing test utilities
and validated input element, then update each test near WbImportAttachmentsView
to use it while preserving their current assertions and behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 59d90721-e259-4208-ae66-847da29982b9
📒 Files selected for processing (1)
specifyweb/frontend/js_src/lib/components/WbImportAttachments/__tests__/WbImportAttachments.test.tsx
Triggered by 8392e2a on branch refs/heads/issue-8347
Fixes #8347
Summary by CodeRabbit