Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Mar 12, 2020
1 parent 30cb24c commit e29eec6
Showing 7 changed files with 178 additions and 124 deletions.
Original file line number Diff line number Diff line change
@@ -391,20 +391,13 @@ Feature: Sharing files and folders with internal groups
And the setting "shareapi_enforce_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "5"
And user "user3" has logged in using the webUI
When the user tries to share file "<shared-resource>" with group "grp1" which expires after 6 days using the webUI
Then user "user3" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | group |
| uid_owner | user3 |
| share_with | grp1 |
| expiration | +5 |
And user "user1" should have received a share with target "<target-resource>" and expiration date in 5 days
And user "user2" should have received a share with target "<target-resource>" and expiration date in 5 days
When the user tries to share file "<shared-resource>" with group "grp1" which expires in "+6" days using the webUI
Then enforced maximum expiration date for group share should be set in the expiration date input field of collaborators form on the webUI
And user "user1" should not have created any shares
Examples:
| shared-resource | target-resource |
| lorem.txt | lorem (2).txt |
| simple-folder | simple-folder (2) |
| shared-resource |
| lorem.txt |
| simple-folder |

Scenario Outline: user cannot change the expiry date of an existing group share to a date that is past enforced maximum expiration date
Given the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes"
@@ -417,13 +410,7 @@ Feature: Sharing files and folders with internal groups
| expireDate | +4 |
And user "user3" has logged in using the webUI
When the user tries to edit the collaborator expiry date of "grp1" of file "<shared-resource>" to "+7" days using the webUI
Then user "user3" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | group |
| uid_owner | user3 |
| share_with | grp1 |
| expiration | +4 |
Then it should not be possible to save the pending share on the webUI
And user "user1" should have received a share with target "<target-resource>" and expiration date in 4 days
And user "user2" should have received a share with target "<target-resource>" and expiration date in 4 days
Examples:
Original file line number Diff line number Diff line change
@@ -593,7 +593,7 @@ Feature: Sharing files and folders with internal users

Scenario: share a file with another internal user which should expire after 2 days
Given user "user1" has logged in using the webUI
When the user shares file "testimage.jpg" with user "User Two" which expires after 2 days using the webUI
When the user shares file "testimage.jpg" with user "User Two" which expires in "+2" days using the webUI
Then user "user2" should have received a share with target "testimage (2).jpg" and expiration date in 2 days

Scenario: share a file with another internal user with default expiration date
@@ -624,19 +624,13 @@ Feature: Sharing files and folders with internal users
And the setting "shareapi_enforce_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_user_share" of app "core" has been set to "5"
And user "user1" has logged in using the webUI
When the user tries to share file "<shared-resource>" with user "User Two" which expires after 6 days using the webUI
Then user "user1" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | user |
| uid_owner | user1 |
| share_with | user2 |
| expiration | +5 |
And user "user2" should have received a share with target "<target-resource>" and expiration date in 5 days
When the user tries to share file "<shared-resource>" with user "User Two" which expires in "+6" days using the webUI
Then enforced maximum expiration date for user share should be set in the expiration date input field of collaborators form on the webUI
And user "user1" should not have created any shares
Examples:
| shared-resource | target-resource |
| lorem.txt | lorem (2).txt |
| simple-folder | simple-folder (2) |
| shared-resource |
| lorem.txt |
| simple-folder |

Scenario Outline: user cannot change the expiry date of an existing user share to a date that is past enforced maximum expiration date
Given the setting "shareapi_default_expire_date_user_share" of app "core" has been set to "yes"
@@ -647,14 +641,8 @@ Feature: Sharing files and folders with internal users
| shareWith | user2 |
| expireDate | +4 |
And user "user1" has logged in using the webUI
When the user tries to edit the collaborator expiry date of "User Two" of file "<shared-resource>" to "+7" days using the webUI
Then user "user1" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | user |
| uid_owner | user1 |
| share_with | user2 |
| expiration | +4 |
When the user tries to edit the collaborator expiry date of "User Two" of resource "<shared-resource>" to "+7" days using the webUI
Then it should not be possible to save the pending share on the webUI
Examples:
| shared-resource |
| lorem.txt |
@@ -665,7 +653,7 @@ Feature: Sharing files and folders with internal users
And the setting "shareapi_enforce_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_user_share" of app "core" has been set to "5"
And user "user1" has logged in using the webUI
When the user shares file "lorem.txt" with user "User Two" which expires after 4 days using the webUI
When the user shares file "lorem.txt" with user "User Two" which expires in "+4" days using the webUI
Then user "user1" should have a share with these details:
| field | value |
| path | /lorem.txt |
@@ -686,15 +674,8 @@ Feature: Sharing files and folders with internal users
And the setting "shareapi_expire_after_n_days_user_share" of app "core" has been set to "10"
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "5"
And user "user3" has logged in using the webUI
When the user shares file "<shared-resource>" with user "User Two" which expires after 6 days using the webUI
Then user "user3" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | user |
| uid_owner | user3 |
| share_with | user2 |
| expiration | +5 |
# | expiration | +6 |
When the user tries to share file "<shared-resource>" with user "User Two" which expires in "+6" days using the webUI
Then enforced maximum expiration date for user share should be set in the expiration date input field of collaborators form on the webUI
Examples:
| shared-resource |
| lorem.txt |
Original file line number Diff line number Diff line change
@@ -107,9 +107,6 @@ module.exports = {
)
const daySelector = this.setExpiryDateDaySelectorXpath(pastDate.getDay())
await this
.initAjaxCounters()
.waitForElementVisible('@linkExpirationDateField')
.click('@linkExpirationDateField')
.waitForElementVisible('@dateTimePopupYear')
.waitForAnimationToFinish()
.waitForElementEnabled(
@@ -150,25 +147,30 @@ module.exports = {
* 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}
* @returns {Promise<boolean>} returns true if succeeds to set provided expiration date
*/
setExpirationDate: async function (value) {
if (value === '') {
return this.click('@publicLinkDeleteExpirationDateButton')
}
value = sharingHelper.calculateDate(value)
const dateToSet = new Date(Date.parse(value))
const disabled = await this.isExpiryDateDisabled(dateToSet)
if (disabled) {
console.log('WARNING: Cannot change expiration date to disabled value!')
await this
.waitForElementVisible('@dateTimeCancelButton')
.click('@dateTimeCancelButton')
return false
}
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)
return true
}
},
elements: {
@@ -191,12 +193,13 @@ module.exports = {
selector: '//div[@class="vdatetime-popup__actions"]/div[.="Ok"]',
locateStrategy: 'xpath'
},
dateTimeCancelButton: {
selector: '//div[@class="vdatetime-popup__actions"]/div[.="Cancel"]',
locateStrategy: 'xpath'
},
dateTimePopupDate: {
selector: '.vdatetime-popup__date'
},
linkExpirationDateField: {
selector: '.vdatetime-input'
},
publicLinkDeleteExpirationDateButton: {
selector: '#oc-files-file-link-expire-date-delete'
}
17 changes: 11 additions & 6 deletions tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js
Original file line number Diff line number Diff line change
@@ -71,18 +71,23 @@ module.exports = {
* @param value values for the different fields to be set
* @returns {*|Promise<void>|exports}
*/
setPublicLinkForm: function (key, value) {
setPublicLinkForm: async function (key, value) {
if (key === 'role') {
return this.setPublicLinkRole(value)
} else if (key === 'name') {
return this.setPublicLinkName(value)
} else if (key === 'password') {
return this.setPublicLinkPassword(value)
} else if (key === 'expireDate') {
return this.api.page
const expectToSucceed = await this.api.page
.FilesPageElement
.expirationDatePicker()
.sharingDialog()
.openExpiryDateCalender()
.setExpirationDate(value)
if (!expectToSucceed) {
console.log('WARNING: Cannot create share with disabled expiration date!')
return
}
}
return this
},
@@ -97,10 +102,10 @@ module.exports = {
* @param {string} editData.expireDate - Expire date for a public link share
* @returns {exports}
*/
editPublicLink: function (linkName, editData) {
this.clickLinkEditBtn(linkName)
editPublicLink: async function (linkName, editData) {
await this.clickLinkEditBtn(linkName)
for (const [key, value] of Object.entries(editData)) {
this.setPublicLinkForm(key, value)
await this.setPublicLinkForm(key, value)
}
return this
},
89 changes: 54 additions & 35 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const util = require('util')
const _ = require('lodash')
const { COLLABORATOR_PERMISSION_ARRAY } = require('../../helpers/sharingHelper')
const sharingHelper = require('../../helpers/sharingHelper')
const { client } = require('nightwatch-api')
const collaboratorDialog = client.page.FilesPageElement.SharingDialog.collaboratorsDialog()
const SHARE_TYPE_STRING = {
@@ -128,38 +128,19 @@ module.exports = {
return this
},

/**
* @param {int} days
*/
selectExpirationDaysOnPendingShare: async function (days) {
const currentDate = new Date()
const currentDay = currentDate.getDate()
const currentMonth = currentDate.getMonth()
const expirationDate = new Date(currentDate.setDate(currentDay + days))
const dateSelector = util.format(this.elements.collaboratorExpirationDateModalDay.selector, expirationDate.getDate())

if (expirationDate.getMonth() !== currentMonth) {
await this.click('@collaboratorExpirationDateModalNextMonthButton')
}

await this.click('@collaboratorExpirationDateInput')
await this.useXpath().click(dateSelector)
await this.click('@collaboratorExpirationDateModalConfirmButton')
await this.useCss()
return this
},

/**
*
* @param {string} sharee
* @param {boolean} shareWithGroup
* @param {string} role
* @param {string} permissions
* @param {boolean} remote
* @param {int} days
* @param {string} days
* @param {boolean} expectToSucceed
*/
shareWithUserOrGroup: async function (
sharee, shareWithGroup = false, role, permissions, remote = false, days
sharee, shareWithGroup = false, role, permissions,
remote = false, days, expectToSucceed = true
) {
await collaboratorDialog.clickCreateShare()
await this.selectCollaboratorForShare(sharee, shareWithGroup, remote)
@@ -170,7 +151,14 @@ module.exports = {
}

if (days) {
await this.selectExpirationDaysOnPendingShare(days)
const dateToSet = sharingHelper.calculateDate(days)
const expectToSucceed = await this
.openExpiryDateCalender()
.setExpirationDate(dateToSet)
if (!expectToSucceed) {
console.log('WARNING: Cannot create share with disabled expiration date!')
return
}
}

return this.confirmShare()
@@ -234,18 +222,18 @@ module.exports = {
const permissions = {}
const panelSelector = this.elements.sharingSidebarRoot.selector
let permissionToggle
for (let i = 0; i < COLLABORATOR_PERMISSION_ARRAY.length; i++) {
for (let i = 0; i < sharingHelper.COLLABORATOR_PERMISSION_ARRAY.length; i++) {
permissionToggle = panelSelector + util.format(
this.elements.permissionCheckbox.selector,
COLLABORATOR_PERMISSION_ARRAY[i]
sharingHelper.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[COLLABORATOR_PERMISSION_ARRAY[i]] = result.value
permissions[sharingHelper.COLLABORATOR_PERMISSION_ARRAY[i]] = result.value
})
})
}
@@ -494,20 +482,48 @@ module.exports = {
/**
* @param {string} collaborator Name of the collaborator
* @param {string} days number of days to be added or subtracted from current date
* @param {boolean} tries
* @param {boolean} expectToSucceed
*
* @return {Promise<*>}
*/
changeCollaboratorExpiryDate: async function (collaborator, days, tries = false) {
changeCollaboratorExpiryDate: async function (collaborator, days) {
await collaboratorDialog.clickEditShare(collaborator)
await this.api.page
.FilesPageElement
.expirationDatePicker()
const expectToSucceed = await this
.openExpiryDateCalender()
.setExpirationDate(days)
if (!tries) {
this.saveChanges()
if (!expectToSucceed) {
console.log('WARNING: Cannot create share with disabled expiration date!')
return
}
await this.saveChanges()
return this
},
openExpiryDateCalender: function () {
this
.initAjaxCounters()
.waitForElementVisible('@expirationDateField')
.click('@expirationDateField')
return client.page.FilesPageElement.expirationDatePicker()
},
getExpirationDateFromInputField: async function () {
let expirationDate
await this
.waitForElementVisible('@expirationDateField')
.getValue('@expirationDateField', (result) => {
console.log(result)
expirationDate = result.value
})
return expirationDate
},
getDisabledAttributeOfSaveShareButton: async function () {
let disabled
await this
.waitForElementVisible('@saveShareButton')
.getAttribute('@saveShareButton', 'disabled', (result) => {
console.log(result)
disabled = result.value
})
return disabled
}
},
elements: {
@@ -621,6 +637,9 @@ module.exports = {
collaboratorsListItemName: {
selector: '//span[contains(@class, "files-collaborators-collaborator-name") and text()="%s"]',
locateStrategy: 'xpath'
},
expirationDateField: {
selector: '.vdatetime-input'
}
}
}
Loading

0 comments on commit e29eec6

Please sign in to comment.