diff --git a/test/gui/shared/scripts/helpers/SyncHelper.py b/test/gui/shared/scripts/helpers/SyncHelper.py index a9b3e92dd..793a8440e 100644 --- a/test/gui/shared/scripts/helpers/SyncHelper.py +++ b/test/gui/shared/scripts/helpers/SyncHelper.py @@ -333,3 +333,26 @@ def wait_for_client_to_be_ready(): def clear_waited_after_sync(): global WAITED_AFTER_SYNC WAITED_AFTER_SYNC = False + + +def perform_file_explorer_action(resource_path, action): + if action == 'online-only': + make_online_only(resource_path) + elif action == 'available-locally': + make_available_locally(resource_path) + else: + raise ValueError( + f'Invalid file explorer action: {action}' + ) + + +def make_online_only(resource_path): + socket_connect = get_socket_connection() + resource_path = resource_path.rstrip('\\').rstrip('/') + socket_connect.sendCommand(f'MAKE_ONLINE_ONLY:{resource_path}\n') + + +def make_available_locally(resource_path): + socket_connect = get_socket_connection() + resource_path = resource_path.rstrip('\\').rstrip('/') + socket_connect.sendCommand(f'MAKE_AVAILABLE_LOCALLY:{resource_path}\n') diff --git a/test/gui/shared/steps/file_context.py b/test/gui/shared/steps/file_context.py index 3ca54a682..badfdf093 100644 --- a/test/gui/shared/steps/file_context.py +++ b/test/gui/shared/steps/file_context.py @@ -8,8 +8,8 @@ import squish from helpers.SetupClientHelper import get_resource_path, get_temp_resource_path -from helpers.SyncHelper import wait_for_client_to_be_ready, listen_sync_status_for_item -from helpers.ConfigHelper import get_config +from helpers.SyncHelper import wait_for_client_to_be_ready, listen_sync_status_for_item, perform_file_explorer_action +from helpers.ConfigHelper import get_config, is_windows from helpers.FilesHelper import ( build_conflicted_regex, sanitize_path, @@ -97,26 +97,27 @@ def extract_zip(zip_file_path, destination_dir): def add_copy_suffix(resource_path, resource_type): + suffix = ' (Copy)' if resource_type == 'file': source_dir = resource_path.rsplit('.', 1) - return source_dir[0] + ' - Copy.' + source_dir[-1] - return resource_path + ' - Copy' + return source_dir[0] + suffix + '.' + source_dir[-1] + return resource_path + suffix def copy_resource(resource_type, source, destination, from_files_for_upload=False): if from_files_for_upload: - source_dir = get_file_for_upload(source) + source = get_file_for_upload(source) else: - source_dir = get_resource_path(source) - destination_dir = get_resource_path(destination) - if source_dir == destination_dir and destination_dir != '/': - destination_dir = add_copy_suffix(source, resource_type) + source = get_resource_path(source) + destination = get_resource_path(destination) + if source == destination and destination != '/': + destination = add_copy_suffix(source, resource_type) wait_for_client_to_be_ready() - listen_sync_status_for_item(destination_dir, resource_type) + listen_sync_status_for_item(destination, resource_type) if resource_type == 'folder': - return shutil.copytree(source_dir, destination_dir) - return shutil.copy2(source_dir, destination_dir) + return shutil.copytree(source, destination) + return shutil.copy2(source, destination) def move_resource(username, resource_type, source, destination, is_temp_folder=False): @@ -164,9 +165,14 @@ def step(context, _, filename, filesize): create_file_with_size(filename, filesize) -@When(r'the user copies the (file|folder) "([^"]*)" to "([^"]*)"', regexp=True) -def step(context, resource_type, file_name, destination): - copy_resource(resource_type, file_name, destination, False) +@When(r'the user copies (file|folder) "([^"]*)" into folder "([^"]*)"', regexp=True) +def step(context, resource_type, resource_name, destination_dir): + copy_resource(resource_type, resource_name, destination_dir, False) + + +@When(r'the user copies (file|folder) "([^"]*)" into the same folder', regexp=True) +def step(context, resource_type, resource_name): + copy_resource(resource_type, resource_name, resource_name, False) @When(r'the user renames a (?:file|folder) "([^"]*)" to "([^"]*)"', regexp=True) @@ -298,6 +304,16 @@ def step(context, file_number, file_size, folder_name): ) +@When( + r'user "([^"]*)" reads the content of file "([^"]*)"', + regexp=True, +) +def step(context, username, file): + file_path = get_resource_path(file, username) + with open(file_path, 'r') as f: + f.read() + + @When( r'user "([^"]*)" moves (folder|file) "([^"]*)" from the temp folder into the sync folder', regexp=True, @@ -307,6 +323,15 @@ def step(context, username, resource_type, resource_name): move_resource(username, resource_type, source_dir, '/', True) +@When( + r'user "([^"]*)" moves (folder|file) "([^"]*)" to the temp folder', + regexp=True, +) +def step(context, username, resource_type, resource_name): + destination= join(get_config('tempFolderPath'), resource_name) + move_resource(username, resource_type, resource_name, destination) + + @When( r'user "([^"]*)" moves (file|folder) "([^"]*)" to "([^"]*)" in the sync folder', regexp=True, @@ -405,3 +430,9 @@ def step(context): @Given('user "|any|" has created a file "|any|" with size "|any|" in the sync folder') def step(context, _, filename, filesize): create_file_with_size(filename, filesize) + + +@When(r'user "([^"]*)" marks file "([^"]*)" as (online-only|available-locally) from the file explorer', regexp=True) +def step(context, user, resource, action): + resource_path = get_resource_path(resource, user) + perform_file_explorer_action(resource_path, action) diff --git a/test/gui/tst_syncing/test.feature b/test/gui/tst_syncing/test.feature index aebe81a11..d79b8ef3f 100644 --- a/test/gui/tst_syncing/test.feature +++ b/test/gui/tst_syncing/test.feature @@ -243,12 +243,12 @@ Feature: Syncing files """ test content """ - And the user copies the folder "original" to "copied" - And the user waits for folder "copied" to be synced + And the user copies folder "original" into the same folder + And the user waits for folder "original (Copy)" to be synced Then as "Alice" folder "original" should exist in the server And as "Alice" the file "original/localFile.txt" should have the content "test content" in the server - And as "Alice" folder "copied" should exist in the server - And as "Alice" the file "copied/localFile.txt" should have the content "test content" in the server + And as "Alice" folder "original (Copy)" should exist in the server + And as "Alice" the file "original (Copy)/localFile.txt" should have the content "test content" in the server @issue-9281 Scenario: Verify that you can create a subfolder with long name(~220 characters) diff --git a/test/gui/tst_vfs/test.feature b/test/gui/tst_vfs/test.feature index 6961f8663..210880061 100644 --- a/test/gui/tst_vfs/test.feature +++ b/test/gui/tst_vfs/test.feature @@ -1,11 +1,24 @@ @skipOnLinux -Feature: Enable/disable virtual file support +Feature: VFS support As a user - I want to enable virtual file support - So that I can synchronize virtual files with local folder + I want to sync files with vfs + So that I can decide which files to download - Scenario: Copy and paste virtual file + Scenario: Default VFS sync + Given user "Alice" has been created in the server with default attributes + And user "Alice" has uploaded file with content "openCloud" to "testFile.txt" in the server + And user "Alice" has created folder "parent" in the server + And user "Alice" has uploaded file with content "some contents" to "parent/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 "parent/lorem.txt" should exist on the file system + When user "Alice" reads the content of file "parent/lorem.txt" + Then the file "parent/lorem.txt" should be downloaded + And the placeholder of file "testFile.txt" should exist on the file system + + + Scenario: Copy placeholder file Given user "Alice" has been created in the server with default attributes And user "Alice" has uploaded file with content "sample file" to "sampleFile.txt" in the server And user "Alice" has uploaded file with content "lorem file" to "lorem.txt" in the server @@ -16,22 +29,22 @@ Feature: Enable/disable virtual file support And the placeholder of file "sampleFile.txt" should exist on the file system And the placeholder of file "testFile.txt" should exist on the file system When user "Alice" copies file "sampleFile.txt" to temp folder - And the user copies the file "lorem.txt" to "Folder" - And the user copies the file "testFile.txt" to "testFile.txt" + And the user copies file "lorem.txt" into folder "Folder" + And the user copies file "testFile.txt" into the same folder And the user waits for file "Folder/lorem.txt" to be synced Then the file "sampleFile.txt" should be downloaded And the file "Folder/lorem.txt" should be downloaded And the file "lorem.txt" should be downloaded And the file "testFile.txt" should be downloaded - And the file "testFile - Copy.txt" should be downloaded + And the file "testFile (Copy).txt" should be downloaded And as "Alice" file "Folder/lorem.txt" should exist in the server And as "Alice" file "lorem.txt" should exist in the server And as "Alice" file "sampleFile.txt" should exist in the server And as "Alice" file "testFile.txt" should exist in the server - And as "Alice" file "testFile - Copy.txt" should exist in the server + And as "Alice" file "testFile (Copy).txt" should exist in the server - Scenario: Move virtual file + Scenario: Move placeholder file Given user "Alice" has been created in the server with default attributes And user "Alice" has uploaded file with content "lorem file" to "lorem.txt" in the server And user "Alice" has uploaded file with content "some contents" to "sampleFile.txt" in the server @@ -44,3 +57,18 @@ Feature: Enable/disable virtual file support And as "Alice" file "Folder/lorem.txt" should exist in the server And as "Alice" file "lorem.txt" should not exist in the server And as "Alice" file "sampleFile.txt" should not exist in the server + + + Scenario: File explorer actions + Given user "Alice" has been created in the server with default attributes + And user "Alice" has uploaded file with content "openCloud" to "testFile.txt" in the server + And user "Alice" has created folder "parent" in the server + And user "Alice" has uploaded file with content "some contents" to "parent/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 + When user "Alice" marks file "testFile.txt" as available-locally from the file explorer + And the user waits for file "testFile.txt" to be synced + Then the file "testFile.txt" should be downloaded + When user "Alice" marks file "testFile.txt" as online-only from the file explorer + And the user waits for file "testFile.txt" to be synced + Then the placeholder of file "testFile.txt" should exist on the file system