Skip to content

Commit

Permalink
POM implementation in the syncing tests (#8655)
Browse files Browse the repository at this point in the history
  • Loading branch information
Talank authored Jun 3, 2021
1 parent f93b107 commit 93cd546
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 39 deletions.
11 changes: 11 additions & 0 deletions test/gui/shared/scripts/helpers/FilesHelper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def buildConflictedRegex(filename):
if '.' in filename:
# TODO: improve this for complex filenames
namepart = filename.split('.')[0]
extpart = filename.split('.')[1]
return '%s \(conflicted copy \d{4}-\d{2}-\d{2} \d{6}\)\.%s' % (
namepart,
extpart,
)
else:
return '%s \(conflicted copy \d{4}-\d{2}-\d{2} \d{6}\)' % (filename)
2 changes: 0 additions & 2 deletions test/gui/shared/scripts/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
proxyGroupBox_labelLocalhost_QLabel = {"container": groupBox_proxyGroupBox_QGroupBox, "name": "labelLocalhost", "type": "QLabel", "visible": 1}
groupBox_uploadBox_QGroupBox = {"container": scrollArea_groupBox_QGroupBox, "name": "uploadBox", "type": "QGroupBox", "visible": 1}
uploadBox_autoUploadLimitRadioButton_QRadioButton = {"container": groupBox_uploadBox_QGroupBox, "name": "autoUploadLimitRadioButton", "type": "QRadioButton", "visible": 1}
settings_settingsdialog_toolbutton_Activity_QToolButton = {"name": "settingsdialog_toolbutton_Activity", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog}
stack_qt_tabwidget_stackedwidget_QStackedWidget = {"container": settings_stack_QStackedWidget, "name": "qt_tabwidget_stackedwidget", "type": "QStackedWidget", "visible": 1}
qt_tabwidget_stackedwidget_OCC_ActivityWidget_OCC_ActivityWidget = {"container": stack_qt_tabwidget_stackedwidget_QStackedWidget, "name": "OCC__ActivityWidget", "type": "OCC::ActivityWidget", "visible": 1}
oCC_ActivityWidget_activityList_QListView = {"container": qt_tabwidget_stackedwidget_OCC_ActivityWidget_OCC_ActivityWidget, "name": "_activityList", "type": "QListView", "visible": 1}
Expand All @@ -70,7 +69,6 @@
qt_tabwidget_stackedwidget_OCC_IssuesWidget_OCC_IssuesWidget = {"container": stack_qt_tabwidget_stackedwidget_QStackedWidget, "name": "OCC__IssuesWidget", "type": "OCC::IssuesWidget", "visible": 1}
oCC_IssuesWidget_treeWidget_QTreeWidget = {"container": qt_tabwidget_stackedwidget_OCC_IssuesWidget_OCC_IssuesWidget, "name": "_treeWidget", "type": "QTreeWidget", "visible": 1}
o_treeWidget_lorem_conflicted_copy_2020_12_14_133239_txt_QModelIndex = {"column": 1, "container": oCC_IssuesWidget_treeWidget_QTreeWidget, "text": RegularExpression("lorem (conflicted copy 2020-12-14 133239).txt"), "type": "QModelIndex"}
stack_QTabWidget = {"container": settings_stack_QStackedWidget, "type": "QTabWidget", "unnamed": 1, "visible": 1}
scrollArea_sharedWith_QLabel = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "sharedWith", "type": "QLabel", "visible": 1}
scrollArea_permissionsEdit_QCheckBox = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "permissionsEdit", "type": "QCheckBox", "visible": 1}
scrollArea_permissionShare_QCheckBox = {"container": sharingDialogUG_scrollArea_QScrollArea, "name": "permissionShare", "type": "QCheckBox", "visible": 1}
Expand Down
30 changes: 30 additions & 0 deletions test/gui/shared/scripts/pageObjects/Activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import names
import squish
from objectmaphelper import RegularExpression
from helpers.FilesHelper import buildConflictedRegex


class Activity:
SUBTAB = {
"container": names.settings_stack_QStackedWidget,
"type": "QTabWidget",
"unnamed": 1,
"visible": 1,
}

def clickTab(self, tabName):
# TODO: find some way to dynamically select the tab name
# It might take some time for all files to sync except the expected number of unsynced files
squish.snooze(10)
squish.clickTab(squish.waitForObject(self.SUBTAB), tabName)

def checkFileExist(self, filename):
squish.waitForObject(names.settings_OCC_SettingsDialog)
squish.waitForObjectExists(
{
"column": 1,
"container": names.oCC_IssuesWidget_tableView_QTableView,
"text": RegularExpression(buildConflictedRegex(filename)),
"type": "QModelIndex",
}
)
17 changes: 17 additions & 0 deletions test/gui/shared/scripts/pageObjects/SyncWizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import names
import squish


class SyncWizard:
ACTION_MENU = {
"container": names.settings_stack_QStackedWidget,
"name": "_folderList",
"type": "QTreeView",
"visible": 1,
}

def performAction(self, action):
squish.openContextMenu(
squish.waitForObjectItem(self.ACTION_MENU, "_1"), 0, 0, squish.Qt.NoModifier
)
squish.activateItem(squish.waitForObjectItem(names.settings_QMenu, action))
14 changes: 14 additions & 0 deletions test/gui/shared/scripts/pageObjects/Toolbar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import names
import squish


class Toolbar:
ACTIVITY_BUTTON = {
"name": "settingsdialog_toolbutton_Activity",
"type": "QToolButton",
"visible": 1,
"window": names.settings_OCC_SettingsDialog,
}

def clickActivity(self):
squish.clickButton(squish.waitForObject(self.ACTIVITY_BUTTON))
51 changes: 14 additions & 37 deletions test/gui/shared/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
from objectmaphelper import RegularExpression
from pageObjects.AccountConnectionWizard import AccountConnectionWizard
from helpers.SetupClientHelper import *
from helpers.FilesHelper import buildConflictedRegex
from pageObjects.EnterPassword import EnterPassword
from pageObjects.PublicLinkDialog import PublicLinkDialog
from pageObjects.SharingDialog import SharingDialog
from pageObjects.SyncWizard import SyncWizard
from pageObjects.Toolbar import Toolbar
from pageObjects.Activity import Activity


# the script needs to use the system wide python
Expand Down Expand Up @@ -281,10 +285,8 @@ def step(context):
lambda: isFolderSynced(context.userData['clientSyncPath']),
context.userData['clientSyncTimeout'] * 1000,
)
openContextMenu(
waitForObjectItem(names.stack_folderList_QTreeView, "_1"), 0, 0, Qt.NoModifier
)
activateItem(waitForObjectItem(names.settings_QMenu, "Pause sync"))
syncWizard = SyncWizard()
syncWizard.performAction("Pause sync")


@Given('the user has changed the content of local file "|any|" to:')
Expand All @@ -297,10 +299,8 @@ def step(context, filename):

@When('the user resumes the file sync on the client')
def step(context):
openContextMenu(
waitForObjectItem(names.stack_folderList_QTreeView, "_1"), 0, 0, Qt.NoModifier
)
activateItem(waitForObjectItem(names.settings_QMenu, "Resume sync"))
syncWizard = SyncWizard()
syncWizard.performAction("Resume sync")


@When('the user triggers force sync on the client')
Expand Down Expand Up @@ -344,9 +344,8 @@ def step(context, filename):

@When('the user clicks on the activity tab')
def step(context):
clickButton(
waitForObject(names.settings_settingsdialog_toolbutton_Activity_QToolButton)
)
toolbar = Toolbar()
toolbar.clickActivity()


@Then('a conflict warning should be shown for |integer| files')
Expand All @@ -369,38 +368,16 @@ def step(context, files):
)


def buildConflictedRegex(filename):
if '.' in filename:
# TODO: improve this for complex filenames
namepart = filename.split('.')[0]
extpart = filename.split('.')[1]
return '%s \(conflicted copy \d{4}-\d{2}-\d{2} \d{6}\)\.%s' % (
namepart,
extpart,
)
else:
return '%s \(conflicted copy \d{4}-\d{2}-\d{2} \d{6}\)' % (filename)


@Then('the table of conflict warnings should include file "|any|"')
def step(context, filename):
waitForObject(names.settings_OCC_SettingsDialog)
waitForObjectExists(
{
"column": 1,
"container": names.oCC_IssuesWidget_tableView_QTableView,
"text": RegularExpression(buildConflictedRegex(filename)),
"type": "QModelIndex",
}
)
activity = Activity()
activity.checkFileExist(filename)


@When('the user selects the unsynced files tab')
def step(context):
# TODO: find some way to dynamically select the tab name
# It might take some time for all files to sync except the expected number of unsynced files
snooze(10)
clickTab(waitForObject(names.stack_QTabWidget), "Not Synced")
activity = Activity()
activity.clickTab("Not Synced")


def openSharingDialog(context, resource, itemType='file'):
Expand Down

0 comments on commit 93cd546

Please sign in to comment.