Skip to content

Commit 26b4352

Browse files
[gui-tests][full-ci] Added test for checking incremented number with bracket while adding new account and folder (#11710)
* added test to check for incremented number in bracket while adding new account and folder * test: remove HOME env * test: do not try to read empty lines * test: make use of default home dir * test: extend test assertion * test: fix python code style --------- Co-authored-by: Saw-jan <saw.jan.grg3e@gmail.com>
1 parent 20e123c commit 26b4352

12 files changed

+176
-12
lines changed

test/gui/envs.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
XDG_CONFIG_HOME=/tmp/owncloudtest/
1+
XDG_CONFIG_HOME=/tmp/owncloudtest/.config

test/gui/shared/scripts/bdd_hooks.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
isLinux,
3333
)
3434
from helpers.api.utils import url_join
35-
from helpers.FilesHelper import prefix_path_namespace
35+
from helpers.FilesHelper import prefix_path_namespace, cleanup_created_paths
3636
from datetime import datetime
3737
from pageObjects.Toolbar import Toolbar
3838
from pageObjects.AccountSetting import AccountSetting
@@ -238,6 +238,8 @@ def teardown_client():
238238
shutil.rmtree(prefix_path_namespace(entry.path))
239239
except Exception as e:
240240
test.log(f'Failed to delete{entry.name}. Reason: {e}.')
241+
# cleanup paths created outside of the temporary directory during the test
242+
cleanup_created_paths()
241243

242244

243245
def close_dialogs():

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

+16-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ def read_env_file():
1111
env_path = os.path.abspath(os.path.join(script_path, '..', '..', '..', 'envs.txt'))
1212
with open(env_path, "rt", encoding="UTF-8") as f:
1313
for line in f:
14+
if not line.strip():
15+
continue
1416
if line.startswith('#'):
1517
continue
1618
key, value = line.split('=', 1)
@@ -51,6 +53,13 @@ def getConfigHome():
5153
return os.path.join(get_config_from_env_file("XDG_CONFIG_HOME"), "ownCloud")
5254

5355

56+
def get_default_home_dir():
57+
if isWindows():
58+
return getWinUserHome()
59+
elif isLinux():
60+
return os.environ.get("HOME")
61+
62+
5463
# map environment variables to config keys
5564
CONFIG_ENV_MAP = {
5665
'localBackendUrl': 'BACKEND_HOST',
@@ -67,6 +76,11 @@ def getConfigHome():
6776
'ocis': 'OCIS',
6877
}
6978

79+
DEFAULT_PATH_CONFIG = {
80+
'custom_lib': os.path.abspath('../shared/scripts/custom_lib'),
81+
'home_dir': get_default_home_dir(),
82+
}
83+
7084
# default config values
7185
CONFIG = {
7286
'localBackendUrl': 'https://localhost:9200/',
@@ -81,10 +95,10 @@ def getConfigHome():
8195
'clientConfigDir': getConfigHome(),
8296
'guiTestReportDir': os.path.abspath('../reports'),
8397
'ocis': False,
84-
'custom_lib': os.path.abspath('../shared/scripts/custom_lib'),
8598
}
99+
CONFIG.update(DEFAULT_PATH_CONFIG)
86100

87-
READONLY_CONFIG = list(CONFIG_ENV_MAP.keys())
101+
READONLY_CONFIG = list(CONFIG_ENV_MAP.keys()) + list(DEFAULT_PATH_CONFIG.keys())
88102

89103

90104
def init_config():

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

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import re
33
import ctypes
4+
import shutil
45
from helpers.ConfigHelper import isWindows
56

67

@@ -104,3 +105,23 @@ def get_file_size_on_disk(resource_path):
104105

105106
def get_file_size(resource_path):
106107
return os.stat(resource_path).st_size
108+
109+
110+
# temp paths created outside of the temporary directory during the test
111+
CREATED_PATHS = []
112+
113+
114+
def remember_path(path):
115+
global CREATED_PATHS
116+
CREATED_PATHS.append(path)
117+
118+
119+
def cleanup_created_paths():
120+
global CREATED_PATHS
121+
for path in CREATED_PATHS:
122+
if os.path.exists(path):
123+
if os.path.isdir(path):
124+
shutil.rmtree(prefix_path_namespace(path))
125+
else:
126+
os.unlink(prefix_path_namespace(path))
127+
CREATED_PATHS = []

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

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def substituteInLineCodes(value):
1919
value = value.replace(
2020
'%local_server_hostname%', urlparse(get_config('localBackendUrl')).netloc
2121
)
22+
value = value.replace('%home%', get_config('home_dir'))
2223

2324
return value
2425

test/gui/shared/scripts/names.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@
5555
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}
5656
groupBox_folderTreeWidget_QTreeWidget = {"container": add_Folder_Sync_Connection_groupBox_QGroupBox, "name": "folderTreeWidget", "type": "QTreeWidget", "visible": 1}
5757
confirm_Folder_Sync_Connection_Removal_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Confirm Folder Sync Connection Removal"}
58+
stackedWidget_quickWidget_OCC_QmlUtils_OCQuickWidget = {"container": stack_stackedWidget_QStackedWidget, "name": "quickWidget", "type": "OCC::QmlUtils::OCQuickWidget", "visible": 1}

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

+8
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,11 @@ def isVFSOptionChecked():
350350
).checked
351351
== True
352352
)
353+
354+
@staticmethod
355+
def get_local_sync_path():
356+
return str(
357+
squish.waitForObjectExists(
358+
AccountConnectionWizard.SELECT_LOCAL_FOLDER
359+
).displayText
360+
)

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

+41
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ class SyncConnectionWizard:
113113
"visible": 1,
114114
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
115115
}
116+
ADD_FOLDER_SYNC_BUTTON = {
117+
"checkable": False,
118+
"container": names.stackedWidget_quickWidget_OCC_QmlUtils_OCQuickWidget,
119+
"id": "addSyncButton",
120+
"type": "Button",
121+
"unnamed": 1,
122+
"visible": True,
123+
}
124+
WARN_LABEL = {
125+
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
126+
"name": "warnLabel",
127+
"type": "QLabel",
128+
"visible": 1,
129+
}
116130

117131
@staticmethod
118132
def setSyncPathInSyncConnectionWizardOc10(sync_path=''):
@@ -334,3 +348,30 @@ def has_remote_folder(folder_name):
334348
except:
335349
return False, None
336350
return True, parent_container
351+
352+
@staticmethod
353+
def is_remote_folder_selected(folder_selector):
354+
return squish.waitForObjectExists(folder_selector).selected
355+
356+
@staticmethod
357+
def select_space_to_sync(space_name):
358+
SyncConnectionWizard.selectSpaceToSync(space_name)
359+
SyncConnectionWizard.nextStep()
360+
361+
@staticmethod
362+
def open_sync_connection_wizard():
363+
squish.mouseClick(
364+
squish.waitForObject(SyncConnectionWizard.ADD_FOLDER_SYNC_BUTTON)
365+
)
366+
367+
@staticmethod
368+
def get_local_sync_path():
369+
return str(
370+
squish.waitForObjectExists(
371+
SyncConnectionWizard.CHOOSE_LOCAL_SYNC_FOLDER
372+
).displayText
373+
)
374+
375+
@staticmethod
376+
def get_warn_label():
377+
return str(squish.waitForObjectExists(SyncConnectionWizard.WARN_LABEL).text)

test/gui/shared/steps/account_context.py

+32-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from helpers.ConfigHelper import get_config, isWindows, isLinux
1818

1919

20-
@When('the user adds the following wrong user credentials:')
20+
@When('the user adds the following user credentials:')
2121
def step(context):
2222
account_details = getClientDetails(context)
2323
AccountConnectionWizard.addUserCreds(
@@ -320,3 +320,34 @@ def step(context, displayname):
320320
has_focus = Toolbar.account_has_focus(account)
321321
if not has_focus:
322322
raise LookupError(f"Account '{displayname}' should be opened, but it is not")
323+
324+
325+
@Then(
326+
r'the default local sync path should contain "([^"]*)" in the (configuration|sync connection) wizard',
327+
regexp=True,
328+
)
329+
def step(context, sync_path, wizard):
330+
sync_path = substituteInLineCodes(sync_path)
331+
332+
actual_sync_path = ""
333+
if wizard == 'configuration':
334+
actual_sync_path = AccountConnectionWizard.get_local_sync_path()
335+
else:
336+
actual_sync_path = SyncConnectionWizard.get_local_sync_path()
337+
338+
test.compare(
339+
actual_sync_path,
340+
sync_path,
341+
"Compare sync path contains the expected path",
342+
)
343+
344+
345+
@Then('the warning "|any|" should appear in the sync connection wizard')
346+
def step(context, warn_message):
347+
actual_message = SyncConnectionWizard.get_warn_label()
348+
contains_warning = True if warn_message in actual_message else False
349+
test.compare(
350+
True,
351+
contains_warning,
352+
"Contains warning message",
353+
)

test/gui/shared/steps/file_context.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import shutil
77
import zipfile
88

9-
from pageObjects.AccountSetting import AccountSetting
10-
119
from helpers.SetupClientHelper import getResourcePath, getTempResourcePath
1210
from helpers.SyncHelper import waitForClientToBeReady
1311
from helpers.ConfigHelper import get_config
@@ -17,12 +15,9 @@
1715
can_read,
1816
can_write,
1917
read_file_content,
20-
is_empty_sync_folder,
2118
get_size_in_bytes,
2219
prefix_path_namespace,
23-
)
24-
from helpers.SetupClientHelper import (
25-
getTempResourcePath,
20+
remember_path,
2621
)
2722

2823

@@ -370,3 +365,12 @@ def step(context, username, source):
370365
source_dir = getResourcePath(source, username)
371366
destination_dir = getTempResourcePath(source)
372367
shutil.copy2(source_dir, destination_dir)
368+
369+
370+
@Given('the user has created folder "|any|" in the default home path')
371+
def step(context, folder_name):
372+
folder_path = join(get_config('home_dir'), folder_name)
373+
os.makedirs(prefix_path_namespace(folder_path))
374+
remember_path(folder_path)
375+
# when account is added, folder with suffix will be created
376+
remember_path(folder_path + " (2)")

test/gui/shared/steps/sync_context.py

+10
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,13 @@ def step(context):
293293
@Then('the file "|any|" should have status "|any|" in the activity tab')
294294
def step(context, file_name, status):
295295
Activity.hasSyncStatus(file_name, status)
296+
297+
298+
@When('the user selects the "|any|" space to sync')
299+
def step(context, space_name):
300+
SyncConnectionWizard.select_space_to_sync(space_name)
301+
302+
303+
@When("the user opens the sync connection wizard")
304+
def step(context):
305+
SyncConnectionWizard.open_sync_connection_wizard()

test/gui/tst_addAccount/test.feature

+32-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Feature: adding accounts
4747
Given the user has started the client
4848
And the user has entered the following account information:
4949
| server | %local_server% |
50-
When the user adds the following wrong user credentials:
50+
When the user adds the following user credentials:
5151
| user | Alice |
5252
| password | 12345 |
5353
Then the error "Invalid credentials" should be displayed in the account connection wizard
@@ -81,3 +81,34 @@ Feature: adding accounts
8181
And the user syncs the "Personal" space
8282
Then the folder "simple-folder" should exist on the file system
8383

84+
@skipOnOCIS
85+
Scenario: Check for incremented number in bracket while adding new account and folder (OC10)
86+
Given the user has created folder "ownCloud" in the default home path
87+
And the user has started the client
88+
And the user has entered the following account information:
89+
| server | %local_server% |
90+
When the user adds the following user credentials:
91+
| user | Alice |
92+
| password | 1234 |
93+
And the user opens the advanced configuration
94+
Then the default local sync path should contain "%home%/ownCloud (2)" in the configuration wizard
95+
When the user selects download everything option in advanced section
96+
And the user opens the sync connection wizard
97+
Then the default local sync path should contain "%home%/ownCloud (2) (2)" in the sync connection wizard
98+
99+
@skipOnOC10
100+
Scenario: Check for incremented number in bracket while adding new account and folder (oCIS)
101+
Given the user has created folder "ownCloud" in the default home path
102+
And the user has started the client
103+
And the user has entered the following account information:
104+
| server | %local_server% |
105+
When the user adds the following user credentials:
106+
| user | Alice |
107+
| password | 1234 |
108+
And the user opens the advanced configuration
109+
Then the default local sync path should contain "%home%/ownCloud (2)" in the configuration wizard
110+
When the user selects download everything option in advanced section
111+
And the user opens the sync connection wizard
112+
And the user selects the "Personal" space to sync
113+
Then the default local sync path should contain "%home%/ownCloud (2)/Personal" in the sync connection wizard
114+
And the warning "There is already a sync from the server to this local folder. Please pick another local folder!" should appear in the sync connection wizard

0 commit comments

Comments
 (0)