AllenInstitute / biofile-finder

An open-use web application created for easy access, collaboration, and sharing of datasets through rich metadata search, filter, sort, and direct viewing in common industry applications or in our web-based 3D Volume Viewer.
https://biofile-finder.allencell.org/
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Fix stalled thumbnail unit tests #302

Closed aswallace closed 1 month ago

aswallace commented 1 month ago

The unit tests for LazilyRenderedThumbnail were getting stalled. It seems the .useEffect was creating an infinite loop, which is apparently a common issue with React/jest.

I'm still not sure if I fully understand, but my best interpretation is that useEffect is dependent on file changes, & calling setThumbnailPath technically modifies file, so the effect runs again. Then toggling isLoading back to true triggers a re-render since the FileThumbnail component depends on isLoading, which calls useEffect again, and the loop starts all over... So our unit tests never fully finished rendering the component.

Proposed change

Since we already initialize isLoading to true and don't set it to false anywhere else, we can remove setting it to true in the effect. This way, useEffect only calls twice (once on initialization, and then once to register the change to file) and then stops.

There's also an unrelated .css change; I missed increasing the font size for thumbnail labels in #287.

Testing/Reviewing

I verified that unit tests run & finish now, but it would be great to double check that the thumbnail loading state still works as expected.