From ea03dab027840d112fa8e44a493c9aaaefa1fed1 Mon Sep 17 00:00:00 2001 From: Swoichha Adhikari Date: Thu, 1 Jul 2021 09:02:49 +0545 Subject: [PATCH] [tests-only] change collaborator permissions (#8788) --- test/gui/shared/scripts/names.py | 1 + .../scripts/pageObjects/SharingDialog.py | 32 ++++++++++++++-- test/gui/shared/steps/steps.py | 34 +++++++++++++++++ test/gui/tst_sharing/test.feature | 38 +++++++++++++++++++ 4 files changed, 101 insertions(+), 4 deletions(-) diff --git a/test/gui/shared/scripts/names.py b/test/gui/shared/scripts/names.py index 7188f72f9d6..01df761a5da 100644 --- a/test/gui/shared/scripts/names.py +++ b/test/gui/shared/scripts/names.py @@ -98,3 +98,4 @@ o_tableView_0_1_QModelIndex = {"column": 1, "container": oCC_IssuesWidget_tableView_QTableView, "row": 0, "type": "QModelIndex"} settings_settingsdialog_toolbutton_Add_account_QToolButton = {"name": "settingsdialog_toolbutton_Add account", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog} settings_settingsdialog_toolbutton_Activity_QToolButton = {"name": "settingsdialog_toolbutton_Activity", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog} +sharingDialog_Close_QPushButton = {"text": "Close", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": sharingDialog_OCC_ShareDialog} \ No newline at end of file diff --git a/test/gui/shared/scripts/pageObjects/SharingDialog.py b/test/gui/shared/scripts/pageObjects/SharingDialog.py index 0447593eb08..c1af02f9ada 100644 --- a/test/gui/shared/scripts/pageObjects/SharingDialog.py +++ b/test/gui/shared/scripts/pageObjects/SharingDialog.py @@ -44,6 +44,15 @@ class SharingDialog: "window": names.sharingDialog_OCC_ShareDialog, } + def getAvailablePermission(self): + + editChecked = squish.waitForObjectExists(self.EDIT_PERMISSIONS_CHECKBOX).checked + shareChecked = squish.waitForObjectExists( + self.SHARE_PERMISSIONS_CHECKBOX + ).checked + + return editChecked, shareChecked + def addCollaborator(self, receiver, permissions): squish.mouseClick( squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD), @@ -65,10 +74,8 @@ def addCollaborator(self, receiver, permissions): ) permissionsList = permissions.split(",") - editChecked = squish.waitForObjectExists(self.EDIT_PERMISSIONS_CHECKBOX).checked - shareChecked = squish.waitForObjectExists( - self.SHARE_PERMISSIONS_CHECKBOX - ).checked + editChecked, shareChecked = self.getAvailablePermission() + if ('edit' in permissionsList and editChecked == False) or ( 'edit' not in permissionsList and editChecked == True ): @@ -82,3 +89,20 @@ def addCollaborator(self, receiver, permissions): def getErrorText(self): return str(squish.waitForObjectExists(self.ERROR_SHOWN_ON_SHARING_DIALOG).text) + + def removePermissions(self, permissions): + removePermissionsList = permissions.split(",") + ( + isEditPermissionAvailable, + isSharePermissionAvailable, + ) = self.getAvailablePermission() + + if 'share' in removePermissionsList and isSharePermissionAvailable: + squish.clickButton( + squish.waitForObject(names.scrollArea_permissionShare_QCheckBox) + ) + + if 'edit' in removePermissionsList and isEditPermissionAvailable: + squish.clickButton( + squish.waitForObject(names.scrollArea_permissionsEdit_QCheckBox) + ) diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index 674d464f8f7..d3ef1d9a87c 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -646,3 +646,37 @@ def step(context): def step(context): for tabName in context.table: test.vp(tabName[0]) + + +@When( + 'the user removes permissions "|any|" for user "|any|" of resource "|any|" using the client-UI' +) +def step(context, permissions, receiver, resource): + openSharingDialog(context, resource) + test.compare( + str(waitForObjectExists(names.scrollArea_sharedWith_QLabel).text), receiver + ) + + shareItem = SharingDialog() + shareItem.removePermissions(permissions) + + +@When("the user closes the sharing dialog") +def step(context): + clickButton(waitForObject(names.sharingDialog_Close_QPushButton)) + + +@Then( + '"|any|" permissions should not be displayed for user "|any|" for resource "|any|" on the client-UI' +) +def step(context, permissions, user, resource): + permissionsList = permissions.split(',') + + shareItem = SharingDialog() + editChecked, shareChecked = shareItem.getAvailablePermission() + + if 'edit' in permissionsList: + test.compare(editChecked, False) + + if 'share' in permissionsList: + test.compare(shareChecked, False) diff --git a/test/gui/tst_sharing/test.feature b/test/gui/tst_sharing/test.feature index 957058cfc5e..f92187219e3 100644 --- a/test/gui/tst_sharing/test.feature +++ b/test/gui/tst_sharing/test.feature @@ -134,3 +134,41 @@ Feature: Sharing | path | /simple-folder | | name | Public link | And the public should not be able to download the file "lorem.txt" from the last created public link by "Alice" on the server + + + Scenario Outline: change collaborator permissions of a file & folder + Given user "Alice" has created on the server folder "simple-folder" + And user "Alice" on the server has created file "lorem.txt" + And user "Brian" has been created on the server with default attributes and without skeleton files + And user "Alice" on the server has shared folder "simple-folder" with user "Brian" with "all" permissions + And user "Alice" on the server has shared file "lorem.txt" with user "Brian" with "all" permissions + And user "Alice" has set up a client with default settings + When the user removes permissions "" for user "Brian Murphy" of resource "%client_sync_path%/simple-folder" using the client-UI + And the user closes the sharing dialog + And the user removes permissions "" for user "Brian Murphy" of resource "%client_sync_path%/lorem.txt" using the client-UI + Then "" permissions should not be displayed for user "Brian Murphy" for resource "%client_sync_path%/simple-folder" on the client-UI + And "" permissions should not be displayed for user "Brian Murphy" for resource "%client_sync_path%/lorem.txt" on the client-UI + And user "Alice" on the server should have a share with these details: + | field | value | + | uid_owner | Alice | + | share_with | Brian | + | share_type | user | + | file_target | /Shares/simple-folder | + | item_type | folder | + | permissions | | + And user "Alice" on the server should have a share with these details: + | field | value | + | uid_owner | Alice | + | share_with | Brian | + | share_type | user | + | file_target | /Shares/lorem.txt | + | item_type | file | + | permissions | | + Examples: + | permissions | expected-folder-permission | expected-file-permission | + | edit | read, share | read, share | + | share | read, update, create, delete | read,update | + | edit,share | read | read | + + +