Skip to content

Commit

Permalink
test scenario to delete and restore folder with same name as file
Browse files Browse the repository at this point in the history
  • Loading branch information
swoichha committed Feb 14, 2020
1 parent 7302781 commit 3052239
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Feature: Restore deleted files/folders
And as "user1" file "simple-folder/file-to-delete-and-restore" should not exist

@issue-1723
Scenario: Delete and restore file with same name as folder
Scenario: Delete and restore a file that hs the same name like a deleted folder
Given the following files have been deleted by user "user1"
| name |
| lorem.txt |
Expand All @@ -134,7 +134,7 @@ Feature: Restore deleted files/folders
Then file "lorem.txt" should be listed on the webUI
And folder "lorem.txt" should not be listed on the webUI

Scenario: Delete and restore folder with same name as file
Scenario: Delete and restore a folder that hs the same name like a deleted file
Given the user has created file "lorem.txt"
And the following files have been deleted by user "user1"
| name |
Expand Down
106 changes: 25 additions & 81 deletions tests/acceptance/pageObjects/FilesPageElement/filesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
},
/**
* Get Selector for Folder Action expander
* @param folderName
* @param {string} folderName
* @returns {string}
*/
getFolderActionBtnSelector: function (folderName) {
Expand All @@ -57,41 +57,17 @@ module.exports = {
* @param {string} action delete|share|rename|download
* @returns {*}
*/
performFileAction: async function (fileName, action, elementType = 'file') {
performFileAction: function (fileName, action, elementType = 'file') {
const { btnSelector, fileActionsBtnSelector } =
await this.getFileRowButtonSelectorsByFileName(fileName, action, elementType)
await this.initAjaxCounters()
this.getFileRowButtonSelectorsByFileName(fileName, action, elementType)
return this.initAjaxCounters()
.useXpath()
await this.waitForElementVisible({
selector: fileActionsBtnSelector,
locateStrategy: 'xpath',
abortOnFailure: false
}, (result) => {
console.log(result)
})
.waitForElementVisible(fileActionsBtnSelector)
.click(fileActionsBtnSelector)
.waitForElementVisible(btnSelector)
.click(btnSelector)
.useCss()
},
/**
* this method does find out itself if the folder-action burger has to be clicked or not
* @param {string}folderName
* @param {string} action delete|share|rename|download
* @returns {*}
// */
// performFolderAction: function (folderName, action) {
// const { btnSelector, fileActionsBtnSelector } =
// this.getFolderRowButtonSelectorsByFolderName(fileName, action)
// return this.initAjaxCounters()
// .useXpath()
// .waitForElementVisible(fileActionsBtnSelector)
// .click(fileActionsBtnSelector)
// .waitForElementVisible(btnSelector)
// .click(btnSelector)
// .useCss()
// },

/**
* Checks whether a given action is disabled for a given file name.
* This method does find out itself if the file-action burger has to be clicked or not.
Expand Down Expand Up @@ -122,12 +98,10 @@ module.exports = {
deleteFile: async function (fileName) {
await this.waitForFileVisible(fileName)

await this
return this
.useXpath()
.performFileAction(fileName, FileAction.delete)
.confirmDeletion()

return this
},
confirmDeletion: async function () {
const clickAction = function () {
Expand Down Expand Up @@ -189,7 +163,9 @@ module.exports = {
},
/**
*
* @param {string} fileName
* @param fileName
* @param elementType
*
*/
restoreFile: async function (fileName, elementType = 'file') {
await this
Expand All @@ -202,20 +178,6 @@ module.exports = {
.waitForOutstandingAjaxCalls()
.useCss()
},
/**
*
* @param folderName
*
*/
restoreDeletedFolder: async function (folderName) {
await this.initAjaxCounters()
.waitForFolderVisible(folderName)
await this
.useXpath()
.performFolderAction(folderName, FileAction.restore)
.waitForOutstandingAjaxCalls()
.useCss()
},
/**
*
* @param {string} folder
Expand Down Expand Up @@ -434,6 +396,7 @@ module.exports = {
* Wait for A filerow with given filename to be visible
*
* @param {string} fileName
* @param {string} elementType
*/
waitForFileVisible: async function (fileName, elementType = 'file') {
const linkSelector = this.getFileLinkSelectorByFileName(fileName, elementType)
Expand All @@ -460,8 +423,8 @@ module.exports = {
*/
waitForFileWithPathVisible: function (path, elementType = 'file') {
if (elementType === 'file') {
const rowSelector = this.getFileRowSelectorByFileName(path)
const linkSelector = this.getFileLinkSelectorByFileName(path)
const rowSelector = this.getFileRowSelectorByFileName(path, elementType)
const linkSelector = this.getFileLinkSelectorByFileName(path, elementType)
return this
.useXpath()
.waitForElementVisible(rowSelector)
Expand All @@ -470,7 +433,7 @@ module.exports = {
})
.useCss
} else if (elementType === 'folder') {
const linkSelector = this.getFolderLinkSelectorByFolderName(path)
const linkSelector = this.getFileLinkSelectorByFileName(path, elementType)
return this.waitForElementVisible({
locateStrategy: 'xpath',
selector: linkSelector
Expand All @@ -480,21 +443,23 @@ module.exports = {
throw new Error(`Excpeted folder or file but got ${elementType}`)
}
},
/**
*
* @param {string} fileName
* @param {string} action
* @param {string} elementType
* @returns {{btnSelector: string, fileActionsBtnSelector: string}}
*/
getFileRowButtonSelectorsByFileName: function (fileName, action, elementType = 'file') {
const btnSelector = this.getActionSelector(action)
const fileActionsBtnSelector = this.getFileActionBtnSelector(fileName, elementType)

return { btnSelector, fileActionsBtnSelector }
},
// getFolderRowButtonSelectorsByFolderName: function (folderName, action) {
// const btnSelector = this.getActionSelector(action)
// const fileActionsBtnSelector = this.getFolderActionBtnSelector(folderName)
//
// return { btnSelector, fileActionsBtnSelector }
// },
/**
*
* @param {string} fileName
* @param {string} elementType
*
* @returns {string}
*/
Expand All @@ -521,14 +486,16 @@ module.exports = {
/**
*
* @param {string} fileName
* @param {string} elementType
*/

getFileLinkSelectorByFileName: function (fileName, elementType = 'file') {
if (elementType === 'file') {
return this.getFileRowSelectorByFileName(fileName) +
this.elements.fileLinkInFileRow.selector
} else if (elementType === 'folder') {
fileName = '"' + fileName + '"'
return (util.format(this.elements.fileRowByName.selector, fileName) + '//div/span')
return (util.format(this.elements.fileRowByName.selector, fileName) + '//div/span[@role="button"]')
} else {
return this
}
Expand All @@ -537,6 +504,7 @@ module.exports = {
* checks whether the element is listed or not on the filesList
*
* @param {string} element Name of the file/folder/resource
* @param {string} elementType
* @returns {boolean}
*/
isElementListed: async function (element, elementType = 'file'
Expand All @@ -555,27 +523,6 @@ module.exports = {
.useCss()
return isListed
},

/**
*
* @param folder
*
*/
isFolderListed: async function (folder) {
let isListed = true
await this
.waitForElementVisible('@filesTable')
.useXpath()
.waitForElementNotPresent('@loadingIndicator')
.api.elements(
'xpath',
this.getFolderRowSelectorByFolderName(folder),
(result) => {
isListed = result.value.length > 0
})
.useCss()
return isListed
},
/**
* checks whether sharing button of given file-row is present
*
Expand Down Expand Up @@ -950,9 +897,6 @@ module.exports = {
fileLinkInFileRow: {
selector: '//span[contains(@class, "file-row-name")]'
},
folderLinkInFolderRow: {
selector: '//span[contains(@class, "file-row-name")]'
},
notMarkedFavoriteInFileRow: {
selector: '//span[contains(@class, "oc-star-dimm")]',
locateStrategy: 'xpath'
Expand Down
4 changes: 0 additions & 4 deletions tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,6 @@ const assertDeletedElementsAreListed = function () {
When(/^the user restores (file|folder) "([^"]*)" from the trashbin using the webUI$/, function (elementType, element) {
return client.page.FilesPageElement.filesList().restoreFile(element, elementType)
})
//
// When('the user restores the folder {string} from the trashbin using the webUI', function (folder) {
// return client.page.FilesPageElement.filesList().restoreDeletedFolder(folder)
// })

Then('the following files/folders/resources should be listed on the webUI', function (table) {
return assertElementsAreListed([].concat.apply([], table.rows()))
Expand Down

0 comments on commit 3052239

Please sign in to comment.