test(index-accessibility): verify Types Integrity & Restrictions#5310
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds compile-time type integrity tests (via Vitest expectTypeOf) to validate exported type unions and branded types.
Changes:
- Introduces a new Vitest type-test suite covering
Scale,NotificationFrequency,BadgeSize,BadgeParams, andHexColor. - Adds negative assertions to prevent invalid literal/type assignments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { describe, it, expectTypeOf } from 'vitest'; | ||
| import type { BadgeSize, Scale, NotificationFrequency, BadgeParams, HexColor } from './index'; | ||
|
|
||
| describe('Types Integrity & Validation Tests', () => { |
| import type { BadgeSize, Scale, NotificationFrequency, BadgeParams, HexColor } from './index'; | ||
|
|
||
| describe('Types Integrity & Validation Tests', () => { | ||
| it('1. correctly restricts Scale to specific valid literals', () => { |
| expectTypeOf<'invalid'>().not.toMatchTypeOf<Scale>(); | ||
| }); | ||
|
|
||
| it('2. properly enforces NotificationFrequency literal unions', () => { |
| expectTypeOf<'monthly'>().not.toMatchTypeOf<NotificationFrequency>(); | ||
| }); | ||
|
|
||
| it('3. validates BadgeSize string unions', () => { |
| expectTypeOf<'xl'>().not.toMatchTypeOf<BadgeSize>(); | ||
| }); | ||
|
|
||
| it('4. ensures BadgeParams defines strict types for core properties', () => { |
| expectTypeOf<BadgeParams['bg']>().toEqualTypeOf<HexColor>(); | ||
| }); | ||
|
|
||
| it('5. confirms HexColor utilizes branding to prevent arbitrary string assignment', () => { |
|
🚨 Hey @realtushartyagi, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Good work on this one. I reviewed the diff and it looks ready to go from my side.
The test coverage added here looks comprehensive and well-structured. It definitely improves the reliability of the system.
No concerns from my end. Approved.
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for putting this together. The code looks clean and solves the issue effectively.
Looks solid. I'll go ahead and approve.
|
🎉 Congratulations @realtushartyagi! Your PR has been successfully merged. 🚀 Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.
Keep building! 💻✨ |
|
Review Summary |
Description
Fixes #4651
Adds type validation tests for types/index.ts using expectTypeOf.
Pillar
Visual Preview
N/A (Integration Test update)
Checklist before requesting a review: