Skip to content
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
3 changes: 2 additions & 1 deletion test/gui/features/spaces/spaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ Feature: Project spaces
"""
When the user opens the activity tab
And the user selects "Not Synced" tab in the activity
Then the following activities should be displayed in not synced table
Then the folder "simple-folder" should be blacklisted
And the following activities should be displayed in not synced table
| resource | status | account |
| simple-folder | Blacklisted | Alice Hansen@%local_server_hostname% |

Expand Down
4 changes: 2 additions & 2 deletions test/gui/features/sync-resources/syncResources.feature
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Feature: Syncing files
When the user selects manual sync folder option in advanced section
And the user sets the sync path in sync connection wizard
And the user selects "Personal" space in sync connection wizard
And the user selects the following folders to sync:
And the user selects only the following folders to sync:
| folder |
| simple-folder |
Then the folder "simple-folder" should exist on the file system
Expand Down Expand Up @@ -473,7 +473,7 @@ Feature: Syncing files
When the user selects manual sync folder option in advanced section
And the user sets the temp folder "~`!@#$^&()-_=+{[}];',)PRN%" as local sync path in sync connection wizard
And the user selects "Personal" space in sync connection wizard
And the user selects the following folders to sync:
And the user selects only the following folders to sync:
| folder |
| ~`!@#$^&()-_=+{[}];',) |
| simple-folder |
Expand Down
1 change: 1 addition & 0 deletions test/gui/helpers/ConfigHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def get_app_env():
'max_timeout': 60,
'min_timeout': 5,
'lowest_timeout': 1,
'min_sync_timeout': 5,
'files_for_upload': os.path.join(CURRENT_DIR.parent, 'files-for-upload'),
}

Expand Down
3 changes: 2 additions & 1 deletion test/gui/helpers/ScreenRecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def _record_loop(video_path):
size=(width, height),
fps=24,
codec="libx264",
output_params=["-crf", "23", "-pix_fmt", "yuv420p"],
pix_fmt_out="yuv420p",
output_params=["-crf", "23"],
)
writer.send(None)

Expand Down
63 changes: 45 additions & 18 deletions test/gui/helpers/SyncHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
],
],
'root_synced': [
[
SYNC_STATUS['NOP'],
SYNC_STATUS['UPDATE'],
],
[
SYNC_STATUS['OK'],
SYNC_STATUS['OK'],
Expand Down Expand Up @@ -242,7 +246,7 @@ def get_current_sync_status(resource, resource_type):


def wait_for_resource_to_sync(
resource, resource_type='FOLDER', patterns=None, force_sync=False
resource, resource_type='FOLDER', patterns=None, force_sync=False, check_queued=True
):
listen_sync_status_for_item(resource, resource_type)

Expand All @@ -252,32 +256,51 @@ def wait_for_resource_to_sync(
if patterns is None:
patterns = get_synced_pattern(resource)

sync_info = []
synced = False
if force_sync:
initial_timeout = get_config('min_timeout')
initial_timeout = get_config('min_sync_timeout')
# first try with 5 seconds timeout
synced = wait_for(
lambda: has_sync_pattern(patterns, resource),
initial_timeout,
)
if not synced:
# trigger force sync if the current status is OK
status = get_current_sync_status(resource, resource_type)
if status.startswith(SYNC_STATUS['OK']):
print('[WARN] Retrying sync pattern check with force sync')
# do not trigger force sync if the sync is still in progress
if check_queued and SyncConnection.is_sync_in_progress(
get_config('syncConnectionName')
):
print('[INFO] Sync is in progress. Waiting...')
elif has_sync_status(resource, SYNC_STATUS['OK']) or has_sync_status(
resource, SYNC_STATUS['UPDATE']
):
sync_info.append('Force synced: True')
print('[INFO] Retrying sync pattern check with force sync')
SyncConnection.force_sync()
else:
clear_socket_messages(resource)
return

synced = wait_for(
lambda: has_sync_pattern(patterns, resource),
timeout - initial_timeout,
)

messages = read_and_update_socket_messages()
messages = filter_messages_for_item(messages, resource)
if not synced:
synced = wait_for(
lambda: has_sync_pattern(patterns, resource),
timeout,
)
sync_messages = read_and_update_socket_messages()
# clear stored socket messages
clear_socket_messages(resource)
sync_info.append('Sync complete (socket): %s' % synced)
if synced:
if check_queued:
loaded = wait_for(
lambda: not SyncConnection.is_sync_in_progress(
get_config('syncConnectionName')
),
get_config('sync_timeout'),
)
sync_info.append('Sync complete (UI): %s' % loaded)
if not loaded:
raise TimeoutError(
'[ERROR] Sync is still in progress after matching the sync pattern.'
+ '\n'.join(sync_info)
)
return
elif not force_sync:
# if the sync pattern doesn't match then check the last sync status
Expand All @@ -291,17 +314,21 @@ def wait_for_resource_to_sync(
+ '. So passing the step.'
)
return
print('[ERROR] Sync patterns: %s' % patterns)
print('[ERROR] Sync messages: %s' % sync_messages)
raise TimeoutError(
'Timeout while waiting for sync to complete for ' + str(timeout) + ' seconds'
'Timeout while waiting for sync to complete for %s seconds.\n' % timeout
+ '\n'.join(sync_info)
)


def wait_for_initial_sync_to_complete(path):
def wait_for_initial_sync_to_complete(path, check_queued=True):
wait_for_resource_to_sync(
path,
'FOLDER',
get_initial_sync_patterns(),
True,
check_queued,
)


Expand Down
20 changes: 14 additions & 6 deletions test/gui/pageObjects/Activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from types import SimpleNamespace
from appium.webdriver.common.appiumby import AppiumBy as By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoSuchElementException, WebDriverException

from helpers.FilesHelper import build_conflicted_regex
from helpers.ConfigHelper import get_config
Expand All @@ -13,8 +13,7 @@
class Activity:
TAB_CONTAINER = SimpleNamespace(by=None, selector=None)
SUBTAB_CONTAINER = SimpleNamespace(
by=By.XPATH,
selector="//page_tab[starts-with(@name, '{tab_name}')]"
by=By.XPATH, selector="//page_tab[starts-with(@name, '{tab_name}')]"
)
NOT_SYNCED_TABLE = SimpleNamespace(by=None, selector=None)
LOCAL_ACTIVITY_FILTER_BUTTON = SimpleNamespace(by=By.NAME, selector="Filter")
Expand All @@ -32,7 +31,6 @@ class Activity:
NOT_SYNCED_ACTIVITY_TABLE_HEADER_SELECTOR = SimpleNamespace(by=None, selector=None)
SYNCED_ACTIVITY_STATUS = SimpleNamespace(by=By.NAME, selector=None)


@staticmethod
def get_not_synced_file_selector(resource):
return {
Expand Down Expand Up @@ -93,10 +91,20 @@ def is_resource_excluded(filename):
@staticmethod
def has_sync_status(filename, status):
try:
app().find_element(Activity.SYNCED_ACTIVITY_STATUS.by, status)
return True
row = app().find_element(By.NAME, filename)
row_y = row.rect['y']
status_cells = app().find_elements(
Activity.SYNCED_ACTIVITY_STATUS.by, status
)
for status_el in status_cells:
if status_el.rect['y'] == row_y:
return True
return False
except NoSuchElementException:
return False
except WebDriverException as e:
if "NoneType" in str(e):
return False

@staticmethod
def select_synced_filter(sync_filter):
Expand Down
41 changes: 32 additions & 9 deletions test/gui/pageObjects/SyncConnection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from types import SimpleNamespace
from appium.webdriver.common.appiumby import AppiumBy as By
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoSuchElementException, WebDriverException

from helpers.ConfigHelper import get_config
from helpers.AppHelper import app
Expand All @@ -22,8 +22,7 @@ class SyncConnection:
by=By.NAME, selector="Remove Space"
)
PERMISSION_ERROR_LABEL = SimpleNamespace(
by=By.XPATH,
selector="//label[contains(@name, 'permission')]"
by=By.XPATH, selector="//label[contains(@name, 'permission')]"
)

@staticmethod
Expand Down Expand Up @@ -100,6 +99,24 @@ def has_sync_connection(sync_folder):
except NoSuchElementException:
return False

@staticmethod
def is_sync_in_progress(sync_folder):
connection = SyncConnection.get_current_account_connection()
try:
connection.find_element(
By.NAME,
"{sync_folder},Queued,Local folder: {sync_path}{sync_folder}".format(
Comment thread
prashant-gurung899 marked this conversation as resolved.
sync_folder=sync_folder,
sync_path=get_config('currentUserSyncPath'),
),
)
return True
except NoSuchElementException:
return False
except WebDriverException as e:
if "NoneType" in str(e):
return False

@staticmethod
def remove_folder_sync_connection():
SyncConnection.perform_action("Remove Space")
Expand All @@ -121,11 +138,18 @@ def confirm_folder_sync_connection_removal():
def wait_for_error_label(to_exist=True):
"""Wait for permission error label to appear or disappear"""

def check_label():
try:
app().find_element(
SyncConnection.PERMISSION_ERROR_LABEL.by,
SyncConnection.PERMISSION_ERROR_LABEL.selector,
)
return True
except NoSuchElementException:
return False

status = wait_for(
lambda: (bool(app().find_elements(
SyncConnection.PERMISSION_ERROR_LABEL.by,
SyncConnection.PERMISSION_ERROR_LABEL.selector
))) == to_exist,
lambda: check_label() == to_exist,
get_config("max_timeout"),
)
if not status:
Expand All @@ -138,7 +162,6 @@ def get_permission_error_message():
SyncConnection.wait_for_error_label(True) # Wait for label to appear
element = app().find_element(
SyncConnection.PERMISSION_ERROR_LABEL.by,
SyncConnection.PERMISSION_ERROR_LABEL.selector
SyncConnection.PERMISSION_ERROR_LABEL.selector,
)
return str(element.text)

Loading