Closed Zafouche closed 4 days ago
I will open this PR for review when the CI passes, such that my teammates can review my work: the feature works well, I just need to write more tests.
I am still working on improving the test coverage by:
Other than that, the test coverage looks pretty good even if the e2e isn't added so I'm happy with it.
Good job implementing this! This nicely completes the event creation. Don't forget to comment your code, but besides that no complaints, LGTM (as long as you add your tests).
Thanks a lot for reminding me to add documentation! I've been deep in testing that I forgot about it, very good point. Just added documentation.
We should also be careful about merging our PRs as I refactored the EventCreation page a bit
And you're right, we should
EventCreationScreen
have been tested through a new test I added in the screen's UI test. This effectively raises the coverage to above 80%!ViewModel Scope
in the collectQuery
function, meaning that, in the tests, if nothing is explicitly defined, it only goes to execute the code inside of that Scope
once, when the view model is initialized. After that, when the query changes, the inside code is simply skipped. I've done a lot of research and manipulating coroutines for tests isn't easy. The only potential solutions I've read look like the one in this stack overflow post. I've successfully made it such that Hilt
injects the correct coroutine in production code, such as the feature still works when we run the app, however the solution does not work in the test, it still skips the code inside the scope block, so I still don't know how to fix this. Considering that the coverage is already over 80% in this PR, I will merge this and report this work for next sprint, in another PR. I will not push the solution of adding a Coroutine
field to the view model, or the tests I've written, since the solution does not make the tests work.However I will push the code of both the start of the e2e test and the attempt using the solution described above in the branch test/geocoder-e2e-and-viewmodel, that I will pick up or delete and start from scratch after #223 has been merged to main.
Issues
3 New issues
0 Accepted issues
Measures
0 Security Hotspots
72.8% Coverage on New Code
0.0% Duplication on New Code
Description
This PR implements the integration of the
Nominatim API
into theEvent
creation screen. It allows users to search for and select a location. Location suggestions are fetched when the user types into the location input text field (with a 1 second debounce delay, to ensure no more than 1 request per second are made), and users can select a place from a dropdown list, which fills the location field with the place’s name and address, and allows us to get the exact coordinates of the address.Motivation and Context
By integrating the
Nominatim API
, we enable users to search and select a location easily. This approach provides greater flexibility, as I have done my best to abstract this as much as possible, to be able to easily switch to another tool, likeSearch Places API
, orPhoton API
.NominatimLocationSearchViewModel:
Nominatim API
as the user types in the search field, with a 1 second debounce delay.NominatimLocationRepository:
Retrofit
andOkHttp
to make network requests to theNominatim API
for location suggestions.NominatimLocationResponse
data class, where theJSON
results will be parsed to.EventCreationScreen:
NominatimLocationSearchViewModel
to handle the fetching of location suggestions.What's next