-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test: src/graphql/types/Advertisement/updatedAt.ts #3138
Test: src/graphql/types/Advertisement/updatedAt.ts #3138
Conversation
Signed-off-by: NishantSinghhhhh <[email protected]>
WalkthroughThe test file Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant R as resolveUpdatedAt
participant DB as Database
U->>R: Invoke resolveUpdatedAt(ad, args, ctx)
R->>R: Check if user is authenticated
alt User not authenticated
R-->>U: Throw "unauthenticated" error
else
R->>R: Validate organizationId
alt organizationId is null
R-->>U: Throw "organization ID cannot be null" error
else
R->>DB: Retrieve user's role and memberships
alt User is administrator or has admin rights in membership
R-->>U: Return updatedAt value
else
R-->>U: Throw "unauthorized_action" error
end
end
end
Assessment against linked issues
Possibly related issues
Suggested reviewers
Tip 🌐 Web search-backed reviews and chat
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
@palisadoes , I have opened a new PR , and still the tests are failing , can you please tell a way by which the tests can pass ?? |
Reinstall the pnpm packages in your local repo. The lockfiles may have changed. |
Signed-off-by: NishantSinghhhhh <[email protected]>
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
Signed-off-by: NishantSinghhhhh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (1)
test/graphql/types/Advertisement/updatedAt.test.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (typescript)
🔇 Additional comments (2)
test/graphql/types/Advertisement/updatedAt.test.ts (2)
1-14
: LGTM! Well-structured imports and table definition.The imports are comprehensive and the table definition correctly references the users table.
1-351
: Overall excellent test implementation!The test file is well-structured with comprehensive coverage of various scenarios. The suggested improvements are minor refinements to an already solid implementation.
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (1)
test/graphql/types/Advertisement/updatedAt.test.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (typescript)
🔇 Additional comments (3)
test/graphql/types/Advertisement/updatedAt.test.ts (3)
20-26
: Use typed roles for better type safety
Consider refactoring therole
fields to a union type such as'administrator' | 'member'
instead ofstring
. This ensures stricter type checking and reduces the risk of accidental typos.
49-123
: Refactor with early returns and more descriptive error messages
Consider restructuring theresolveUpdatedAt
function to reduce nested conditionals and provide more explicit error messages, enhancing readability and maintainability.
125-129
: Add JSDoc comments for WhereClause
Documenting the purpose and usage of theWhereClause
type will improve clarity for contributors and maintainers.
@palisadoes, I have installed the PNPM packages, but the tests are still failing. Could the issue be with my test cases, or is it related to the GitHub test setup? |
|
Should I merge with the latest upstream of develop-postgres? If yes then I will try doing it in sometime |
Yes. |
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
Codecov isn't showing a 100% coverage. |
@palisadoes , what should I do for 100% coverage , as I believe I cannot add more test cases for this specific file |
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
Thanks I'll merge this |
3cce3c3
into
PalisadoesFoundation:develop-postgres
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #3138 +/- ##
=================================================
Coverage 39.72% 39.72%
=================================================
Files 455 455
Lines 33541 33541
Branches 407 407
=================================================
Hits 13324 13324
Misses 20217 20217 ☔ View full report in Codecov by Sentry. |
What kind of change does this PR introduce?
Feature: Adds functionality to resolve the updatedAt field in an advertisement.
Issue Number:
Fixes: #3087
Snapshots/Videos:
Screencast from 2025-02-03 00-38-21.webm
If relevant, did you update the documentation?
Summary
This PR introduces logic for resolving the updatedAt field in advertisements. It ensures that only authenticated users with the correct roles (administrator or organization administrator) can access the field. The change involves the following key checks:
Authentication Check: If the user is not logged in, an unauthenticated error is thrown.
Role-based Access: If the user is an organization administrator or system administrator, access is granted to the updatedAt field.
Database Query Logic: A series of database queries checks the user’s role and membership in the specified organization to ensure appropriate access.
Error Handling: Comprehensive error handling is implemented for missing or invalid data and database connection errors.
This PR also adds several test cases to validate the functionality, ensuring that unauthorized users cannot access the field and that proper database queries are executed.
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
Other information
The test suite includes multiple scenarios such as verifying authentication, role validation, handling missing or incorrect data, and ensuring correct database queries are being executed.
Have you read the contributing guide?
Yes.
Summary by CodeRabbit