Skip to content

fix: remove mock data fallbacks and add proper loading/error states in profile hooks (closes #1676)#1869

Open
Emmanard wants to merge 2 commits into
EarnQuestOne:mainfrom
Emmanard:fix/issue-1676-remove-mock-fallbacks
Open

fix: remove mock data fallbacks and add proper loading/error states in profile hooks (closes #1676)#1869
Emmanard wants to merge 2 commits into
EarnQuestOne:mainfrom
Emmanard:fix/issue-1676-remove-mock-fallbacks

Conversation

@Emmanard

Copy link
Copy Markdown

Summary

The hooks named in the issue (useProfile, useQuests, useSubmissions) already make real API calls correctly. The actual source of mock data was one layer deeper — lib/api/profile.ts had all 6 exported functions fully mocked with hardcoded data behind await delay(ms), with the real endpoints left as TODO comments.

Changes

  • lib/api/profile.ts — rewrote all 6 functions to delegate to the existing get/post/patch client instead of returning mock data (238 → 39 lines)
  • tests/mocks/handlers.ts — added MSW handlers for all 6 profile endpoints, following the existing quest handler dual-URL pattern
  • lib/api/profile.integration.test.ts — new integration test file with 7 tests covering all 6 functions, happy path and error path

Scope notes

  • lib/mock/quests.ts and lib/mock/submissions.ts were intentionally left untouched — they are still used by lib/api/admin.ts and the submissions page respectively, which are outside the scope of this issue
  • ProfileStats.tsx required no changes — it already reads from the stats prop and will display real data automatically now that the API layer returns real data
  • Hook files (useProfile.ts, useQuests.ts, useSubmissions.ts) required no changes — they were already correctly structured

Testing

All 7 new integration tests run under both npm test and npm run test:integration (file matches **/*.integration.test.ts)

Closes #1676

@Emmanard Emmanard requested a review from RUKAYAT-CODER as a code owner June 30, 2026 08:36
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Great job so far

There’s just one blocker — the workflow is failing. Could you take a look and fix it so all checks pass?

Happy to review again once that’s done.
You can pull from the main first before pushing. The workflow should pass

@Emmanard Emmanard force-pushed the fix/issue-1676-remove-mock-fallbacks branch from e91d421 to 304839c Compare June 30, 2026 19:33
@Emmanard

Emmanard commented Jun 30, 2026

Copy link
Copy Markdown
Author

@RUKAYAT-CODER Rebased onto latest upstream main and fixed the Prettier formatting failures in the two new files (tests/mocks/handlers.ts and lib/api/profile.integration.test.ts). The rebase also pulled in upstream workflow file changes, which means the CI runs are currently in action_required state and need maintainer approval to run. Happy to address any further feedback once the checks complete.

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Great job so far

There’s just one blocker — the workflow is failing. Could you take a look and fix it so all checks pass?
You could pull from the main to get the changes before pushing.

@Emmanard

Emmanard commented Jul 1, 2026

Copy link
Copy Markdown
Author

Great job so far

There’s just one blocker — the workflow is failing. Could you take a look and fix it so all checks pass?

You could pull from the main to get the changes before pushing.

Did you please confirm what I commented first ? @RUKAYAT-CODER

@RUKAYAT-CODER

RUKAYAT-CODER commented Jul 2, 2026 via email

Copy link
Copy Markdown
Contributor

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Have approve all workflow

@Emmanard

Emmanard commented Jul 2, 2026

Copy link
Copy Markdown
Author

Thanks will debug and fix now

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.

Replace Mock Data with Real API Calls in Profile Page

2 participants