Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only] Added more gui tests for sharing with user and group (Part 01) #9190

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 98 additions & 46 deletions test/gui/shared/scripts/pageObjects/PublicLinkDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class PublicLinkDialog:
"type": "QCheckBox",
"visible": 1,
}
PASSWORD_INPUT_FIELD = {
"container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget,
"name": "lineEdit_password",
"type": "QLineEdit",
"visible": 1,
}
EXPIRYDATE_CHECKBOX = {
"container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget,
"name": "checkBox_expire",
"type": "QCheckBox",
"visible": 1,
}
CREATE_SHARE_BUTTON = {
"container": names.qt_tabwidget_stackedwidget_OCC_ShareLinkWidget_OCC_ShareLinkWidget,
"name": "createShareButton",
Expand Down Expand Up @@ -69,7 +81,9 @@ def openPublicLinkDialog(self):
squish.Qt.LeftButton,
)

def createPublicLink(self, context, resource, password='', permissions=''):
def createPublicLink(
self, context, resource, password='', permissions='', expireDate='', linkName=''
):
radioObjectName = ''
if permissions:
radioObjectName = self.getRadioObjectForPermssion(permissions)
Expand All @@ -86,18 +100,13 @@ def createPublicLink(self, context, resource, password='', permissions=''):
squish.clickButton(squish.waitForObject(radioObjectName))

if password:
squish.clickButton(squish.waitForObject(self.PASSWORD_CHECKBOX))
squish.mouseClick(
squish.waitForObject(self.PASSWORD_CHECKBOX),
0,
0,
squish.Qt.NoModifier,
squish.Qt.LeftButton,
)
squish.type(
squish.waitForObject(self.PASSWORD_CHECKBOX),
password,
)
self.setPassword(password)

if expireDate:
self.setExpirationDate(expireDate)

if linkName:
self.setLinkName(linkName)

squish.clickButton(squish.waitForObject(self.CREATE_SHARE_BUTTON))
squish.waitFor(
Expand All @@ -107,22 +116,35 @@ def createPublicLink(self, context, resource, password='', permissions=''):
)
)

def togglesPassword(self):
def togglePassword(self):
squish.clickButton(squish.waitForObject(self.PASSWORD_CHECKBOX))

def setExpirationDate(self, context, publicLinkName, resource):
test.compare(
str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text),
resource,
def setPassword(self, password):
enabled = squish.waitForObjectExists(self.PASSWORD_CHECKBOX).checked
if not enabled:
self.togglePassword()

squish.mouseClick(
squish.waitForObject(self.PASSWORD_INPUT_FIELD),
0,
0,
squish.Qt.NoModifier,
squish.Qt.LeftButton,
)
test.compare(
str(squish.waitForObjectExists(self.PUBLIC_LINK_NAME).text),
publicLinkName,
squish.type(
squish.waitForObject(self.PASSWORD_INPUT_FIELD),
password,
)
expDate = []
for row in context.table:
if row[0] == 'expireDate':
expDate = datetime.datetime.strptime(row[1], '%Y-%m-%d')

def toggleExpirationDate(self):
squish.clickButton(squish.waitForObject(self.EXPIRYDATE_CHECKBOX))

def setExpirationDate(self, expireDate):
enabled = squish.waitForObjectExists(self.EXPIRYDATE_CHECKBOX).checked
if not enabled:
self.toggleExpirationDate()

expDate = datetime.datetime.strptime(expireDate, '%Y-%m-%d')
expYear = expDate.year - 2000
squish.mouseClick(
squish.waitForObject(self.EXPIRATION_DATE_FIELD),
Expand All @@ -137,17 +159,49 @@ def setExpirationDate(self, context, publicLinkName, resource):
squish.nativeType(expDate.day)
squish.nativeType(expYear)
squish.nativeType("<Return>")
squish.testSettings.silentVerifications = True

actualDate = squish.waitForObjectExists(self.EXPIRATION_DATE_FIELD).displayText
expectedDate = f"{expDate.month}/{expDate.day}/{expYear}"
if not actualDate == expectedDate:
# retry with workaround
self.setExpirationDateWithWorkaround(expYear, expDate.month, expDate.day)

squish.waitFor(
lambda: (test.xvp("publicLinkExpirationProgressIndicatorInvisible"))
lambda: (test.vp("publicLinkExpirationProgressIndicatorInvisible"))
saw-jan marked this conversation as resolved.
Show resolved Hide resolved
)
waitFor(lambda: (test.vp("publicLinkExpirationProgressIndicatorInvisible")))
squish.testSettings.silentVerifications = False
test.compare(
str(squish.waitForObjectExists(self.EXPIRATION_DATE_FIELD).displayText),
str(expDate.month) + "/" + str(expDate.day) + "/" + str(expYear),
str(expectedDate),
)

# This workaround is needed because the above function 'setExpirationDate'
# will not work while creating new public link
# See for more details: https://github.com/owncloud/client/issues/9218
def setExpirationDateWithWorkaround(self, year, month, day):
squish.mouseClick(
squish.waitForObject(self.EXPIRATION_DATE_FIELD),
0,
0,
squish.Qt.NoModifier,
squish.Qt.LeftButton,
)

# date can be edited from backward only
# date format is 'mm/dd/yy', so we have to edit 'year' first
# then 'day' and then 'month'.
# Move the cursor to year field
squish.nativeType("<Ctrl+Right>")
squish.nativeType("<Ctrl+Right>")
squish.nativeType(year)
# Move the cursor to day field
squish.nativeType("<Ctrl+Left>")
squish.nativeType(day)
# Move the cursor to month field
squish.nativeType("<Ctrl+Left>")
squish.nativeType("<Ctrl+Left>")
squish.nativeType(month)
squish.nativeType("<Return>")

def getRadioObjectForPermssion(self, permissions):
radioObjectName = ''
if permissions == 'Download / View' or permissions == 'Viewer':
Expand All @@ -173,24 +227,22 @@ def createPublicLinkWithRole(self, role):
)
)

def changePassword(self, publicLinkName, password):
test.compare(
str(squish.waitForObjectExists(self.PUBLIC_LINK_NAME).text),
publicLinkName,
)
squish.mouseClick(
squish.waitForObject(names.oCC_ShareLinkWidget_lineEdit_password_QLineEdit),
0,
0,
squish.Qt.NoModifier,
squish.Qt.LeftButton,
)
squish.type(
squish.waitForObject(names.oCC_ShareLinkWidget_lineEdit_password_QLineEdit),
password,
)
def changePassword(self, password):
self.setPassword(password)
saw-jan marked this conversation as resolved.
Show resolved Hide resolved
squish.clickButton(
squish.waitForObject(
names.oCC_ShareLinkWidget_pushButton_setPassword_QPushButton
)
)

def verifyPublicLinkName(self, publicLinkName):
test.compare(
str(squish.waitForObjectExists(self.PUBLIC_LINK_NAME).text),
publicLinkName,
)

def verifyResource(self, resource):
test.compare(
str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text),
resource,
)
34 changes: 22 additions & 12 deletions test/gui/shared/scripts/pageObjects/SharingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ def getAvailablePermission(self):

return editChecked, shareChecked

def searchCollaborator(self, collaborator):
squish.mouseClick(
squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD),
0,
0,
squish.Qt.NoModifier,
squish.Qt.LeftButton,
)
squish.type(
squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD),
collaborator,
)

def addCollaborator(self, receiver, permissions, isGroup=False):
self.selectCollaborator(receiver, isGroup)
permissionsList = permissions.split(",")
Expand All @@ -85,20 +98,17 @@ def selectCollaborator(self, receiver, isGroup=False):
if isGroup:
postFixInSuggestion = " (group)"

squish.mouseClick(
squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD),
0,
0,
squish.Qt.NoModifier,
squish.Qt.LeftButton,
)
squish.type(
squish.waitForObject(self.SHARE_WITH_COLLABORATOR_INPUT_FIELD),
receiver,
)
self.searchCollaborator(receiver)

# collaborator name with special characters contains escape characters '\\'
# in the squish object
# Example:
# Actual collaborator name: Speci@l_Name-.+
# Collaborator name in object: Speci@l\\_Name-\\.+
escapedReceiverName = receiver.replace("_", "\\_").replace(".", "\\.")
saw-jan marked this conversation as resolved.
Show resolved Hide resolved
squish.mouseClick(
squish.waitForObjectItem(
self.SUGGESTED_COLLABORATOR, receiver + postFixInSuggestion
self.SUGGESTED_COLLABORATOR, escapedReceiverName + postFixInSuggestion
),
0,
0,
Expand Down
Loading