From a713423ae0826e4383b8603212879e9ab836a63f Mon Sep 17 00:00:00 2001 From: HariBhandari Date: Mon, 16 Mar 2020 12:11:23 +0545 Subject: [PATCH] fixes --- .../shareWithGroups.feature | 4 +-- .../shareWithUsers.feature | 30 +++++++++++++++---- .../FilesPageElement/sharingDialog.js | 16 +++++----- .../stepDefinitions/sharingContext.js | 2 +- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature b/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature index 9dbae2430bf..90ab43e6a01 100644 --- a/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature +++ b/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature @@ -388,7 +388,7 @@ Feature: Sharing files and folders with internal groups 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 resource "" with group "grp1" which expires in "+6" days using the webUI - Then the expiration date input field of collaborators form should have value with "+5" days on the webUI + Then the expiration date shown on the webUI should be "+5" days And user "user1" should not have created any shares Examples: | shared-resource | @@ -406,7 +406,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 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 the expiration date shown on the webUI should be "+4" days And it should not be possible to save the pending share on the webUI And user "user1" should have received a share with target "" and expiration date in 4 days And user "user2" should have received a share with target "" and expiration date in 4 days diff --git a/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature b/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature index d6830d27b4b..3a2c157b9e4 100644 --- a/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature +++ b/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature @@ -638,8 +638,8 @@ 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 "" with user "User Two" which expires in "+6" days using the webUI - Then the expiration date input field of collaborators form should have value with "+5" days on the webUI + When the user tries to share resource "" with user "User Two" which expires in "+6" days using the webUI + Then the expiration date shown on the webUI should be "+5" days And user "user1" should not have created any shares Examples: | shared-resource | @@ -656,7 +656,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 "" 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 the expiration date shown on the webUI should be "+4" days And it should not be possible to save the pending share on the webUI Examples: | shared-resource | @@ -664,7 +664,7 @@ Feature: Sharing files and folders with internal users | simple-folder | @issue-3174 - Scenario Outline: user cannot share with user with expiration date within set enforced maximum date if default expiry date for both user and group is enabled + Scenario Outline: enforced expiry date for groups does not affect user shares Given user "user3" has been created with default attributes And group "grp1" has been created And user "user2" has been added to group "grp1" @@ -675,8 +675,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 tries to share file "" with user "User Two" which expires in "+6" days using the webUI - Then the expiration date input field of collaborators form should have value with "+5" days on the webUI + When the user tries to share resource "" with user "User Two" which expires in "+6" days using the webUI + Then the expiration date shown on the webUI should be "+5" days # Then user "user2" should have received a share with target "" and expiration date in 6 days # And user "user1" should have a share with these details: # | field | value | @@ -689,3 +689,21 @@ Feature: Sharing files and folders with internal users | shared-resource | | lorem.txt | | simple-folder | + + Scenario Outline: enforced expiry date for users does not affect group shares + Given user "user3" has been created with default attributes + And group "grp1" has been created + And user "user2" has been added to group "grp1" + And the setting "shareapi_default_expire_date_user_share" of app "core" has been set to "yes" + And the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes" + And the setting "shareapi_enforce_expire_date_user_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_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 tries to share resource "" with group "grp1" which expires in "+6" days using the webUI + Then the expiration date shown on the webUI should be "+5" days + Examples: + | shared-resource | + | lorem.txt | + | simple-folder | diff --git a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js index 8dcc599807f..10c8d3ea492 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js +++ b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js @@ -1,6 +1,6 @@ const util = require('util') const _ = require('lodash') -const sharingHelper = require('../../helpers/sharingHelper') +const { COLLABORATOR_PERMISSION_ARRAY, calculateDate } = require('../../helpers/sharingHelper') const { client } = require('nightwatch-api') const collaboratorDialog = client.page.FilesPageElement.SharingDialog.collaboratorsDialog() const SHARE_TYPE_STRING = { @@ -8,7 +8,6 @@ const SHARE_TYPE_STRING = { group: 'group', federation: 'remote' } -const COLLABORATOR_PERMISSION_ARRAY = sharingHelper.COLLABORATOR_PERMISSION_ARRAY module.exports = { commands: { @@ -150,11 +149,11 @@ module.exports = { } if (days) { - const dateToSet = sharingHelper.calculateDate(days) - const expectToSucceed = await this + const dateToSet = calculateDate(days) + const isExpiryDateChanged = await this .openExpirationDatePicker() .setExpirationDate(dateToSet) - if (!expectToSucceed) { + if (!isExpiryDateChanged) { console.log('WARNING: Cannot create share with disabled expiration date!') return } @@ -481,17 +480,16 @@ 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} expectToSucceed * * @return {Promise<*>} */ changeCollaboratorExpiryDate: async function (collaborator, days) { await collaboratorDialog.clickEditShare(collaborator) - const dateToSet = sharingHelper.calculateDate(days) - const expectToSucceed = await this + const dateToSet = calculateDate(days) + const isExpiryDateChanged = await this .openExpirationDatePicker() .setExpirationDate(dateToSet) - if (!expectToSucceed) { + if (!isExpiryDateChanged) { console.log('WARNING: Cannot create share with disabled expiration date!') return } diff --git a/tests/acceptance/stepDefinitions/sharingContext.js b/tests/acceptance/stepDefinitions/sharingContext.js index a41a8aa1e71..c09b665538d 100644 --- a/tests/acceptance/stepDefinitions/sharingContext.js +++ b/tests/acceptance/stepDefinitions/sharingContext.js @@ -1017,7 +1017,7 @@ Then('user {string} should have received a share with target {string} and expira return checkReceivedSharesExpirationDate(user, target, days) }) -Then('the expiration date input field of collaborators form should have value with {string} days on the webUI', +Then('the expiration date shown on the webUI should be {string} days', async function (expectedDays) { let expectedDate = sharingHelper.calculateDate(expectedDays) expectedDate = new Date((Date.parse(expectedDate)))