Skip to content

Commit

Permalink
Merge pull request #3094 from swoichha/sharingDialog-PageObjectSplit-…
Browse files Browse the repository at this point in the history
…clickEditShare

[Tests-Only] Moved clickEditShare command into collaboratorsDialog
  • Loading branch information
jasson99 authored Feb 27, 2020
2 parents 0056156 + 3162263 commit 744f98c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const util = require('util')
module.exports = {
commands: {
/**
* @param collaborator
* @param {string} collaborator
* @returns {Promise.<string[]>} Array of autocomplete webElementIds
*/
deleteShareWithUserGroup: function (collaborator) {
Expand Down Expand Up @@ -31,6 +31,24 @@ module.exports = {
.waitForOutstandingAjaxCalls()
.waitForElementVisible('@createShareDialog')
.waitForAnimationToFinish()
.useCss()
},
/**
*
* @param {string} collaborator
*/
clickEditShare: function (collaborator) {
const informationSelector = util.format(
this.elements.collaboratorInformationByCollaboratorName.selector,
collaborator
)
const editSelector = informationSelector + this.elements.editShareButton.selector
return this
.useXpath()
.waitForElementVisible(editSelector)
.click(editSelector)
.waitForElementVisible('@editShareDialog')
.useCss()
}
},
elements: {
Expand All @@ -50,6 +68,15 @@ module.exports = {
createShareDialog: {
selector: '//*[contains(@class, "files-collaborators-collaborator-add-dialog")]',
locateStrategy: 'xpath'
},
editShareButton: {
// within collaboratorInformationByCollaboratorName
selector: '//*[contains(@class, "files-collaborators-collaborator-edit")]',
locateStrategy: 'xpath'
},
editShareDialog: {
selector: '//*[contains(@class, "files-collaborators-collaborator-edit-dialog")]',
locateStrategy: 'xpath'
}
}
}
37 changes: 7 additions & 30 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const federationSharePostfix = '\nRemote user'
const util = require('util')
const _ = require('lodash')
const { COLLABORATOR_PERMISSION_ARRAY } = require('../../helpers/sharingHelper')
const { client } = require('nightwatch-api')
const collaboratorDialog = client.page.FilesPageElement.SharingDialog.collaboratorsDialog()

module.exports = {
commands: {
Expand Down Expand Up @@ -146,7 +148,7 @@ module.exports = {
* @param {string} permissions
*/
shareWithUserOrGroup: async function (sharee, shareWithGroup = false, role, permissions, remote = false) {
await this.api.page.FilesPageElement.SharingDialog.collaboratorsDialog().clickCreateShare()
await collaboratorDialog.clickCreateShare()
await this.selectCollaboratorForShare(sharee, shareWithGroup, remote)
await this.selectRoleForNewCollaborator(role)
if (permissions === undefined) {
Expand Down Expand Up @@ -183,22 +185,6 @@ module.exports = {
.waitForOutstandingAjaxCalls()
.waitForElementNotPresent('@saveShareButton')
},
/**
*
* @param {string} collaborator
*/
clickEditShare: function (collaborator) {
const informationSelector = util.format(
this.elements.collaboratorInformationByCollaboratorName.selector,
collaborator
)
const editSelector = informationSelector + this.elements.editShareButton.selector
return this
.useXpath()
.waitForElementVisible(editSelector)
.click(editSelector)
.waitForElementVisible('@editShareDialog')
},
clickCancel: function () {
return this
.waitForElementVisible('@cancelButton')
Expand Down Expand Up @@ -254,7 +240,7 @@ module.exports = {
* @param {string} requiredPermissions
*/
changeCustomPermissionsTo: async function (collaborator, requiredPermissions) {
await this.clickEditShare(collaborator)
await collaboratorDialog.clickEditShare(collaborator)

const requiredPermissionArray = this.getArrayFromPermissionString(requiredPermissions)
const sharePermissions = await this.getSharePermissions()
Expand All @@ -281,7 +267,7 @@ module.exports = {
* @param {string} permissions
*/
getDisplayedPermission: async function (collaborator) {
await this.clickEditShare(collaborator)
await collaboratorDialog.clickEditShare(collaborator)
// read the permissions from the checkboxes
const currentSharePermissions = await this.getSharePermissions()
await this.clickCancel()
Expand All @@ -292,7 +278,7 @@ module.exports = {
* @param {string} collaborator
*/
disableAllCustomPermissions: async function (collaborator) {
await this.clickEditShare(collaborator)
await collaboratorDialog.clickEditShare(collaborator)
const sharePermissions = await this.getSharePermissions(collaborator)
const enabledPermissions = Object.keys(sharePermissions)
.filter(permission => sharePermissions[permission] === true)
Expand Down Expand Up @@ -370,7 +356,7 @@ module.exports = {
* @returns {Promise}
*/
changeCollaboratorRole: async function (collaborator, newRole) {
await this.clickEditShare(collaborator)
await collaboratorDialog.clickEditShare(collaborator)
await this.changeCollaboratorRoleInDropdown(newRole)
return this.saveCollaboratorPermission()
},
Expand Down Expand Up @@ -569,18 +555,9 @@ module.exports = {
selector: '/a',
locateStrategy: 'xpath'
},
editShareButton: {
// within collaboratorInformationByCollaboratorName
selector: '//*[contains(@class, "files-collaborators-collaborator-edit")]',
locateStrategy: 'xpath'
},
cancelButton: {
selector: '.files-collaborators-collaborator-cancel'
},
editShareDialog: {
selector: '//*[contains(@class, "files-collaborators-collaborator-edit-dialog")]',
locateStrategy: 'xpath'
},
addShareSaveButton: {
selector: '#files-collaborators-collaborator-save-new-share-button'
},
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ When('the user opens the share creation dialog in the webUI', function () {
})

When('the user cancels the share creation dialog in the webUI', function () {
return client.page.FilesPageElement.collaboratorsDialog().clickCancel()
return client.page.FilesPageElement.sharingDialog().clickCancel()
})

When('the user types {string} in the share-with-field', function (input) {
Expand Down

0 comments on commit 744f98c

Please sign in to comment.