From d08062250c23b2a926ef7cae0c90ccdba42d0e86 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Wed, 1 Sep 2021 22:51:43 +0200 Subject: [PATCH] Refactor acceptance tests --- .../pageObjects/FilesPageElement/filesList.js | 4 +- .../FilesPageElement/sharingDialog.js | 59 +++++++++---------- .../stepDefinitions/sharingContext.js | 4 +- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/tests/acceptance/pageObjects/FilesPageElement/filesList.js b/tests/acceptance/pageObjects/FilesPageElement/filesList.js index c4533832cbd..6845e6fecc9 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/filesList.js +++ b/tests/acceptance/pageObjects/FilesPageElement/filesList.js @@ -564,9 +564,7 @@ module.exports = { await this.waitForFileVisible(resource) - return this.useXpath() - .click(resourceRowSelector + actionSelector) - .useCss() + return await this.click('xpath', resourceRowSelector + actionSelector) }, moveResource: async function(resource, target) { diff --git a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js index aa33deb2dfc..a7212533ae8 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js +++ b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js @@ -88,24 +88,26 @@ module.exports = { // We need waitForElementPresent here. // waitForElementVisible would break even with 'abortOnFailure: false' if the element is not present - await this.enterAutoComplete(sharee).waitForElementPresent( - { - selector: '@sharingAutoCompleteDropDownElements', - abortOnFailure: false - }, + let failedOnFirstTry = false + await this.enterAutoComplete(sharee) + const dropdownElement = this.elements.sharingAutoCompleteDropDownElements + await this.waitForElementVisible( + dropdownElement.locateStrategy, + dropdownElement.selector, + this.api.globals.waitForConditionTimeout, + this.api.globals.waitForConditionPollInterval, + false, result => { - if (result.value === false) { - // sharing dropdown was not shown - console.log('WARNING: no sharing autocomplete dropdown found, retry typing') - this.clearValue('@sharingAutoComplete') - .enterAutoComplete(sharee) - .waitForElementPresent({ - selector: '@sharingAutoCompleteDropDownElements', - abortOnFailure: false - }) - } + failedOnFirstTry = result.status === -1 } ) + if (failedOnFirstTry) { + // sharing dropdown was not shown. Try a second time. + console.log('WARNING: no sharing autocomplete dropdown found, retry typing') + await this.clearValue('@sharingAutoComplete') + await this.enterAutoComplete(sharee) + await this.waitForElementVisible(dropdownElement.selector) + } let receiverType = shareWithGroup === true ? SHARE_TYPE_STRING.group : SHARE_TYPE_STRING.user receiverType = remoteShare === true ? SHARE_TYPE_STRING.federation : receiverType @@ -308,11 +310,11 @@ module.exports = { * * @param {string} input */ - enterAutoComplete: function(input) { - return this.waitForElementVisible('@sharingAutoComplete') - .initAjaxCounters() + enterAutoComplete: async function(input) { + await this.waitForElementVisible('@sharingAutoComplete') + await this.initAjaxCounters() .setValueBySingleKeys('@sharingAutoComplete', input) - .waitForAjaxCallsToStartAndFinish() + .waitForOutstandingAjaxCalls() }, /** * @@ -338,27 +340,20 @@ module.exports = { */ getShareAutocompleteWebElementIdList: async function() { const webElementIdList = [] - const showAllResultsXpath = this.elements.sharingAutoCompleteShowAllResultsButton.selector + const showAllResultsSelector = this.elements.sharingAutoCompleteShowAllResultsButton.selector // wait for autocomplete to finish loading - try { - await this.waitForElementVisible('@sharingAutoCompleteDropDown') - } catch (e) { - // FIXME: the dropdown will not appear when there are zero results - // (https://github.com/owncloud/owncloud-design-system/issues/547) - // so need to catch the error here - return [] - } + await this.waitForElementVisible('@sharingAutoCompleteDropDown') await this.waitForElementNotPresent('@sharingAutoCompleteSpinner') // note: some result lists don't have the "show all" button depending on the number of entries, // so we only click it if present - await this.api.element('css selector', showAllResultsXpath, result => { + await this.api.element('css selector', showAllResultsSelector, result => { if (result.status !== -1) { return this.click('@sharingAutoCompleteShowAllResultsButton') } }) await this.api.elements( - 'css selector', + this.elements.sharingAutoCompleteDropDownElements.locateStrategy, this.elements.sharingAutoCompleteDropDownElements.selector, result => { result.value.forEach(value => { @@ -629,7 +624,9 @@ module.exports = { selector: '#files-share-invite .vs__dropdown-menu' }, sharingAutoCompleteDropDownElements: { - selector: '#files-share-invite .vs__dropdown-menu .files-collaborators-autocomplete-user-text' + selector: + '#files-share-invite .vs__dropdown-menu .files-collaborators-autocomplete-user-text', + locateStrategy: 'css selector' }, sharingAutoCompleteShowAllResultsButton: { selector: '.oc-autocomplete-suggestion-overflow' diff --git a/tests/acceptance/stepDefinitions/sharingContext.js b/tests/acceptance/stepDefinitions/sharingContext.js index 23aa47fdab1..58a3eb0ea89 100644 --- a/tests/acceptance/stepDefinitions/sharingContext.js +++ b/tests/acceptance/stepDefinitions/sharingContext.js @@ -597,8 +597,8 @@ When('the user cancels the share creation dialog on the webUI', function() { return client.page.FilesPageElement.sharingDialog().clickCancel() }) -When('the user types {string} in the share-with-field', function(input) { - return client.page.FilesPageElement.sharingDialog().enterAutoComplete(input) +When('the user types {string} in the share-with-field', async function(input) { + return await client.page.FilesPageElement.sharingDialog().enterAutoComplete(input) }) When(