Skip to content

test(screens): add comprehensive SubmitProofScreen test coverage (#81) - #114

Open
Abdul-dev-creator wants to merge 1 commit into
ecotask-network:mainfrom
Abdul-dev-creator:fix/issue-81-submitproofscreen-tests
Open

test(screens): add comprehensive SubmitProofScreen test coverage (#81)#114
Abdul-dev-creator wants to merge 1 commit into
ecotask-network:mainfrom
Abdul-dev-creator:fix/issue-81-submitproofscreen-tests

Conversation

@Abdul-dev-creator

Copy link
Copy Markdown

Overview

This PR adds a comprehensive test suite for src/screens/SubmitProofScreen.tsx — the most complex screen in the app, which previously had zero test coverage. The suite locks in the core value loop (task → proof → reward): camera permission handling, photo capture and preview, proof submission with activity creation and stat updates, offline queueing, retake reset, empty state, and location display/errors.

Related Issue

Closes #81

Changes

🧪 SubmitProofScreen Test Suite (18 test cases)

  • [ADD] src/__tests__/SubmitProofScreen.test.tsx
  • Covers the full camera capture flow: permission prompt → grant → capture → preview.
  • Verifies successful submission creates a pending activity, updates user stats (treesPlanted, co2Reduced), starts proof-status polling with the correct activity context, and defers the notification until polling confirms.
  • Verifies submission without a proofId confirms the activity immediately and fires the reward local notification with deep link payload.
  • Covers offline/failed submission: activity queued as pending with error surfaced in the UI.
  • Covers retake flow: preview cleared, state reset back to capture mode.
  • Covers empty state when no taskId is provided in route params.
  • Covers location loading placeholder and location error display.
  • Covers progress labels (Uploading..., Verifying..., failed, confirmed) and disabled button states while submitting.
  • Covers capture failure alerting and header back navigation.

🔧 Mocking Infrastructure

  • [ADD] Mocks for react-native-vision-camera (useCameraPermission, useCameraDevice, Camera.takePhoto), @react-navigation/native, useLocation, useProofSubmit, useProofStatus, and scheduleLocalNotification.
  • Uses deferred mock references inside jest.mock factories so hoisted factories never capture uninitialized bindings.

Screenshots / Verification

npm run lint ✅ completed (existing repo warnings only)
npm run typecheck ✅ passed
npx tsc --noEmit ✅ passed
npm test ✅ passed (34 suites / 303 tests, incl. 18 new SubmitProofScreen tests)

@cybermax4200 cybermax4200 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ci checks are failing please fix them

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 SubmitProofScreen — the core proof submission flow

2 participants