mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Only record query breadcrumbs when the search is submitted
Queries were previously stored whenever a result was selected, which meant half-typed queries ended up in the history. Now a query is only recorded when the user submits the search field, while selecting a result only records the room.
This commit is contained in:
@@ -127,16 +127,26 @@ struct SearchScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
func selectionRecordsBreadcrumbs() {
|
||||
// Typing alone doesn't record the query, only submitting it does.
|
||||
context.searchQuery = "Second"
|
||||
context.send(viewAction: .selectRoom(roomID: "2"))
|
||||
|
||||
#expect(userSettings.searchBreadcrumbs == [.room(roomID: "2"), .query("Second")])
|
||||
#expect(userSettings.searchBreadcrumbs == [.room(roomID: "2")])
|
||||
|
||||
context.send(viewAction: .submitQuery)
|
||||
|
||||
#expect(userSettings.searchBreadcrumbs == [.query("Second"), .room(roomID: "2")])
|
||||
|
||||
// Selecting the same room again from the empty state only bumps it back to the top.
|
||||
context.searchQuery = ""
|
||||
context.send(viewAction: .selectRoom(roomID: "2"))
|
||||
|
||||
#expect(userSettings.searchBreadcrumbs == [.room(roomID: "2"), .query("Second")])
|
||||
|
||||
// Submitting an empty query records nothing.
|
||||
context.send(viewAction: .submitQuery)
|
||||
|
||||
#expect(userSettings.searchBreadcrumbs == [.room(roomID: "2"), .query("Second")])
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user