Skip to content

feat: project discovery filtering, sorting & test suite#33

Merged
Iwueseiter merged 4 commits into
HubDApp:mainfrom
mayasimi:main
Apr 26, 2026
Merged

feat: project discovery filtering, sorting & test suite#33
Iwueseiter merged 4 commits into
HubDApp:mainfrom
mayasimi:main

Conversation

@mayasimi
Copy link
Copy Markdown
Contributor

Resolve #26
Summary

Enhances the discovery experience by letting users filter projects by category and sort them by rating, recency, or review count. State persists across navigation via sessionStorage. Includes a full test suite.


What changed

  • data/projects.ts — typed Project interface, single source of truth for all project data with createdAt for recency sorting
  • hooks/useProjectFilters.ts — filter + sort logic with sessionStorage persistence and hydration-safe state restore
  • components/landing/FeaturedProjects.tsx — converted to client component, added category pills and sort dropdown (shows top 6)
  • app/discover/page.tsx — new /discover route showing all projects with the same filter/sort controls

Testing

  • Added Vitest + React Testing Library
  • 27 tests across 3 suites — all passing
  • Covers: data integrity, filtering, sorting, persistence, hydration restore, corrupt storage fallback, component rendering and interactions

Acceptance criteria

  • ✅ Filtering works correctly
  • ✅ Sorting updates results instantly
  • ✅ State persists during navigation

- Extract project data to data/projects.ts with typed Project interface
  and createdAt field for recency sorting
- Add useProjectFilters hook with sessionStorage persistence for
  category filter and sort state across navigation
- Rewrite FeaturedProjects as client component with category pills
  and sort dropdown (Top Rated / Newest / Most Reviewed)
- Add /discover page showing all projects with same filter/sort controls
- Hydration-safe skeleton loading to prevent SSR mismatch
- Accessible: aria-pressed on filter buttons, aria-label on ratings,
  sr-only labels on selects, aria-hidden on decorative SVGs
…uredProjects component

- Install vitest, @vitejs/plugin-react, jsdom, @testing-library/react,
  @testing-library/jest-dom, @testing-library/user-event
- Add vitest.config.ts with jsdom environment and @ path alias
- Add vitest.setup.ts with jest-dom matchers
- Add npm test script (vitest --run for single-pass CI)
- 27 tests across 3 suites, all passing:
  - data/projects: field validation, unique ids, rating bounds, ISO dates
  - hooks/useProjectFilters: filtering, sorting, persistence, hydration restore, corrupt data fallback
  - components/FeaturedProjects: rendering, category filter, sort dropdown, empty state, sessionStorage persistence
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 25, 2026

@mayasimi 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

- Replace setState-in-effect pattern with useSyncExternalStore for
  hydration detection (fixes react-hooks/set-state-in-effect error)
- Use lazy useState initializer to read sessionStorage on first render
  instead of inside useEffect (no cascading renders)
- Change let to const for result in useMemo (fixes prefer-const error)
- Remove unused vi import from useProjectFilters.test.ts (fixes no-unused-vars warning)

All 27 tests pass, lint exits 0 with --max-warnings 0
- Update package.json lint script to match exact CI command:
  eslint . --max-warnings 0 --ext .js,.jsx,.ts,.tsx --format stylish
- All lint errors were already fixed in 91e06d4 (useSyncExternalStore,
  const result, removed unused vi import) — this commit forces CI to
  re-run against the clean codebase
@Iwueseiter Iwueseiter merged commit 715e467 into HubDApp:main Apr 26, 2026
1 check passed
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.

Add filtering and sorting system

2 participants