Skip to content

Commit

Permalink
Fix broken search tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Jul 29, 2021
1 parent 653d00b commit 8c51111
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/web-app-files/src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ export default {
}
state.selected = []
},
REMOVE_FILE_FROM_SEARCHED(state, file) {
state.filesSearched = state.filesSearched.filter(i => file.id !== i.id)
},
RESET_SELECTION(state) {
state.selected = []
},
Expand Down
6 changes: 3 additions & 3 deletions tests/acceptance/features/webUIFilesSearch/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Feature: Search
@issue-980
Scenario: search in sub folder
When the user opens folder "simple-folder" using the webUI
And the user searches for "lorem" using the webUI
And the user searches globally for "lorem" using the webUI
Then file "lorem.txt" should be listed on the webUI
And file "lorem-big.txt" should be listed on the webUI
#And file "lorem.txt" with path "/" should be listed in the search results in the other folders section on the webUI
Expand Down Expand Up @@ -131,9 +131,9 @@ Feature: Search
And the user opens folder "simple-folder" using the webUI
And the user uploads file "simple.odt" using the webUI
And the user browses to the files page
And the user searches for "simple" using the webUI
And the user searches globally for "simple" using the webUI
Then file "simple.pdf" should be listed on the webUI
And file "simple.odt" should be listed on the webUI
And file "simple-folder/simple.odt" should be listed on the webUI


Scenario: Search for files with difficult names
Expand Down
23 changes: 22 additions & 1 deletion tests/acceptance/pageObjects/webPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,24 @@ module.exports = {
*
* @param {string} searchTerm
*/
search: function(searchTerm) {
search: function(searchTerm, global = false) {
if (global === true) {
return this.initAjaxCounters()
.isVisible('#files-open-search-btn', result => {
if (result.value === true) {
this.click('#files-open-search-btn')
.waitForElementVisible('@searchInputFieldLowResolution')
.setValue('@searchInputFieldLowResolution', [searchTerm])
.click('@searchGlobalButton')
} else {
this.waitForElementVisible('@searchInputFieldHighResolution')
.setValue('@searchInputFieldHighResolution', [searchTerm])
.click('@searchGlobalButton')
}
})
.waitForElementNotVisible('@searchLoadingIndicator')
.waitForOutstandingAjaxCalls()
}
return this.initAjaxCounters()
.isVisible('#files-open-search-btn', result => {
if (result.value === true) {
Expand Down Expand Up @@ -253,6 +270,10 @@ module.exports = {
searchLoadingIndicator: {
selector: '#files-global-search-bar .oc-spinner'
},
searchGlobalButton: {
selector: '//button[.="Search all files ↵"]',
locateStrategy: 'xpath'
},
userMenuButton: {
selector: '#_userMenuButton'
},
Expand Down
4 changes: 4 additions & 0 deletions tests/acceptance/stepDefinitions/searchContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ const { When } = require('cucumber')
When('the user searches for {string} using the webUI', function(searchTerm) {
return client.page.webPage().search(searchTerm)
})

When('the user searches globally for {string} using the webUI', function(searchTerm) {
return client.page.webPage().search(searchTerm, true)
})

0 comments on commit 8c51111

Please sign in to comment.