Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gui-tests][full-ci] Added test for checking incremented number with bracket while adding new account and folder #11710

Merged
merged 6 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/gui/envs.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
XDG_CONFIG_HOME=/tmp/owncloudtest/
XDG_CONFIG_HOME=/tmp/owncloudtest/.config
4 changes: 3 additions & 1 deletion test/gui/shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
isLinux,
)
from helpers.api.utils import url_join
from helpers.FilesHelper import prefix_path_namespace
from helpers.FilesHelper import prefix_path_namespace, cleanup_created_paths
from datetime import datetime
from pageObjects.Toolbar import Toolbar
from pageObjects.AccountSetting import AccountSetting
Expand Down Expand Up @@ -238,6 +238,8 @@ def teardown_client():
shutil.rmtree(prefix_path_namespace(entry.path))
except Exception as e:
test.log(f'Failed to delete{entry.name}. Reason: {e}.')
# cleanup paths created outside of the temporary directory during the test
cleanup_created_paths()


def close_dialogs():
Expand Down
18 changes: 16 additions & 2 deletions test/gui/shared/scripts/helpers/ConfigHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def read_env_file():
env_path = os.path.abspath(os.path.join(script_path, '..', '..', '..', 'envs.txt'))
with open(env_path, "rt", encoding="UTF-8") as f:
for line in f:
if not line.strip():
continue
if line.startswith('#'):
continue
key, value = line.split('=', 1)
Expand Down Expand Up @@ -51,6 +53,13 @@ def getConfigHome():
return os.path.join(get_config_from_env_file("XDG_CONFIG_HOME"), "ownCloud")


def get_default_home_dir():
if isWindows():
return getWinUserHome()
elif isLinux():
return os.environ.get("HOME")


# map environment variables to config keys
CONFIG_ENV_MAP = {
'localBackendUrl': 'BACKEND_HOST',
Expand All @@ -67,6 +76,11 @@ def getConfigHome():
'ocis': 'OCIS',
}

DEFAULT_PATH_CONFIG = {
'custom_lib': os.path.abspath('../shared/scripts/custom_lib'),
'home_dir': get_default_home_dir(),
}

# default config values
CONFIG = {
'localBackendUrl': 'https://localhost:9200/',
Expand All @@ -81,10 +95,10 @@ def getConfigHome():
'clientConfigDir': getConfigHome(),
'guiTestReportDir': os.path.abspath('../reports'),
'ocis': False,
'custom_lib': os.path.abspath('../shared/scripts/custom_lib'),
}
CONFIG.update(DEFAULT_PATH_CONFIG)

READONLY_CONFIG = list(CONFIG_ENV_MAP.keys())
READONLY_CONFIG = list(CONFIG_ENV_MAP.keys()) + list(DEFAULT_PATH_CONFIG.keys())


def init_config():
Expand Down
21 changes: 21 additions & 0 deletions test/gui/shared/scripts/helpers/FilesHelper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
import ctypes
import shutil
from helpers.ConfigHelper import isWindows


Expand Down Expand Up @@ -104,3 +105,23 @@ def get_file_size_on_disk(resource_path):

def get_file_size(resource_path):
return os.stat(resource_path).st_size


# temp paths created outside of the temporary directory during the test
CREATED_PATHS = []


def remember_path(path):
global CREATED_PATHS
CREATED_PATHS.append(path)


def cleanup_created_paths():
global CREATED_PATHS
for path in CREATED_PATHS:
if os.path.exists(path):
if os.path.isdir(path):
shutil.rmtree(prefix_path_namespace(path))
else:
os.unlink(prefix_path_namespace(path))
CREATED_PATHS = []
1 change: 1 addition & 0 deletions test/gui/shared/scripts/helpers/SetupClientHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def substituteInLineCodes(value):
value = value.replace(
'%local_server_hostname%', urlparse(get_config('localBackendUrl')).netloc
)
value = value.replace('%home%', get_config('home_dir'))

return value

Expand Down
1 change: 1 addition & 0 deletions test/gui/shared/scripts/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@
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}
confirm_Folder_Sync_Connection_Removal_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Confirm Folder Sync Connection Removal"}
stackedWidget_quickWidget_OCC_QmlUtils_OCQuickWidget = {"container": stack_stackedWidget_QStackedWidget, "name": "quickWidget", "type": "OCC::QmlUtils::OCQuickWidget", "visible": 1}
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,11 @@ def isVFSOptionChecked():
).checked
== True
)

@staticmethod
def get_local_sync_path():
return str(
squish.waitForObjectExists(
AccountConnectionWizard.SELECT_LOCAL_FOLDER
).displayText
)
41 changes: 41 additions & 0 deletions test/gui/shared/scripts/pageObjects/SyncConnectionWizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ class SyncConnectionWizard:
"visible": 1,
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
}
ADD_FOLDER_SYNC_BUTTON = {
"checkable": False,
"container": names.stackedWidget_quickWidget_OCC_QmlUtils_OCQuickWidget,
"id": "addSyncButton",
"type": "Button",
"unnamed": 1,
"visible": True,
}
WARN_LABEL = {
"window": names.add_Folder_Sync_Connection_OCC_FolderWizard,
"name": "warnLabel",
"type": "QLabel",
"visible": 1,
}

@staticmethod
def setSyncPathInSyncConnectionWizardOc10(sync_path=''):
Expand Down Expand Up @@ -334,3 +348,30 @@ def has_remote_folder(folder_name):
except:
return False, None
return True, parent_container

@staticmethod
def is_remote_folder_selected(folder_selector):
return squish.waitForObjectExists(folder_selector).selected

@staticmethod
def select_space_to_sync(space_name):
SyncConnectionWizard.selectSpaceToSync(space_name)
SyncConnectionWizard.nextStep()

@staticmethod
def open_sync_connection_wizard():
squish.mouseClick(
squish.waitForObject(SyncConnectionWizard.ADD_FOLDER_SYNC_BUTTON)
)

@staticmethod
def get_local_sync_path():
return str(
squish.waitForObjectExists(
SyncConnectionWizard.CHOOSE_LOCAL_SYNC_FOLDER
).displayText
)

@staticmethod
def get_warn_label():
return str(squish.waitForObjectExists(SyncConnectionWizard.WARN_LABEL).text)
33 changes: 32 additions & 1 deletion test/gui/shared/steps/account_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from helpers.ConfigHelper import get_config, isWindows, isLinux


@When('the user adds the following wrong user credentials:')
@When('the user adds the following user credentials:')
def step(context):
account_details = getClientDetails(context)
AccountConnectionWizard.addUserCreds(
Expand Down Expand Up @@ -320,3 +320,34 @@ def step(context, displayname):
has_focus = Toolbar.account_has_focus(account)
if not has_focus:
raise LookupError(f"Account '{displayname}' should be opened, but it is not")


@Then(
r'the default local sync path should contain "([^"]*)" in the (configuration|sync connection) wizard',
regexp=True,
)
def step(context, sync_path, wizard):
sync_path = substituteInLineCodes(sync_path)

actual_sync_path = ""
if wizard == 'configuration':
actual_sync_path = AccountConnectionWizard.get_local_sync_path()
else:
actual_sync_path = SyncConnectionWizard.get_local_sync_path()

test.compare(
actual_sync_path,
sync_path,
"Compare sync path contains the expected path",
)


@Then('the warning "|any|" should appear in the sync connection wizard')
def step(context, warn_message):
actual_message = SyncConnectionWizard.get_warn_label()
contains_warning = True if warn_message in actual_message else False
test.compare(
True,
contains_warning,
"Contains warning message",
)
16 changes: 10 additions & 6 deletions test/gui/shared/steps/file_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import shutil
import zipfile

from pageObjects.AccountSetting import AccountSetting

from helpers.SetupClientHelper import getResourcePath, getTempResourcePath
from helpers.SyncHelper import waitForClientToBeReady
from helpers.ConfigHelper import get_config
Expand All @@ -17,12 +15,9 @@
can_read,
can_write,
read_file_content,
is_empty_sync_folder,
get_size_in_bytes,
prefix_path_namespace,
)
from helpers.SetupClientHelper import (
getTempResourcePath,
remember_path,
)


Expand Down Expand Up @@ -370,3 +365,12 @@ def step(context, username, source):
source_dir = getResourcePath(source, username)
destination_dir = getTempResourcePath(source)
shutil.copy2(source_dir, destination_dir)


@Given('the user has created folder "|any|" in the default home path')
def step(context, folder_name):
folder_path = join(get_config('home_dir'), folder_name)
os.makedirs(prefix_path_namespace(folder_path))
remember_path(folder_path)
# when account is added, folder with suffix will be created
remember_path(folder_path + " (2)")
10 changes: 10 additions & 0 deletions test/gui/shared/steps/sync_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,13 @@ def step(context):
@Then('the file "|any|" should have status "|any|" in the activity tab')
def step(context, file_name, status):
Activity.hasSyncStatus(file_name, status)


@When('the user selects the "|any|" space to sync')
def step(context, space_name):
SyncConnectionWizard.select_space_to_sync(space_name)


@When("the user opens the sync connection wizard")
def step(context):
SyncConnectionWizard.open_sync_connection_wizard()
33 changes: 32 additions & 1 deletion test/gui/tst_addAccount/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Feature: adding accounts
Given the user has started the client
And the user has entered the following account information:
| server | %local_server% |
When the user adds the following wrong user credentials:
When the user adds the following user credentials:
| user | Alice |
| password | 12345 |
Then the error "Invalid credentials" should be displayed in the account connection wizard
Expand Down Expand Up @@ -81,3 +81,34 @@ Feature: adding accounts
And the user syncs the "Personal" space
Then the folder "simple-folder" should exist on the file system

@skipOnOCIS
Scenario: Check for incremented number in bracket while adding new account and folder (OC10)
Given the user has created folder "ownCloud" in the default home path
And the user has started the client
And the user has entered the following account information:
| server | %local_server% |
When the user adds the following user credentials:
| user | Alice |
| password | 1234 |
And the user opens the advanced configuration
Then the default local sync path should contain "%home%/ownCloud (2)" in the configuration wizard
When the user selects download everything option in advanced section
And the user opens the sync connection wizard
Then the default local sync path should contain "%home%/ownCloud (2) (2)" in the sync connection wizard

@skipOnOC10
Scenario: Check for incremented number in bracket while adding new account and folder (oCIS)
Given the user has created folder "ownCloud" in the default home path
And the user has started the client
And the user has entered the following account information:
| server | %local_server% |
When the user adds the following user credentials:
| user | Alice |
| password | 1234 |
And the user opens the advanced configuration
Then the default local sync path should contain "%home%/ownCloud (2)" in the configuration wizard
When the user selects download everything option in advanced section
And the user opens the sync connection wizard
And the user selects the "Personal" space to sync
Then the default local sync path should contain "%home%/ownCloud (2)/Personal" in the sync connection wizard
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
Loading