From 8839c21c3a2f8c23f8415905deccd201f5ab3919 Mon Sep 17 00:00:00 2001 From: sepeterson <10458078+sepeterson@users.noreply.github.com> Date: Thu, 18 Dec 2025 10:20:26 -0600 Subject: [PATCH] MOB-722: photo section test fixes --- .../components/Match/PhotosSection.test.js | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/tests/unit/components/Match/PhotosSection.test.js b/tests/unit/components/Match/PhotosSection.test.js index e481c7503..14f79bea4 100644 --- a/tests/unit/components/Match/PhotosSection.test.js +++ b/tests/unit/components/Match/PhotosSection.test.js @@ -8,7 +8,7 @@ describe( "PhotosSection", () => { const mockNavToTaxonDetails = jest.fn(); const defaultProps = { - representativePhoto: factory( "RemotePhoto" ), + representativePhoto: { ...factory( "RemotePhoto" ), ...{ id: 4 } }, obsPhotos: [factory( "LocalObservationPhoto" )], navToTaxonDetails: mockNavToTaxonDetails, taxon: factory( "LocalTaxon", { @@ -49,8 +49,10 @@ describe( "PhotosSection", () => { ); await waitFor( () => { - expect( screen.queryByTestId( "TaxonDetails.photo.1" ) ).toBeFalsy(); + expect( screen.getByTestId( "MatchScreen.ObsPhoto" ) ).toBeTruthy(); } ); + expect( screen.queryByTestId( "TaxonDetails.photo.1" ) ).toBeFalsy(); + expect( screen.queryByTestId( "TaxonDetails.photo.4" ) ).toBeFalsy(); } ); // Not working due to known bug: https://linear.app/inaturalist/issue/MOB-1069/taxon-photos-hidden-for-iconic-taxa-match-screens @@ -68,28 +70,18 @@ describe( "PhotosSection", () => { expect( screen.queryByTestId( "TaxonDetails.photo.1" ) ).toBeFalsy(); } ); */ - it( "navigates to taxon details when taxon photo is pressed", async () => { - const taxonWithPhoto = factory( "LocalTaxon", { - taxonPhotos: [ - { photo: factory( "RemotePhoto", { id: 1 } ) }, - { photo: factory( "RemotePhoto", { id: 2 } ) }, - { photo: factory( "RemotePhoto", { id: 3 } ) } - ] - } ); - + it( "calls navToTaxonDetails prop when taxon photo is pressed", async () => { renderComponent( ); - const repPhotoId = defaultProps.representativePhoto.id; await waitFor( () => { - expect( screen.getByTestId( `TaxonDetails.photo.${repPhotoId}` ) ).toBeTruthy(); + expect( screen.getByTestId( "TaxonDetails.photo.4" ) ).toBeTruthy(); } ); - const photoButton = screen.getByTestId( `TaxonDetails.photo.${repPhotoId}` ); + const photoButton = screen.getByTestId( "TaxonDetails.photo.4" ); fireEvent.press( photoButton ); expect( mockNavToTaxonDetails ).toHaveBeenCalled(); @@ -103,9 +95,8 @@ describe( "PhotosSection", () => { ); // Representative photo + 2 more = 3 total - const repPhotoId = defaultProps.representativePhoto.id; await waitFor( () => { - expect( screen.getByTestId( `TaxonDetails.photo.${repPhotoId}` ) ).toBeTruthy(); + expect( screen.getByTestId( "TaxonDetails.photo.4" ) ).toBeTruthy(); } ); expect( screen.getByTestId( "TaxonDetails.photo.1" ) ).toBeTruthy(); expect( screen.getByTestId( "TaxonDetails.photo.2" ) ).toBeTruthy();