From 6919eddd86e9cb29ecd7ff59c88937b5c24a1518 Mon Sep 17 00:00:00 2001 From: prashant-gurung899 Date: Thu, 4 Jun 2026 09:29:39 +0545 Subject: [PATCH] enable more sync resources tests Signed-off-by: prashant-gurung899 --- .../sync-resources/syncResources.feature | 5 ++-- test/gui/helpers/SyncHelper.py | 2 +- test/gui/pageObjects/Activity.py | 16 ++++++---- test/gui/pageObjects/SyncConnection.py | 30 +++++++++++++++---- test/gui/steps/file_context.py | 8 ++--- test/gui/steps/sync_context.py | 11 +++---- 6 files changed, 48 insertions(+), 24 deletions(-) diff --git a/test/gui/features/sync-resources/syncResources.feature b/test/gui/features/sync-resources/syncResources.feature index 619b67507..921e65072 100644 --- a/test/gui/features/sync-resources/syncResources.feature +++ b/test/gui/features/sync-resources/syncResources.feature @@ -33,18 +33,17 @@ Feature: Syncing files And the folder "simple-folder" should exist on the file system And the folder "large-folder" should exist on the file system - @issue-9733 @skip + @issue-9733 Scenario: Syncing a file from the server and creating a conflict Given user "Alice" has uploaded file with content "server content" to "/conflict.txt" in the server And user "Alice" has set up a client with default settings - And the user has paused the file sync And the user has changed the content of local file "conflict.txt" to: """ client content """ And user "Alice" has uploaded file with content "changed server content" to "/conflict.txt" in the server And the user has waited for "5" seconds - When the user resumes the file sync on the client + When the user waits for the files to sync And the user opens the activity tab And the user selects "Not Synced" tab in the activity Then the table of conflict warnings should include file "conflict.txt" diff --git a/test/gui/helpers/SyncHelper.py b/test/gui/helpers/SyncHelper.py index 750aa14ff..12a0808b6 100644 --- a/test/gui/helpers/SyncHelper.py +++ b/test/gui/helpers/SyncHelper.py @@ -272,7 +272,7 @@ def wait_for_resource_to_sync( 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) diff --git a/test/gui/pageObjects/Activity.py b/test/gui/pageObjects/Activity.py index 442e49348..fc06895cb 100644 --- a/test/gui/pageObjects/Activity.py +++ b/test/gui/pageObjects/Activity.py @@ -30,6 +30,7 @@ class Activity: NOT_SYNCED_FILTER_OPTION_SELECTOR = SimpleNamespace(by=None, selector=None) SYNCED_ACTIVITY_TABLE_HEADER_SELECTOR = SimpleNamespace(by=None, selector=None) NOT_SYNCED_ACTIVITY_TABLE_HEADER_SELECTOR = SimpleNamespace(by=None, selector=None) + NOT_SYNCED_ACTIVITY_CONFLICT_FILE = SimpleNamespace(by=By.XPATH, selector="//*[starts-with(@name, '{filename} (conflicted copy')]") SYNCED_ACTIVITY_STATUS = SimpleNamespace(by=By.NAME, selector=None) @@ -59,12 +60,17 @@ def open_tab(tab_name): app().find_element(Activity.SUBTAB_CONTAINER.by, selector).click() @staticmethod - def check_file_exist(filename): - squish.waitForObjectExists( - Activity.get_not_synced_file_selector( - RegularExpression(build_conflicted_regex(filename)) - ) + def has_conflict_file(filename): + filename = filename.rsplit(".", 1)[0] + has_activity = wait_for( + lambda: app().find_element( + Activity.NOT_SYNCED_ACTIVITY_CONFLICT_FILE.by, + Activity.NOT_SYNCED_ACTIVITY_CONFLICT_FILE.selector.format(filename=filename) + ).is_displayed(), + get_config('max_timeout') ) + if not has_activity: + raise AssertionError(f"File conflict activity not found") @staticmethod def is_resource_blacklisted(filename): diff --git a/test/gui/pageObjects/SyncConnection.py b/test/gui/pageObjects/SyncConnection.py index a5990378c..685231f0d 100644 --- a/test/gui/pageObjects/SyncConnection.py +++ b/test/gui/pageObjects/SyncConnection.py @@ -13,7 +13,7 @@ class SyncConnection: ) FOLDER_SYNC_CONNECTION_MENU_BUTTON = SimpleNamespace( by=By.NAME, - selector="{sync_folder},Success,Local folder: {sync_path}{sync_folder}", + selector="{sync_folder},{status},Local folder: {sync_path}{sync_folder}", ) MENU_ITEM = SimpleNamespace(by=By.NAME, selector=None) SELECTIVE_SYNC_APPLY_BUTTON = SimpleNamespace(by=None, selector=None) @@ -39,23 +39,40 @@ def get_current_account_connection(): return None @staticmethod - def open_menu(sync_folder=None): + def open_menu(sync_folder=None, sync_state="success"): if sync_folder is None: sync_folder = get_config('syncConnectionName') + if sync_state == "success": + status = "Success" + elif sync_state == "paused": + status = "Sync paused" + elif sync_state == "queued": + status = "Queued" + else: + raise ValueError(f"Unknown sync_state: {sync_state}") + connection = SyncConnection.get_current_account_connection() + print( + SyncConnection.FOLDER_SYNC_CONNECTION_MENU_BUTTON.selector.format( + sync_folder=sync_folder, + sync_path=get_config("currentUserSyncPath"), + status=status, + ) + ) menu_button = connection.find_element( SyncConnection.FOLDER_SYNC_CONNECTION_MENU_BUTTON.by, SyncConnection.FOLDER_SYNC_CONNECTION_MENU_BUTTON.selector.format( sync_folder=sync_folder, - sync_path=get_config('currentUserSyncPath'), + sync_path=get_config("currentUserSyncPath"), + status=status, ), ) menu_button.native_click(button='right') @staticmethod - def perform_action(action): - SyncConnection.open_menu() + def perform_action(action, sync_state="success"): + SyncConnection.open_menu(sync_state=sync_state) app().find_element(SyncConnection.MENU_ITEM.by, action).click() @staticmethod @@ -68,7 +85,7 @@ def pause_sync(): @staticmethod def resume_sync(): - SyncConnection.perform_action("Resume sync") + SyncConnection.perform_action("Resume sync", "paused") @staticmethod def has_menu_item(item): @@ -94,6 +111,7 @@ def has_sync_connection(sync_folder): SyncConnection.FOLDER_SYNC_CONNECTION_MENU_BUTTON.selector.format( sync_folder=sync_folder, sync_path=get_config('currentUserSyncPath'), + status="success" ), ) return True diff --git a/test/gui/steps/file_context.py b/test/gui/steps/file_context.py index 80d70b07b..f6dddb0bc 100644 --- a/test/gui/steps/file_context.py +++ b/test/gui/steps/file_context.py @@ -239,17 +239,17 @@ def step(context, resource_type, resource): exists(resource_path).should.be.false -@Given('the user has changed the content of local file "|any|" to:') +@Given('the user has changed the content of local file "{filename}" to:') def step(context, filename): - file_content = '\n'.join(context.multiLineText) + file_content = context.text wait_and_write_file(get_resource_path(filename), file_content) @Then( - 'a conflict file for "|any|" should exist on the file system with the following content' + 'a conflict file for "{filename}" should exist on the file system with the following content' ) def step(context, filename): - expected = '\n'.join(context.multiLineText) + expected = context.text onlyfiles = [ f for f in os.listdir(get_resource_path()) if isfile(get_resource_path(f)) diff --git a/test/gui/steps/sync_context.py b/test/gui/steps/sync_context.py index 421ad481b..129c8e930 100644 --- a/test/gui/steps/sync_context.py +++ b/test/gui/steps/sync_context.py @@ -1,4 +1,5 @@ -from behave import when as When, then as Then +import time +from behave import when as When, then as Then, given as Given from sure import ensure from pageObjects.SyncConnectionWizard import SyncConnectionWizard @@ -108,9 +109,9 @@ def step(context): Toolbar.open_settings_tab() -@Then('the table of conflict warnings should include file "|any|"') +@Then('the table of conflict warnings should include file "{filename}"') def step(context, filename): - Activity.check_file_exist(filename) + Activity.has_conflict_file(filename) @Then('the file "{filename}" should be blacklisted') @@ -345,9 +346,9 @@ def step(context): expected_error_message.should.equal(actual_error_message) -@Given('the user has waited for "|any|" seconds') +@Given('the user has waited for "{wait_for}" seconds') def step(context, wait_for): - squish.snooze(float(wait_for)) + time.sleep(float(wait_for)) @When(