Skip to content

test(badges): add unit tests for condition-badge, status-badge, and validation - #1375

Merged
yusuftomilola merged 1 commit into
DistinctCodes:mainfrom
ibrahimmosouf-png:feat/issue-1299-badge-validation-tests
Aug 26, 2026
Merged

test(badges): add unit tests for condition-badge, status-badge, and validation#1375
yusuftomilola merged 1 commit into
DistinctCodes:mainfrom
ibrahimmosouf-png:feat/issue-1299-badge-validation-tests

Conversation

@ibrahimmosouf-png

@ibrahimmosouf-png ibrahimmosouf-png commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1299
Closes #1296
Closes #1297
Closes #1298

Adds co-located unit tests for condition-badge.tsx, status-badge.tsx, and validation.tsx — three high-reuse components in frontend/components/assets/ that had no test coverage despite being used across the assets list, detail page, and both modals.

Why

These badge components render status/condition values with specific Tailwind color classes that are easy to accidentally break during styling changes. Without tests, a regression in color mapping (e.g., swapping bg-green-100 for bg-red-100 on the ACTIVE status) would go unnoticed until a visual review. The tests assert both the correct label text and the correct Tailwind class strings for every enum value.

What was built

frontend/components/assets/condition-badge.test.tsx:

Test What it covers
NEW Renders "New" with bg-emerald-100 text-emerald-800
GOOD Renders "Good" with bg-green-100 text-green-800
FAIR Renders "Fair" with bg-yellow-100 text-yellow-900
POOR Renders "Poor" with bg-orange-100 text-orange-900
DAMAGED Renders "Damaged" with bg-red-100 text-red-800
Unknown Fallback rendering with bg-gray-100 text-gray-700

frontend/components/assets/status-badge.test.tsx:

Test What it covers
ACTIVE Renders "Active" with bg-green-100 text-green-800
ASSIGNED Renders "Assigned" with bg-blue-100 text-blue-800
MAINTENANCE Renders "Maintenance" with bg-yellow-100 text-yellow-900
RETIRED Renders "Retired" with bg-gray-100 text-gray-700
Unknown Fallback rendering with bg-gray-100 text-gray-700

frontend/components/assets/validation.test.tsx:

Test What it covers
ACTIVE Renders "Active" with bg-green-100 text-green-700
ASSIGNED Renders "Assigned" with bg-blue-100 text-blue-700
MAINTENANCE Renders "Maintenance" with bg-yellow-100 text-yellow-700
RETIRED Renders "Retired" with bg-gray-100 text-gray-500
Unknown Fallback rendering with bg-gray-100 text-gray-500

No existing files modified — only additions, so regression risk is low.

Acceptance criteria coverage

  • Badge rendering and shared validation logic both have direct unit tests (16 tests across 3 spec files)

Test plan

  • npm test in frontend/ — 16/16 passing (all new tests for this feature)

Env vars / Notes

No new environment variables. Tests use @testing-library/react with the existing jest-environment-jsdom configuration in frontend/jest.config.js.

…alidation

Tests every AssetCondition and AssetStatus enum value against expected
label text and Tailwind color classes. Covers the fallback path for
unknown values. Files: condition-badge.test.tsx (6 tests),
status-badge.test.tsx (5 tests), validation.test.tsx (5 tests).

Closes DistinctCodes#1299
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@ibrahimmosouf-png is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@ibrahimmosouf-png Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@yusuftomilola yusuftomilola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No merge conflicts with main. Good unit test coverage for the badge components and validation - approving.

@yusuftomilola
yusuftomilola merged commit b54e87f into DistinctCodes:main Aug 26, 2026
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment