Skip to content

Add unit tests and avatar null-guard to UserProfileDropdown #175

Description

@Jagadeeshftw

📌 Description

UserProfileDropdown (src/shared/components/UserProfileDropdown.tsx) assumes user.github?.avatar_url exists, hardcodes navigation paths, and has no tests. A missing avatar or long username can break the UI.

💡 Why it matters: The account menu is shown app-wide and must handle missing avatars gracefully.

🧩 Requirements and context

  • Add a fallback when avatar_url is missing (initials/placeholder).
  • Add title for truncated usernames.
  • Add tests for authenticated vs unauthenticated (Sign In) rendering and menu actions.
  • Extract hardcoded paths into shared route constants where practical.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b test/userprofiledropdown

2. Implement changes

  • Write/modify the relevant source: src/shared/components/UserProfileDropdown.tsx
  • Write comprehensive tests: src/shared/components/UserProfileDropdown.test.tsx
  • Add documentation: inline TSDoc
  • Include TSDoc doc comments
  • Validate security assumptions: n/a

3. Test and commit

  • Run tests:
npm run test
  • Cover edge cases: missing avatar, long username, signed out
  • Include test output and security notes in the PR description.

Example commit message

test(userprofile): coverage + avatar fallback

✅ Acceptance criteria

  • Missing avatar renders a fallback
  • Long usernames get a title tooltip
  • Tests cover signed-in/out + actions

🔒 Security notes

None.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issuebugSomething isn't workingfrontendFrontend / UI worktestingTests and coverage

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions