-
-
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
Creator vitest #3109
Creator vitest #3109
Conversation
Signed-off-by: NishantSinghhhhh <[email protected]>
WalkthroughThis pull request introduces several significant changes across multiple files, focusing on enhancing type safety, database schema, and GraphQL API functionality. The changes include adding type annotations in Docusaurus configuration, creating a comprehensive database migration with multiple tables, introducing language and country code enumerations, implementing an advertisement creator resolver with authorization logic, and updating TypeScript definitions for user-related operations. Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
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
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #3109 +/- ##
====================================================
+ Coverage 39.85% 39.88% +0.02%
====================================================
Files 453 453
Lines 33203 33273 +70
Branches 385 397 +12
====================================================
+ Hits 13234 13270 +36
- Misses 19969 20003 +34 ☔ View full report in Codecov by Sentry. |
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: 6
🔭 Outside diff range comments (2)
drizzle_migrations/meta/20250122092015_snapshot.json (2)
Line range hint
1-1000
: Consider enabling Row Level Security (RLS) for sensitive tables.The schema shows that RLS is disabled for all tables (
"isRLSEnabled": false
). For tables containing sensitive data likeusers
,organizations
, andchat_messages
, consider enabling RLS to enforce row-level access control at the database level.
Line range hint
1-1000
: Consider enhancing the audit trail.While the schema includes
creator_id
,updater_id
,created_at
, andupdated_at
fields, consider adding:
- Soft delete functionality (
deleted_at
,deleter_id
)- Version history for critical tables
- Change tracking for sensitive fields
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (9)
docs/docusaurus.config.ts
(1 hunks)drizzle_migrations/20250130163044_mature_james_howlett.sql
(1 hunks)drizzle_migrations/meta/20250122092015_snapshot.json
(1 hunks)drizzle_migrations/meta/_journal.json
(1 hunks)schema.graphql
(6 hunks)src/graphql/types/Advertisement/Advertisement.ts
(1 hunks)test/graphql/types/Advertisement/creator.test.ts
(1 hunks)test/routes/graphql/gql.tada-cache.d.ts
(1 hunks)test/routes/graphql/gql.tada.d.ts
(6 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/graphql/types/Advertisement/Advertisement.ts
[warning] 54-64: src/graphql/types/Advertisement/Advertisement.ts#L54-L64
Added lines #L54 - L64 were not covered by tests
[warning] 72-83: src/graphql/types/Advertisement/Advertisement.ts#L72-L83
Added lines #L72 - L83 were not covered by tests
[warning] 103-110: src/graphql/types/Advertisement/Advertisement.ts#L103-L110
Added lines #L103 - L110 were not covered by tests
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test Deployment to https://docs-api.talawa.io
🔇 Additional comments (18)
src/graphql/types/Advertisement/Advertisement.ts (4)
10-13
: NewUser
type looks solid.These fields (
id
,isAdmin
) sufficiently capture the minimal user data for authorization checks. Good job keeping it lightweight.
15-30
: Well-structuredContextType
.Encapsulating the drizzle client, logger, and current client context ensures that
resolveCreator
has just enough dependencies. The separation of concerns looks well architected.
54-64
: Add test coverage for missingcreatorId
.Currently, the flow that throws an error when
creatorId
is missing (lines #54-64) isn't covered by tests. This scenario is critical to ensure the function behaves as expected when the advertisement lacks acreatorId
.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 54-64: src/graphql/types/Advertisement/Advertisement.ts#L54-L64
Added lines #L54 - L64 were not covered by tests
71-84
: Add test coverage for when user is not found.According to static analysis, lines #71-84 lack coverage. Consider creating a dedicated test case that simulates
findFirst
returningnull
, verifying your exception handling and logging code paths.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 72-83: src/graphql/types/Advertisement/Advertisement.ts#L72-L83
Added lines #L72 - L83 were not covered by testsdocs/docusaurus.config.ts (1)
37-37
: Thanks for adding type annotations.Explicitly typing
docPath
asstring
helps clarify usage and prevents potential type mismatches. This is a neat improvement for type safety.test/routes/graphql/gql.tada-cache.d.ts (1)
8-8
: LGTM! Type definitions are well-structured and comprehensive.The type definitions for mutations and queries are properly typed with TadaDocumentNode, ensuring type safety throughout the GraphQL operations. The naturalLanguageCode field is consistently implemented across all relevant operations.
Also applies to: 14-14, 16-16, 18-18
test/routes/graphql/gql.tada.d.ts (3)
51-51
: LGTM! Well-structured language code enum.The
Iso639Set1LanguageCode
enum provides comprehensive ISO 639-1 language code support, enabling proper internationalization.
71-71
: LGTM! Consistent language code support across user mutations.The
naturalLanguageCode
field has been consistently added to all user-related input types:
- MutationCreateUserInput
- MutationSignUpInput
- MutationUpdateCurrentUserInput
This ensures consistent language preference handling across all user operations.
Also applies to: 95-95, 105-105
181-181
: LGTM! User type updated with language support.The
User
type has been updated to include thenaturalLanguageCode
field, maintaining consistency with the input types.drizzle_migrations/meta/_journal.json (1)
8-9
: LGTM! Migration metadata properly updated.The migration metadata has been correctly updated with:
- New timestamp: 1738254644389
- New migration tag: "20250130163044_mature_james_howlett"
drizzle_migrations/20250130163044_mature_james_howlett.sql (3)
1-418
: LGTM! Well-structured table definitions with consistent patterns.The table definitions follow good practices:
- Consistent audit fields across tables
- Appropriate use of UUIDs for primary keys
- Proper use of NOT NULL constraints
- Well-defined relationships between tables
528-675
: LGTM! Well-designed index strategy.The index definitions follow best practices:
- Indexes on frequently queried columns
- Composite indexes for uniqueness constraints
- Indexes on foreign key columns
420-527
: Review foreign key cascade behavior for potential data integrity issues.The foreign key constraints use appropriate cascade behaviors:
ON DELETE cascade
for parent-child relationshipsON DELETE set null
for optional relationshipsON UPDATE cascade
consistently appliedHowever, some cascade behaviors might need verification:
✅ Verification successful
Cascade delete behaviors are properly implemented
The foreign key constraints follow best practices for maintaining data integrity:
- Organization hierarchies use appropriate cascading
- Self-referential relationships (folders) maintain tree structure
- User references correctly differentiate between ownership (SET NULL) and membership (CASCADE)
- No circular dependencies or problematic cascade paths detected
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential circular dependencies in cascade delete paths # Search for tables with multiple cascade delete constraints echo "Tables with multiple cascade delete constraints:" rg "ON DELETE cascade" drizzle_migrations/20250130163044_mature_james_howlett.sql | sort | uniq -c | sort -nrLength of output: 9632
schema.graphql (3)
609-796
: LGTM! Comprehensive ISO 639-1 language code enum.The
Iso639Set1LanguageCode
enum includes all valid two-letter language codes as defined in ISO 639-1.
Line range hint
797-1774
: LGTM! Complete ISO 3166-1 alpha-2 country code enum.The
Iso3166Alpha2CountryCode
enum includes all valid two-letter country codes as defined in ISO 3166-1.
1775-1777
: 🧹 Nitpick (assertive)Verify the optional nature of the naturalLanguageCode field.
The
naturalLanguageCode
field is added as optional in all input types and the User type. Consider whether it should be required for new user creation to ensure proper internationalization support.Consider making
naturalLanguageCode
required inMutationCreateUserInput
andMutationSignUpInput
with a default value of "en" to ensure consistent language handling.Also applies to: 2007-2009, 2227-2229, 3180-3182
drizzle_migrations/meta/20250122092015_snapshot.json (2)
1-2
: LGTM! Migration snapshot ID updated.The snapshot ID has been updated to reflect the new migration version.
Line range hint
1-1000
: Well-designed schema with proper relationships and indexing.The schema demonstrates good practices:
- Consistent naming conventions
- Proper foreign key constraints with appropriate ON DELETE/UPDATE actions
- Strategic indexing for performance optimization
- Composite unique constraints where needed
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]>
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 raised a PR for adding test to creator.ts , what more should I do so that i can make this PR mergeable |
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.
See comments
"created_at" timestamp (3) with time zone DEFAULT now() NOT NULL, | ||
"creator_id" uuid, | ||
"description" text, | ||
"id" uuid PRIMARY KEY NOT NULL, |
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.
Why was this file created? There was a migration file there previously. This seems unnecessary.
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.
This is not resolved. The current file in the repo is 20250122092015_sweet_scrambler.sql
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
|
@palisadoes , I have restored both the files, any more changes that you think are important |
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.
- This is not resolved.
- The current file in the repo is
20250122092015_sweet_scrambler.sql
- This does not appear to be a solution
drizzle_migrations/20250130163044_mature_james_howlett.sql
"created_at" timestamp (3) with time zone DEFAULT now() NOT NULL, | ||
"creator_id" uuid, | ||
"description" text, | ||
"id" uuid PRIMARY KEY NOT NULL, |
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.
This is not resolved. The current file in the repo is 20250122092015_sweet_scrambler.sql
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
|
6683e62
into
PalisadoesFoundation:develop-postgres
What kind of change does this PR introduce?
Added tests for creator.ts.
Issue Number: Fixes: #3064
Snapshots/Videos:
Summary
This PR adds test cases for creator.ts to ensure better reliability and maintainability. The tests cover key functionalities and edge cases, improving the overall test coverage of the project.
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
Have you read the contributing guide?
Yes.
Summary by CodeRabbit
Release Notes
New Features
Documentation
Chores
Testing