Skip to content

Commit

Permalink
Added acceptance test for changing existing expiration date of a user…
Browse files Browse the repository at this point in the history
… share
  • Loading branch information
kiranparajuli589 committed Mar 10, 2020
1 parent dd34644 commit b65eda1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,21 @@ Feature: Sharing files and folders with internal users
And default expiration date for users is set to 3 days
And user "user1" has logged in using the webUI
When the user shares file "testimage.jpg" with user "User Two" using the webUI
Then user "user2" should have received a share with target "testimage (2).jpg" and expiration date in 3 days
Then user "user2" should have received a share with target "testimage (2).jpg" and expiration date in 3 days

Scenario: change existing expiration date of an existing share with another internal user
Given user "user1" has created a new share with following settings
| path | lorem.txt |
| shareWith | user2 |
| expireDate | 2038-10-12 |
And user "user1" has logged in using the webUI
When the user edits share with user "User Two" of file "lorem.txt" changing following
| expireDate | +7 |
Then user "user2" should have received a share with target "lorem (2).txt" and expiration date in 7 days
And user "user1" should have a share with these details:
| field | value |
| path | /lorem.txt |
| share_type | user |
| uid_owner | user1 |
| share_with | user2 |
| expiration | +7 |
22 changes: 18 additions & 4 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module.exports = {
.waitForOutstandingAjaxCalls()
.waitForElementNotPresent('@addShareSaveButton')
},
saveCollaboratorPermission: function () {
saveChanges: function () {
return this.waitForElementVisible('@saveShareButton')
.initAjaxCounters()
.click('@saveShareButton')
Expand Down Expand Up @@ -268,7 +268,7 @@ module.exports = {
}
}
if (changed) {
await this.saveCollaboratorPermission()
await this.saveChanges()
} else {
await this.clickCancel()
}
Expand Down Expand Up @@ -298,7 +298,7 @@ module.exports = {
for (const permission of enabledPermissions) {
await this.toggleSinglePermission(permission)
}
await this.saveCollaboratorPermission()
await this.saveChanges()
},
/**
*
Expand Down Expand Up @@ -370,7 +370,7 @@ module.exports = {
changeCollaboratorRole: async function (collaborator, newRole) {
await collaboratorDialog.clickEditShare(collaborator)
await this.changeCollaboratorRoleInDropdown(newRole)
return this.saveCollaboratorPermission()
return this.saveChanges()
},
/**
* @params {string} newRole
Expand Down Expand Up @@ -485,6 +485,20 @@ module.exports = {
}

return this.useXpath().expect.element(collaboratorSelector).to.not.be.present
},
/**
* @param collaborator
* @param value
*
* @return {Promise<*>}
*/
changeCollaboratorExpiryDate: async function (collaborator, value) {
await collaboratorDialog.clickEditShare(collaborator)
await this.api.page
.FilesPageElement
.publicLinksDialog()
.setPublicLinkExpiryDate(value)
return this.saveChanges()
}
},
elements: {
Expand Down
41 changes: 41 additions & 0 deletions tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,36 @@ const shareFileFolder = function (
httpHelper.checkOCSStatus(json, 'Could not create share. Message: ' + json.ocs.meta.message)
})
}
/**
* create any share using dataTable
*
* @param {string} sharer
* @param {object} dataTable (attrs like: path, shareWith, expireDate, name, permissionString,
* password can be passed inside dataTable)
*
* @return void
*/
Given('user {string} has created a new share with following settings',
function (sharer, dataTable) {
const settings = dataTable.rowsHash()
let expireDate = settings.expireDate
if (typeof expireDate !== 'undefined') {
expireDate = sharingHelper.calculateDate(expireDate)
}
return shareFileFolder(
settings.path,
sharer,
settings.shareWith,
settings.shareType,
settings.permissionString,
settings.name,
{
expireDate: expireDate,
password: settings.password
}
)
})

/**
* sets up data into a standard format for creating new public link share
*
Expand Down Expand Up @@ -742,6 +772,17 @@ When(
}
)

When('the user edits share with user {string} of file/folder/resource {string} changing following',
async function (collaborator, resource, dataTable) {
const api = client.page.FilesPageElement
const settings = dataTable.rowsHash()
await api
.appSideBar()
.closeSidebar(100)
.openSharingDialog(resource)
return api.sharingDialog().changeCollaboratorExpiryDate(collaborator, settings.expireDate)
})

Then('user {string} should be listed as {string} in the collaborators list on the webUI', function (user, role) {
return assertCollaboratorslistContains('user', user, { role })
})
Expand Down

0 comments on commit b65eda1

Please sign in to comment.