-
-
Notifications
You must be signed in to change notification settings - Fork 40
Add Cypress test for foraging site display on desktop #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
- Implement test case for foraging site display in siteInfo.cy.js - Add foraging test data to testData.json with two sample foraging locations - Include proper forage_type arrays (FRUIT, LEAVES, NUT, BARK, FLOWERS) - Include optional tags (IN_SEASON, COMMUNITY_GARDEN, MEDICINAL) - Test clicks Resources button, selects Foraging resource type, and verifies site info display - All tests passing with video recording captured Fixes #484
marcbachan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test looks good, the pattern match for the title element instead of exact match is a nice touch.
I had some issues running the tests, but later realized it was because a) my location is far enough from the city to not have some elements, and b) the default to Center City when location is off causes the tests to fail.
I manually adjusted the location like this and got it to work:
// mock geolocation to West Phila
cy.window().then((win) => {
cy.stub(win.navigator.geolocation, 'getCurrentPosition').callsFake((success) => {
success({
coords: {
latitude: 39.962250,
longitude: -75.211028,
accuracy: 10
}
});
});
});We may want to consider anchoring the tests to specific coordinates (more elegantly than I did) to align to the test data regardless of the location of the person running the test?
icycoldveins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right that was a limitation I ran into as well lol
icycoldveins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess where im located theres plenty of resources
icycoldveins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would make sense to mock the location for the tests to be like centey city area ish
icycoldveins
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably update the rests of my open prs as well then
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 So either we
|
|
Good point |
|
Adding commentary from @gcardonag - there is a line in 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. |
- Add geolocation mock to City Hall coordinates in beforeEach() - Replace with visibility check before clicking marker - Ensures tests pass regardless of tester's actual location Addresses feedback from PR #642 review
|
@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 |
|
@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 |
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
should successfully display a foraging sitetest incypress/e2e/desktop/siteInfo.cy.jspublic/testData.json(2 sample foraging locations)forage_typearrays (FRUIT, LEAVES, NUT, BARK, FLOWERS)tagsarrays (IN_SEASON, COMMUNITY_GARDEN, MEDICINAL)Video Recording
foraging.js.mp4
Related Issue: #484