Skip to content

refactor(freelancer-reviews): remove mock data and related functions …#297

Open
DanielCotoJ wants to merge 1 commit into
OFFER-HUB:mainfrom
DanielCotoJ:fix/remove-mock-freelancer-reviews
Open

refactor(freelancer-reviews): remove mock data and related functions …#297
DanielCotoJ wants to merge 1 commit into
OFFER-HUB:mainfrom
DanielCotoJ:fix/remove-mock-freelancer-reviews

Conversation

@DanielCotoJ

Copy link
Copy Markdown

📝 Pull Request

🔧 Title:

  • fix: remove hardcoded mock review data from lib/api/freelancer-public.ts

🛠️ Issue

📚 Description

src/lib/api/freelancer-public.ts contained hardcoded fake data: fabricated reviewers
(Jordan Lee, Sam Rivera, Casey Kim) with static ratings/dates in MOCK_REVIEWS_BASE, and
a fake profile summary ("Alex Morgan", 4.7 rating) in MOCK_SUMMARY. This scaffolding was
gated behind the NEXT_PUBLIC_USE_MOCK_FREELANCER_PUBLIC env flag and risked surfacing
fabricated reviews/profiles on public freelancer pages, which is misleading and breaks
trust.

All mock scaffolding has been removed so both public functions
(getPublicFreelancerSummary and getPublicFreelancerReviews) call the real backend
endpoints only:

  • GET /marketplace/freelancers/:id
  • GET /marketplace/freelancers/:id/reviews

Error handling was already throw-based and is left unchanged: getPublicFreelancerReviews
propagates API errors (the consumer page catches them and renders an error state), and a
404 returns an empty result that renders the existing "No reviews yet" empty state. No new
error pattern was introduced and no consumer changes were needed.

✅ Changes applied

  • Removed MOCK_REVIEWS_BASE (fake reviewers/ratings/dates) and all references to it.
  • Removed the remaining mock scaffolding in the same file: USE_MOCK flag, MOCK_SUMMARY,
    MOCK_DIST, buildMockStats(), mockSummaryForId(), mockReviewsResult().
  • Removed the two if (USE_MOCK) early-return branches in getPublicFreelancerSummary
    and getPublicFreelancerReviews.
  • Kept unwrapData() and all real fetch/normalization logic (existing repo convention).
  • No hardcoded names, ratings, or dates remain in the file.
  • No consumer edits: the reviews page (src/app/marketplace/freelancers/[id]/reviews/page.tsx)
    already renders an empty state ("No reviews yet") and an error state.

Out of scope / not testable until backend is live

  • The live happy path (rendering real reviews) is only fully testable once
    GET /marketplace/freelancers/:id/reviews serves live data. Until then the page shows
    the empty or error state, which is the intended behavior.
  • No accessibility code was touched (the issue's referenced "Accessibility Improvements #34" dependency is an
    unrelated accessibility task).

🔍 Evidence/Media (screenshots/videos)

image

The command searched the src/ folder for the old mock freelancer review identifiers. It returned no matches, which means those mock references are no longer present in the source code. The exit code 1 is expected for grep when nothing is found.

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.

Fix: Remove hardcoded mock review data from lib/api/freelancer-public.ts

1 participant