diff options
author | Saw-jan Gurung <saw.jan.grg3e@gmail.com> | 2021-10-26 13:08:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-26 13:08:26 +0300 |
commit | d4f52b107fe5a066662a060bdbc2e7357f8be084 (patch) | |
tree | 90f304c83dd973fb504e79392e072ef7088bfa4f /test/gui/shared | |
parent | 4479ec828b6d7ee497147c7f4120c02dcf897360 (diff) |
add gui tests for selective sync scenarios (#9009)
add more tests for selective sync scenarios
address reviews
refactor test steps
address reviews
Diffstat (limited to 'test/gui/shared')
-rw-r--r-- | test/gui/shared/scripts/names.py | 7 | ||||
-rw-r--r-- | test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py | 97 | ||||
-rw-r--r-- | test/gui/shared/steps/steps.py | 220 |
3 files changed, 288 insertions, 36 deletions
diff --git a/test/gui/shared/scripts/names.py b/test/gui/shared/scripts/names.py index d0e955dbe..f17255648 100644 --- a/test/gui/shared/scripts/names.py +++ b/test/gui/shared/scripts/names.py @@ -106,4 +106,9 @@ error_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowT oCC_SslErrorDialog_OCC_SslErrorDialog = {"name": "OCC__SslErrorDialog", "type": "OCC::SslErrorDialog", "visible": 1} oCC_SslErrorDialog_cbTrustConnect_QCheckBox = {"name": "_cbTrustConnect", "type": "QCheckBox", "visible": 1, "window": oCC_SslErrorDialog_OCC_SslErrorDialog} oCC_SslErrorDialog_OK_QPushButton = {"text": "OK", "type": "QPushButton", "unnamed": 1, "visible": 1, "window": oCC_SslErrorDialog_OCC_SslErrorDialog} -owncloudWizard_urlLabel_QLabel = {"name": "urlLabel", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard}
\ No newline at end of file +owncloudWizard_urlLabel_QLabel = {"name": "urlLabel", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard} +owncloudWizard_urlLabel_QLabel = {"name": "urlLabel", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard} +choose_What_to_Sync_OCC_SelectiveSyncDialog = {"type": "OCC::SelectiveSyncDialog", "unnamed": 1, "visible": 1, "windowTitle": "Choose What to Sync"} +choose_What_to_Sync_Deselect_remote_folders_you_do_not_wish_to_synchronize_QLabel = {"text": "Deselect remote folders you do not wish to synchronize.", "type": "QLabel", "unnamed": 1, "visible": 1, "window": choose_What_to_Sync_OCC_SelectiveSyncDialog} +choose_What_To_Synchronize_QTreeWidget = {"aboveWidget": choose_What_to_Sync_Deselect_remote_folders_you_do_not_wish_to_synchronize_QLabel, "type": "QTreeWidget", "unnamed": 1, "visible": 1, "window": choose_What_to_Sync_OCC_SelectiveSyncDialog} +deselect_remote_folders_you_do_not_wish_to_synchronize_QHeaderView = {"container": choose_What_To_Synchronize_QTreeWidget, "orientation": 1, "type": "QHeaderView", "unnamed": 1, "visible": 1} diff --git a/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py b/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py index 264dadba2..4fa2f233c 100644 --- a/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py +++ b/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py @@ -31,6 +31,45 @@ class AccountConnectionWizard: "visible": 1, "window": names.owncloudWizard_OCC_OwncloudWizard, } + CREDENTIAL_PAGE = { + "name": "OwncloudHttpCredsPage", + "type": "OCC::OwncloudHttpCredsPage", + "visible": 1, + "window": names.owncloudWizard_OCC_OwncloudWizard, + } + ADVANCE_SETUP_PAGE = { + "name": "OwncloudAdvancedSetupPage", + "type": "OCC::OwncloudAdvancedSetupPage", + "visible": 1, + "window": names.owncloudWizard_OCC_OwncloudWizard, + } + MANUAL_SYNC_FOLDER_OPTION = { + "name": "rManualFolder", + "type": "QRadioButton", + "visible": 1, + "window": names.owncloudWizard_OCC_OwncloudWizard, + } + CHOOSE_WHAT_TO_SYNC_BUTTON = { + "name": "bSelectiveSync", + "type": "QPushButton", + "visible": 1, + "window": names.owncloudWizard_OCC_OwncloudWizard, + } + SELECTIVE_SYNC_DIALOG = names.choose_What_to_Sync_OCC_SelectiveSyncDialog + SYNC_DIALOG_FOLDER_TREE = names.choose_What_To_Synchronize_QTreeWidget + SYNC_DIALOG_ROOT_FOLDER = { + "column": 0, + "container": SYNC_DIALOG_FOLDER_TREE, + "text": "/", + "type": "QModelIndex", + } + SYNC_DIALOG_OK_BUTTON = { + "text": "OK", + "type": "QPushButton", + "unnamed": 1, + "visible": 1, + "window": SELECTIVE_SYNC_DIALOG, + } def __init__(self): pass @@ -38,15 +77,16 @@ class AccountConnectionWizard: def sanitizeFolderPath(self, folderPath): return folderPath.rstrip("/") - def addServer(self, serverAddress): + def addServer(self, context): + clientDetails = getClientDetails(context) squish.mouseClick(squish.waitForObject(self.SERVER_ADDRESS_BOX)) - squish.type(squish.waitForObject(self.SERVER_ADDRESS_BOX), serverAddress) + squish.type( + squish.waitForObject(self.SERVER_ADDRESS_BOX), clientDetails['server'] + ) squish.clickButton(squish.waitForObject(self.NEXT_BUTTON)) - def addAccount(self, context): + def addUserCreds(self, context): clientDetails = getClientDetails(context) - self.addServer(clientDetails['server']) - squish.mouseClick(squish.waitForObject(self.SERVER_ADDRESS_BOX)) squish.type(squish.waitForObject(self.USERNAME_BOX), clientDetails['user']) squish.type(squish.waitForObject(self.USERNAME_BOX), "<Tab>") squish.type(squish.waitForObject(self.PASSWORD_BOX), clientDetails['password']) @@ -69,4 +109,51 @@ class AccountConnectionWizard: str(squish.waitForObjectExists(self.SELECT_LOCAL_FOLDER).text), self.sanitizeFolderPath(clientDetails['localfolder']), ) + + def connectAccount(self): squish.clickButton(squish.waitForObject(self.FINISH_BUTTON)) + + def addAccount(self, context): + self.addServer(context) + self.addUserCreds(context) + self.selectSyncFolder(context) + self.connectAccount() + + def openSyncDialog(self): + squish.clickButton(squish.waitForObject(self.CHOOSE_WHAT_TO_SYNC_BUTTON)) + + def selectManualSyncFolder(self): + squish.clickButton(squish.waitForObject(self.MANUAL_SYNC_FOLDER_OPTION)) + + def selectFoldersToSync(self, context): + self.openSyncDialog() + + # first deselect all + squish.mouseClick( + squish.waitForObject(self.SYNC_DIALOG_ROOT_FOLDER), + 11, + 11, + squish.Qt.NoModifier, + squish.Qt.LeftButton, + ) + for row in context.table[1:]: + squish.mouseClick( + squish.waitForObjectItem(self.SYNC_DIALOG_FOLDER_TREE, "/." + row[0]), + 11, + 11, + squish.Qt.NoModifier, + squish.Qt.LeftButton, + ) + squish.clickButton(squish.waitForObject(self.SYNC_DIALOG_OK_BUTTON)) + + def sortBy(self, headerText): + squish.mouseClick( + squish.waitForObject( + { + "container": names.deselect_remote_folders_you_do_not_wish_to_synchronize_QHeaderView, + "text": headerText, + "type": "HeaderViewItem", + "visible": True, + } + ) + ) diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index ee7db0304..879466b15 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -3,7 +3,7 @@ import names import os import sys from os import listdir -from os.path import isfile, join +from os.path import isfile, join, isdir import re import urllib.request import json @@ -64,29 +64,20 @@ def hook(context): pass -def addAccount(context): +@Given(r'the user has added (the first|another) account with', regexp=True) +def step(context, accountType): newAccount = AccountConnectionWizard() - newAccount.addAccount(context) - newAccount.selectSyncFolder(context) - - -@Given('the user has added an account with') -def step(context): - toolbar = Toolbar() - toolbar.clickAddAccount() - - addAccount(context) + if accountType == 'another': + toolbar = Toolbar() + toolbar.clickAddAccount() - -@When('the user adds the first account with') -def step(context): - addAccount(context) + newAccount.addAccount(context) -@When('the user adds the account with wrong credentials') +@When('the user adds the following wrong user credentials:') def step(context): newAccount = AccountConnectionWizard() - newAccount.addAccount(context) + newAccount.addUserCreds(context) @Then('an account should be displayed with the displayname |any| and host |any|') @@ -131,23 +122,22 @@ def step(context): startClient(context) -@When('the user adds an account with') -def step(context): - toolbar = Toolbar() - toolbar.clickAddAccount() +@When(r'the user adds (the first|another) account with', regexp=True) +def step(context, accountType): + newAccount = AccountConnectionWizard() + if accountType == 'another': + toolbar = Toolbar() + toolbar.clickAddAccount() - addAccount(context) + newAccount.addAccount(context) -@When('the user adds an account with the following secure server address') +@Given('the user has added the following account information:') def step(context): - for row in context.table[0:]: - row[1] = substituteInLineCodes(context, row[1]) - if row[0] == 'server': - server = row[1] - newAccount = AccountConnectionWizard() - newAccount.addServer(server) + newAccount.addServer(context) + newAccount.addUserCreds(context) + newAccount.selectSyncFolder(context) def isItemSynced(type, itemName): @@ -191,6 +181,20 @@ def waitForFolderToBeSynced(context, folderName): ) +def folderExists(folderPath, timeout=1000): + return waitFor( + lambda: isdir(sanitizePath(folderPath)), + timeout, + ) + + +def fileExists(filePath, timeout=1000): + return waitFor( + lambda: isfile(sanitizePath(filePath)), + timeout, + ) + + def sanitizePath(path): return path.replace('//', '/') @@ -346,6 +350,46 @@ def step(context, filePath): ) +@Then(r'^the (file|folder) "([^"]*)" should exist on the file system$', regexp=True) +def step(context, resourceType, resource): + resourcePath = join(context.userData['clientSyncPathUser1'], resource) + resourceExists = False + if resourceType == 'file': + resourceExists = fileExists( + resourcePath, context.userData['clientSyncTimeout'] * 1000 + ) + elif resourceType == 'folder': + resourceExists = folderExists( + resourcePath, context.userData['clientSyncTimeout'] * 1000 + ) + else: + raise Exception("Unsupported resource type '" + resourceType + "'") + + test.compare( + True, + resourceExists, + "Assert " + resourceType + " '" + resource + "' exists on the system", + ) + + +@Then(r'^the (file|folder) "([^"]*)" should not exist on the file system$', regexp=True) +def step(context, resourceType, resource): + resourcePath = join(context.userData['clientSyncPathUser1'], resource) + resourceExists = False + if resourceType == 'file': + resourceExists = fileExists(resourcePath, 1000) + elif resourceType == 'folder': + resourceExists = folderExists(resourcePath, 1000) + else: + raise Exception("Unsupported resource type '" + resourceType + "'") + + test.compare( + False, + resourceExists, + "Assert " + resourceType + " '" + resource + "' doesn't exist on the system", + ) + + @Given('the user has paused the file sync') def step(context): waitForFolderToBeSynced(context, '/') @@ -884,3 +928,119 @@ def step(context, resource, receiver): str(waitForObjectExists(names.scrollArea_sharedWith_QLabel).text), receiver ) clickButton(waitForObject(names.scrollArea_deleteShareButton_QToolButton)) + + +@Given('the user has added the following server address:') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.addServer(context) + test.compare( + waitForObjectExists(newAccount.CREDENTIAL_PAGE).visible, + True, + "Assert credentials page is visible", + ) + + +@When('the user adds the following server address:') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.addServer(context) + + +@Given('the user has added the following user credentials:') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.addUserCreds(context) + test.compare( + waitForObjectExists(newAccount.ADVANCE_SETUP_PAGE).visible, + True, + "Assert setup page is visible", + ) + + +@Given('the user has changed the sync directory') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.selectSyncFolder(context) + + +@Given('the user has opened chose_what_to_sync dialog') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.openSyncDialog() + test.compare( + waitForObjectExists(newAccount.SELECTIVE_SYNC_DIALOG).visible, + True, + "Assert selective sync dialog is visible", + ) + + +@When('the user opens chose_what_to_sync dialog') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.openSyncDialog() + + +@When('the user selects the following folders to sync:') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.selectFoldersToSync(context) + + +@When('the user selects manual sync folder option') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.selectManualSyncFolder() + + +@When('the user connects the account') +def step(context): + newAccount = AccountConnectionWizard() + newAccount.connectAccount() + + +@When('the user sorts the folder list by "|any|"') +def step(context, headerText): + headerText = headerText.capitalize() + if headerText in ["Size", "Name"]: + newAccount = AccountConnectionWizard() + newAccount.sortBy(headerText) + else: + raise Exception("Sorting by '" + headerText + "' is not supported.") + + +@Then('the dialog chose_what_to_sync should be visible') +def step(context): + newAccount = AccountConnectionWizard() + test.compare( + waitForObjectExists(newAccount.SELECTIVE_SYNC_DIALOG).visible, + True, + "Assert selective sync dialog is visible", + ) + + +@Then('the sync all checkbox should be checked') +def step(context): + newAccount = AccountConnectionWizard() + test.compare( + waitForObjectExists(newAccount.SYNC_DIALOG_ROOT_FOLDER).checkState, + "checked", + "Assert sync all checkbox is checked", + ) + + +@Then("the folders should be in the following order:") +def step(context): + newAccount = AccountConnectionWizard() + rowIndex = 0 + for row in context.table[1:]: + FOLDER_TREE_ROW = { + "row": rowIndex, + "container": newAccount.SYNC_DIALOG_ROOT_FOLDER, + "type": "QModelIndex", + } + expectedFolder = row[0] + actualFolder = waitForObjectExists(FOLDER_TREE_ROW).displayText + test.compare(actualFolder, expectedFolder) + + rowIndex += 1 |