Skip to content

Commit

Permalink
added tests for adding folder to sync
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwolAmatya committed Jun 11, 2024
1 parent a329436 commit 02562e1
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 2 deletions.
2 changes: 2 additions & 0 deletions test/gui/shared/scripts/helpers/SetupClientHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def setUpClient(username, displayName, space="Personal"):
0/url={local_server}
0/user={displayUserFirstName}
0/version=1
0/supportsSpaces={supportsSpaces}
version=2
'''

Expand Down Expand Up @@ -154,6 +155,7 @@ def setUpClient(username, displayName, space="Personal"):
'local_server': server_url,
'oauth': 'true' if is_ocis else 'false',
'vfs': 'wincfapi' if isWindows() else 'off',
'supportsSpaces': 'true' if is_ocis else 'false',
}
userSetting = userSetting.format(**args)

Expand Down
3 changes: 3 additions & 0 deletions test/gui/shared/scripts/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@
o_folderList_Personal_QModelIndex = {"column": 0, "container": stack_folderList_QTreeView, "text": "Personal", "type": "QModelIndex"}
add_Folder_Sync_Connection_tableView_QTableView = {"name": "tableView","type": "QTableView","visible": 1,"window": add_Folder_Sync_Connection_OCC_FolderWizard}
stack_scrollArea_QScrollArea = {"container": settings_stack_QStackedWidget, "name": "scrollArea", "type": "QScrollArea", "visible": 1}
create_Remote_Folder_QInputDialog = {"type": "QInputDialog", "unnamed": 1, "visible": 1, "windowTitle": "Create Remote Folder"}
create_Remote_Folder_Enter_the_name_of_the_new_folder_to_be_created_below_QLabel = {"text": "Enter the name of the new folder to be created below '/':", "type": "QLabel", "unnamed": 1, "visible": 1, "window": create_Remote_Folder_QInputDialog}
groupBox_folderTreeWidget_QTreeWidget = {"container": add_Folder_Sync_Connection_groupBox_QGroupBox, "name": "folderTreeWidget", "type": "QTreeWidget", "visible": 1}
103 changes: 101 additions & 2 deletions test/gui/shared/scripts/pageObjects/SyncConnectionWizard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import names
import squish
import object
from os import path
from helpers.SetupClientHelper import (
getCurrentUserSyncPath,
Expand All @@ -21,11 +22,17 @@ class SyncConnectionWizard:
"visible": 1,
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
}
NEXT_BUTTON = {
"name": "__qt__passive_wizardbutton1",
BACK_BUTTON = {
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
"type": "QPushButton",
"text": "< &Back",
"visible": 1,
}
NEXT_BUTTON = {
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
"type": "QPushButton",
"text": "&Next >",
"visible": 1,
}
SELECTIVE_SYNC_ROOT_FOLDER = {
"column": 0,
Expand Down Expand Up @@ -75,6 +82,37 @@ class SyncConnectionWizard:
"container": names.add_Folder_Sync_Connection_tableView_QTableView,
"type": "QModelIndex",
}
CREATE_REMOTE_FOLDER_BUTTON = {
"container": names.add_Folder_Sync_Connection_groupBox_QGroupBox,
"name": "addFolderButton",
"type": "QPushButton",
"visible": 1,
}
CREATE_REMOTE_FOLDER_INPUT = {
"buddy": names.create_Remote_Folder_Enter_the_name_of_the_new_folder_to_be_created_below_QLabel,
"type": "QLineEdit",
"unnamed": 1,
"visible": 1,
}
CREATE_REMOTE_FOLDER_CONFIRM_BUTTON = {
"text": "OK",
"type": "QPushButton",
"unnamed": 1,
"visible": 1,
"window": names.create_Remote_Folder_QInputDialog,
}
REFRESH_BUTTON = {
"container": names.add_Folder_Sync_Connection_groupBox_QGroupBox,
"name": "refreshButton",
"type": "QPushButton",
"visible": 1,
}
REMOTE_FOLDER_SELECTION_INPUT = {
"name": "folderEntry",
"type": "QLineEdit",
"visible": 1,
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
}

@staticmethod
def setSyncPathInSyncConnectionWizardOc10(sync_path=''):
Expand All @@ -101,6 +139,10 @@ def setSyncPathInSyncConnectionWizard(sync_path=''):
def nextStep():
squish.clickButton(squish.waitForObject(SyncConnectionWizard.NEXT_BUTTON))

@staticmethod
def back():
squish.clickButton(squish.waitForObject(SyncConnectionWizard.BACK_BUTTON))

@staticmethod
def selectRemoteDestinationFolder(folder):
squish.mouseClick(
Expand Down Expand Up @@ -251,3 +293,60 @@ def syncSpace(spaceName):
path.join(getCurrentUserSyncPath(), spaceName)
)
SyncConnectionWizard.addSyncConnection()

@staticmethod
def create_folder_in_remote_destination(folder_name):
squish.clickButton(
squish.waitForObject(SyncConnectionWizard.CREATE_REMOTE_FOLDER_BUTTON)
)
squish.type(
squish.waitForObject(SyncConnectionWizard.CREATE_REMOTE_FOLDER_INPUT),
folder_name,
)
squish.clickButton(
squish.waitForObject(
SyncConnectionWizard.CREATE_REMOTE_FOLDER_CONFIRM_BUTTON
)
)

@staticmethod
def refresh_remote():
squish.clickButton(squish.waitForObject(SyncConnectionWizard.REFRESH_BUTTON))

@staticmethod
def generate_remote_folder_selector(folder_name, parent_container=None):
if not parent_container:
parent_container = {
"container": names.groupBox_folderTreeWidget_QTreeWidget,
"text": "ownCloud",
"type": "QModelIndex",
}
return {
"container": parent_container,
"text": folder_name,
"type": "QModelIndex",
}

@staticmethod
def has_remote_folder(folder_name):
folder_tree = folder_name.strip("/").split("/")
parent_container = None

for folder in folder_tree:
folder_selector = SyncConnectionWizard.generate_remote_folder_selector(
folder, parent_container
)
try:
if parent_container:
squish.doubleClick(parent_container)

squish.waitForObject(folder_selector)

parent_container = folder_selector
except:
return False, None
return True, parent_container

@staticmethod
def is_remote_folder_selected(folder_selector):
return squish.waitForObjectExists(folder_selector).selected
27 changes: 27 additions & 0 deletions test/gui/shared/steps/sync_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,30 @@ def step(context, action):
def step(context, folder_name):
SyncConnection.choose_what_to_sync()
SyncConnection.unselect_folder_in_selective_sync(folder_name)

@When('the user navigates back in the sync connection wizard')
def step(context):
SyncConnectionWizard.back()


@When('the user creates a folder "|any|" in the remote destination wizard')
def step(context, folder_name):
SyncConnectionWizard.create_folder_in_remote_destination(folder_name)

@When('the user refreshes the remote destination in the sync connection wizard')
def step(context):
SyncConnectionWizard.refresh_remote()


@Then(
r'the folder "([^"]*)" should be present and (selected|not selected) in the remote destination wizard',
regexp=True,
)
def step(context, folder_name, selected):
has_folder, folder_selector = SyncConnectionWizard.has_remote_folder(folder_name)
test.compare(True, has_folder, "Folder should be in the remote list")
test.compare(
selected == 'selected',
SyncConnectionWizard.is_remote_folder_selected(folder_selector),
"Folder should be selected",
)
22 changes: 22 additions & 0 deletions test/gui/tst_syncing/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,25 @@ Feature: Syncing files
Then the folder "simple-folder" should not exist on the file system
And the folder "test-folder/sub-folder2" should exist on the file system
And the folder "test-folder/sub-folder1" should not exist on the file system

@skipOnOCIS
Scenario: Add sync folder configuration manually
Given the user has started the client
And the user has entered the following account information:
| server | %local_server% |
| user | Alice |
| password | 1234 |
When the user selects manual sync folder option in advanced section
And the user sets the temp folder "tempSyncFolder" as local sync path in sync connection wizard
And the user navigates back in the sync connection wizard
And the user sets the temp folder "localSyncFolder" as local sync path in sync connection wizard
And the user creates a folder "test-folder" in the remote destination wizard
Then the folder "test-folder" should be present and selected in the remote destination wizard
When the user refreshes the remote destination in the sync connection wizard
Then the folder "test-folder" should be present and not selected in the remote destination wizard
When the user selects "ownCloud" as a remote destination folder
And the user selects the following folders to sync:
| folder |
| test-folder |
Then the folder "test-folder" should exist on the file system
And as "Alice" folder "test-folder" should exist in the server

0 comments on commit 02562e1

Please sign in to comment.