From 3052239dbaca1d945b1b252a53c88249ce6daf48 Mon Sep 17 00:00:00 2001 From: swoichha Date: Fri, 14 Feb 2020 16:29:35 +0545 Subject: [PATCH] test scenario to delete and restore folder with same name as file --- .../webUITrashbin/trashbinRestore.feature | 4 +- .../pageObjects/FilesPageElement/filesList.js | 106 +++++------------- .../stepDefinitions/filesContext.js | 4 - 3 files changed, 27 insertions(+), 87 deletions(-) diff --git a/tests/acceptance/features/webUITrashbin/trashbinRestore.feature b/tests/acceptance/features/webUITrashbin/trashbinRestore.feature index de712af1db1..2197b37da33 100644 --- a/tests/acceptance/features/webUITrashbin/trashbinRestore.feature +++ b/tests/acceptance/features/webUITrashbin/trashbinRestore.feature @@ -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 | @@ -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 | diff --git a/tests/acceptance/pageObjects/FilesPageElement/filesList.js b/tests/acceptance/pageObjects/FilesPageElement/filesList.js index 14a4132ccfb..d623bffbc28 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/filesList.js +++ b/tests/acceptance/pageObjects/FilesPageElement/filesList.js @@ -42,7 +42,7 @@ module.exports = { }, /** * Get Selector for Folder Action expander - * @param folderName + * @param {string} folderName * @returns {string} */ getFolderActionBtnSelector: function (folderName) { @@ -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. @@ -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 () { @@ -189,7 +163,9 @@ module.exports = { }, /** * - * @param {string} fileName + * @param fileName + * @param elementType + * */ restoreFile: async function (fileName, elementType = 'file') { await this @@ -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 @@ -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) @@ -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) @@ -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 @@ -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} */ @@ -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 } @@ -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' @@ -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 * @@ -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' diff --git a/tests/acceptance/stepDefinitions/filesContext.js b/tests/acceptance/stepDefinitions/filesContext.js index 26b4e6285ac..87b5fe599af 100644 --- a/tests/acceptance/stepDefinitions/filesContext.js +++ b/tests/acceptance/stepDefinitions/filesContext.js @@ -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()))