phlask-map icon indicating copy to clipboard operation
phlask-map copied to clipboard

Add Cypress test for foraging site display on desktop

Open icycoldveins opened this issue 6 months ago • 5 comments

Pull Request

Change Summary

Add automated Cypress test for displaying foraging sites on desktop, ensuring this functionality works consistently throughout future development.

Change Reason

As part of improving test coverage for the PHLASK application, we need automated tests for all resource types. This PR adds the missing test for foraging site display functionality.

Changes

  • Implement should successfully display a foraging site test in cypress/e2e/desktop/siteInfo.cy.js
  • Add foraging test data entries to public/testData.json (2 sample foraging locations)
  • Test performs the following actions:
    • Clicks on the "Resources" button on the bottom toolbar
    • Clicks on the "Foraging" button on the resources modal
    • Clicks on one of the foraging markers that appear on the map
    • Confirms that the window shows the correct location name
  • Foraging test data includes proper structure with:
    • forage_type arrays (FRUIT, LEAVES, NUT, BARK, FLOWERS)
    • Optional tags arrays (IN_SEASON, COMMUNITY_GARDEN, MEDICINAL)

Video Recording

https://github.com/user-attachments/assets/49830c57-a121-431f-ac97-f50fdf8ea502

Related Issue: #484

icycoldveins avatar Aug 21 '25 08:08 icycoldveins

I wonder if it would make sense to mock the location for the tests to be like centey city area ish

I have location turned off and the app appears to default to City Hall, but tests failed there too. I think it's a mix of some of the tests looking for specific resources like data-cy-1 for a water site that won't render in the viewport (it's in University City), and others looking for the Test Organization text attached to a resource that also is out west.

So either we

  • anchor the test location to a point where the test data will always be in view, or
  • we move those test data coordinates to Center City and adjust the test to ignore location so it always runs with the default location

marcbachan avatar Sep 23 '25 23:09 marcbachan

Good point

icycoldveins avatar Sep 24 '25 01:09 icycoldveins

Adding commentary from @gcardonag - there is a line in package.json: "start:cypress": "VITE_CYPRESS_TEST=true yarn start", that's intended to test right around Center City and fetch specific test data points.

While we can fetch any available site that renders, we should still anchor the tests to specific points so as to not be dependent on the database.

marcbachan avatar Sep 26 '25 22:09 marcbachan

@marcbachan I made a recent commit, not sure if it addressed what we talked about last time because I forgot, but basically I added a location mock prior to the test run to have it be centered around center city

icycoldveins avatar Oct 08 '25 22:10 icycoldveins

@gcardonag lmk if the tests makes sense. Im thinking if anyone else wants to do the other display tests ill just stop with just the foraging site test

icycoldveins avatar Oct 08 '25 22:10 icycoldveins