Skip to content

Commit

Permalink
wip1
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Mar 13, 2020
1 parent e29eec6 commit c955ea7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ Feature: Sharing files and folders with internal groups
| share_with | grp1 |
| expiration | +7 |

Scenario Outline: default expiration date on group share
Scenario Outline: auto set default expiration date on group share
Given the setting "shareapi_default_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 "42"
And user "user3" has logged in using the webUI
Expand All @@ -386,13 +386,13 @@ Feature: Sharing files and folders with internal groups
| lorem.txt | lorem (2).txt |
| simple-folder | simple-folder (2) |

Scenario Outline: enforced expiration date on group share
Scenario Outline: user cannot create a group share with expiry date beyond enforced maximum expiration date
Given the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes"
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 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
Then the expiration date input field of collaborators form should have value with "+5" days on the webUI
And user "user1" should not have created any shares
Examples:
| shared-resource |
Expand All @@ -410,6 +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 the expiration date input field of collaborators form should have value with "+4" days on the webUI
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ 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 "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 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
Then the expiration date input field of collaborators form should have value with "+5" days on the webUI
And user "user1" should not have created any shares
Examples:
| shared-resource |
Expand All @@ -642,6 +642,7 @@ Feature: Sharing files and folders with internal users
| 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 resource "<shared-resource>" to "+7" days using the webUI
Then the expiration date input field of collaborators form should have value with "+4" days on the webUI
Then it should not be possible to save the pending share on the webUI
Examples:
| shared-resource |
Expand Down Expand Up @@ -675,7 +676,7 @@ Feature: Sharing files and folders with internal users
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 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
Then the expiration date input field of collaborators form should have value with "+5" days on the webUI
Examples:
| shared-resource |
| lorem.txt |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = {
const monthSelector = this.setExpiryDateMonthSelectorXpath(
pastDate.toLocaleString('en-GB', { month: 'long' })
)
const daySelector = this.setExpiryDateDaySelectorXpath(pastDate.getDay())
const daySelector = this.setExpiryDateDaySelectorXpath(pastDate.getDate())
await this
.waitForElementVisible('@dateTimePopupYear')
.waitForAnimationToFinish()
Expand Down Expand Up @@ -147,21 +147,24 @@ 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
* @param {string} shareType link|collaborator
* @returns {Promise<boolean>} returns true if succeeds to set provided expiration date
*/
setExpirationDate: async function (value) {
setExpirationDate: async function (value, shareType = 'collaborator') {
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
if (shareType === 'collaborator') {
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' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,20 @@ module.exports = {
* @param value values for the different fields to be set
* @returns {*|Promise<void>|exports}
*/
setPublicLinkForm: async function (key, value) {
setPublicLinkForm: 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') {
const expectToSucceed = await this.api.page
return this.api.page
.FilesPageElement
.sharingDialog()
.openExpiryDateCalender()
.setExpirationDate(value)
if (!expectToSucceed) {
console.log('WARNING: Cannot create share with disabled expiration date!')
return
}
.setExpirationDate(value, 'link')
}
return this
},
/**
* sets up public link share edit form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ module.exports = {
await this
.waitForElementVisible('@expirationDateField')
.getValue('@expirationDateField', (result) => {
console.log(result)
expirationDate = result.value
})
return expirationDate
Expand All @@ -520,7 +519,6 @@ module.exports = {
await this
.waitForElementVisible('@saveShareButton')
.getAttribute('@saveShareButton', 'disabled', (result) => {
console.log(result)
disabled = result.value
})
return disabled
Expand Down
61 changes: 12 additions & 49 deletions tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,56 +1031,19 @@ Then('user {string} should have received a share with target {string} and expira
return checkReceivedSharesExpirationDate(user, target, days)
})

const assertExpirationInputValueWithEnforcedDays = async function (enforcedDays) {
const expectedDateTime = new Date()
enforcedDays = parseInt(enforcedDays.ocs.data.stdOut)
expectedDateTime.setDate(expectedDateTime.getDate() + parseInt(enforcedDays))
const expectedDate = new Date(Date.UTC(
expectedDateTime.getFullYear(),
expectedDateTime.getMonth(),
expectedDateTime.getDate()
))
const actualExpirationDate = await client.page.FilesPageElement
.sharingDialog()
.getExpirationDateFromInputField()
const [month, day, year] = actualExpirationDate.split(' ')
const monthNames = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
]
const actualDate = new Date(Date.UTC(
parseInt(year),
monthNames.indexOf(month),
parseInt(day)
))
const actualDays = Math.floor((actualDate - expectedDate) / (86400000))
assert.strictEqual(
enforcedDays,
actualDays
)
}

Then('enforced maximum expiration date for group share should be set in the expiration date input field of collaborators form on the webUI',
async function () {
const enforcedDays = await runOcc(
[
'config:app:get',
'core',
'shareapi_expire_after_n_days_group_share'
]
)
return assertExpirationInputValueWithEnforcedDays(enforcedDays)
})

Then('enforced maximum expiration date for user share should be set in the expiration date input field of collaborators form on the webUI',
async function () {
const enforcedDays = await runOcc(
[
'config:app:get',
'core',
'shareapi_expire_after_n_days_user_share'
]
Then('the expiration date input field of collaborators form should have value with {string} days on the webUI',
async function (expectedDays) {
let expectedDate = sharingHelper.calculateDate(expectedDays)
expectedDate = new Date((Date.parse(expectedDate)))
const expectedDateString = expectedDate.toLocaleString('en-GB', { month: 'short' }) + ' ' +
(expectedDate.getDate()).toString() + ', ' + expectedDate.getFullYear()
const dateStringFromInputField = await client.page.FilesPageElement
.sharingDialog()
.getExpirationDateFromInputField()
assert.strictEqual(
expectedDateString,
dateStringFromInputField
)
return assertExpirationInputValueWithEnforcedDays(enforcedDays)
})

Then('it should not be possible to save the pending share on the webUI', async function () {
Expand Down

0 comments on commit c955ea7

Please sign in to comment.