From 8c511119a868a270f4b4d1f44a509000ebf045f5 Mon Sep 17 00:00:00 2001 From: Pascal Wengerter Date: Thu, 29 Jul 2021 13:26:41 +0200 Subject: [PATCH] Fix broken search tests --- packages/web-app-files/src/store/mutations.js | 3 +++ .../features/webUIFilesSearch/search.feature | 6 ++--- tests/acceptance/pageObjects/webPage.js | 23 ++++++++++++++++++- .../stepDefinitions/searchContext.js | 4 ++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/web-app-files/src/store/mutations.js b/packages/web-app-files/src/store/mutations.js index ed68277fd6a..217c1dcbad1 100644 --- a/packages/web-app-files/src/store/mutations.js +++ b/packages/web-app-files/src/store/mutations.js @@ -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 = [] }, diff --git a/tests/acceptance/features/webUIFilesSearch/search.feature b/tests/acceptance/features/webUIFilesSearch/search.feature index 22284b1229a..ca1c171f1ac 100644 --- a/tests/acceptance/features/webUIFilesSearch/search.feature +++ b/tests/acceptance/features/webUIFilesSearch/search.feature @@ -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 @@ -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 diff --git a/tests/acceptance/pageObjects/webPage.js b/tests/acceptance/pageObjects/webPage.js index bedafc88d28..87d52f55b5c 100644 --- a/tests/acceptance/pageObjects/webPage.js +++ b/tests/acceptance/pageObjects/webPage.js @@ -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) { @@ -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' }, diff --git a/tests/acceptance/stepDefinitions/searchContext.js b/tests/acceptance/stepDefinitions/searchContext.js index 0f980befbbd..b69d9a35c3f 100644 --- a/tests/acceptance/stepDefinitions/searchContext.js +++ b/tests/acceptance/stepDefinitions/searchContext.js @@ -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) +})