Skip to content

Add React Testing Library and PhotoViewer component/hook tests #24

Description

@kulcsarrudolf

Problem

The test suite currently consists of two pure utility test files (src/utils/photo-viewer/__tests__/transformUtils.test.ts and gestureUtils.test.ts).
There are zero component or hook tests, React Testing Library is not installed, and Jest runs with --passWithNoTests.
PhotoViewer was recently refactored into 9 hooks and several sub-components (#7, PR #13), which makes it very testable, but nothing locks in its behavior.

Proposed change

  1. Add dev dependencies: @testing-library/react, @testing-library/user-event, @testing-library/jest-dom.
    These are dev-only, so the zero-runtime-dependency guarantee is unaffected.
  2. Add a jest setup file wiring in @testing-library/jest-dom.
  3. Write PhotoViewer tests covering at least:
    • Opens with the expected image and closes via the close control and the Escape key.
    • Next/previous navigation updates the displayed image, including wrap-around behavior.
    • Keyboard shortcuts from useKeyboardShortcuts (arrow keys, Escape, zoom keys if any).
    • Zoom interaction updates the transform (integration with useTransform / useWheelZoom).
    • Image preloading behavior from useImagePreloader (adjacent images requested).

MediaGrid and ImageCarousel tests are tracked as separate follow-up issues so this one stays reviewable.

Acceptance criteria

  • RTL infrastructure in place and documented in CONTRIBUTING.md.
  • PhotoViewer interaction tests passing in CI.
  • --passWithNoTests removed from the test script.

Compatibility

Dev dependencies and tests only.
No runtime or API changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions