Skip to content

Qr code scanner permissions error boundary#221

Merged
johdanike merged 2 commits into
SwiftChainn:mainfrom
GiftedGiftB:QRCodeScannerPermissionsErrorBoundary
Jul 1, 2026
Merged

Qr code scanner permissions error boundary#221
johdanike merged 2 commits into
SwiftChainn:mainfrom
GiftedGiftB:QRCodeScannerPermissionsErrorBoundary

Conversation

@GiftedGiftB

Copy link
Copy Markdown
Contributor

Closes #155

This PR introduces robust error handling and interaction tests for the Driver QR Code Scanner, specifically targeting the scenario where a user denies camera permissions. The implementation strictly follows the Component -> Hook -> Service layered architecture, ensuring separation of concerns and maintainability.

📋 Summary of Work Done

  • Component Layer (QrScanner.tsx): Built the QR scanner UI with an explicit error boundary fallback that clearly directs drivers to their browser settings if camera permissions are denied.
  • Hook Layer (useQrScanner.ts): Implemented the camera stream initialization logic, properly catching NotAllowedError and PermissionDeniedError exceptions to surface meaningful error states.
  • Service Layer (qrScannerService.ts): Created a mock API service layer for verifying QR data, adhering to the requirement for externalized response data.
  • Testing (QrScanner.test.tsx): Wrote rigorous unit tests utilizing Jest and React Testing Library to mock navigator.mediaDevices.getUserMedia. Verified that the fallback UI correctly renders upon a rejected promise.
  • Mock Data (qrScannerMockData.ts): Extracted mock responses to prevent the use of inline mock objects within the test assertions.

✅ Acceptance Criteria Met

  • Renders 'Camera Permission Denied' fallback UI when the mock API rejects the promise.
  • Strict Layered Architecture utilized (Component -> Hook -> Service).
  • Response data retrieved from backend API (via mock data file) with No Inline Mock Objects.
  • All unit tests are passing successfully.

📸 Screenshots

(Please drag and drop the screenshot of your terminal showing the passing pnpm test execution here before submitting)

🧪 How to Test

  1. Pull this branch: git checkout QRCodeScannerPermissionsErrorBoundary
  2. Run the test suite: pnpm test -- __tests__/components/logistics/QrScanner.test.tsx
  3. Verify that all test cases pass without any console errors.

@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@GiftedGiftB Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@johdanike johdanike merged commit ca1496c into SwiftChainn:main Jul 1, 2026
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.

Test: QR Code Scanner Permissions & Error Boundary

2 participants