feat(metadata-editor): reset setShouldShowOnlyReviewFields on delete action#4517
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)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAfter deleting a metadata instance, the component now resets the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx`:
- Around line 357-386: The test currently clicks a generic Edit button which is
ambiguous when multiple metadata cards render; update the interaction to scope
the query to the specific card for mockCustomTemplateInstance (e.g., locate the
card element by text from mockCustomTemplateInstance such as its template title
or a unique field key and then use within(card).getByRole('button', { name:
/^Edit\s*$/ }) to click Edit and similarly scope the subsequent Delete click),
ensuring the call to handleDeleteMetadataInstance(mockCustomTemplateInstance)
targets the intended instance.
🪄 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: a89e7a2a-6776-4931-85c5-ffb7eb647e2e
📒 Files selected for processing (2)
src/elements/content-sidebar/MetadataSidebarRedesign.tsxsrc/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx (1)
378-380:⚠️ Potential issue | 🟡 MinorTarget the intended metadata instance explicitly.
Using generic
'Edit'/'Delete'selectors is ambiguous with multiple cards and can hit the wrong instance. Use an instance-specific accessible name (or scope withwithinon the intended card) before triggering delete.Suggested test hardening
- await userEvent.click(screen.getByRole('button', { name: 'Edit' })); - await userEvent.click(screen.getByRole('button', { name: 'Delete' })); + await userEvent.click(screen.getByRole('button', { name: 'Edit Custom Metadata' })); + await userEvent.click(screen.getByRole('button', { name: 'Delete' }));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx` around lines 378 - 380, The test is clicking generic buttons which is ambiguous when multiple metadata cards exist; update the clicks to target the specific metadata instance by first locating the intended card element (e.g., find the card by its unique text or title) and then scope the queries using within(card).getByRole('button', { name: 'Edit' }) and within(card).getByRole('button', { name: 'Delete' }) (or use instance-specific accessible names like "Edit metadata for <name>" / "Delete metadata for <name>") before calling userEvent.click so the correct card's edit/delete buttons are activated.
🧹 Nitpick comments (1)
src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx (1)
385-385: Tighten the delete callback assertion.Also assert call count so this test fails on duplicate/unexpected invocations.
Suggested assertion update
- expect(handleDeleteMetadataInstance).toHaveBeenCalledWith(mockCustomTemplateInstance); + expect(handleDeleteMetadataInstance).toHaveBeenCalledTimes(1); + expect(handleDeleteMetadataInstance).toHaveBeenCalledWith(mockCustomTemplateInstance);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx` at line 385, Update the test to assert the exact number of times the delete callback was invoked in addition to its argument: add an assertion that handleDeleteMetadataInstance was called exactly once (e.g., expect(handleDeleteMetadataInstance).toHaveBeenCalledTimes(1)) and then keep the existing expect(handleDeleteMetadataInstance).toHaveBeenCalledWith(mockCustomTemplateInstance) to ensure no duplicate or unexpected invocations occur; locate the assertions around handleDeleteMetadataInstance in MetadataSidebarRedesign.test.tsx and place the toHaveBeenCalledTimes(1) check immediately before or after the existing toHaveBeenCalledWith check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx`:
- Around line 378-380: The test is clicking generic buttons which is ambiguous
when multiple metadata cards exist; update the clicks to target the specific
metadata instance by first locating the intended card element (e.g., find the
card by its unique text or title) and then scope the queries using
within(card).getByRole('button', { name: 'Edit' }) and
within(card).getByRole('button', { name: 'Delete' }) (or use instance-specific
accessible names like "Edit metadata for <name>" / "Delete metadata for <name>")
before calling userEvent.click so the correct card's edit/delete buttons are
activated.
---
Nitpick comments:
In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx`:
- Line 385: Update the test to assert the exact number of times the delete
callback was invoked in addition to its argument: add an assertion that
handleDeleteMetadataInstance was called exactly once (e.g.,
expect(handleDeleteMetadataInstance).toHaveBeenCalledTimes(1)) and then keep the
existing
expect(handleDeleteMetadataInstance).toHaveBeenCalledWith(mockCustomTemplateInstance)
to ensure no duplicate or unexpected invocations occur; locate the assertions
around handleDeleteMetadataInstance in MetadataSidebarRedesign.test.tsx and
place the toHaveBeenCalledTimes(1) check immediately before or after the
existing toHaveBeenCalledWith check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cc296573-9b8c-4f21-a76c-79e54a3e7908
📒 Files selected for processing (1)
src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx
Merge Queue Status
This pull request spent 11 minutes 10 seconds in the queue, including 10 minutes 45 seconds running CI. Required conditions to merge
|
…action (box#4517) * feat(metadata-editor): reset setShouldShowOnlyReviewFields on delete action * feat(metadata-editor): simplify test selector * feat(metadata-editor): update mocks --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Reset
setShouldShowOnlyReviewFieldsto false on metadata instance delete to prevent stale review-only field state from persisting after deletion.Summary by CodeRabbit
Bug Fixes
Tests