fix: merge custom td-class over base classes in CodeBlock#1763
Conversation
📝 WalkthroughWalkthrough
ChangesCodeBlock tdClass extra-classes refactor
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tests/components/CodeBlock.test.ts`:
- Around line 103-108: The test 'keeps base td-class defaults when a custom
td-class is passed' validates that base classes are retained but does not verify
that the passed custom-class is actually preserved in the rendered HTML output.
Add an assertion using expect(html).toMatch() to verify that 'custom-class'
appears in the td class attribute, ensuring the additive class merge behavior is
fully tested.
🪄 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 Plus
Run ID: 5d29d8a8-6275-4643-bb84-24692c2135b3
📒 Files selected for processing (2)
src/components/CodeBlock.vuesrc/tests/components/CodeBlock.test.ts
| it('keeps base td-class defaults when a custom td-class is passed', async () => { | ||
| const html = await render({ code: '<div>test</div>', 'td-class': 'custom-class' }) | ||
|
|
||
| expect(html).toMatch(/<td class="[^"]*\bmax-w-0\b/) | ||
| expect(html).toMatch(/<td class="[^"]*\bmso-padding-alt-4\b/) | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Assert the custom class is preserved in the additive td-class test.
The test checks base class retention but not that the passed custom class survives merge (Line 104). Add an assertion for custom-class so the additive contract is fully covered.
Suggested test tweak
it('keeps base td-class defaults when a custom td-class is passed', async () => {
const html = await render({ code: '<div>test</div>', 'td-class': 'custom-class' })
+ expect(html).toMatch(/<td class="[^"]*\bcustom-class\b/)
expect(html).toMatch(/<td class="[^"]*\bmax-w-0\b/)
expect(html).toMatch(/<td class="[^"]*\bmso-padding-alt-4\b/)
})📝 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.
| it('keeps base td-class defaults when a custom td-class is passed', async () => { | |
| const html = await render({ code: '<div>test</div>', 'td-class': 'custom-class' }) | |
| expect(html).toMatch(/<td class="[^"]*\bmax-w-0\b/) | |
| expect(html).toMatch(/<td class="[^"]*\bmso-padding-alt-4\b/) | |
| }) | |
| it('keeps base td-class defaults when a custom td-class is passed', async () => { | |
| const html = await render({ code: '<div>test</div>', 'td-class': 'custom-class' }) | |
| expect(html).toMatch(/<td class="[^"]*\bcustom-class\b/) | |
| expect(html).toMatch(/<td class="[^"]*\bmax-w-0\b/) | |
| expect(html).toMatch(/<td class="[^"]*\bmso-padding-alt-4\b/) | |
| }) |
🤖 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/tests/components/CodeBlock.test.ts` around lines 103 - 108, The test
'keeps base td-class defaults when a custom td-class is passed' validates that
base classes are retained but does not verify that the passed custom-class is
actually preserved in the rendered HTML output. Add an assertion using
expect(html).toMatch() to verify that 'custom-class' appears in the td class
attribute, ensuring the additive class merge behavior is fully tested.
Summary by CodeRabbit
Release Notes
Refactor
Tests