Context
Interactive hit-detection tests (like Interaction.test.tsx) currently use hardcoded clientX and clientY coordinates to simulate user interaction.
The Problem
- Coordinates are derived from global layout constants (e.g.,
lineHeight, baseY, TOP_OFFSET).
- When these constants change (as
MEASURE_HIT_AREA_TOP_OFFSET recently did from 50 to 56), the tests break even if the logic is correct.
- This creates high maintenance overhead for layout-related refactors.
Proposed Improvement
- Move toward a more robust hit-detection testing strategy.
- Options:
- Calculate coordinates in the test based on the same constants used in production.
- Use relative offsets within the hit area (e.g., 'middle of the staff', 'top ledger line').
- Find specific visual elements (staff lines) and offset from them.
Related Files
src/__tests__/Interaction.test.tsx
src/components/Canvas/Measure.tsx
src/constants.ts
Context
Interactive hit-detection tests (like
Interaction.test.tsx) currently use hardcodedclientXandclientYcoordinates to simulate user interaction.The Problem
lineHeight,baseY,TOP_OFFSET).MEASURE_HIT_AREA_TOP_OFFSETrecently did from 50 to 56), the tests break even if the logic is correct.Proposed Improvement
Related Files
src/__tests__/Interaction.test.tsxsrc/components/Canvas/Measure.tsxsrc/constants.ts