Skip to content

Commit

Permalink
[test-only][full-ci] Adjust GUI tests as per the new changes in login…
Browse files Browse the repository at this point in the history
… wizard (#11906)

* adjust GUI tests as per the new changes in login wizard

* test: fix selectors

---------

Co-authored-by: Saw-jan <[email protected]>
  • Loading branch information
ishabaral and saw-jan authored Sep 27, 2024
1 parent 4ca07fd commit 0d7fd2c
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 78 deletions.
5 changes: 2 additions & 3 deletions test/gui/shared/scripts/helpers/SetupClientHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,18 @@ def unlock_keyring():
output = stdout.decode('utf-8')
if stderr:
output = stderr.decode('utf-8')
test.log(output)

if not output.strip().endswith('false'):
test.log('Unlocking keyring...')
password = os.getenv('VNC_PW')
command = f'echo -n "{password}" | gnome-keyring-daemon -r --unlock'
command = f'echo -n "{password}" | gnome-keyring-daemon -r -d --unlock'
stdout, stderr, returncode = run_sys_command(command, True)
if stdout:
output = stdout.decode('utf-8')
if stderr:
output = stderr.decode('utf-8')
if returncode:
test.log(f'Failed to unlock keyring:\n{output}')
test.log(output)


def run_sys_command(command=None, shell=False):
Expand Down
7 changes: 6 additions & 1 deletion test/gui/shared/scripts/names.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# encoding: UTF-8
# fmt: off

from objectmaphelper import *

settings_OCC_SettingsDialog = {"name": "Settings", "type": "OCC::SettingsDialog", "visible": 1}
owncloudWizard_OCC_OwncloudWizard = {"name": "owncloudWizard", "type": "OCC::OwncloudWizard", "visible": 1}
qFileDialog_QFileDialog = {"name": "QFileDialog", "type": "QFileDialog", "visible": 1}
settings_stack_QStackedWidget = {"name": "stack", "type": "QStackedWidget", "visible": 1, "window": settings_OCC_SettingsDialog}
settings_dialogStack_QStackedWidget = {"name": "dialogStack", "type": "QStackedWidget", "visible": 1, "window": settings_OCC_SettingsDialog}
qFileDialog_fileNameLabel_QLabel = {"name": "fileNameLabel", "type": "QLabel", "visible": 1, "window": qFileDialog_QFileDialog}
sharingDialog_OCC_ShareDialog = {"name": "SharingDialog", "type": "OCC::ShareDialog", "visible": 1}
sharingDialog_qt_tabwidget_stackedwidget_QStackedWidget = {"name": "qt_tabwidget_stackedwidget", "type": "QStackedWidget", "visible": 1, "window": sharingDialog_OCC_ShareDialog}
Expand Down Expand Up @@ -48,7 +50,6 @@
stackedWidget_quickWidget_QQuickWidget = {"container": stack_stackedWidget_QStackedWidget, "name": "quickWidget", "type": "QQuickWidget", "visible": 1}
quickWidget_scrollView_ScrollView = {"container": stackedWidget_quickWidget_QQuickWidget, "id": "scrollView", "type": "ScrollView", "unnamed": 1, "visible": True}
scrollView_ListView = {"container": quickWidget_scrollView_ScrollView, "type": "ListView", "unnamed": 1, "visible": True}
settings_dialogStack_QStackedWidget = {"name": "dialogStack", "type": "QStackedWidget", "visible": 1, "window": settings_OCC_SettingsDialog}
dialogStack_quickWidget_QQuickWidget = {"container": settings_dialogStack_QStackedWidget, "name": "quickWidget", "type": "QQuickWidget", "visible": 1}
create_Remote_Folder_QInputDialog = {"type": "QInputDialog", "unnamed": 1, "visible": 1, "windowTitle": "Create Remote Folder"}
create_Remote_Folder_Enter_the_name_of_the_new_folder_to_be_created_below_QLabel = {"text": "Enter the name of the new folder to be created below '/':", "type": "QLabel", "unnamed": 1, "visible": 1, "window": create_Remote_Folder_QInputDialog}
Expand All @@ -59,3 +60,7 @@
oCC_ProtocolWidget_tableView_QTableView = {"container": qt_tabwidget_stackedwidget_OCC_ProtocolWidget_OCC_ProtocolWidget, "name": "_tableView", "type": "QTableView", "visible": 1}
oCC_IssuesWidget_tableView_QTableView = {"container": qt_tabwidget_stackedwidget_OCC_IssuesWidget_OCC_IssuesWidget, "name": "_tableView", "type": "QTableView", "visible": 1}
dialogStack_quickWidget_OCC_QmlUtils_OCQuickWidget = {"container": settings_dialogStack_QStackedWidget, "name": "quickWidget", "type": "OCC::QmlUtils::OCQuickWidget", "visible": 1}
contentWidget_OCC_QmlUtils_OCQuickWidget = {"container": contentWidget_contentWidget_QStackedWidget, "type": "OCC::QmlUtils::OCQuickWidget", "unnamed": 1, "visible": 1}
stackedWidget_Add_Folder_Sync_Connection_QGroupBox = {"container": stack_stackedWidget_QStackedWidget, "title": "Add Folder Sync Connection", "type": "QGroupBox", "unnamed": 1, "visible": 1}
stackedWidget_groupBox_QGroupBox = {"container": settings_stack_QStackedWidget, "name": "groupBox", "type": "QGroupBox", "visible": 1}
groupBox_OCC_QmlUtils_OCQuickWidget = {"container": stackedWidget_groupBox_QGroupBox, "type": "OCC::QmlUtils::OCQuickWidget", "unnamed": 1, "visible": 1}
54 changes: 23 additions & 31 deletions test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class AccountConnectionWizard:
"visible": 1,
}
NEXT_BUTTON = {
"container": names.settings_dialogStack_QStackedWidget,
"name": "nextButton",
"type": "QPushButton",
"visible": 1,
"window": names.setupWizardWindow_OCC_Wizard_SetupWizardWindow,
}
CONFIRM_INSECURE_CONNECTION_BUTTON = {
"text": "Confirm",
Expand All @@ -35,16 +35,16 @@ class AccountConnectionWizard:
"window": names.insecure_connection_QMessageBox,
}
USERNAME_BOX = {
"container": names.setupWizardWindow_contentWidget_QStackedWidget,
"name": "usernameLineEdit",
"type": "QLineEdit",
"visible": 1,
"container": names.contentWidget_OCC_QmlUtils_OCQuickWidget,
"id": "userNameField",
"type": "TextField",
"visible": True,
}
PASSWORD_BOX = {
"container": names.setupWizardWindow_contentWidget_QStackedWidget,
"name": "passwordLineEdit",
"type": "QLineEdit",
"visible": 1,
"container": names.contentWidget_OCC_QmlUtils_OCQuickWidget,
"id": "passwordField",
"type": "TextField",
"visible": True,
}
SELECT_LOCAL_FOLDER = {
"container": names.advancedConfigGroupBox_localDirectoryGroupBox_QGroupBox,
Expand Down Expand Up @@ -72,22 +72,20 @@ class AccountConnectionWizard:
"window": names.setupWizardWindow_OCC_Wizard_SetupWizardWindow,
}
BASIC_CREDENTIAL_PAGE = {
"container": names.setupWizardWindow_contentWidget_QStackedWidget,
"name": "CredentialsSetupWizardPage",
"container": names.contentWidget_contentWidget_QStackedWidget,
"type": "OCC::Wizard::BasicCredentialsSetupWizardPage",
"visible": 1,
}
OAUTH_CREDENTIAL_PAGE = {
"container": names.setupWizardWindow_contentWidget_QStackedWidget,
"name": "CredentialsSetupWizardPage",
"container": names.contentWidget_contentWidget_QStackedWidget,
"type": "OCC::Wizard::OAuthCredentialsSetupWizardPage",
"visible": 1,
}
COPY_URL_TO_CLIPBOARD_BUTTON = {
"container": names.contentWidget_contentWidget_QStackedWidget,
"name": "copyUrlToClipboardButton",
"type": "QPushButton",
"visible": 1,
"container": names.contentWidget_OCC_QmlUtils_OCQuickWidget,
"id": "copyToClipboardButton",
"type": "Button",
"visible": True,
}
CONF_SYNC_MANUALLY_RADIO_BUTTON = {
"container": names.advancedConfigGroupBox_syncModeGroupBox_QGroupBox,
Expand Down Expand Up @@ -160,18 +158,10 @@ def addUserCreds(username, password, oauth=False):

@staticmethod
def basicLogin(username, password):
squish.type(
squish.waitForObject(AccountConnectionWizard.USERNAME_BOX),
username,
)
squish.type(
squish.waitForObject(AccountConnectionWizard.USERNAME_BOX),
"<Tab>",
)
squish.type(
squish.waitForObject(AccountConnectionWizard.PASSWORD_BOX),
password,
)
squish.mouseClick(squish.waitForObject(AccountConnectionWizard.USERNAME_BOX))
squish.nativeType(username)
squish.mouseClick(squish.waitForObject(AccountConnectionWizard.PASSWORD_BOX))
squish.nativeType(password)
AccountConnectionWizard.nextStep()

@staticmethod
Expand All @@ -186,14 +176,16 @@ def oauthLogin(username, password):
def browserLogin(username, password, login_type=None):
# wait 500ms for copy button to fully load
squish.snooze(1 / 2)
squish.clickButton(
squish.mouseClick(
squish.waitForObject(AccountConnectionWizard.COPY_URL_TO_CLIPBOARD_BUTTON)
)
authorize_via_webui(username, password, login_type)

@staticmethod
def nextStep():
squish.clickButton(squish.waitForObject(AccountConnectionWizard.NEXT_BUTTON))
squish.clickButton(
squish.waitForObjectExists(AccountConnectionWizard.NEXT_BUTTON)
)

@staticmethod
def selectSyncFolder(user):
Expand Down
10 changes: 5 additions & 5 deletions test/gui/shared/scripts/pageObjects/AccountSetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class AccountSetting:
MANAGE_ACCOUNT_BUTTON = {
"container": names.settings_stack_QStackedWidget,
"container": names.settings_dialogStack_QStackedWidget,
"name": "manageAccountButton",
"type": "QToolButton",
"visible": 1,
Expand All @@ -15,15 +15,15 @@ class AccountSetting:
"visible": 1,
"window": names.settings_OCC_SettingsDialog,
}
REMOVE_CONNECTION_BUTTON = {
"container": names.settings_stack_QStackedWidget,
CONFIRM_REMOVE_CONNECTION_BUTTON = {
"container": names.settings_dialogStack_QStackedWidget,
"text": "Remove connection",
"type": "QPushButton",
"unnamed": 1,
"visible": 1,
}
ACCOUNT_CONNECTION_LABEL = {
"container": names.settings_stack_QStackedWidget,
"container": names.settings_dialogStack_QStackedWidget,
"name": "connectionStatusLabel",
"type": "QLabel",
"visible": 1,
Expand Down Expand Up @@ -58,7 +58,7 @@ def accountAction(action):
def removeAccountConnection():
AccountSetting.accountAction("Remove")
squish.clickButton(
squish.waitForObject(AccountSetting.REMOVE_CONNECTION_BUTTON)
squish.waitForObject(AccountSetting.CONFIRM_REMOVE_CONNECTION_BUTTON)
)

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions test/gui/shared/scripts/pageObjects/Activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

class Activity:
TAB_CONTAINER = {
"container": names.settings_stack_QStackedWidget,
"container": names.settings_dialogStack_QStackedWidget,
"type": "QTabWidget",
"visible": 1,
}
SUBTAB_CONTAINER = {
"container": names.settings_stack_QStackedWidget,
"container": names.settings_dialogStack_QStackedWidget,
"name": "qt_tabwidget_tabbar",
"type": "QTabBar",
"visible": 1,
Expand Down
63 changes: 31 additions & 32 deletions test/gui/shared/scripts/pageObjects/EnterPassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class EnterPassword:
"visible": 1,
}
LOGIN_USER_LABEL = {
"name": "topLabel",
"type": "QLabel",
"visible": 1,
"window": LOGIN_CONTAINER,
"container": names.groupBox_OCC_QmlUtils_OCQuickWidget,
"type": "Label",
"visible": True,
}
USERNAME_BOX = {
"name": "usernameLineEdit",
Expand All @@ -25,28 +24,28 @@ class EnterPassword:
"window": LOGIN_CONTAINER,
}
PASSWORD_BOX = {
"name": "passwordLineEdit",
"type": "QLineEdit",
"visible": 1,
"window": LOGIN_CONTAINER,
"container": names.groupBox_OCC_QmlUtils_OCQuickWidget,
"id": "passwordField",
"type": "TextField",
"visible": True,
}
LOGIN_BUTTON = {
"text": "Log in",
"type": "QPushButton",
"visible": 1,
"window": names.stack_stackedWidget_QStackedWidget,
"container": names.groupBox_OCC_QmlUtils_OCQuickWidget,
"id": "loginButton",
"type": "Button",
"visible": True,
}
LOGOUT_BUTTON = {
"text": "Log out",
"type": "QPushButton",
"visible": 1,
"window": names.stack_stackedWidget_QStackedWidget,
"container": names.groupBox_OCC_QmlUtils_OCQuickWidget,
"id": "logOutButton",
"type": "Button",
"visible": True,
}
COPY_URL_TO_CLIPBOARD_BUTTON = {
"name": "copyUrlToClipboardButton",
"type": "QPushButton",
"visible": 1,
"window": LOGIN_CONTAINER,
"container": names.groupBox_OCC_QmlUtils_OCQuickWidget,
"id": "copyToClipboardButton",
"type": "Button",
"visible": True,
}
TLS_CERT_WINDOW = {
"name": "OCC__TlsErrorDialog",
Expand All @@ -65,29 +64,29 @@ def __init__(self, occurrence=1):
self.TLS_CERT_WINDOW.update({"occurrence": occurrence})

def get_username(self):
# Parse username from following label:
# Please enter your password to log in to the account Alice Hansen@localhost.
# The account Alice Hansen@localhost:9200 is currently logged out.
# Parse username from the login label:
label = str(squish.waitForObjectExists(self.LOGIN_USER_LABEL).text)
label = label.split("@", maxsplit=1)[0].split(" ")
label.reverse()
return label[1].capitalize()
username = label.split(" ", maxsplit=2)[1]
return username.capitalize()

def enterPassword(self, password):
squish.waitForObject(self.PASSWORD_BOX, get_config("maxSyncTimeout") * 1000)
squish.type(squish.waitForObject(self.PASSWORD_BOX), password)
squish.clickButton(squish.waitForObject(self.LOGIN_BUTTON))
squish.waitForObjectExists(
self.PASSWORD_BOX, get_config("maxSyncTimeout") * 1000
)
squish.mouseClick(squish.waitForObjectExists(self.PASSWORD_BOX))
squish.nativeType(password)
squish.mouseClick(squish.waitForObjectExists(self.LOGIN_BUTTON))

def oidcReLogin(self, username, password):
# wait 500ms for copy button to fully load
squish.snooze(1 / 2)
squish.clickButton(squish.waitForObject(self.COPY_URL_TO_CLIPBOARD_BUTTON))
squish.mouseClick(squish.waitForObject(self.COPY_URL_TO_CLIPBOARD_BUTTON))
authorize_via_webui(username, password)

def oauthReLogin(self, username, password):
# wait 500ms for copy button to fully load
squish.snooze(1 / 2)
squish.clickButton(squish.waitForObject(self.COPY_URL_TO_CLIPBOARD_BUTTON))
squish.mouseClick(squish.waitForObject(self.COPY_URL_TO_CLIPBOARD_BUTTON))
authorize_via_webui(username, password, "oauth")

def reLogin(self, username, password, oauth=False):
Expand All @@ -105,7 +104,7 @@ def loginAfterSetup(self, username, password):
self.enterPassword(password)

def logout(self):
squish.clickButton(squish.waitForObject(self.LOGOUT_BUTTON))
squish.mouseClick(squish.waitForObject(self.LOGOUT_BUTTON))

def accept_certificate(self):
squish.clickButton(squish.waitForObject(self.ACCEPT_CERTIFICATE_YES))
12 changes: 10 additions & 2 deletions test/gui/shared/scripts/pageObjects/Toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ def quit_owncloud():
def get_accounts():
accounts = {}
selectors = {}
children_obj = object.children(squish.waitForObject(Toolbar.TOOLBAR_ROW))
children_obj = object.children(squish.waitForObjectExists(Toolbar.TOOLBAR_ROW))
account_idx = 1
for obj in children_obj:
if hasattr(obj, "accountState"):
account_info = {
"displayname": str(obj.accountState.account.davDisplayName),
"username": str(obj.accountState.account.davUser),
"hostname": str(obj.accountState.account.hostname),
"hostname": str(obj.accountState.account.hostName),
"initials": str(obj.accountState.account.initials),
"current": obj.checked,
}
Expand All @@ -139,6 +139,14 @@ def get_account(display_name):
accounts, selectors = Toolbar.get_accounts()
return accounts.get(display_name), selectors.get(display_name)

@staticmethod
def get_active_account():
accounts, selectors = Toolbar.get_accounts()
for account, info in accounts.items():
if info["current"]:
return info, selectors[account]
return None, None

@staticmethod
def account_has_focus(display_name):
account, selector = Toolbar.get_account(display_name)
Expand Down
4 changes: 2 additions & 2 deletions test/gui/tst_addAccount/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Feature: adding accounts
Then the folder "simple-folder" should exist on the file system

@skipOnOCIS
Scenario: Check for incremented number in bracket while adding new account and folder (OC10)
Scenario: Check for suffix when sync path exists (OC10)
Given the user has created folder "ownCloud" in the default home path
And the user has started the client
And the user has entered the following account information:
Expand All @@ -95,7 +95,7 @@ Feature: adding accounts
Then the default local sync path should contain "%home%/ownCloud (2) (2)" in the sync connection wizard

@skipOnOC10
Scenario: Button to open sync connection wizard should be disabled when all available spaces are synced (oCIS)
Scenario: Check for suffix when sync path exists (oCIS)
Given the user has created folder "ownCloud" in the default home path
And the user has started the client
And the user has entered the following account information:
Expand Down

0 comments on commit 0d7fd2c

Please sign in to comment.