Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit b93b94a

Browse files
committedJan 17, 2017
Fix search autocomplete
Fix #6696 Broke from a recent fix I made from the refactor Auditors: @bsclifton
1 parent 9b25725 commit b93b94a

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed
 

‎app/renderer/fetchSearchSuggestions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ const fetchSearchSuggestions = debounce((tabId, autocompleteURL, searchTerms) =>
1616
// Once we have the online suggestions, append them to the others
1717
windowActions.searchSuggestionResultsAvailable(tabId, Immutable.fromJS(xhr.response[1]))
1818
}
19-
}, 50)
19+
}, 100)
2020

2121
module.exports = fetchSearchSuggestions

‎app/renderer/reducers/urlBarSuggestionsReducer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const updateSearchEngineInfoFromInput = (state, frameProps) => {
3939
return state
4040
}
4141
}
42-
state = state.setIn(searchDetailPath, Immutable.fromJS({}))
42+
state = state.deleteIn(searchDetailPath)
4343
}
4444
}
4545
return state
@@ -342,6 +342,7 @@ const urlBarSuggestionsReducer = (state, action) => {
342342
case windowConstants.WINDOW_SEARCH_SUGGESTION_RESULTS_AVAILABLE:
343343
const frameKey = getFrameKeyByTabId(state, action.tabId)
344344
state = state.setIn(frameStatePath(state, frameKey).concat(['navbar', 'urlbar', 'suggestions', 'searchResults']), action.searchResults)
345+
state = generateNewSuggestionsList(state)
345346
break
346347
case windowConstants.WINDOW_SET_NAVBAR_INPUT:
347348
const activeFrameProps = getActiveFrame(state)

‎test/components/urlBarSuggestionsTest.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/* global describe, it, beforeEach */
1+
/* global describe, it, before, beforeEach */
22

33
const Brave = require('../lib/brave')
44
const messages = require('../../js/constants/messages')
5+
const settings = require('../../js/constants/settings')
56
const {urlInput, urlBarSuggestions} = require('../lib/selectors')
67

78
describe('urlBarSuggestions', function () {
@@ -164,6 +165,28 @@ describe('urlBarSuggestions', function () {
164165
.waitForVisible(urlBarSuggestions)
165166
.waitForExist(urlBarSuggestions + ' li.suggestionItem[data-index="0"]:not(.selected)')
166167
.keys(Brave.keys.ENTER)
167-
.waitForInputText(urlInput, /google.com\/.*q=ave/)
168+
.waitForInputText(urlInput, /google.*\/.*q=ave/)
169+
})
170+
})
171+
172+
describe('search suggestions', function () {
173+
Brave.beforeAll(this)
174+
175+
before(function * () {
176+
yield this.app.client
177+
.waitForUrl(Brave.newTabUrl)
178+
.waitForBrowserWindow()
179+
.waitForVisible(urlInput)
180+
})
181+
182+
it('Finds search suggestions and performs a search when selected', function * () {
183+
yield this.app.client
184+
.changeSetting(settings.OFFER_SEARCH_SUGGESTIONS, true)
185+
.setInputText(urlInput, 'what is')
186+
.waitForVisible(urlBarSuggestions)
187+
.keys(Brave.keys.DOWN)
188+
.waitForExist(urlBarSuggestions + ' li.suggestionItem[data-index="0"]:not(.selected)')
189+
.keys(Brave.keys.ENTER)
190+
.waitForInputText(urlInput, /google.*\/.*q=what\+is/)
168191
})
169192
})

‎test/lib/brave.js

+1
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ var exports = {
391391
} else {
392392
ret = val === input
393393
}
394+
logVerbose('Current val: ' + val)
394395
logVerbose('waitForInputText("' + selector + '", "' + input + '") => ' + ret)
395396
return ret
396397
})

0 commit comments

Comments
 (0)