PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

test: Add unit test coverage for imageFallback utility

Open Saksham-official opened this issue 2 weeks ago • 3 comments

Describe the feature

The frontend/src/utils/imageFallback.ts utility centralizes error handling for <img> tags across media and memories components to prevent infinite fallback error loops. While other utilities in frontend/src/utils/ have test suites in __tests__/, imageFallback.ts currently has no test coverage.

Proposed Solution

Add a dedicated unit test suite at frontend/src/utils/__tests__/imageFallback.test.ts covering:

  • Default fallback: verifying createImageErrorHandler() swaps img.src to PLACEHOLDER_IMAGE_SRC.
  • Custom fallback: verifying custom placeholder strings when provided to createImageErrorHandler(customSrc).
  • Loop prevention: verifying that img.onerror is set to null upon error to detach the listener and prevent infinite retry loops.
  • Shared handler: verifying the exported handlePlaceholderImageError singleton.

I have already implemented and verified this test suite locally (5 tests passing, TypeScript typecheck passing, and ESLint / Prettier clean).

Could you please assign this to me so I can open the PR?

Record

  • [x] I agree to follow this project's Code of Conduct
  • [x] I want to work on this issue

Saksham-official avatar Nov 17 '26 14:11 Saksham-official

👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)

Discussions are carried on Discord.

Instead of commenting here, join the AOSSIE Discord server and go to Projects → PictoPy.

If you find this project useful, a GitHub star would be appreciated.

github-actions[bot] avatar Nov 17 '26 14:11 github-actions[bot]

@rohan-pandeyy i want to work on this issue can i get assigned to it?

swastiksharma45 avatar Nov 18 '26 11:11 swastiksharma45

@swastiksharma45 Hi! As noted in the issue description, I discovered this gap, opened the issue, and already have the test suite implemented and verified locally. Waiting on @rohan-pandeyy's confirmation to open the PR.

Saksham-official avatar Nov 18 '26 17:11 Saksham-official