Skip to content

Commit

Permalink
More Refactors and added jsDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Mar 13, 2020
1 parent 6e5a9d1 commit 46301da
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = {
return this.api.page
.FilesPageElement
.sharingDialog()
.openExpiryDateCalender()
.openExpirationDatePicker()
.setExpirationDate(value, 'link')
}
},
Expand Down
31 changes: 21 additions & 10 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const util = require('util')
const _ = require('lodash')
const sharingHelper = require('../../helpers/sharingHelper')
const { client } = require('nightwatch-api')
const sharingHelper = require('../../helpers/sharingHelper')
const collaboratorDialog = client.page.FilesPageElement.SharingDialog.collaboratorsDialog()
const SHARE_TYPE_STRING = {
user: 'user',
group: 'group',
federation: 'remote'
}
const COLLABORATOR_PERMISSION_ARRAY = sharingHelper.COLLABORATOR_PERMISSION_ARRAY

module.exports = {
commands: {
Expand Down Expand Up @@ -139,9 +140,7 @@ module.exports = {
*
* @return void
*/
shareWithUserOrGroup: async function (
sharee, shareWithGroup = false, role, permissions, remote = false, days
) {
shareWithUserOrGroup: async function (sharee, shareWithGroup = false, role, permissions, remote = false, days) {
await collaboratorDialog.clickCreateShare()
await this.selectCollaboratorForShare(sharee, shareWithGroup, remote)
await this.selectRoleForNewCollaborator(role)
Expand All @@ -153,7 +152,7 @@ module.exports = {
if (days) {
const dateToSet = sharingHelper.calculateDate(days)
const expectToSucceed = await this
.openExpiryDateCalender()
.openExpirationDatePicker()
.setExpirationDate(dateToSet)
if (!expectToSucceed) {
console.log('WARNING: Cannot create share with disabled expiration date!')
Expand Down Expand Up @@ -222,18 +221,18 @@ module.exports = {
const permissions = {}
const panelSelector = this.elements.sharingSidebarRoot.selector
let permissionToggle
for (let i = 0; i < sharingHelper.COLLABORATOR_PERMISSION_ARRAY.length; i++) {
for (let i = 0; i < COLLABORATOR_PERMISSION_ARRAY.length; i++) {
permissionToggle = panelSelector + util.format(
this.elements.permissionCheckbox.selector,
sharingHelper.COLLABORATOR_PERMISSION_ARRAY[i]
COLLABORATOR_PERMISSION_ARRAY[i]
)

await this.api.element('xpath', permissionToggle, result => {
if (!result.value.ELEMENT) {
return
}
return this.api.elementIdSelected(result.value.ELEMENT, result => {
permissions[sharingHelper.COLLABORATOR_PERMISSION_ARRAY[i]] = result.value
permissions[COLLABORATOR_PERMISSION_ARRAY[i]] = result.value
})
})
}
Expand Down Expand Up @@ -490,21 +489,29 @@ module.exports = {
await collaboratorDialog.clickEditShare(collaborator)
const dateToSet = sharingHelper.calculateDate(days)
const expectToSucceed = await this
.openExpiryDateCalender()
.openExpirationDatePicker()
.setExpirationDate(dateToSet)
if (!expectToSucceed) {
console.log('WARNING: Cannot create share with disabled expiration date!')
return
}
return this.saveChanges()
},
openExpiryDateCalender: function () {
/**
* opens expiration date field on the webUI
* @return {*}
*/
openExpirationDatePicker: function () {
this
.initAjaxCounters()
.waitForElementVisible('@expirationDateField')
.click('@expirationDateField')
return client.page.FilesPageElement.expirationDatePicker()
},
/**
* extracts set value in expiration date field
* @return {Promise<*>}
*/
getExpirationDateFromInputField: async function () {
let expirationDate
await this
Expand All @@ -514,6 +521,10 @@ module.exports = {
})
return expirationDate
},
/**
* gets disabled status of save share button
* @return {Promise<*>}
*/
getDisabledAttributeOfSaveShareButton: async function () {
let disabled
await this
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/stepDefinitions/publicLinkContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ When('the user tries to edit expiration of the public link named {string} of fil
const dateToSet = new Date(Date.parse(value))
const isDisabled = await api
.sharingDialog()
.openExpiryDateCalender()
.openExpirationDatePicker()
.isExpiryDateDisabled(dateToSet)
return assert.ok(
isDisabled,
Expand Down

0 comments on commit 46301da

Please sign in to comment.