Skip to content

Commit

Permalink
Retry clicking on delete confirmation popup
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry committed Nov 11, 2019
1 parent 8cc4dba commit 0c5ad8b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 21 deletions.
11 changes: 6 additions & 5 deletions tests/acceptance/customCommands/waitForElementEnabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
module.exports.command = function (
selector, locateStrategy = 'css selector', timeout = this.globals.waitForConditionTimeout
) {
let self = this
if (locateStrategy === 'xpath') {
this.useXpath()
self = this.useXpath()
} else if (locateStrategy === 'css selector') {
this.useCss()
self = this.useCss()
} else {
this.assert.fail('invalid locateStrategy')
return this.assert.fail('invalid locateStrategy')
}
this.expect.element(selector).enabled.before(timeout)
return this
self.expect.element(selector).enabled.before(timeout)
return self
}
70 changes: 57 additions & 13 deletions tests/acceptance/pageObjects/FilesPageElement/filesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,69 @@ module.exports = {
*
* @param {string} fileName
*/
deleteFile: function (fileName) {
return this.initAjaxCounters()
deleteFile: async function (fileName) {
await this
.waitForFileVisible(fileName)
.useXpath()
.performFileAction(fileName, 'delete')
.waitForElementEnabled(
this.elements.deleteFileConfirmationBtn.selector,
this.elements.deleteFileConfirmationBtn.locateStrategy
)
.click('@deleteFileConfirmationBtn')
.waitForCSSPropertyEquals(
{
selector: this.elements.deleteFileConfirmationDialog.selector,
locateStrategy: this.elements.deleteFileConfirmationBtn.locateStrategy,
property: 'display',
value: 'none'
}
'css selector'
)
.waitForOutstandingAjaxCalls()

const clickAction = function () {
return this.initAjaxCounters().click('@deleteFileConfirmationBtn')
.waitForOutstandingAjaxCalls()
.waitForElementNotVisible(
this.elements.deleteFileConfirmationDialog.selector,
this.api.globals.waitForConditionTimeout,
this.api.globals.waitForConditionPollInterval,
false,
function () {
console.log('waited for popup to disappear.')
}
)
}.bind(this)
await clickAction()

let isPopupVisible = false

/* issue: https://github.com/owncloud/phoenix/issues/1728
Clicking "OK" button on deletion confirmation dialog does not
disappear some of the times.
Why not just wait and click again later?
Some of the times, the "click" works and the popup starts
disappearing, but hasn't yet. So, it requires us to wait for
popup to disappear for quite a while and then, again recheck
if it's visible again. And, if it is, then only re-click.
We have `waitForCSSPropertyEquals` below that should check if clicking
once or twice really worked.
TODO: Investigate further why the "click" is not working
*/
await this.isVisible(
{
selector: this.elements.deleteFileConfirmationDialog.selector,
locateStrategy: this.elements.deleteFileConfirmationDialog.locateStrategy,
suppressNotFoundErrors: true
},
({ value }) => { isPopupVisible = value }
)
if (isPopupVisible === true) {
console.log('Retrying again. Popup did not disappear.')
await clickAction()
}

return this.waitForCSSPropertyEquals(
{
selector: this.elements.deleteFileConfirmationDialog.selector,
locateStrategy: this.elements.deleteFileConfirmationBtn.locateStrategy,
property: 'display',
value: 'none'
}
)
.useCss()
},
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/setup-drone.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { setDefaultTimeout, After, Before } from 'cucumber'
import { createSession, closeSession, client } from 'nightwatch-api'

setDefaultTimeout(120000)
setDefaultTimeout(180000)

Before(async () => {
await createSession({ env: 'drone' })
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ When('the user deletes file/folder {string} using the webUI', function (element)
return client.page.FilesPageElement.filesList().deleteFile(element)
})

When('the user deletes the following elements using the webUI', function (table) {
When('the user deletes the following elements using the webUI', async function (table) {
for (const line of table.rows()) {
client.page.FilesPageElement.filesList().deleteFile(line[0])
await client.page.FilesPageElement.filesList().deleteFile(line[0])
deletedElements.push(line[0])
}
return client.page.filesPage()
Expand Down

0 comments on commit 0c5ad8b

Please sign in to comment.