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
11 changes: 2 additions & 9 deletions test/gui/environment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import psutil
import shutil
import os

Expand All @@ -7,7 +6,7 @@
from helpers.SpaceHelper import delete_project_spaces
from helpers.ConfigHelper import set_config, get_config
from helpers.FilesHelper import prefix_path_namespace, cleanup_created_paths
from helpers.SetupClientHelper import app
from helpers.SetupClientHelper import close_and_kill_app
from step_types.types import * # register all step types


Expand Down Expand Up @@ -37,10 +36,4 @@ def after_scenario(context, scenario):
delete_project_spaces()
delete_created_users()
# quit the application
if app() is not None:
app().quit()
for process in psutil.process_iter(['pid', 'exe']):
if process.info['exe'] == get_config("app_path"):
print("Closing desktop client...")
psutil.Process(process.info['pid']).kill()
break
close_and_kill_app()
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Feature: Logout users
Background:
Given user "Alice" has been created in the server with default attributes

@smoke @skip
@smoke
Scenario: logging out
Given user "Alice" has set up a client with default settings
When the user "Alice" logs out using the client-UI
Then user "Alice" should be signed out

@smoke @skip
@smoke
Scenario: login after logging out
Given user "Alice" has set up a client with default settings
And user "Alice" has logged out from the client-UI
Expand Down
22 changes: 22 additions & 0 deletions test/gui/helpers/SetupClientHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,25 @@ def run_sys_command(command=None, shell=False):
check=False,
)
return cmd.stdout, cmd.stderr, cmd.returncode


def close_and_kill_app():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to think of grouping AUT related functions in a separate file. But we can do it in the coming refactor process.

"""
Close Appium session and kill the desktop client process.
Use this for both mid-scenario and end-of-scenario cleanup.
"""
global app_driver
# Quit Appium session
if app_driver is not None:
app_driver.quit()

# Kill remaining process by exe path
app_path = get_config("app_path")
for process in psutil.process_iter(['pid', 'exe']):
if process.info['exe'] == app_path:
print("Closing desktop client...")
psutil.Process(process.info['pid']).kill()
break

# Reset driver for reuse
app_driver = None
16 changes: 9 additions & 7 deletions test/gui/helpers/SyncHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import re
import time
import urllib.request
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException

from helpers.ConfigHelper import get_config, is_linux, is_windows
from helpers.FilesHelper import sanitize_path
Expand Down Expand Up @@ -357,10 +359,10 @@ def make_available_locally(resource_path):


def wait_for(condition, timeout, interval=0.5):
start = time.time() * 1000
while True:
if condition():
return True
if time.time() * 1000 - start > timeout:
return False
time.sleep(interval)
from helpers.SetupClientHelper import app
wait = WebDriverWait(app(), timeout / 1000, poll_frequency=interval)
try:
wait.until(lambda _: condition())
return True
except TimeoutException:
return False
15 changes: 10 additions & 5 deletions test/gui/pageObjects/AccountSetting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from types import SimpleNamespace
from appium.webdriver.common.appiumby import AppiumBy as By
from helpers.UserHelper import get_displayname_for_user
from helpers.SetupClientHelper import substitute_inline_codes, app

from pageObjects.Toolbar import Toolbar
from helpers.UserHelper import get_displayname_for_user
Expand All @@ -16,7 +18,10 @@ class AccountSetting:
CONFIRM_REMOVE_CONNECTION_BUTTON = SimpleNamespace(
by=By.NAME, selector="Remove connection"
)
ACCOUNT_CONNECTION_LABEL = SimpleNamespace(by=None, selector=None)
ACCOUNT_CONNECTION_LABEL = SimpleNamespace(
by=By.XPATH,
selector="//list[@name='Folder Sync']//label",
)
LOG_BROWSER_WINDOW = SimpleNamespace(by=None, selector=None)
ACCOUNT_LOADING = SimpleNamespace(by=None, selector=None)
DIALOG_STACK = SimpleNamespace(by=None, selector=None)
Expand Down Expand Up @@ -61,9 +66,8 @@ def login():

@staticmethod
def get_account_connection_label():
return str(
squish.waitForObjectExists(AccountSetting.ACCOUNT_CONNECTION_LABEL).text
)
label = app().find_element(AccountSetting.ACCOUNT_CONNECTION_LABEL.by, AccountSetting.ACCOUNT_CONNECTION_LABEL.selector).text
return label

@staticmethod
def is_connecting():
Expand Down Expand Up @@ -93,7 +97,7 @@ def wait_until_connection_is_configured(timeout=5000):

@staticmethod
def wait_until_account_is_connected(timeout=5000):
result = squish.waitFor(
result = wait_for(
AccountSetting.is_user_signed_in,
timeout,
)
Expand All @@ -106,6 +110,7 @@ def wait_until_account_is_connected(timeout=5000):
)
return result


@staticmethod
def wait_until_sync_folder_is_configured(timeout=5000):
result = squish.waitFor(
Expand Down
29 changes: 19 additions & 10 deletions test/gui/pageObjects/Toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from appium.webdriver.common.appiumby import AppiumBy as By
from selenium.webdriver.common.keys import Keys

from helpers.SetupClientHelper import wait_until_app_killed
from helpers.SetupClientHelper import app, close_and_kill_app
from helpers.ConfigHelper import get_config
from helpers.SetupClientHelper import app
from helpers.UserHelper import get_displayname_for_user


Expand All @@ -15,8 +14,14 @@ class Toolbar:
ADD_ACCOUNT_BUTTON = SimpleNamespace(by=By.NAME, selector="Add Account")
ACTIVITY_BUTTON = SimpleNamespace(by=By.NAME, selector="Activity")
SETTINGS_BUTTON = SimpleNamespace(by=None, selector=None)
QUIT_BUTTON = SimpleNamespace(by=None, selector=None)
CONFIRM_QUIT_BUTTON = SimpleNamespace(by=None, selector=None)
QUIT_BUTTON = SimpleNamespace(
by=By.NAME,
selector="Quit"
)
CONFIRM_QUIT_BUTTON = SimpleNamespace(
by=By.ACCESSIBILITY_ID,
selector="QApplication.QMessageBox.qt_msgbox_buttonbox.QPushButton"
)

TOOLBAR_ITEMS = ["Add Account", "Activity", "Settings", "Quit"]

Expand Down Expand Up @@ -75,12 +80,16 @@ def open_settings_tab():

@staticmethod
def quit_opencloud():
squish.mouseClick(squish.waitForObject(Toolbar.QUIT_BUTTON))
squish.clickButton(squish.waitForObject(Toolbar.CONFIRM_QUIT_BUTTON))
for ctx in squish.applicationContextList():
pid = ctx.pid
ctx.detach()
wait_until_app_killed(pid)
app().find_element(
Toolbar.QUIT_BUTTON.by,
Toolbar.QUIT_BUTTON.selector
).click()
app().find_element(
Toolbar.CONFIRM_QUIT_BUTTON.by,
Toolbar.CONFIRM_QUIT_BUTTON.selector
).click()
close_and_kill_app()


@staticmethod
def get_accounts():
Expand Down
30 changes: 15 additions & 15 deletions test/gui/steps/account_context.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import shutil
import os
from behave import given as Given, when as When, then as Then
from sure import expect
from sure import expect, ensure

from pageObjects.AccountConnectionWizard import AccountConnectionWizard
from pageObjects.SyncConnectionWizard import SyncConnectionWizard
from pageObjects.AccountSetting import AccountSetting
from pageObjects.Toolbar import Toolbar
from pageObjects.EnterPassword import EnterPassword
from pageObjects.AccountSetting import AccountSetting
from helpers.SetupClientHelper import (
start_client,
setup_client,
substitute_inline_codes,
get_client_details,
generate_account_config,
get_resource_path,
app,
)
from helpers.SyncHelper import (
wait_for_initial_sync_to_complete,
Expand Down Expand Up @@ -113,28 +115,27 @@ def step(context):
AccountConnectionWizard.add_account_information(account_details)


@When('the user "|any|" logs out using the client-UI')
def step(context, _):
@When('the user "{username}" logs out using the client-UI')
def step(context, username):
AccountSetting.logout()


@Then('user "|any|" should be signed out')
@Then('user "{username}" should be signed out')
def step(context, username):
test.compare(
AccountSetting.is_user_signed_out(),
True,
f'User "{username}" is signed out',
)
user_signed_out = AccountSetting.is_user_signed_out()

with ensure('User "{0}" should be signed out, but is still signed in', username):
user_signed_out.should.be.true


@Given('user "|any|" has logged out from the client-UI')
@Given('user "{username}" has logged out from the client-UI')
def step(context, username):
AccountSetting.logout()
if not AccountSetting.is_user_signed_out():
raise LookupError(f'Failed to logout user {username}')


@When('user "|any|" logs in using the client-UI')
@When('user "{username}" logs in using the client-UI')
def step(context, username):
AccountSetting.login()
password = get_password_for_user(username)
Expand All @@ -150,10 +151,9 @@ def step(context, _):
AccountSetting.login()


@Then('user "|any|" should be connected to the server')
def step(context, _):
@Then('user "{username}" should be connected to the server')
def step(context, username):
AccountSetting.wait_until_account_is_connected()
AccountSetting.wait_until_sync_folder_is_configured()


@When('the user removes the connection for user "{username}"')
Expand Down Expand Up @@ -233,7 +233,7 @@ def step(context):
test.compare(True, AccountSetting.is_log_dialog_visible(), 'Log dialog is opened')


@Step('the user cancels the sync connection wizard')
@When('the user cancels the sync connection wizard')
def step(context):
SyncConnectionWizard.cancel_folder_sync_connection_wizard()

Expand Down
8 changes: 0 additions & 8 deletions test/gui/tst_loginLogout/test.py

This file was deleted.

Loading