Skip to content

Commit

Permalink
moved setExpirationDate function to expiration PO
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Mar 11, 2020
1 parent b8acffd commit 735f875
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const util = require('util')
const sharingHelper = require('../../helpers/sharingHelper')

module.exports = {
commands: {
Expand Down Expand Up @@ -144,6 +145,30 @@ module.exports = {
}
})
return disabled
},
/**
* sets expiration date on collaborators/public-link shares
*
* @param {string} value - provided date in format YYYY-MM-DD, or empty string to unset date
* @returns {Promise}
*/
setExpirationDate: async function (value) {
if (value === '') {
return this.click('@publicLinkDeleteExpirationDateButton')
}
value = sharingHelper.calculateDate(value)
const dateToSet = new Date(Date.parse(value))
const year = dateToSet.getFullYear()
const month = dateToSet.toLocaleString('en-GB', { month: 'long' })
const day = dateToSet.getDate()
await this
.initAjaxCounters()
.waitForElementVisible('@linkExpirationDateField')
.click('@linkExpirationDateField')
return this
.setExpiryDateYear(year)
.setExpiryDateMonth(month)
.setExpiryDateDay(day)
}
},
elements: {
Expand Down Expand Up @@ -171,6 +196,9 @@ module.exports = {
},
linkExpirationDateField: {
selector: '.vdatetime-input'
},
publicLinkDeleteExpirationDateButton: {
selector: '#oc-files-file-link-expire-date-delete'
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const util = require('util')
const _ = require('lodash')
const sharingHelper = require('../../helpers/sharingHelper')

module.exports = {
commands: {
Expand Down Expand Up @@ -65,32 +64,6 @@ module.exports = {
.clearValue('@publicLinkPasswordField')
.setValue('@publicLinkPasswordField', linkPassword)
},
/**
* sets expire date of the public link share using webUI
*
* @param {string} value - provided date in format YYYY-MM-DD, or empty string to unset date
* @returns {Promise}
*/
setPublicLinkExpiryDate: async function (value) {
const expirationDatePicker = this.api.page.FilesPageElement.expirationDatePicker()
if (value === '') {
return this.click('@publicLinkDeleteExpirationDateButton')
}
value = sharingHelper.calculateDate(value)
const dateToSet = new Date(Date.parse(value))
const year = dateToSet.getFullYear()
const month = dateToSet.toLocaleString('en-GB', { month: 'long' })
const day = dateToSet.getDate()
const linkExpirationDateField = expirationDatePicker.elements.linkExpirationDateField.selector
await this
.initAjaxCounters()
.waitForElementVisible(linkExpirationDateField)
.click(linkExpirationDateField)
return expirationDatePicker
.setExpiryDateYear(year)
.setExpiryDateMonth(month)
.setExpiryDateDay(day)
},
/**
* function sets different fields for public link
*
Expand All @@ -106,7 +79,7 @@ module.exports = {
} else if (key === 'password') {
return this.setPublicLinkPassword(value)
} else if (key === 'expireDate') {
return this.setPublicLinkExpiryDate(value)
return this.setExpirationDate(value)
}
return this
},
Expand Down Expand Up @@ -430,9 +403,6 @@ module.exports = {
},
sidebarPrivateLinkIconCopied: {
selector: '#files-sidebar-private-link-icon-copied'
},
publicLinkDeleteExpirationDateButton: {
selector: '#oc-files-file-link-expire-date-delete'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ module.exports = {
await collaboratorDialog.clickEditShare(collaborator)
await this.api.page
.FilesPageElement
.publicLinksDialog()
.setPublicLinkExpiryDate(value)
.expirationDatePicker()
.setExpirationDate(value)
return this.saveChanges()
}
},
Expand Down

0 comments on commit 735f875

Please sign in to comment.