Skip to content

Commit

Permalink
[test-only][full-ci] Fix GUI tests (#11963)
Browse files Browse the repository at this point in the history
* fix personal space name

* test: fix sync path

* test: fix sync path

---------

Co-authored-by: Saw-jan <[email protected]>
  • Loading branch information
ishabaral and saw-jan authored Oct 28, 2024
1 parent 2ac7ce4 commit b056cf0
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 19 deletions.
5 changes: 4 additions & 1 deletion test/gui/shared/scripts/bdd_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def hook(context):
os.makedirs(tmp_dir)

# sync connection folder display name
set_config("syncConnectionName", "Personal" if get_config("ocis") else "ownCloud")
# For oCIS, it will be the user's display name
# and will be set while adding the account or creating resources
if not get_config("ocis"):
set_config("syncConnectionName", "ownCloud")


# determines if the test scenario failed or not
Expand Down
1 change: 1 addition & 0 deletions test/gui/shared/scripts/helpers/ConfigHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def get_default_home_dir():
'ocis': False,
'record_video_on_failure': False,
'files_for_upload': os.path.join(CURRENT_DIR.parent.parent, 'files-for-upload'),
'syncConnectionName': '',
}
CONFIG.update(DEFAULT_PATH_CONFIG)

Expand Down
34 changes: 23 additions & 11 deletions test/gui/shared/scripts/helpers/SetupClientHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,18 @@ def set_current_user_sync_path(sync_path):

def get_resource_path(resource='', user='', space=''):
sync_path = get_config('currentUserSyncPath')
if user:
sync_path = user
if get_config('ocis'):
space = space or get_config('syncConnectionName')
sync_path = join(sync_path, space)
if not sync_path.startswith(get_config('tempFolderPath')):
if user:
sync_path = user
else:
user = parse_username_from_sync_path(sync_path)
if get_config('ocis'):
space = (
space
or get_config('syncConnectionName')
or get_displayname_for_user(user)
)
sync_path = join(sync_path, space)
sync_path = join(get_config('clientRootSyncPath'), sync_path)
resource = resource.replace(sync_path, '').strip('/').strip('\\')
if is_windows():
Expand All @@ -89,6 +96,10 @@ def get_resource_path(resource='', user='', space=''):
)


def parse_username_from_sync_path(sync_path):
return sync_path.split('/').pop()


def get_temp_resource_path(resource_name):
return join(get_config('tempFolderPath'), resource_name)

Expand Down Expand Up @@ -155,12 +166,10 @@ def generate_account_config(users, space='Personal'):
server_url = get_config('localBackendUrl')

if is_ocis := get_config('ocis'):
set_config('syncConnectionName', space)
sync_path = create_space_path(space)
space_name = space
if space == 'Personal':
space_name = get_displayname_for_user(username)
dav_endpoint = url_join('dav/spaces', get_space_id(space_name, username))
space = get_displayname_for_user(username)
sync_path = create_space_path(space)
dav_endpoint = url_join('dav/spaces', get_space_id(space, username))

args = {
'url': url_join(server_url, dav_endpoint, ''),
Expand Down Expand Up @@ -188,7 +197,10 @@ def generate_account_config(users, space='Personal'):
return sync_paths


def setup_client(username, space='Personal'):
def setup_client(username, space=None):
if not space or space == 'Personal':
space = get_displayname_for_user(username)
set_config('syncConnectionName', space)
sync_paths = generate_account_config([username], space)
start_client()
for _, sync_path in sync_paths.items():
Expand Down
8 changes: 7 additions & 1 deletion test/gui/shared/steps/account_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
wait_for_initial_sync_to_complete,
listen_sync_status_for_item,
)
from helpers.ConfigHelper import get_config, is_windows, is_linux
from helpers.ConfigHelper import get_config, set_config, is_windows, is_linux


@When('the user adds the following user credentials:')
def step(context):
account_details = get_client_details(context)
set_config('syncConnectionName', get_displayname_for_user(account_details['user']))
AccountConnectionWizard.add_user_credentials(
account_details['user'], account_details['password']
)
Expand Down Expand Up @@ -105,6 +106,7 @@ def step(context):
@When('the user adds the following account:')
def step(context):
account_details = get_client_details(context)
set_config('syncConnectionName', get_displayname_for_user(account_details['user']))
AccountConnectionWizard.add_account(account_details)
# wait for files to sync
wait_for_initial_sync_to_complete(get_resource_path('/', account_details['user']))
Expand All @@ -113,6 +115,10 @@ def step(context):
@Given('the user has entered the following account information:')
def step(context):
account_details = get_client_details(context)
if account_details['user']:
set_config(
'syncConnectionName', get_displayname_for_user(account_details['user'])
)
AccountConnectionWizard.add_account_information(account_details)


Expand Down
3 changes: 2 additions & 1 deletion test/gui/shared/steps/spaces_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
get_file_content,
resource_exists,
)
from helpers.ConfigHelper import get_config
from helpers.ConfigHelper import get_config, set_config


@Given('the administrator has created a space "|any|"')
Expand Down Expand Up @@ -43,6 +43,7 @@ def step(context, user, space_name):
enter_password = EnterPassword()
if get_config('ocis'):
enter_password.accept_certificate()
set_config('syncConnectionName', space_name)
enter_password.login_after_setup(user, password)
# wait for files to sync
wait_for_initial_sync_to_complete(get_resource_path('/', user, space_name))
Expand Down
2 changes: 1 addition & 1 deletion test/gui/tst_addAccount/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Feature: adding accounts
| user | Alice |
| password | 1234 |
When the user selects manual sync folder option in advanced section
And the user syncs the "Personal" space
And the user syncs the "Alice Hansen" space
Then the folder "simple-folder" should exist on the file system

@skipOnOCIS
Expand Down
8 changes: 4 additions & 4 deletions test/gui/tst_syncing/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Feature: Syncing files
| user | Alice |
| password | 1234 |
When the user selects manual sync folder option in advanced section
And the user selects "Personal" space in sync connection wizard
And the user selects "Alice Hansen" space in sync connection wizard
And the user sets the sync path in sync connection wizard
And the user navigates back in the sync connection wizard
And the user sets the temp folder "localSyncFolder" as local sync path in sync connection wizard
Expand Down Expand Up @@ -97,7 +97,7 @@ Feature: Syncing files
| user | Alice |
| password | 1234 |
When the user selects manual sync folder option in advanced section
And the user selects "Personal" space in sync connection wizard
And the user selects "Alice Hansen" space in sync connection wizard
And the user sets the sync path in sync connection wizard
And the user selects "ownCloud" as a remote destination folder
And the user disables VFS support for Windows
Expand Down Expand Up @@ -133,7 +133,7 @@ Feature: Syncing files
| user | Alice |
| password | 1234 |
When the user selects manual sync folder option in advanced section
And the user selects "Personal" space in sync connection wizard
And the user selects "Alice Hansen" space in sync connection wizard
And the user sets the sync path in sync connection wizard
And the user selects "ownCloud" as a remote destination folder
And the user disables VFS support for Windows
Expand Down Expand Up @@ -471,7 +471,7 @@ Feature: Syncing files
| user | Alice |
| password | 1234 |
When the user selects manual sync folder option in advanced section
And the user selects "Personal" space in sync connection wizard
And the user selects "Alice Hansen" space in sync connection wizard
And the user sets the temp folder "~`!@#$^&()-_=+{[}];',)PRN%" as local sync path in sync connection wizard
And the user selects "ownCloud" as a remote destination folder
And the user disables VFS support for Windows
Expand Down

0 comments on commit b056cf0

Please sign in to comment.