-
-
Notifications
You must be signed in to change notification settings - Fork 757
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
fixed super admin profile #2340
fixed super admin profile #2340
Conversation
WalkthroughThe pull request introduces a new GraphQL query, Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 ProcessWe have these basic policies to make the approval process smoother for our volunteer team. Testing Your CodePlease make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:
The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing. 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: 3
🧹 Outside diff range and nitpick comments (2)
src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx (2)
Line range hint
1-458
: Suggestions for further test improvementsWhile the test suite is comprehensive, here are some suggestions to further enhance its robustness and consistency:
Consider replacing all instances of the custom
wait
function withwaitFor
from@testing-library/react
for consistency and improved reliability.Some test descriptions could be more specific. For example, "Testing Menu Buttons" could be "Clicking Dashboard button navigates to the correct route".
Add an explicit test for error handling when fetching organizations fails. This could involve mocking a network error response.
For consistency, consider using either
userEvent
orfireEvent
throughout the file, not both.userEvent
is generally preferred as it more closely simulates real user interactions.The
resizeWindow
function could be moved to a separate test utilities file if it's used in other test files as well.These changes would further improve the test suite's reliability and maintainability.
Line range hint
1-458
: Additional test coverage needed for the reported bug fixWhile this test file provides good coverage for the LeftDrawerOrg component, it doesn't directly address the bug fix mentioned in the PR objectives (error when editing the Super Admin profile). To ensure the reported issue is resolved and prevent regression, consider adding the following tests:
- A test case that simulates editing the Super Admin profile and verifies that no error occurs.
- A test that checks the correct handling of CreatorId when passed to the talawa-api.
- Tests for the new GraphQL query
ORGANIZATIONS_LIST_BY_CREATOR_ID
mentioned in the AI summary.- Tests for any modifications made to the LeftDrawerOrg component related to the bug fix.
Adding these tests will increase confidence in the bug fix and improve overall test coverage.
Would you like assistance in drafting these additional test cases?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (3)
- src/GraphQl/Queries/Queries.ts (2 hunks)
- src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx (2 hunks)
- src/components/LeftDrawerOrg/LeftDrawerOrg.tsx (3 hunks)
🧰 Additional context used
🔇 Additional comments (6)
src/components/LeftDrawerOrg/LeftDrawerOrg.tsx (4)
186-186
: LGTM! Minor style improvement.Moving the export statement to its own line is a good stylistic choice. It improves code readability by clearly separating the component definition from its export.
Line range hint
1-186
: Summary: Changes address the Super Admin profile editing issue effectively.The modifications to the GraphQL query and its usage in this component are well-aligned with the PR objectives. These changes should resolve the issue #1924 by correctly fetching organizations based on the creator's ID for the Super Admin profile. The component's core logic remains intact, focusing the changes on the data retrieval mechanism.
To ensure the effectiveness of these changes:
- Verify that the new query
ORGANIZATIONS_LIST_BY_CREATOR_ID
is correctly defined and used consistently across the codebase.- Test the Super Admin profile editing functionality to confirm that the error has been resolved.
- Update any relevant documentation or comments to reflect the new query usage.
Overall, these changes appear to be a solid fix for the reported issue.
3-3
: LGTM! Verify query usage across the codebase.The import change from
ORGANIZATIONS_LIST
toORGANIZATIONS_LIST_BY_CREATOR_ID
aligns with the PR objective to fix the Super Admin profile editing issue. This more specific query should resolve the error mentioned in issue #1924.To ensure consistency, let's verify the usage of this new query across the codebase:
52-53
: LGTM! Verify query structure and variable usage.The update to use
ORGANIZATIONS_LIST_BY_CREATOR_ID
withcreatorId: orgId
is consistent with the import change and should resolve the Super Admin profile editing issue.Let's verify the structure of the new query and its variable usage:
src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx (1)
307-307
: Excellent improvement in test reliability!This change from
await wait()
toawait waitFor(() => expect(screen.getByTestId(/OrgBtn/i)).toBeInTheDocument())
is a significant improvement in the test's reliability and specificity. Here's why this change is beneficial:
- It uses the
waitFor
function from@testing-library/react
, which is designed specifically for handling asynchronous operations in React tests.- The new code includes an explicit expectation, making the test more precise about what it's waiting for.
- This approach reduces the likelihood of false positives that could occur with a simple timeout.
- It aligns with current best practices for testing asynchronous React components.
This change will make the test more robust and less prone to flakiness, especially in CI/CD environments where timing can be unpredictable.
src/GraphQl/Queries/Queries.ts (1)
338-341
: Verify the correctness of thecreatorId
filterIn the
ORGANIZATIONS_LIST_BY_CREATOR_ID
query (lines 339-341), ensure that filtering bycreatorId
functions as intended. Confirm that thecreatorId
field exists on theOrganization
model and is the appropriate field for identifying the creator of an organization.Run the following script to confirm that
creatorId
is a valid field in theOrganization
schema:
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2340 +/- ##
===========================================
- Coverage 97.62% 97.53% -0.09%
===========================================
Files 250 250
Lines 7188 7189 +1
Branches 2069 2071 +2
===========================================
- Hits 7017 7012 -5
- Misses 159 165 +6
Partials 12 12 ☔ 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: 0
🧹 Outside diff range and nitpick comments (1)
src/GraphQl/Queries/Queries.ts (1)
338-392
: Consider Adding Unit Tests for the New QueryTo ensure the reliability of the
ORGANIZATIONS_LIST_BY_CREATOR_ID
query and to prevent future regressions, it's recommended to add unit tests covering various scenarios such as valid creator IDs, invalid IDs, and cases where no organizations are returned. This will enhance the robustness of the application and align with best practices.Would you like assistance in creating these unit tests or opening a GitHub issue to track this task?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (3)
- src/GraphQl/Queries/Queries.ts (1 hunks)
- src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx (3 hunks)
- src/components/LeftDrawerOrg/LeftDrawerOrg.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx
- src/components/LeftDrawerOrg/LeftDrawerOrg.tsx
🧰 Additional context used
🔇 Additional comments (1)
src/GraphQl/Queries/Queries.ts (1)
338-392
: Addition ofORGANIZATIONS_LIST_BY_CREATOR_ID
Query is Well-ImplementedThe new GraphQL query
ORGANIZATIONS_LIST_BY_CREATOR_ID
correctly retrieves organizations based on the creator's ID and includes all the necessary fields. It aligns with the existing codebase conventions and should effectively address the bug related to editing the Super Admin profile as outlined in the PR objectives.
Please fix failing tests |
I am working on it i dont know why is the test coverage failing |
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: 0
🧹 Outside diff range and nitpick comments (2)
src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx (2)
80-80
: LGTM: Mock updated correctly with a minor suggestion.The GraphQL query in the MOCKS array has been correctly updated to
ORGANIZATIONS_LIST_BY_CREATOR_ID
. This change is consistent with the import statement update and aligns with the PR objective.Consider updating the mock data to include a
creatorId
field in the returned organization object, as it might be relevant for the new query:organizations: [ { _id: '123', + creatorId: '123', // Add this line image: null, creator: { firstName: 'John', lastName: 'Doe', email: '[email protected]', }, // ... rest of the mock data }, ],This addition would make the mock data more representative of the expected API response for the new query.
143-143
: LGTM: Mock updated correctly with a minor suggestion.The GraphQL query in the MOCKS_WITH_IMAGE array has been correctly updated to
ORGANIZATIONS_LIST_BY_CREATOR_ID
. This change is consistent with the previous updates in the file and aligns with the PR objective.Similar to the previous suggestion, consider updating the mock data to include a
creatorId
field in the returned organization object:organizations: [ { _id: '123', + creatorId: '123', // Add this line image: 'https://api.dicebear.com/5.x/initials/svg?seed=Test%20Organization', creator: { firstName: 'John', lastName: 'Doe', email: '[email protected]', }, // ... rest of the mock data }, ],This addition would make the mock data more representative of the expected API response for the new query.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (3)
- src/GraphQl/Queries/Queries.ts (1 hunks)
- src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx (4 hunks)
- src/components/LeftDrawerOrg/LeftDrawerOrg.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/LeftDrawerOrg/LeftDrawerOrg.tsx
🧰 Additional context used
🔇 Additional comments (3)
src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx (2)
Line range hint
1-443
: Summary: Test file updated correctly to use new GraphQL query.The changes in this file consistently update the GraphQL query from
ORGANIZATIONS_LIST
toORGANIZATIONS_LIST_BY_CREATOR_ID
across all mock data. These modifications align with the PR objective of fixing the Super Admin profile editing issue.Key points:
- Import statement updated (line 14)
- MOCKS array updated (line 80)
- MOCKS_WITH_IMAGE array updated (line 143)
- MOCKS_EMPTY array updated (line 207, not highlighted but verified)
The structure of the tests remains unchanged, which is correct as the functionality being tested should remain the same. The only difference is the query being used to fetch the data.
To ensure all tests are passing with the new changes:
#!/bin/bash # Description: Run tests for the LeftDrawerOrg component # Test: Run Jest tests for LeftDrawerOrg npm test -- src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsxIf any tests fail, please review and update them accordingly.
14-14
: LGTM: Import statement updated correctly.The import statement has been updated to use
ORGANIZATIONS_LIST_BY_CREATOR_ID
instead ofORGANIZATIONS_LIST
. This change aligns with the PR objective and is consistent with the modifications mentioned in the summary.To ensure consistency, let's verify that this change is applied throughout the file:
✅ Verification successful
Verified: Import statement updated consistently.
All instances of
ORGANIZATIONS_LIST
have been successfully replaced withORGANIZATIONS_LIST_BY_CREATOR_ID
throughout the file. No inconsistent usages detected.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that ORGANIZATIONS_LIST_BY_CREATOR_ID is used consistently throughout the file. # Test: Search for any remaining instances of ORGANIZATIONS_LIST rg -i 'ORGANIZATIONS_LIST(?!_BY_CREATOR_ID)' src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx # Test: Confirm the usage of ORGANIZATIONS_LIST_BY_CREATOR_ID rg 'ORGANIZATIONS_LIST_BY_CREATOR_ID' src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsxLength of output: 879
Script:
#!/bin/bash # Description: Verify that there are no remaining instances of ORGANIZATIONS_LIST not replaced with ORGANIZATIONS_LIST_BY_CREATOR_ID. # Test: Search for any remaining instances of ORGANIZATIONS_LIST not followed by _BY_CREATOR_ID using PCRE2. rg -i --pcre2 'ORGANIZATIONS_LIST(?!_BY_CREATOR_ID)' src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx # Confirm the usage of ORGANIZATIONS_LIST_BY_CREATOR_ID rg 'ORGANIZATIONS_LIST_BY_CREATOR_ID' src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsxLength of output: 413
src/GraphQl/Queries/Queries.ts (1)
338-392
: LGTM!The
ORGANIZATIONS_LIST_BY_CREATOR_ID
query is implemented correctly and follows the existing code patterns. The fields included are appropriate for fetching detailed organization information based on the creator's ID.
What kind of change does this PR introduce?
Bugfix
Issue Number:
Fixes #1924
It does not give error as CreatorId is being passed to the talawa-api so i havefixed it in the api also so that it handles it correctly and then it will not throw error
Summary by CodeRabbit
New Features
Bug Fixes
LeftDrawerOrg
component to ensure more reliable assertions in asynchronous scenarios.Refactor
LeftDrawerOrg
component to utilize the new query, aligning data retrieval with the creator's ID instead of a general organization ID.