Skip to content

Commit 29104b9

Browse files
committed
added tests for adding folder to sync
1 parent a329436 commit 29104b9

File tree

7 files changed

+184
-11
lines changed

7 files changed

+184
-11
lines changed

test/gui/TestLogParser.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import sys
55

6+
67
# Method that tries to find the data using nested loops
78
def traverse_loop(data):
89
failing_tests = []
@@ -51,11 +52,11 @@ def traverse_loop(data):
5152
"Scenario": str(scenario['name']),
5253
"Example": str(test_step['name']),
5354
"Test Step": str(test_log['name']),
54-
"Error Details": str(
55-
outlineStep['detail']
56-
)
57-
if ('detail' in outlineStep)
58-
else "Error details not found",
55+
"Error Details": (
56+
str(outlineStep['detail'])
57+
if ('detail' in outlineStep)
58+
else "Error details not found"
59+
),
5960
}
6061
failing_tests.append(failing_test)
6162
continue
@@ -71,9 +72,11 @@ def traverse_loop(data):
7172
"Feature": str(feature['name']),
7273
"Scenario": str(scenario['name']),
7374
"Test Step": str(test_step['name']),
74-
"Error Details": str(test_log['detail'])
75-
if ('detail' in test_log)
76-
else "Error details not found",
75+
"Error Details": (
76+
str(test_log['detail'])
77+
if ('detail' in test_log)
78+
else "Error details not found"
79+
),
7780
}
7881
failing_tests.append(failing_test)
7982

test/gui/shared/scripts/helpers/SetupClientHelper.py

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def setUpClient(username, displayName, space="Personal"):
127127
0/url={local_server}
128128
0/user={displayUserFirstName}
129129
0/version=1
130+
0/supportsSpaces={supportsSpaces}
130131
version=2
131132
'''
132133

@@ -154,6 +155,7 @@ def setUpClient(username, displayName, space="Personal"):
154155
'local_server': server_url,
155156
'oauth': 'true' if is_ocis else 'false',
156157
'vfs': 'wincfapi' if isWindows() else 'off',
158+
'supportsSpaces': 'true' if is_ocis else 'false',
157159
}
158160
userSetting = userSetting.format(**args)
159161

test/gui/shared/scripts/names.py

+3
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@
4949
o_folderList_Personal_QModelIndex = {"column": 0, "container": stack_folderList_QTreeView, "text": "Personal", "type": "QModelIndex"}
5050
add_Folder_Sync_Connection_tableView_QTableView = {"name": "tableView","type": "QTableView","visible": 1,"window": add_Folder_Sync_Connection_OCC_FolderWizard}
5151
stack_scrollArea_QScrollArea = {"container": settings_stack_QStackedWidget, "name": "scrollArea", "type": "QScrollArea", "visible": 1}
52+
create_Remote_Folder_QInputDialog = {"type": "QInputDialog", "unnamed": 1, "visible": 1, "windowTitle": "Create Remote Folder"}
53+
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}
54+
groupBox_folderTreeWidget_QTreeWidget = {"container": add_Folder_Sync_Connection_groupBox_QGroupBox, "name": "folderTreeWidget", "type": "QTreeWidget", "visible": 1}

test/gui/shared/scripts/pageObjects/SyncConnection.py

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ class SyncConnection:
2929
"type": "QPushButton",
3030
"visible": 1,
3131
}
32+
ADD_SYNC_CONNECTION_BUTTON = {
33+
"container": names.settings_stack_QStackedWidget,
34+
"name": "addButton",
35+
"type": "QPushButton",
36+
"visible": 1,
37+
}
3238

3339
@staticmethod
3440
def openMenu():
@@ -80,6 +86,12 @@ def menu_item_exists(menuItem):
8086
obj.update({"type": "QAction", "text": menuItem})
8187
return object.exists(obj)
8288

89+
@staticmethod
90+
def open_sync_connection_wizard():
91+
squish.clickButton(
92+
squish.waitForObject(SyncConnection.ADD_SYNC_CONNECTION_BUTTON)
93+
)
94+
8395
@staticmethod
8496
def choose_what_to_sync():
8597
SyncConnection.openMenu()

test/gui/shared/scripts/pageObjects/SyncConnectionWizard.py

+102-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import names
22
import squish
3+
import object
34
from os import path
45
from helpers.SetupClientHelper import (
56
getCurrentUserSyncPath,
@@ -21,11 +22,17 @@ class SyncConnectionWizard:
2122
"visible": 1,
2223
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
2324
}
24-
NEXT_BUTTON = {
25-
"name": "__qt__passive_wizardbutton1",
25+
BACK_BUTTON = {
26+
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
2627
"type": "QPushButton",
28+
"text": "< &Back",
2729
"visible": 1,
30+
}
31+
NEXT_BUTTON = {
2832
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
33+
"type": "QPushButton",
34+
"text": "&Next >",
35+
"visible": 1,
2936
}
3037
SELECTIVE_SYNC_ROOT_FOLDER = {
3138
"column": 0,
@@ -75,6 +82,37 @@ class SyncConnectionWizard:
7582
"container": names.add_Folder_Sync_Connection_tableView_QTableView,
7683
"type": "QModelIndex",
7784
}
85+
CREATE_REMOTE_FOLDER_BUTTON = {
86+
"container": names.add_Folder_Sync_Connection_groupBox_QGroupBox,
87+
"name": "addFolderButton",
88+
"type": "QPushButton",
89+
"visible": 1,
90+
}
91+
CREATE_REMOTE_FOLDER_INPUT = {
92+
"buddy": names.create_Remote_Folder_Enter_the_name_of_the_new_folder_to_be_created_below_QLabel,
93+
"type": "QLineEdit",
94+
"unnamed": 1,
95+
"visible": 1,
96+
}
97+
CREATE_REMOTE_FOLDER_CONFIRM_BUTTON = {
98+
"text": "OK",
99+
"type": "QPushButton",
100+
"unnamed": 1,
101+
"visible": 1,
102+
"window": names.create_Remote_Folder_QInputDialog,
103+
}
104+
REFRESH_BUTTON = {
105+
"container": names.add_Folder_Sync_Connection_groupBox_QGroupBox,
106+
"name": "refreshButton",
107+
"type": "QPushButton",
108+
"visible": 1,
109+
}
110+
REMOTE_FOLDER_SELECTION_INPUT = {
111+
"name": "folderEntry",
112+
"type": "QLineEdit",
113+
"visible": 1,
114+
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
115+
}
78116

79117
@staticmethod
80118
def setSyncPathInSyncConnectionWizardOc10(sync_path=''):
@@ -101,6 +139,10 @@ def setSyncPathInSyncConnectionWizard(sync_path=''):
101139
def nextStep():
102140
squish.clickButton(squish.waitForObject(SyncConnectionWizard.NEXT_BUTTON))
103141

142+
@staticmethod
143+
def back():
144+
squish.clickButton(squish.waitForObject(SyncConnectionWizard.BACK_BUTTON))
145+
104146
@staticmethod
105147
def selectRemoteDestinationFolder(folder):
106148
squish.mouseClick(
@@ -251,3 +293,61 @@ def syncSpace(spaceName):
251293
path.join(getCurrentUserSyncPath(), spaceName)
252294
)
253295
SyncConnectionWizard.addSyncConnection()
296+
297+
@staticmethod
298+
def create_folder_in_remote_destination(folder_name):
299+
squish.clickButton(
300+
squish.waitForObject(SyncConnectionWizard.CREATE_REMOTE_FOLDER_BUTTON)
301+
)
302+
squish.type(
303+
squish.waitForObject(SyncConnectionWizard.CREATE_REMOTE_FOLDER_INPUT),
304+
folder_name,
305+
)
306+
squish.clickButton(
307+
squish.waitForObject(
308+
SyncConnectionWizard.CREATE_REMOTE_FOLDER_CONFIRM_BUTTON
309+
)
310+
)
311+
312+
@staticmethod
313+
def refresh_remote():
314+
squish.clickButton(squish.waitForObject(SyncConnectionWizard.REFRESH_BUTTON))
315+
316+
@staticmethod
317+
def generate_remote_folder_selector(folder_name, parent_container=None):
318+
if not parent_container:
319+
parent_container = {
320+
"container": names.groupBox_folderTreeWidget_QTreeWidget,
321+
"text": "ownCloud",
322+
"type": "QModelIndex",
323+
}
324+
return {
325+
"container": parent_container,
326+
"text": folder_name,
327+
"type": "QModelIndex",
328+
}
329+
330+
@staticmethod
331+
def has_remote_folder(folder_name):
332+
folder_tree = folder_name.strip("/").split("/")
333+
parent_container = None
334+
335+
for folder in folder_tree:
336+
folder_selector = SyncConnectionWizard.generate_remote_folder_selector(
337+
folder, parent_container
338+
)
339+
try:
340+
if parent_container:
341+
squish.doubleClick(parent_container)
342+
343+
squish.waitForObject(folder_selector)
344+
345+
parent_container = folder_selector
346+
except Exception as e:
347+
print(e)
348+
return False, None
349+
return True, parent_container
350+
351+
@staticmethod
352+
def is_remote_folder_selected(folder_selector):
353+
return squish.waitForObjectExists(folder_selector).selected

test/gui/shared/steps/sync_context.py

+39
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,42 @@ def step(context, action):
237237
def step(context, folder_name):
238238
SyncConnection.choose_what_to_sync()
239239
SyncConnection.unselect_folder_in_selective_sync(folder_name)
240+
241+
242+
@When("the user opens the sync connection wizard")
243+
def step(context):
244+
SyncConnection.open_sync_connection_wizard()
245+
246+
247+
@When('the user navigates back in the sync connection wizard')
248+
def step(context):
249+
SyncConnectionWizard.back()
250+
251+
252+
@When('the user creates a folder "|any|" in the remote destination wizard')
253+
def step(context, folder_name):
254+
SyncConnectionWizard.create_folder_in_remote_destination(folder_name)
255+
256+
257+
@When('the user refreshes the remote destination in the sync connection wizard')
258+
def step(context):
259+
SyncConnectionWizard.refresh_remote()
260+
261+
262+
@Then(
263+
r'the folder "([^"]*)" should be present and (selected|not selected) in the remote destination wizard',
264+
regexp=True,
265+
)
266+
def step(context, folder_name, is_selected):
267+
has_folder, folder_selector = SyncConnectionWizard.has_remote_folder(folder_name)
268+
if is_selected == 'selected':
269+
expected = True
270+
else:
271+
expected = False
272+
273+
test.compare(True, has_folder, "Folder should be in the remote list")
274+
test.compare(
275+
expected,
276+
SyncConnectionWizard.is_remote_folder_selected(folder_selector),
277+
"Folder should be selected",
278+
)

test/gui/tst_syncing/test.feature

+15-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ Feature: Syncing files
420420
And as user "Alice" folder "folder2" should contain "500" items in the server
421421

422422

423-
Scenario: Skip sync folder configuration
423+
Scenario: Skip sync folder configuration and add it manually
424424
Given the user has started the client
425425
And the user has entered the following account information:
426426
| server | %local_server% |
@@ -430,6 +430,20 @@ Feature: Syncing files
430430
And the user cancels the sync connection wizard
431431
Then the account with displayname "Alice Hansen" and host "%local_server_hostname%" should be displayed
432432
And the sync folder should not be added
433+
When the user opens the sync connection wizard
434+
And the user sets the temp folder "tempSyncFolder" as local sync path in sync connection wizard
435+
And the user navigates back in the sync connection wizard
436+
And the user sets the temp folder "localSyncFolder" as local sync path in sync connection wizard
437+
And the user creates a folder "test-folder" in the remote destination wizard
438+
Then the folder "test-folder" should be present and selected in the remote destination wizard
439+
When the user refreshes the remote destination in the sync connection wizard
440+
Then the folder "test-folder" should be present and not selected in the remote destination wizard
441+
When the user selects "ownCloud" as a remote destination folder
442+
And the user selects the following folders to sync:
443+
| folder |
444+
| test-folder |
445+
Then the folder "test-folder" should exist on the file system
446+
And as "Alice" folder "test-folder" should exist in the server
433447

434448

435449
Scenario: extract a zip file in the sync folder

0 commit comments

Comments
 (0)