Skip to content

Add profile platform link route tests - #238

Merged
Harxhit merged 3 commits into
Dev-Card:mainfrom
dangzitou:openmeta/agent-5-backend-add-coverage-for-platfor-1779408254282
Aug 30, 2026
Merged

Add profile platform link route tests#238
Harxhit merged 3 commits into
Dev-Card:mainfrom
dangzitou:openmeta/agent-5-backend-add-coverage-for-platfor-1779408254282

Conversation

@dangzitou

Copy link
Copy Markdown
Contributor

Summary

The profiles API currently lacks focused backend coverage for creating, updating, and deleting platform links, making validation and typed response behavior harder to verify. This change adds Vitest coverage for POST /api/profiles/me/links validation and success paths, PUT /api/profiles/me/links/:id not-found handling, and DELETE /api/profiles/me/links/:id successful deletion using mocked Prisma platformLink methods.

Changes

  • Extended the profiles route test Prisma mock to include platformLink methods used by link routes.
  • Added a POST /api/profiles/me/links invalid body test covering createLinkSchema.safeParse failure and ensuring no link is created.
  • Added a POST /api/profiles/me/links valid body test covering successful link creation and expected Prisma create data.
  • Added a PUT /api/profiles/me/links/:id test verifying a missing link returns 404 and does not call update.
  • Added a DELETE /api/profiles/me/links/:id test verifying an existing authenticated link can be deleted with a 204 response.

Validation

  • pnpm run test is the provided test command for the backend test suite; execution is still pending because runnable commands were not available in this environment.
  • pnpm run lint is the provided lint command for TypeScript and formatting checks; execution is still pending because runnable commands were not available in this environment.

Risks

  • Mocking Prisma platformLink methods may require local test type adjustments if the existing mock is narrowly typed.
  • Assertions around generated platform URLs may be brittle if shared platform URL generation behavior changes.
  • DELETE 204 responses have an empty body, so tests must avoid parsing JSON from that response.

@Harxhit Harxhit added the gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. label May 22, 2026
@Harxhit

Harxhit commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

If your work is completed please mark it for review.

@dangzitou

Copy link
Copy Markdown
Contributor Author

I re-audited this draft. The branch is currently conflicting with main, and the existing maintainer request to mark it ready can’t be acted on responsibly until the branch is rebased and the profile-link route tests are run on the current backend. I’m keeping it as draft and flagging the rebase/test requirement here.

@dangzitou
dangzitou force-pushed the openmeta/agent-5-backend-add-coverage-for-platfor-1779408254282 branch from f88b18e to d9233be Compare August 30, 2026 14:59
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

@dangzitou is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel.

A member of the Team first needs to authorize it.

@dangzitou

Copy link
Copy Markdown
Contributor Author

Rebased onto the current main and resolved the profile-test conflict while retaining the existing username-race/error coverage plus the platform-link route coverage. I also corrected the P2002 regression fixture to use Prisma's actual PrismaClientKnownRequestError, matching the production instanceof guard.

Validation: vitest run src/__tests__/profiles.test.ts passes (12 tests); ESLint passes for the file; git diff --check is clean. GitHub detect-changes is running after the force-push; the previous Vercel failure is stale and has not yet been replaced by a new result. The PR remains draft pending that check.

@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

CI — All Checks Passed

Backend — PASS

Check Result
Lint PASS
Test PASS
Typecheck PASS

Mobile — SKIP

Check Result
Lint -
Test -

Web — SKIP

Check Result
Build -

Last updated: Sun, 30 Aug 2026 16:29:14 GMT

@dangzitou

Copy link
Copy Markdown
Contributor Author

Current remote checks after the rebase: backend-ci, detect-changes, and comment-results pass; web/mobile are correctly skipped. The only failure is the external Vercel check, which reports Authorization required to deploy for the repository owner's Vercel project and is not actionable from this PR. No further code changes are indicated.

@dangzitou
dangzitou marked this pull request as ready for review August 30, 2026 15:09
Copilot AI lite review requested due to automatic review settings August 30, 2026 15:09
@dangzitou

Copy link
Copy Markdown
Contributor Author

The rebased branch passes backend CI and the targeted profile tests (12/12) plus ESLint; the remaining Vercel failure is external authorization. I have marked the PR ready for maintainer review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change set is low-risk and limited to test coverage additions, with only minor test-assertion hardening suggested.

Pull request overview

Adds backend route-level Vitest coverage for profile platform link endpoints to improve confidence in validation, not-found handling, and successful create/delete behaviors (with Prisma mocked).

Changes:

  • Expanded the Prisma mock used by profile route tests to include platformLink model methods.
  • Added tests for POST /api/profiles/me/links covering invalid-body validation and successful creation.
  • Added tests for PUT /api/profiles/me/links/:id not-found behavior and DELETE /api/profiles/me/links/:id successful deletion (204, empty body).
File summaries
File Description
apps/backend/src/tests/profiles.test.ts Extends Prisma mocks and adds focused tests for platform link create/update/delete routes.
Review details

Suppressed comments (1)

apps/backend/src/tests/profiles.test.ts:186

  • For the invalid POST /me/links body test, also assert that platformLink.aggregate is not called. Validation should short-circuit before any DB reads, and this extra assertion will catch regressions where the handler does work before schema validation.
    expect(res.statusCode).toBe(400);
    expect(res.json().error).toBe('Validation failed');
    expect(mockPlatformLinkCreate).not.toHaveBeenCalled();
  });
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/backend/src/__tests__/profiles.test.ts
Copilot AI review requested due to automatic review settings August 30, 2026 16:28
@dangzitou

Copy link
Copy Markdown
Contributor Author

Follow-up pushed in 2e6af63: rejected profile updates now explicitly assert that no database write occurs. The focused suite passes 12/12, ESLint is clean, and repository backend CI is green. The remaining Vercel failure requires authorization from the project Vercel team. @Harxhit, ready for review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are isolated to test code and the added assertions align with the current route/service behavior for platform-link create/update/delete flows.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@Harxhit

Harxhit commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Follow-up pushed in 2e6af63: rejected profile updates now explicitly assert that no database write occurs. The focused suite passes 12/12, ESLint is clean, and repository backend CI is green. The remaining Vercel failure requires authorization from the project Vercel team. @Harxhit, ready for review.

Allow me some time please.

@Harxhit Harxhit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Harxhit
Harxhit merged commit ddf42b0 into Dev-Card:main Aug 30, 2026
5 of 6 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Congratulations @dangzitou on getting PR #238 merged!

Thank you for your contribution to the project.

To receive the appropriate GSSoC labels and recognition, please mention @Harxhit in the #get-labels channel on our Discord server and share your merged PR link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants