Skip to content

Commit

Permalink
Refactor acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Sep 1, 2021
1 parent d4d447f commit d080622
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 36 deletions.
4 changes: 1 addition & 3 deletions tests/acceptance/pageObjects/FilesPageElement/filesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
59 changes: 28 additions & 31 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
},
/**
*
Expand All @@ -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 => {
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d080622

Please sign in to comment.