Skip to content

Conversation

@utact
Copy link

@utact utact commented Dec 14, 2025

Summary

Currently, there is no testing infrastructure in the project. I've set up Vitest to start ensuring code reliability and added initial test cases for the sort utility function.

Motivation

While reviewing features/dashboard/lib/sort.ts, I noticed it contains multiple layers of fallback logic (Query Params → Initial Sort → Preferred Fields → ID). Adding unit tests ensures this logic behaves consistently across different scenarios.

Changes

  • Installed vitest as a dev dependency.
  • Configured vitest.config.ts (using node environment for performance).
  • Added unit tests for features/dashboard/lib/sort.ts.
  • Added "test": "vitest" script to package.json.

Verification

I verified the test coverage locally using vitest run --coverage.
The core logic in sort.ts has achieved 100% Statement & Line Coverage, ensuring that all edge cases (fallback logic, invalid params) are handled correctly.

$ npx vitest run --coverage

 ✓ features/dashboard/lib/sort.test.ts (9 tests)

 % Coverage report from v8
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |     100 |    88.88 |     100 |     100 |                  
 sort.ts  |     100 |    88.88 |     100 |     100 | 49-51            
----------|---------|----------|---------|---------|-------------------

Future Plan

If this PR is accepted, I'd love to contribute further by setting up a GitHub Actions workflow to run these tests automatically on every PR.

- 📦 Install vitest as a dev dependency
- ⚙️ Configure vitest.config.ts (using node environment)
- 📝 Add unit tests for features/dashboard/lib/sort.ts
- ▶️ Add 'test': 'vitest' script to package.json
@netlify
Copy link

netlify bot commented Dec 14, 2025

👷 Deploy request for opensourcebuilders pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8ac30d3

@utact utact changed the title test(dashboard): Setup Vitest environment & add initial unit tests test(dashboard): setup Vitest environment & add initial unit tests Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant