chore(Progress): Include OUIAProps for Progress#12576
Conversation
Add OUIA attribute support to Progress for better test automation, and update dependent MultipleFileUploadStatusItem snapshots. Co-authored-by: Cursor <cursoragent@cursor.com>
WalkthroughThe Progress component now supports OUIA identifiers and safety attributes through typed props, default values, and root-element rendering. Tests cover custom and default OUIA values, and the OUIA documentation lists Progress. ChangesProgress OUIA integration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/react-core/src/components/Progress/__tests__/Progress.test.tsx (1)
112-115: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTest the default
ouiaIdfallback behavior.Consider adding a test case to verify that
data-ouia-component-idsuccessfully falls back to the generated ID (oridProp) whenouiaIdis omitted, ensuring this default behavior is preserved in future refactors.🧪 Proposed test addition
test('Renders with custom ouiaId', () => { render(<Progress value={33} id="progress-ouia-id" ouiaId="test-id" title="Test" />); expect(document.getElementById('progress-ouia-id')).toHaveAttribute('data-ouia-component-id', 'test-id'); }); + +test('Renders with default ouiaId when omitted', () => { + render(<Progress value={33} id="progress-ouia-id-default" title="Test" />); + expect(document.getElementById('progress-ouia-id-default')).toHaveAttribute('data-ouia-component-id', 'progress-ouia-id-default'); +});🤖 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 `@packages/react-core/src/components/Progress/__tests__/Progress.test.tsx` around lines 112 - 115, Add a test alongside “Renders with custom ouiaId” that renders Progress without ouiaId and verifies data-ouia-component-id falls back to the generated ID or provided idProp. Keep the assertion focused on the component identified by the existing id and preserve the current custom-ouiaId coverage.
🤖 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 `@packages/react-core/src/components/Progress/Progress.tsx`:
- Line 157: Update the getOUIAProps call in Progress to pass ouiaId with id as
its fallback, ensuring the documented default generated component ID is provided
when ouiaId is omitted.
---
Nitpick comments:
In `@packages/react-core/src/components/Progress/__tests__/Progress.test.tsx`:
- Around line 112-115: Add a test alongside “Renders with custom ouiaId” that
renders Progress without ouiaId and verifies data-ouia-component-id falls back
to the generated ID or provided idProp. Keep the assertion focused on the
component identified by the existing id and preserve the current custom-ouiaId
coverage.
🪄 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: aa8e56ee-54e0-4a67-986b-2cfbc62d127f
⛔ Files ignored due to path filters (2)
packages/react-core/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatusItem.test.tsx.snapis excluded by!**/*.snappackages/react-core/src/components/Progress/__tests__/__snapshots__/Progress.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (3)
packages/react-core/src/components/Progress/Progress.tsxpackages/react-core/src/components/Progress/__tests__/Progress.test.tsxpackages/react-core/src/helpers/OUIA/OUIA.md
| className | ||
| )} | ||
| id={id} | ||
| {...getOUIAProps(Progress.displayName, ouiaId, ouiaSafe)} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Implement the documented default behavior for ouiaId.
The documentation for ouiaId states that it is a "Value to overwrite the randomly generated data-ouia-component-id." However, because ouiaId is passed directly to getOUIAProps without a fallback, data-ouia-component-id will be completely missing from the rendered output when ouiaId is omitted.
To fix this, fall back to the id variable (which combines idProp and generatedId) so a default OUIA ID is always provided for the instance.
🐛 Proposed fix
- {...getOUIAProps(Progress.displayName, ouiaId, ouiaSafe)}
+ {...getOUIAProps(Progress.displayName, ouiaId !== undefined ? ouiaId : id, ouiaSafe)}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {...getOUIAProps(Progress.displayName, ouiaId, ouiaSafe)} | |
| {...getOUIAProps(Progress.displayName, ouiaId !== undefined ? ouiaId : id, ouiaSafe)} |
🤖 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 `@packages/react-core/src/components/Progress/Progress.tsx` at line 157, Update
the getOUIAProps call in Progress to pass ouiaId with id as its fallback,
ensuring the documented default generated component ID is provided when ouiaId
is omitted.
Add OUIA attribute support to Progress for better test automation, and update dependent MultipleFileUploadStatusItem snapshots.
What:
Closes #12575
Additional issues:
Summary by CodeRabbit
New Features
Documentation