Skip to content

test(profile): add coverage for ProfileScreen and EditProfileScreen - #154

Merged
cybermax4200 merged 1 commit into
ecotask-network:mainfrom
devOgazi:test/profile-editprofile-coverage
Aug 29, 2026
Merged

test(profile): add coverage for ProfileScreen and EditProfileScreen#154
cybermax4200 merged 1 commit into
ecotask-network:mainfrom
devOgazi:test/profile-editprofile-coverage

Conversation

@devOgazi

Copy link
Copy Markdown
Contributor

Summary

Closes #145

Adds the missing test suites for the two profile screens — ProfileScreen (the primary impact-dashboard UX surface) and EditProfileScreen (the only path to update name/bio via api.updateProfile).

What's covered

ProfileScreen.test.tsx (9 tests)

  • Renders the profile name, truncated wallet address (truncatePublicKey), and bio from userStore.profile.
  • Renders ImpactStats and AchievementGrid driven by userStore.profile.stats (the previously-untested integration), verifying stat values (12 trees, 30kg plastic, 500kg CO₂) and the achievements header flow through.
  • Atomic disconnect: pressing Disconnect & Sign Out calls useStellarWallet().disconnectWallet() and useUserStore().logout() (clears walletStore and useUserStore() — both stores end up cleared.
  • Navigation to EditProfile and NotificationPreferences.
  • Empty state ("No profile") when the wallet is not connected.

EditProfileScreen.test.tsx (9 tests)

  • Inputs initialize from the current profile and update local state.
  • Save calls mocked api.updateProfile with the trimmed payload; bio is omitted when blank.
  • Success updates userStore.profile and navigates back.
  • API failure shows the Save Failed alert and leaves the profile unchanged.
  • Blocks save with an Error alert when the name is empty; Cancel navigates back.

Approach

  • Uses the real userStore/walletStore (via the existing __mocks__/setup MMKV/zustand shim) so the disconnect/logout "both stores cleared" assertion is genuine.
  • useStellarWallet, useNotificationPreferences, and services/api are mocked.
  • Avatar upload and the no-op Language/About rows are intentionally out of scope (not yet implemented).

Verification

  • npm test → 432/432 passing (47 suites).
  • npm run lint → 0 errors on the new files (warnings match the existing test suite style).

Add ProfileScreen.test.tsx and EditProfileScreen.test.tsx to cover
profile display (name, wallet address, ImpactStats, AchievementGrid),
atomic disconnect/logout that clears both stores, settings navigation,
and edit persistence through api.updateProfile (success, empty-name
guard, and API-failure error state).

Closes ecotask-network#145
@devOgazi
devOgazi force-pushed the test/profile-editprofile-coverage branch from 75373a1 to e839155 Compare August 29, 2026 02:07
@cybermax4200
cybermax4200 merged commit 9068ce2 into ecotask-network:main Aug 29, 2026
4 checks passed
@devOgazi
devOgazi deleted the test/profile-editprofile-coverage branch August 29, 2026 02:25
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.

[Testing] Zero test coverage for ProfileScreen and EditProfileScreen — profile display, stats, achievement unlock, and edit persistence

2 participants