diff --git a/test/gui/shared/scripts/helpers/FilesHelper.py b/test/gui/shared/scripts/helpers/FilesHelper.py index b60cf68ab32..6e967a09f07 100644 --- a/test/gui/shared/scripts/helpers/FilesHelper.py +++ b/test/gui/shared/scripts/helpers/FilesHelper.py @@ -91,3 +91,9 @@ def get_file_size_on_disk(resource_path): raise Exception( "'get_file_size_on_disk' function is only supported for Windows OS." ) + + +def get_file_size(resource_path): + if isWindows(): + return os.stat(resource_path).st_size + raise Exception("'get_file_size' function is only supported for Windows OS.") diff --git a/test/gui/shared/scripts/pageObjects/SyncConnection.py b/test/gui/shared/scripts/pageObjects/SyncConnection.py index 999b7a4363d..30ebc9fca54 100644 --- a/test/gui/shared/scripts/pageObjects/SyncConnection.py +++ b/test/gui/shared/scripts/pageObjects/SyncConnection.py @@ -1,7 +1,10 @@ import names import squish +import object +import os from helpers.ConfigHelper import get_config +from helpers.SetupClientHelper import getResourcePath class SyncConnection: @@ -22,6 +25,12 @@ class SyncConnection: "visible": 1, "window": names.disable_virtual_file_support_QMessageBox, } + SELECTIVE_SYNC_APPLY_BUTTON = { + "container": names.settings_stack_QStackedWidget, + "name": "selectiveSyncApply", + "type": "QPushButton", + "visible": 1, + } @staticmethod def openMenu(): @@ -62,3 +71,50 @@ def disableVFS(): @staticmethod def hasMenuItem(item): return squish.waitForObjectItem(SyncConnection.MENU, item) + + @staticmethod + def menu_item_exists(menuItem): + obj = SyncConnection.MENU.copy() + obj.update({"type": "QAction", "text": menuItem}) + return object.exists(obj) + + @staticmethod + def enable_selective_sync(): + SyncConnection.openMenu() + SyncConnection.performAction("Choose what to sync") + + @staticmethod + def get_dir_size(folder_path): + size = 0 + for ele in os.scandir(folder_path): + size += os.path.getsize(ele) + return size + + @staticmethod + def convert_bytes(bytes): + suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] + index = 0 + while bytes >= 1024 and index < len(suffixes) - 1: + bytes /= 1024.0 + index += 1 + return f"{bytes:.0f} {suffixes[index]}" + + @staticmethod + def unselect_folder_in_sync_connection(folder_name): + resource_path = getResourcePath(folder_name) + file_size = SyncConnection.get_dir_size(resource_path) + size = SyncConnection.convert_bytes(file_size) + squish.mouseClick( + squish.waitForObjectItem( + SyncConnection.FOLDER_SYNC_CONNECTION, + f'{get_config("syncConnectionName")}.{folder_name} ({size})', + ), + 9, + 9, + squish.Qt.NoModifier, + squish.Qt.LeftButton, + ) + squish.snooze(0.1) + squish.clickButton( + squish.waitForObject(SyncConnection.SELECTIVE_SYNC_APPLY_BUTTON) + ) diff --git a/test/gui/shared/steps/sync_context.py b/test/gui/shared/steps/sync_context.py index 34b641a728c..8a9e66ab9c6 100644 --- a/test/gui/shared/steps/sync_context.py +++ b/test/gui/shared/steps/sync_context.py @@ -4,7 +4,6 @@ from pageObjects.Activity import Activity from pageObjects.Settings import Settings -from helpers.SetupClientHelper import getResourcePath from helpers.ConfigHelper import get_config, isWindows from helpers.SyncHelper import ( waitForFileOrFolderToSync, @@ -61,6 +60,16 @@ def step(context, item): SyncConnection.hasMenuItem(item) +@Then('the "|any|" button should not be available') +def step(context, item): + SyncConnection.openMenu() + test.compare( + SyncConnection.menu_item_exists(item), + False, + f'Menu item "{item}" does not exist.', + ) + + @When("the user disables virtual file support") def step(context): SyncConnection.disableVFS() @@ -200,3 +209,9 @@ def step(context, action): if isWindows(): action = action.rstrip("s") SyncConnectionWizard.enableOrDisableVfsSupport(action) + + +@When('user unselects a folder "|any|" in selective sync') +def step(context, folder_name): + SyncConnection.enable_selective_sync() + SyncConnection.unselect_folder_in_sync_connection(folder_name) diff --git a/test/gui/tst_vfs/test.feature b/test/gui/tst_vfs/test.feature index b3490e2cf0b..c87ef15e5f7 100644 --- a/test/gui/tst_vfs/test.feature +++ b/test/gui/tst_vfs/test.feature @@ -11,20 +11,24 @@ Feature: Enable/disable virtual file support And user "Alice" has uploaded file with content "ownCloud" to "testFile.txt" in the server And user "Alice" has created folder "folder1" in the server And user "Alice" has uploaded file with content "some contents" to "folder1/lorem.txt" in the server + And user "Alice" has created folder "folder2" in the server + And user "Alice" has uploaded file with content "content" to "folder2/lorem.txt" in the server And user "Alice" has set up a client with default settings Then the placeholder of file "testFile.txt" should exist on the file system And the placeholder of file "folder1/lorem.txt" should exist on the file system + And the placeholder of file "folder2/lorem.txt" should exist on the file system + And the "Choose what to sync" button should not be available When the user disables virtual file support Then the "Enable virtual file support..." button should be available And the file "testFile.txt" should be downloaded And the file "folder1/lorem.txt" should be downloaded - And the file "testFile.txt" should exist on the file system with the following content - """ - ownCloud - """ - And the file "folder1/lorem.txt" should exist on the file system with the following content - """ - some contents - """ + And the file "folder2/lorem.txt" should be downloaded + When user unselects a folder "folder1" in selective sync + And the user waits for the files to sync + Then the folder "folder1" should not exist on the file system + And the file "folder2/lorem.txt" should exist on the file system When the user enables virtual file support Then the "Disable virtual file support..." button should be available + And the placeholder of file "folder1/lorem.txt" should exist on the file system + And the file "testFile.txt" should be downloaded + And the file "folder2/lorem.txt" should be downloaded