Skip to content

Add API tests, extract client modules, add templates, and clean up console.error - #670

Merged
DeFiVC merged 5 commits into
ChainLearnOfficial:mainfrom
osasfaith:feat/api-improvements-and-docs
Oct 23, 2026
Merged

DeFiVC merged 5 commits into
ChainLearnOfficial:mainfrom
osasfaith:feat/api-improvements-and-docs

Conversation

@osasfaith

Copy link
Copy Markdown
Contributor

Closes #536, Closes #537, Closes #538, Closes #539

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Refactoring (no functional or behavioral changes)
  • Documentation update

Summary

This PR addresses four issues in a single set of incremental commits:

  1. Add GitHub issue templates and CONTRIBUTING.md #538 — Adds GitHub issue templates (bug report, feature request), a PR template, and CONTRIBUTING.md covering setup, branch naming, commit conventions, and the PR process.
  2. Clean up stale files, duplicate imports, and console.error in production code #539 — Removes all console.error calls from production source files (replaced with silent catches), adds test_output.log to .gitignore, and verifies credentials.ts imports are clean.
  3. Add tests for auth, rewards, quizzes, and notifications API modules #536 — Adds test files for auth.ts, rewards.ts, and quizzes.ts API modules using vitest with mocked API client (success and error paths). Note: notifications.ts does not exist in the codebase.
  4. Split src/lib/api/client.ts into focused modules #537 — Extracts retry logic (retry.ts), LRU caching (cache.ts), and request deduplication (dedup.ts) into focused, independently testable modules. Re-exports from client.ts so all existing imports continue to work with no behavioral changes.

Motivation / Context

Untested API modules are prone to regression bugs. console.error in production leaks internal details. Missing templates increase maintainer review burden. A single-file API client is hard to navigate and test in isolation.

Closes #536, Closes #537, Closes #538, Closes #539

@netlify

netlify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for chainlearn failed.

Name Link
🔨 Latest commit c361d10
🔍 Latest deploy log https://app.netlify.com/projects/chainlearn/deploys/6adbb64e6ff55a33de50415d

Closes ChainLearnOfficial#538

- Add bug report and feature request issue templates
- Add pull request template with summary, type, and testing checklist
- Add CONTRIBUTING.md with setup, branch naming, commit conventions, and PR process
…o gitignore

Closes ChainLearnOfficial#539

- Add test_output.log to .gitignore
- Replace console.error calls with silent catches in hooks and components
- Remove console.error from error-boundary and route-error
- All production source files are now free of console.error
Closes ChainLearnOfficial#536

- Add auth.test.ts covering challenge, verify, profile, update, and refresh flows
- Add rewards.test.ts covering balances, history, claim, and claimables
- Add quizzes.test.ts covering quiz fetch, submission, and attempt history
- Add vitest config and test script
- All tests mock the API client (no real HTTP calls)
Closes ChainLearnOfficial#537

- Extract retry logic with exponential backoff into retry.ts
- Extract LRU response caching into cache.ts
- Extract request deduplication into dedup.ts
- Re-export from client.ts so all existing imports continue to work
- No behavioral changes to the API client
Clean up console.error calls in files added/modified upstream:
- storage.ts, avatar-upload.tsx, use-notifications.ts, use-local-storage.ts
- error-boundary.tsx, layout.tsx, wallet components, share-button.tsx
- client.ts logging interceptor default
- courses hooks, quiz-interface, credentials page
@osasfaith
osasfaith force-pushed the feat/api-improvements-and-docs branch from 405bd77 to c361d10 Compare October 23, 2026 19:32
@DeFiVC
DeFiVC merged commit b4bec1a into ChainLearnOfficial:main Oct 23, 2026
1 of 8 checks 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

2 participants