Skip to content

Commit

Permalink
Merge pull request #1279 from dpc-sdp/bugfix/SD-75-clear-errors
Browse files Browse the repository at this point in the history
[SD-75] Clear geolocation button errors on search or reset
  • Loading branch information
dylankelly authored Jul 29, 2024
2 parents 8377be7 + 15e916a commit ca89a2c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/nuxt-app/test/features/maps/geolocate.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Feature: Custom collection map component

I want to display a map of features from an indexed data pipeline

Background:
Given the site endpoint returns fixture "/site/vic" with status 200
And the search autocomplete request is stubbed with "/search-listing/suggestions/none" fixture
Given I am using a "macbook-16" device
Given the "/api/tide/elasticsearch/elasticsearch_index_develop_node/_search" aggregation request is stubbed with fixture "/map-table/vsba/aggregations" and status 200 as alias "aggReq"
Given the "/test-map-shape-layer" network request is stubbed with fixture "/maps/sample-shapes"
| method | status |
| GET | 200 |
Given the "https://base.maps.vic.gov.au/service*" network request is stubbed with fixture "/maps/service.png"
| method | status |
| GET | 200 |

@mockserver
Scenario: The geolocate button is hidden when not enabled
Given I load the page fixture with "/maps/basic-page"
Given the geolocation button is not enabled
And the page endpoint for path "/map" returns the loaded fixture
And the "/api/tide/elasticsearch/elasticsearch_index_develop_node/_search" network request is delayed by 1000 milliseconds and stubbed with fixture "/site/search-response", status 200 and alias "searchReq"
Given I visit the page "/map"

Then the geolocate button is hidden

@mockserver
Scenario: The geolocate button is shown when enabled
Given I load the page fixture with "/maps/basic-page"
Given the geolocation button is enabled
And the page endpoint for path "/map" returns the loaded fixture
And the "/api/tide/elasticsearch/elasticsearch_index_develop_node/_search" network request is delayed by 1000 milliseconds and stubbed with fixture "/site/search-response", status 200 and alias "searchReq"
Given I visit the page "/map"
Then the geolocate button is displayed
28 changes: 28 additions & 0 deletions packages/ripple-test-utils/step_definitions/components/maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,31 @@ Given(
)
}
)

Given(`the geolocation button is not enabled`, () => {
cy.get('@pageFixture').then((response) => {
set(
response,
'bodyComponents[0].props.locationQueryConfig.showGeolocationButton',
false
)
})
})

Given(`the geolocation button is enabled`, () => {
cy.get('@pageFixture').then((response) => {
set(
response,
'bodyComponents[0].props.locationQueryConfig.showGeolocationButton',
true
)
})
})

Given(`the geolocate button is hidden`, () => {
cy.get('.rpl-map-geolocate__btn').should('not.exist')
})

Given(`the geolocate button is displayed`, () => {
cy.get('.rpl-map-geolocate__btn').should('exist')
})
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ const emitSearchEvent = (event) => {
}
const handleSearchSubmit = (event) => {
geolocationError.value = null
if (props.userFilters && props.userFilters.length) {
cachedSubmitEvent.value = event
// Submitting the search term should also 'apply' the filters, but the filters live in a seperate form.
Expand Down Expand Up @@ -378,6 +380,7 @@ const handleFilterReset = (event: rplEventPayload) => {
)
locationQuery.value = null
geolocationError.value = null
resetSearch()
resetFilters()
submitSearch()
Expand Down

0 comments on commit ca89a2c

Please sign in to comment.