Skip to content

Commit

Permalink
Wait for preview call to end in file list
Browse files Browse the repository at this point in the history
When displaying the file list or scrolling down to formerly invisible
resources, wait for ajax calls to make sure the mediaSource and
preview loading call has ended before performing any operations.

This is to avoid running into file lock issues while loading the
previews.
  • Loading branch information
Vincent Petry committed Mar 23, 2020
1 parent 66975fd commit 701c048
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/acceptance/helpers/loginHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ module.exports = {
}
return client
.page.phoenixPage()
.initAjaxCounters()
.waitForElementVisible('@appContainer')
.waitForOutstandingAjaxCalls()
.then(() => {
client.globals.currentUser = userId
})
Expand Down
2 changes: 2 additions & 0 deletions tests/acceptance/helpers/navigationHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ module.exports = {
throw new Error('Invalid type for loading indicator selector')
}
return client
.initAjaxCounters()
.waitForElementPresent({ ...locator, abortOnFailure: false }) // don't fail if we are too late
.waitForElementNotPresent(locator)
.waitForOutstandingAjaxCalls()
}
}
9 changes: 9 additions & 0 deletions tests/acceptance/pageObjects/FilesPageElement/filesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,17 @@ module.exports = {
*/
navigateToFolder: async function (folder) {
await this.waitForFileVisible(folder)
await this.initAjaxCounters()

await this.useXpath()
.moveToElement(this.getFileRowSelectorByFileName(folder), 0, 0)
.click(this.getFileLinkSelectorByFileName(folder))
.useCss()
.waitForElementNotPresent('@filesListProgressBar')

// wait for previews to finish loading
await this.waitForOutstandingAjaxCalls()

return this
},
/**
Expand Down Expand Up @@ -540,6 +544,7 @@ module.exports = {
itemName = this.replaceChar(itemName, '"', '\\"')
}

await this.initAjaxCounters()
await this.waitForElementVisible('@virtualScrollWrapper')
await this.api.executeAsync(
function (
Expand Down Expand Up @@ -588,6 +593,10 @@ module.exports = {
listHeaderSelector: this.elements.filesTableHeader.selector
}])

// wait for previews to be loaded after scrolling to resources that were
// not rendered before
await this.waitForOutstandingAjaxCalls()

return this
},

Expand Down

0 comments on commit 701c048

Please sign in to comment.