WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@rohit746
Copy link

@rohit746 rohit746 commented Dec 4, 2025

What kind of change does this PR introduce?

  • Test (Adding missing tests or correcting existing tests)
  • Refactoring (No functional changes, no api changes)

Issue Number:

Fixes #3650

Snapshots/Videos:

image

If relevant, did you update the documentation?

N/A

Summary

This PR improves the test code coverage for the ProfileDropdown component to 100%. It adds comprehensive tests for user interactions, navigation, and state changes within the dropdown menu.

Key changes include:

  • Added tests for rendering the profile dropdown button and avatar.
  • Added tests for toggling the dropdown menu (open/close).
  • Covered navigation events when clicking profile menu items (e.g., Profile, Settings).
  • Added tests for the Logout functionality and session clearing.
  • Mocked necessary hooks (navigation, translation, and user context) to isolate component behavior.

Does this PR introduce a breaking change?

No. This change only affects test files and internal implementation details; no functional code logic was altered.

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

Used vi.mock to handle navigation and local storage interactions during the logout process.

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • Tests
    • Added tests for name truncation with ellipsis handling.
    • Added tests for Avatar fallback rendering when no image or invalid image is present.
    • Added tests for error handling during logout operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@keploy
Copy link

keploy bot commented Dec 4, 2025

No significant changes currently retry

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

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

Thanks for contributing!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Warning

Rate limit exceeded

@rohit746 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 30 seconds before requesting another review.

⌛ 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 0fc945c and 1b3102a.

⛔ Files ignored due to path filters (2)
  • docs/docs/auto-docs/components/ProfileDropdown/ProfileDropdown/functions/default.md is excluded by !**/docs/docs/**
  • docs/docs/auto-docs/components/ProfileDropdown/ProfileDropdown/variables/MAX_NAME_LENGTH.md is excluded by !**/docs/docs/**
📒 Files selected for processing (2)
  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx (3 hunks)
  • src/components/ProfileDropdown/ProfileDropdown.tsx (1 hunks)

Walkthrough

Adds new tests to ProfileDropdown.spec.tsx covering name truncation, Avatar fallback when UserImage is absent or the string 'null', and error handling during logout when revokeRefreshToken fails; one error-handling test is duplicated in the file.

Changes

Cohort / File(s) Change Summary
ProfileDropdown Test Suite
src/components/ProfileDropdown/ProfileDropdown.spec.tsx
Added tests verifying: (1) long display names are truncated to MAX_NAME_LENGTH with an ellipsis, (2) Avatar fallback renders when UserImage is missing, (3) Avatar fallback renders when UserImage is the string 'null', and (4) logout error handling when revokeRefreshToken fails (asserts console.error). Note: the error-handling test is present twice (duplicate).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify the duplicate error-handling test — remove or justify duplicate.
  • Confirm assertions and mocks correctly simulate revokeRefreshToken failure and console error capture.
  • Ensure tests reliably run in CI (no flaky timing or global state leaks).

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the PR's main change: improving test code coverage for ProfileDropdown.tsx.
Description check ✅ Passed The description adequately covers what kind of change is made, includes the linked issue number, provides a clear summary of the tests added, and addresses the checklist items.
Linked Issues check ✅ Passed The PR addresses all key objectives from #3650: tests are added to improve coverage, mocked hooks for isolation, and claims to reach 100% coverage with passing tests.
Out of Scope Changes check ✅ Passed All changes are focused on adding test coverage to ProfileDropdown.spec.tsx with no modifications to the component implementation or exported APIs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

Copy link
Contributor

@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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82160c3 and dd11dbd.

📒 Files selected for processing (1)
  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx (2 hunks)
🧰 Additional context used
🧠 Learnings (20)
📓 Common learnings
Learnt from: Chaitanya1672
Repo: PalisadoesFoundation/talawa-admin PR: 2049
File: src/screens/OrganizationActionItems/ActionItemUpdateModal.tsx:112-138
Timestamp: 2024-10-08T16:13:41.996Z
Learning: The `istanbul ignore next` comments in the `ActionItemUpdateModal.tsx` file were added as part of a commit that introduced tests for the `ActionItemUpdateModal` component. Removing these comments and writing tests to cover the previously ignored lines is recommended to ensure code integrity and improve test coverage.
Learnt from: Ansingh0305
Repo: PalisadoesFoundation/talawa-admin PR: 0
File: :0-0
Timestamp: 2025-11-30T23:13:22.697Z
Learning: In talawa-admin PR #4908, increasing test concurrency from maxConcurrency: 1 to 6-12 with TOTAL_SHARDS: 12 exposed three critical latent bugs: (1) EventsAttendedByUser.spec.tsx used wrong GraphQL query mock (EVENT_DETAILS vs EVENT_DETAILS_BASIC with incorrect variable names), (2) User.mocks.ts missing search/reset refetch scenarios causing "No more mocked responses" errors, (3) EventCalendar.spec.tsx UTC timezone bug where new Date().toISOString() caused date calculation mismatches in non-UTC timezones. These bugs were masked at lower concurrency but surfaced consistently under parallel execution stress-testing. Fix involved aligning mocks with actual component queries and explicit timezone-aware date construction.
Learnt from: Ansingh0305
Repo: PalisadoesFoundation/talawa-admin PR: 0
File: :0-0
Timestamp: 2025-11-12T00:28:53.713Z
Learning: In talawa-admin PR #4565 continuation (PR #4664 planned), Phase 2A mock isolation strategy uses global vi.clearAllMocks() in afterEach (vitest.setup.ts) plus refactoring module-level vi.fn() into per-test beforeEach blocks across 6 parallelizable issues (2A.0 foundation, 2A.1-2A.4 directory-based fixes, 2A.5 validation). This approach addresses mock call history accumulation enabling maxConcurrency: 2 and 2.3-2.5x speedup. vi.restoreAllMocks() alternative considered for spy restoration during validation phase. Phase 2A (mocks) correctly separated from Phase 2B (DOM/Apollo).
Learnt from: Ansingh0305
Repo: PalisadoesFoundation/talawa-admin PR: 0
File: :0-0
Timestamp: 2025-11-11T11:51:09.236Z
Learning: In talawa-admin PR #4664 (continuation of PR #4565 sharding work), global mock cleanup was implemented via vi.clearAllMocks() in vitest.setup.ts afterEach, along with Apollo Client warning suppression (temporary, pending follow-up PR) and test suite refactoring to per-test StaticMockLink instances. This test isolation strategy addresses mock state leakage that forced maxConcurrency: 1 in PR #4565, enabling future parallel test execution improvements and 3-4x speedup potential.
Learnt from: Ansingh0305
Repo: PalisadoesFoundation/talawa-admin PR: 0
File: :0-0
Timestamp: 2025-11-28T22:51:12.245Z
Learning: In talawa-admin PR #4826, mock cleanup implementation uses global vi.clearAllMocks() in vitest.setup.ts afterEach hook, combined with proper vi.hoisted() usage for module-level mocks. This strategy successfully achieved test isolation across 273 test files, passing the mock cleanup checker script with exit code 0. The implementation is ready for increasing maxConcurrency from conservative settings (CI: 1, local: 2) to higher concurrency levels (recommended gradual rollout: CI 1→2→4, local 2→4→8) to achieve Phase 2A goals of 2.3-2.5x speedup. Global cleanup strategy eliminates need for explicit afterEach blocks in every individual test file.
Learnt from: bitbard3
Repo: PalisadoesFoundation/talawa-admin PR: 2588
File: src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx:155-162
Timestamp: 2024-12-03T05:52:37.888Z
Learning: In the `ChangeLanguageDropdown` component (`src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.tsx`), error handling has not been implemented. Therefore, test cases in `src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx` do not cover error scenarios related to error handling.
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4419
File: src/components/ProfileCard/ProfileCard.spec.tsx:112-131
Timestamp: 2025-10-12T21:51:10.123Z
Learning: In the ProfileCard component (`src/components/ProfileCard/ProfileCard.tsx`), when an image load error occurs, the component only sets the image's `display: 'none'` style and does not render the Avatar component with "dummy picture" alt text. The Avatar component is only rendered when `userImage` is falsy or equals 'null', not when the image fails to load.
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2398
File: src/components/AddPeopleToTag/AddPeopleToTag.test.tsx:177-241
Timestamp: 2024-11-02T07:48:36.443Z
Learning: In `src/components/AddPeopleToTag/AddPeopleToTag.test.tsx`, prefer keeping test cases separate and more readable, even if it involves some duplication, instead of extracting common logic into helper functions.
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2362
File: src/components/TagActions/TagActions.test.tsx:123-131
Timestamp: 2024-10-28T06:38:43.765Z
Learning: In `TagActions.test.tsx`, `link2` is the error link used to simulate errors, so the existing test cases sufficiently cover error handling.
Learnt from: rawadhossain
Repo: PalisadoesFoundation/talawa-admin PR: 4882
File: src/screens/UserPortal/Volunteer/UpcomingEvents/RecurringEventVolunteerModal.spec.tsx:69-109
Timestamp: 2025-11-28T16:02:31.814Z
Learning: In Talawa Admin test files (e.g., src/screens/UserPortal/Volunteer/UpcomingEvents/RecurringEventVolunteerModal.spec.tsx), developers prefer keeping date/time mocks (like vi.spyOn(Date.prototype, 'toLocaleDateString')) inline within individual test cases rather than consolidating them in beforeEach blocks, to maintain clarity and keep mocks close to the tests that use them, even if it results in some duplication.
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4524
File: src/screens/Requests/Requests.spec.tsx:0-0
Timestamp: 2025-10-22T22:22:27.696Z
Learning: In talawa-admin tests using react-infinite-scroll-component (e.g., src/screens/Requests/Requests.spec.tsx), jsdom scroll is flaky. Prefer a resilient approach: try querying the container via document.querySelector('[data-testid="infinite-scroll-component"]') and fall back to window scroll if missing. Strengthen assertions by checking for page-2 items (e.g., "User9 Test") to ensure fetchMore actually ran instead of relying only on row counts.
Learnt from: syedali237
Repo: PalisadoesFoundation/talawa-admin PR: 3988
File: cypress/e2e/admin_spec/people.cy.ts:25-33
Timestamp: 2025-07-02T19:15:13.036Z
Learning: In the talawa-admin project, specifically in cypress/e2e/admin_spec/people.cy.ts, the user syedali237 intentionally designed the "add an existing member" and "delete a member" tests to work simultaneously with interdependencies, where the delete test relies on the add test having run first.
Learnt from: syedali237
Repo: PalisadoesFoundation/talawa-admin PR: 4077
File: package.json:189-213
Timestamp: 2025-08-17T07:39:34.255Z
Learning: The Talawa Admin codebase primarily uses .spec.tsx/.spec.ts naming convention for unit tests, with Cypress tests using .cy.ts pattern. However, there is at least one .test.tsx file in the codebase, so NYC exclude patterns should include both .spec and .test patterns.
📚 Learning: 2024-12-03T05:52:37.888Z
Learnt from: bitbard3
Repo: PalisadoesFoundation/talawa-admin PR: 2588
File: src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx:155-162
Timestamp: 2024-12-03T05:52:37.888Z
Learning: In the `ChangeLanguageDropdown` component (`src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.tsx`), error handling has not been implemented. Therefore, test cases in `src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx` do not cover error scenarios related to error handling.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-10-12T21:51:10.123Z
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4419
File: src/components/ProfileCard/ProfileCard.spec.tsx:112-131
Timestamp: 2025-10-12T21:51:10.123Z
Learning: In the ProfileCard component (`src/components/ProfileCard/ProfileCard.tsx`), when an image load error occurs, the component only sets the image's `display: 'none'` style and does not render the Avatar component with "dummy picture" alt text. The Avatar component is only rendered when `userImage` is falsy or equals 'null', not when the image fails to load.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-10-08T16:13:41.996Z
Learnt from: Chaitanya1672
Repo: PalisadoesFoundation/talawa-admin PR: 2049
File: src/screens/OrganizationActionItems/ActionItemUpdateModal.tsx:112-138
Timestamp: 2024-10-08T16:13:41.996Z
Learning: The `istanbul ignore next` comments in the `ActionItemUpdateModal.tsx` file were added as part of a commit that introduced tests for the `ActionItemUpdateModal` component. Removing these comments and writing tests to cover the previously ignored lines is recommended to ensure code integrity and improve test coverage.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-11-30T23:13:22.697Z
Learnt from: Ansingh0305
Repo: PalisadoesFoundation/talawa-admin PR: 0
File: :0-0
Timestamp: 2025-11-30T23:13:22.697Z
Learning: In talawa-admin PR #4908, increasing test concurrency from maxConcurrency: 1 to 6-12 with TOTAL_SHARDS: 12 exposed three critical latent bugs: (1) EventsAttendedByUser.spec.tsx used wrong GraphQL query mock (EVENT_DETAILS vs EVENT_DETAILS_BASIC with incorrect variable names), (2) User.mocks.ts missing search/reset refetch scenarios causing "No more mocked responses" errors, (3) EventCalendar.spec.tsx UTC timezone bug where new Date().toISOString() caused date calculation mismatches in non-UTC timezones. These bugs were masked at lower concurrency but surfaced consistently under parallel execution stress-testing. Fix involved aligning mocks with actual component queries and explicit timezone-aware date construction.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-10-22T22:00:53.943Z
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4524
File: src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts:0-0
Timestamp: 2025-10-22T22:00:53.943Z
Learning: In src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts (and similar mock files), avoid duplicating identical Apollo MockedProvider mocks for repeated query consumption. Prefer adding `maxUsageCount` to the existing mock or using `newData` for reusable responses to keep tests deterministic and reduce drift.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-11-02T07:48:36.443Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2398
File: src/components/AddPeopleToTag/AddPeopleToTag.test.tsx:177-241
Timestamp: 2024-11-02T07:48:36.443Z
Learning: In `src/components/AddPeopleToTag/AddPeopleToTag.test.tsx`, prefer keeping test cases separate and more readable, even if it involves some duplication, instead of extracting common logic into helper functions.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-04-27T10:59:45.144Z
Learnt from: MayankJha014
Repo: PalisadoesFoundation/talawa-admin PR: 3946
File: src/components/UserPortal/ChatRoom/ChatRoom.spec.tsx:5670-5693
Timestamp: 2025-04-27T10:59:45.144Z
Learning: When testing UI components that display user names, test for firstName and lastName separately rather than as a combined full name, as the UI might render these in separate DOM elements, making combined assertions brittle.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-09-29T06:51:31.295Z
Learnt from: Doraemon012
Repo: PalisadoesFoundation/talawa-admin PR: 1988
File: src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx:282-282
Timestamp: 2024-09-29T06:51:31.295Z
Learning: In the test 'Component should be rendered properly' within 'Testing LeftDrawerOrg component for SUPERADMIN', setting 'SuperAdmin' to false is intentional.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-11-21T12:42:24.884Z
Learnt from: palisadoes
Repo: PalisadoesFoundation/talawa-admin PR: 4718
File: src/components/EventManagement/Dashboard/EventDashboard.mocks.ts:83-114
Timestamp: 2025-11-21T12:42:24.884Z
Learning: In talawa-admin mock files (e.g., EventDashboard.mocks.ts), mock constant names must accurately reflect what they test. Mock names suggesting role-based logic (e.g., MOCKS_WITH_ADMIN_ROLE) are misleading when the component derives role from localStorage rather than mock data. Name mocks based on their distinguishing data features (e.g., MOCKS_WITH_SINGLE_ATTENDEE) or test context (e.g., MOCKS_FOR_ADMIN_STORAGE_TEST).

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-04-20T06:45:57.175Z
Learnt from: bandhan-majumder
Repo: PalisadoesFoundation/talawa-admin PR: 3926
File: src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx:403-421
Timestamp: 2025-04-20T06:45:57.175Z
Learning: In the talawa-admin project, the Advertisement component tests (3 files) use both ApolloProvider and MockedProvider together, though it's not a widespread pattern in the codebase. The maintainer has confirmed this approach is needed for these specific tests.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-10-30T12:01:40.366Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2387
File: src/screens/ManageTag/ManageTagMockComponents/MockAddPeopleToTag.tsx:1-28
Timestamp: 2024-10-30T12:01:40.366Z
Learning: In the `MockAddPeopleToTag` component in `src/screens/ManageTag/ManageTagMockComponents/MockAddPeopleToTag.tsx`, it's acceptable to implement only the necessary props from `InterfaceAddPeopleToTagProps` and omit others like `refetchAssignedMembersData`, `t`, and `tCommon` that are tested separately.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-11-24T19:35:45.258Z
Learnt from: aditya-bansal-7
Repo: PalisadoesFoundation/talawa-admin PR: 2459
File: src/screens/UserPortal/People/People.test.tsx:226-242
Timestamp: 2024-11-24T19:35:45.258Z
Learning: In the `People` component, roles are not displayed in the table, so tests related to role display should account for this.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-10-25T19:31:37.405Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2355
File: src/screens/ManageTag/ManageTagMocks.ts:187-269
Timestamp: 2024-10-25T19:31:37.405Z
Learning: In `src/screens/ManageTag/ManageTagMocks.ts`, when mocking data for `USER_TAGS_ASSIGNED_MEMBERS` and `USER_TAGS_MEMBERS_TO_ASSIGN_TO`, it's acceptable for user IDs to overlap because the queries serve different purposes and the overlapping IDs can represent realistic scenarios in tests.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-11-11T07:47:39.266Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2425
File: src/screens/MemberDetail/MemberDetail.test.tsx:100-100
Timestamp: 2024-11-11T07:47:39.266Z
Learning: In `src/screens/MemberDetail/MemberDetail.test.tsx`, using `await wait();` is acceptable to wait for the render to complete.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-03-11T17:45:54.621Z
Learnt from: PurnenduMIshra129th
Repo: PalisadoesFoundation/talawa-admin PR: 3814
File: src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx:137-146
Timestamp: 2025-03-11T17:45:54.621Z
Learning: In OrganizationNavbar.spec.tsx, separate vi.mock implementations for react-router-dom are needed to avoid errors - one for useNavigate and another for useParams.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-11-28T16:02:31.814Z
Learnt from: rawadhossain
Repo: PalisadoesFoundation/talawa-admin PR: 4882
File: src/screens/UserPortal/Volunteer/UpcomingEvents/RecurringEventVolunteerModal.spec.tsx:69-109
Timestamp: 2025-11-28T16:02:31.814Z
Learning: In Talawa Admin test files (e.g., src/screens/UserPortal/Volunteer/UpcomingEvents/RecurringEventVolunteerModal.spec.tsx), developers prefer keeping date/time mocks (like vi.spyOn(Date.prototype, 'toLocaleDateString')) inline within individual test cases rather than consolidating them in beforeEach blocks, to maintain clarity and keep mocks close to the tests that use them, even if it results in some duplication.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-10-28T06:38:43.765Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2362
File: src/components/TagActions/TagActions.test.tsx:123-131
Timestamp: 2024-10-28T06:38:43.765Z
Learning: In `TagActions.test.tsx`, `link2` is the error link used to simulate errors, so the existing test cases sufficiently cover error handling.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-10-22T22:22:27.696Z
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4524
File: src/screens/Requests/Requests.spec.tsx:0-0
Timestamp: 2025-10-22T22:22:27.696Z
Learning: In talawa-admin tests using react-infinite-scroll-component (e.g., src/screens/Requests/Requests.spec.tsx), jsdom scroll is flaky. Prefer a resilient approach: try querying the container via document.querySelector('[data-testid="infinite-scroll-component"]') and fall back to window scroll if missing. Strengthen assertions by checking for page-2 items (e.g., "User9 Test") to ensure fetchMore actually ran instead of relying only on row counts.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-01-15T05:39:30.480Z
Learnt from: arpit-chakraborty
Repo: PalisadoesFoundation/talawa-admin PR: 3158
File: src/screens/OrganizationTags/OrganizationTagsMocks.ts:384-524
Timestamp: 2025-01-15T05:39:30.480Z
Learning: In OrganizationTagsMocks.ts, MOCKS_NULL_END_CURSOR and MOCKS_NO_MORE_PAGES are designed to test UI handling of edge cases where pagination data is inconsistent (e.g., hasNextPage is true but endCursor is null, or next page returns undefined data).

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
🧬 Code graph analysis (1)
src/components/ProfileDropdown/ProfileDropdown.spec.tsx (4)
src/utils/useLocalstorage.ts (1)
  • setItem (41-44)
src/components/MemberActivity/MemberActivityMocks.ts (1)
  • errorMocks (73-81)
src/GraphQl/Mutations/mutations.ts (1)
  • REVOKE_REFRESH_TOKEN (247-251)
src/GraphQl/Queries/Queries.ts (1)
  • GET_COMMUNITY_SESSION_TIMEOUT_DATA_PG (1154-1160)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Check Python Code Style
  • GitHub Check: Generate and Validate Documentation
  • GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (4)
src/components/ProfileDropdown/ProfileDropdown.spec.tsx (4)

120-137: LGTM!

This test correctly verifies that the Avatar fallback component renders when no UserImage is set in localStorage. The approach aligns with established patterns for testing image fallback behavior.


139-156: LGTM!

This test properly covers the edge case where UserImage is the string 'null' rather than an actual null value, ensuring the Avatar fallback is rendered correctly.


328-363: Verify no duplicate exists for this error handling test.

The test logic correctly verifies error handling when token revocation fails during logout, with proper console.error spy setup and restoration. However, the provided context indicates a potential duplicate may exist elsewhere in the file. This requires manual verification in the full test file to confirm no redundant error-handling test for the same scenario is present.


1-364: Manual verification required: 100% coverage goal and istanbul ignore directives.

The automated repository access failed, preventing verification of:

  1. Whether /* istanbul ignore */ comments remain in ProfileDropdown.tsx and if they are justified
  2. Confirmation that 100% code coverage for the component has been achieved

Please manually verify these items against the acceptance criteria in issue #3650. The test suite provided appears comprehensive, but confirmation of coverage metrics and removal of any coverage-ignore directives is necessary to complete this review.

@rohit746 rohit746 force-pushed the test/profile-dropdown-coverage branch from dd11dbd to 0fc945c Compare December 4, 2025 07:51
Copy link
Contributor

@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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd11dbd and 0fc945c.

📒 Files selected for processing (1)
  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx (2 hunks)
🧰 Additional context used
🧠 Learnings (21)
📓 Common learnings
Learnt from: Chaitanya1672
Repo: PalisadoesFoundation/talawa-admin PR: 2049
File: src/screens/OrganizationActionItems/ActionItemUpdateModal.tsx:112-138
Timestamp: 2024-10-08T16:13:41.996Z
Learning: The `istanbul ignore next` comments in the `ActionItemUpdateModal.tsx` file were added as part of a commit that introduced tests for the `ActionItemUpdateModal` component. Removing these comments and writing tests to cover the previously ignored lines is recommended to ensure code integrity and improve test coverage.
Learnt from: Ansingh0305
Repo: PalisadoesFoundation/talawa-admin PR: 0
File: :0-0
Timestamp: 2025-11-30T23:13:22.697Z
Learning: In talawa-admin PR #4908, increasing test concurrency from maxConcurrency: 1 to 6-12 with TOTAL_SHARDS: 12 exposed three critical latent bugs: (1) EventsAttendedByUser.spec.tsx used wrong GraphQL query mock (EVENT_DETAILS vs EVENT_DETAILS_BASIC with incorrect variable names), (2) User.mocks.ts missing search/reset refetch scenarios causing "No more mocked responses" errors, (3) EventCalendar.spec.tsx UTC timezone bug where new Date().toISOString() caused date calculation mismatches in non-UTC timezones. These bugs were masked at lower concurrency but surfaced consistently under parallel execution stress-testing. Fix involved aligning mocks with actual component queries and explicit timezone-aware date construction.
Learnt from: bitbard3
Repo: PalisadoesFoundation/talawa-admin PR: 2588
File: src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx:155-162
Timestamp: 2024-12-03T05:52:37.888Z
Learning: In the `ChangeLanguageDropdown` component (`src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.tsx`), error handling has not been implemented. Therefore, test cases in `src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx` do not cover error scenarios related to error handling.
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4419
File: src/components/ProfileCard/ProfileCard.spec.tsx:112-131
Timestamp: 2025-10-12T21:51:10.123Z
Learning: In the ProfileCard component (`src/components/ProfileCard/ProfileCard.tsx`), when an image load error occurs, the component only sets the image's `display: 'none'` style and does not render the Avatar component with "dummy picture" alt text. The Avatar component is only rendered when `userImage` is falsy or equals 'null', not when the image fails to load.
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2398
File: src/components/AddPeopleToTag/AddPeopleToTag.test.tsx:177-241
Timestamp: 2024-11-02T07:48:36.443Z
Learning: In `src/components/AddPeopleToTag/AddPeopleToTag.test.tsx`, prefer keeping test cases separate and more readable, even if it involves some duplication, instead of extracting common logic into helper functions.
Learnt from: syedali237
Repo: PalisadoesFoundation/talawa-admin PR: 3988
File: cypress/e2e/admin_spec/people.cy.ts:25-33
Timestamp: 2025-07-02T19:15:13.036Z
Learning: In the talawa-admin project, specifically in cypress/e2e/admin_spec/people.cy.ts, the user syedali237 intentionally designed the "add an existing member" and "delete a member" tests to work simultaneously with interdependencies, where the delete test relies on the add test having run first.
Learnt from: rawadhossain
Repo: PalisadoesFoundation/talawa-admin PR: 4882
File: src/screens/UserPortal/Volunteer/UpcomingEvents/RecurringEventVolunteerModal.spec.tsx:69-109
Timestamp: 2025-11-28T16:02:31.814Z
Learning: In Talawa Admin test files (e.g., src/screens/UserPortal/Volunteer/UpcomingEvents/RecurringEventVolunteerModal.spec.tsx), developers prefer keeping date/time mocks (like vi.spyOn(Date.prototype, 'toLocaleDateString')) inline within individual test cases rather than consolidating them in beforeEach blocks, to maintain clarity and keep mocks close to the tests that use them, even if it results in some duplication.
Learnt from: MayankJha014
Repo: PalisadoesFoundation/talawa-admin PR: 3946
File: src/components/UserPortal/ChatRoom/ChatRoom.spec.tsx:5670-5693
Timestamp: 2025-04-27T10:59:45.144Z
Learning: When testing UI components that display user names, test for firstName and lastName separately rather than as a combined full name, as the UI might render these in separate DOM elements, making combined assertions brittle.
Learnt from: syedali237
Repo: PalisadoesFoundation/talawa-admin PR: 4077
File: package.json:189-213
Timestamp: 2025-08-17T07:39:34.255Z
Learning: The Talawa Admin codebase primarily uses .spec.tsx/.spec.ts naming convention for unit tests, with Cypress tests using .cy.ts pattern. However, there is at least one .test.tsx file in the codebase, so NYC exclude patterns should include both .spec and .test patterns.
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4524
File: src/screens/Requests/Requests.spec.tsx:0-0
Timestamp: 2025-10-22T22:22:27.696Z
Learning: In talawa-admin tests using react-infinite-scroll-component (e.g., src/screens/Requests/Requests.spec.tsx), jsdom scroll is flaky. Prefer a resilient approach: try querying the container via document.querySelector('[data-testid="infinite-scroll-component"]') and fall back to window scroll if missing. Strengthen assertions by checking for page-2 items (e.g., "User9 Test") to ensure fetchMore actually ran instead of relying only on row counts.
📚 Learning: 2024-12-03T05:52:37.888Z
Learnt from: bitbard3
Repo: PalisadoesFoundation/talawa-admin PR: 2588
File: src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx:155-162
Timestamp: 2024-12-03T05:52:37.888Z
Learning: In the `ChangeLanguageDropdown` component (`src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.tsx`), error handling has not been implemented. Therefore, test cases in `src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.spec.tsx` do not cover error scenarios related to error handling.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-10-12T21:51:10.123Z
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4419
File: src/components/ProfileCard/ProfileCard.spec.tsx:112-131
Timestamp: 2025-10-12T21:51:10.123Z
Learning: In the ProfileCard component (`src/components/ProfileCard/ProfileCard.tsx`), when an image load error occurs, the component only sets the image's `display: 'none'` style and does not render the Avatar component with "dummy picture" alt text. The Avatar component is only rendered when `userImage` is falsy or equals 'null', not when the image fails to load.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-10-08T16:13:41.996Z
Learnt from: Chaitanya1672
Repo: PalisadoesFoundation/talawa-admin PR: 2049
File: src/screens/OrganizationActionItems/ActionItemUpdateModal.tsx:112-138
Timestamp: 2024-10-08T16:13:41.996Z
Learning: The `istanbul ignore next` comments in the `ActionItemUpdateModal.tsx` file were added as part of a commit that introduced tests for the `ActionItemUpdateModal` component. Removing these comments and writing tests to cover the previously ignored lines is recommended to ensure code integrity and improve test coverage.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-11-30T23:13:22.697Z
Learnt from: Ansingh0305
Repo: PalisadoesFoundation/talawa-admin PR: 0
File: :0-0
Timestamp: 2025-11-30T23:13:22.697Z
Learning: In talawa-admin PR #4908, increasing test concurrency from maxConcurrency: 1 to 6-12 with TOTAL_SHARDS: 12 exposed three critical latent bugs: (1) EventsAttendedByUser.spec.tsx used wrong GraphQL query mock (EVENT_DETAILS vs EVENT_DETAILS_BASIC with incorrect variable names), (2) User.mocks.ts missing search/reset refetch scenarios causing "No more mocked responses" errors, (3) EventCalendar.spec.tsx UTC timezone bug where new Date().toISOString() caused date calculation mismatches in non-UTC timezones. These bugs were masked at lower concurrency but surfaced consistently under parallel execution stress-testing. Fix involved aligning mocks with actual component queries and explicit timezone-aware date construction.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-10-22T22:00:53.943Z
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4524
File: src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts:0-0
Timestamp: 2025-10-22T22:00:53.943Z
Learning: In src/screens/OrganizationDashboard/OrganizationDashboardMocks.ts (and similar mock files), avoid duplicating identical Apollo MockedProvider mocks for repeated query consumption. Prefer adding `maxUsageCount` to the existing mock or using `newData` for reusable responses to keep tests deterministic and reduce drift.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-11-02T07:48:36.443Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2398
File: src/components/AddPeopleToTag/AddPeopleToTag.test.tsx:177-241
Timestamp: 2024-11-02T07:48:36.443Z
Learning: In `src/components/AddPeopleToTag/AddPeopleToTag.test.tsx`, prefer keeping test cases separate and more readable, even if it involves some duplication, instead of extracting common logic into helper functions.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-10-22T22:22:27.696Z
Learnt from: Jashan32
Repo: PalisadoesFoundation/talawa-admin PR: 4524
File: src/screens/Requests/Requests.spec.tsx:0-0
Timestamp: 2025-10-22T22:22:27.696Z
Learning: In talawa-admin tests using react-infinite-scroll-component (e.g., src/screens/Requests/Requests.spec.tsx), jsdom scroll is flaky. Prefer a resilient approach: try querying the container via document.querySelector('[data-testid="infinite-scroll-component"]') and fall back to window scroll if missing. Strengthen assertions by checking for page-2 items (e.g., "User9 Test") to ensure fetchMore actually ran instead of relying only on row counts.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-04-27T10:59:45.144Z
Learnt from: MayankJha014
Repo: PalisadoesFoundation/talawa-admin PR: 3946
File: src/components/UserPortal/ChatRoom/ChatRoom.spec.tsx:5670-5693
Timestamp: 2025-04-27T10:59:45.144Z
Learning: When testing UI components that display user names, test for firstName and lastName separately rather than as a combined full name, as the UI might render these in separate DOM elements, making combined assertions brittle.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-11-28T18:25:57.426Z
Learnt from: krikera
Repo: PalisadoesFoundation/talawa-admin PR: 4887
File: src/components/LoginPortalToggle/LoginPortalToggle.spec.tsx:57-59
Timestamp: 2025-11-28T18:25:57.426Z
Learning: In talawa-admin tests, when testing CSS module class names (imported as `styles from '*.module.css'`), prefer importing the styles module and using `toHaveClass(styles.className)` over `className.toContain('className')`. Vite hashes CSS module class names (e.g., activeLink → _activeLink_d8535b), so `toHaveClass('activeLink')` with plain strings will fail. The styles import approach is semantic, type-safe, and matches patterns in SideToggle.spec.tsx. Alternatively, `className.toContain()` is acceptable for substring matching without imports.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-10-30T12:01:40.366Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2387
File: src/screens/ManageTag/ManageTagMockComponents/MockAddPeopleToTag.tsx:1-28
Timestamp: 2024-10-30T12:01:40.366Z
Learning: In the `MockAddPeopleToTag` component in `src/screens/ManageTag/ManageTagMockComponents/MockAddPeopleToTag.tsx`, it's acceptable to implement only the necessary props from `InterfaceAddPeopleToTagProps` and omit others like `refetchAssignedMembersData`, `t`, and `tCommon` that are tested separately.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-11-28T16:02:31.814Z
Learnt from: rawadhossain
Repo: PalisadoesFoundation/talawa-admin PR: 4882
File: src/screens/UserPortal/Volunteer/UpcomingEvents/RecurringEventVolunteerModal.spec.tsx:69-109
Timestamp: 2025-11-28T16:02:31.814Z
Learning: In Talawa Admin test files (e.g., src/screens/UserPortal/Volunteer/UpcomingEvents/RecurringEventVolunteerModal.spec.tsx), developers prefer keeping date/time mocks (like vi.spyOn(Date.prototype, 'toLocaleDateString')) inline within individual test cases rather than consolidating them in beforeEach blocks, to maintain clarity and keep mocks close to the tests that use them, even if it results in some duplication.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-09-29T06:51:31.295Z
Learnt from: Doraemon012
Repo: PalisadoesFoundation/talawa-admin PR: 1988
File: src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx:282-282
Timestamp: 2024-09-29T06:51:31.295Z
Learning: In the test 'Component should be rendered properly' within 'Testing LeftDrawerOrg component for SUPERADMIN', setting 'SuperAdmin' to false is intentional.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-11-21T12:42:24.884Z
Learnt from: palisadoes
Repo: PalisadoesFoundation/talawa-admin PR: 4718
File: src/components/EventManagement/Dashboard/EventDashboard.mocks.ts:83-114
Timestamp: 2025-11-21T12:42:24.884Z
Learning: In talawa-admin mock files (e.g., EventDashboard.mocks.ts), mock constant names must accurately reflect what they test. Mock names suggesting role-based logic (e.g., MOCKS_WITH_ADMIN_ROLE) are misleading when the component derives role from localStorage rather than mock data. Name mocks based on their distinguishing data features (e.g., MOCKS_WITH_SINGLE_ATTENDEE) or test context (e.g., MOCKS_FOR_ADMIN_STORAGE_TEST).

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-04-20T06:45:57.175Z
Learnt from: bandhan-majumder
Repo: PalisadoesFoundation/talawa-admin PR: 3926
File: src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.spec.tsx:403-421
Timestamp: 2025-04-20T06:45:57.175Z
Learning: In the talawa-admin project, the Advertisement component tests (3 files) use both ApolloProvider and MockedProvider together, though it's not a widespread pattern in the codebase. The maintainer has confirmed this approach is needed for these specific tests.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-11-24T19:35:45.258Z
Learnt from: aditya-bansal-7
Repo: PalisadoesFoundation/talawa-admin PR: 2459
File: src/screens/UserPortal/People/People.test.tsx:226-242
Timestamp: 2024-11-24T19:35:45.258Z
Learning: In the `People` component, roles are not displayed in the table, so tests related to role display should account for this.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-10-25T19:31:37.405Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2355
File: src/screens/ManageTag/ManageTagMocks.ts:187-269
Timestamp: 2024-10-25T19:31:37.405Z
Learning: In `src/screens/ManageTag/ManageTagMocks.ts`, when mocking data for `USER_TAGS_ASSIGNED_MEMBERS` and `USER_TAGS_MEMBERS_TO_ASSIGN_TO`, it's acceptable for user IDs to overlap because the queries serve different purposes and the overlapping IDs can represent realistic scenarios in tests.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-11-11T07:47:39.266Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2425
File: src/screens/MemberDetail/MemberDetail.test.tsx:100-100
Timestamp: 2024-11-11T07:47:39.266Z
Learning: In `src/screens/MemberDetail/MemberDetail.test.tsx`, using `await wait();` is acceptable to wait for the render to complete.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-03-11T17:45:54.621Z
Learnt from: PurnenduMIshra129th
Repo: PalisadoesFoundation/talawa-admin PR: 3814
File: src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.spec.tsx:137-146
Timestamp: 2025-03-11T17:45:54.621Z
Learning: In OrganizationNavbar.spec.tsx, separate vi.mock implementations for react-router-dom are needed to avoid errors - one for useNavigate and another for useParams.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2024-10-28T06:38:43.765Z
Learnt from: meetulr
Repo: PalisadoesFoundation/talawa-admin PR: 2362
File: src/components/TagActions/TagActions.test.tsx:123-131
Timestamp: 2024-10-28T06:38:43.765Z
Learning: In `TagActions.test.tsx`, `link2` is the error link used to simulate errors, so the existing test cases sufficiently cover error handling.

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
📚 Learning: 2025-01-15T05:39:30.480Z
Learnt from: arpit-chakraborty
Repo: PalisadoesFoundation/talawa-admin PR: 3158
File: src/screens/OrganizationTags/OrganizationTagsMocks.ts:384-524
Timestamp: 2025-01-15T05:39:30.480Z
Learning: In OrganizationTagsMocks.ts, MOCKS_NULL_END_CURSOR and MOCKS_NO_MORE_PAGES are designed to test UI handling of edge cases where pagination data is inconsistent (e.g., hasNextPage is true but endCursor is null, or next page returns undefined data).

Applied to files:

  • src/components/ProfileDropdown/ProfileDropdown.spec.tsx
🧬 Code graph analysis (1)
src/components/ProfileDropdown/ProfileDropdown.spec.tsx (3)
src/utils/useLocalstorage.ts (1)
  • setItem (41-44)
src/GraphQl/Mutations/mutations.ts (1)
  • REVOKE_REFRESH_TOKEN (247-251)
src/GraphQl/Queries/Queries.ts (1)
  • GET_COMMUNITY_SESSION_TIMEOUT_DATA_PG (1154-1160)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Check Python Code Style
  • GitHub Check: Generate and Validate Documentation
  • GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (2)
src/components/ProfileDropdown/ProfileDropdown.spec.tsx (2)

119-155: LGTM! Avatar fallback tests cover the correct scenarios.

Both tests appropriately verify the Avatar component renders when:

  1. UserImage is not set in localStorage (falsy case)
  2. UserImage is explicitly set to the string 'null'

These align with the component's documented behavior and provide good coverage for the fallback rendering logic.

Based on learnings, the Avatar component is specifically rendered when userImage is falsy or equals the string 'null', which these tests correctly verify.


327-362: Verify logout completion when revokeRefreshToken fails.

The test correctly logs errors but doesn't verify whether logout proceeds. Based on standard logout patterns, logout should complete despite token revocation failures to ensure users can always log out locally. Consider verifying:

  • localStorage is cleared (following the pattern of clearing both client-side storage and server-side sessions)
  • Navigation to '/' occurs
  • User is fully logged out
 expect(consoleSpy).toHaveBeenCalledWith(
   'Error revoking refresh token:',
   expect.any(Error),
 );
+
+// Verify logout completes despite error
+await waitFor(() => {
+  expect(window.location.pathname).toBe('/');
+});

- Add test for revokeRefreshToken error handling during logout
- Add test for long name truncation (>20 chars)
- Add tests for Avatar fallback when no user image available
- Add test for user image as 'null' string edge case

Fixes PalisadoesFoundation#3650
@rohit746 rohit746 force-pushed the test/profile-dropdown-coverage branch from 0fc945c to 1b3102a Compare December 4, 2025 07:58
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.

1 participant