Skip to content

Added Tests for: src/graphql/types/User/homePhoneNumber.ts#5352

Open
Ayush4958 wants to merge 4 commits intoPalisadoesFoundation:developfrom
Ayush4958:add-test-coverage-for-homephonenumber
Open

Added Tests for: src/graphql/types/User/homePhoneNumber.ts#5352
Ayush4958 wants to merge 4 commits intoPalisadoesFoundation:developfrom
Ayush4958:add-test-coverage-for-homephonenumber

Conversation

@Ayush4958
Copy link
Copy Markdown

@Ayush4958 Ayush4958 commented Apr 29, 2026

What kind of change does this PR introduce?
It adds the test for homePhoneNumber.ts file.

Issue Number:
Fixes #5082

Summary

I had added comprehensive unit tests for homePhoneNumber.ts GraphQL field resolver to improve code coverage. Added homePhoneNumber.test.ts to improve coverage and validate resolver behavior.

Test Cover

  • Validates unauthenticated requests return the expected error and skip database queries.
  • Ensures authenticated requests fail when the current user record is missing.
  • Verifies regular users cannot access another user's home phone number.
  • Confirms self-access and administrator access return the expected value.
  • Covers null, empty string, and undefined resolver return values.

Does this PR introduce a breaking change?
No.

Checklist

CodeRabbit AI Review

  • I have reviewed and addressed all critical issues flagged by CodeRabbit AI
  • I have implemented or provided justification for each non-critical suggestion
  • I have documented my reasoning in the PR comments where CodeRabbit AI suggestions were not implemented

Test Coverage

  • I have written tests for all new changes/features
  • I have verified that test coverage meets or exceeds 95%
  • I have run the test suite locally and all tests pass

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for the homePhoneNumber field: verifies unauthenticated and unauthorized access are rejected, confirms admin and self-access succeed, and validates handling of null, empty string, and undefined values. Also asserts that the resolver performs the expected user lookups and query shapes during access checks.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

Our Pull Request Approval Process

This PR will be reviewed according to our:

  1. Palisadoes Contributing Guidelines

  2. AI Usage Policy

Your PR may be automatically closed if:

  1. Our PR template isn't filled in correctly
  2. You haven't correctly linked your PR to an issue

👉 https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue

Thanks for contributing!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Warning

Rate limit exceeded

@Ayush4958 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 6 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 267ed470-78ba-44e0-9b83-02a3b46975af

📥 Commits

Reviewing files that changed from the base of the PR and between 7d4df9e and bd5f627.

📒 Files selected for processing (1)
  • test/graphql/types/User/homePhoneNumber.test.ts

Walkthrough

Adds a Vitest test suite for the GraphQL User.homePhoneNumber field resolver that exercises authentication, authorization (self vs. admin), successful returns, and edge cases for null, empty string, and undefined, using a mocked GraphQL context and assertions on usersTable.findFirst calls.

Changes

Cohort / File(s) Summary
User homePhoneNumber Test Suite
test/graphql/types/User/homePhoneNumber.test.ts
Adds a new Vitest test file (+202 lines) that: verifies unauthenticated access errors, missing-current-user handling, authorization rejection for regular users accessing others’ data, allowed self/admin access returning the parent's homePhoneNumber, and null/empty/undefined edge cases; asserts usersTable.findFirst mock invocation shapes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding tests for the homePhoneNumber.ts file, which matches the PR's primary objective.
Description check ✅ Passed The description includes the change type, linked issue reference, summary, test coverage details, breaking change status, and most checklist items are addressed.
Linked Issues check ✅ Passed The PR addresses all key requirements from issue #5082: creates test file with authentication checks, authorization restrictions, null/empty handling, and database query mocking.
Out of Scope Changes check ✅ Passed The PR contains only test additions for homePhoneNumber.ts with no modifications to the source file or unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 9 minutes and 6 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Ayush4958 Ayush4958 closed this Apr 29, 2026
@Ayush4958 Ayush4958 reopened this Apr 29, 2026
@Ayush4958 Ayush4958 changed the base branch from main to develop April 29, 2026 08:08
@Ayush4958 Ayush4958 requested a review from palisadoes as a code owner April 29, 2026 08:08
@Ayush4958 Ayush4958 force-pushed the add-test-coverage-for-homephonenumber branch from 4cb55f8 to da0d17c Compare April 29, 2026 08:22
@palisadoes palisadoes changed the title feat: added comprehensive test Added Tests for: src/graphql/types/User/homePhoneNumber.ts Apr 29, 2026
@palisadoes
Copy link
Copy Markdown
Contributor

Please fix the failing test

Signed-off-by: Ayush <bhandariayush935@gmail.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/graphql/types/User/homePhoneNumber.test.ts`:
- Around line 72-74: Replace the loose call-count assertion on
mocks.drizzleClient.query.usersTable.findFirst with an argument-aware assertion:
assert that mocks.drizzleClient.query.usersTable.findFirst was called with an
object containing the expected columns.role selection and the where callback
(e.g. use toHaveBeenCalledWith(expect.objectContaining({ columns:
expect.objectContaining({ role: expect.anything() }), where:
expect.any(Function) })) so the resolver's query shape/filter is validated;
apply the same change for the other occurrences that currently use
toHaveBeenCalledOnce (the other findFirst assertions noted in the comment).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a025855a-51b8-4d52-8738-22183b77a1c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5246239 and 3932893.

📒 Files selected for processing (1)
  • test/graphql/types/User/homePhoneNumber.test.ts

Comment thread test/graphql/types/User/homePhoneNumber.test.ts Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/graphql/types/User/homePhoneNumber.test.ts`:
- Around line 60-201: Add a test that simulates a DB failure by having
mocks.drizzleClient.query.usersTable.findFirst.mockRejectedValue(new Error("db
error")) and asserting runResolver(parent, context) rejects; ensure the test
uses the same setup helper (createSetup) and asserts the call to
mocks.drizzleClient.query.usersTable.findFirst was made with the same options
(expect.objectContaining with columns.role and where: expect.any(Function)), so
the resolver's error path for current-user lookup is covered (referencing
runResolver, createSetup, and mocks.drizzleClient.query.usersTable.findFirst).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1f11bc8d-6359-4fff-8179-754226d78ff4

📥 Commits

Reviewing files that changed from the base of the PR and between 3932893 and 7d4df9e.

📒 Files selected for processing (1)
  • test/graphql/types/User/homePhoneNumber.test.ts

Comment thread test/graphql/types/User/homePhoneNumber.test.ts
@PalisadoesFoundation PalisadoesFoundation deleted a comment from codecov Bot Apr 30, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.38%. Comparing base (675939c) to head (bd5f627).
⚠️ Report is 194 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5352      +/-   ##
===========================================
+ Coverage    93.69%   95.38%   +1.68%     
===========================================
  Files          861      909      +48     
  Lines        71332    78564    +7232     
  Branches      9893    11414    +1521     
===========================================
+ Hits         66838    74942    +8104     
+ Misses        4494     3622     -872     
Flag Coverage Δ
install 72.15% <ø> (?)
integration 94.93% <ø> (+1.76%) ⬆️
unit 98.96% <ø> (+1.84%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 201 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ayush4958
Copy link
Copy Markdown
Author

Hi @palisadoes ,
could u review it pls , I had fix it all ...

@Ayush4958
Copy link
Copy Markdown
Author

@palisadoes ,
If there is any other changes done to be in this test integration ,
I could add on ...

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.

Test: src/graphql/types/User/homePhoneNumber.ts

2 participants