Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only] remove connection #8682

Merged
merged 1 commit into from
Jun 7, 2021
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
2 changes: 0 additions & 2 deletions test/gui/shared/scripts/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from objectmaphelper import *

settings_OCC_SettingsDialog = {"name": "Settings", "type": "OCC::SettingsDialog", "visible": 1}
settings_settingsdialog_toolbutton_Add_account_QToolButton = {"name": "settingsdialog_toolbutton_Add account", "type": "QToolButton", "visible": 1, "window": settings_OCC_SettingsDialog}
owncloudWizard_OCC_OwncloudWizard = {"name": "owncloudWizard", "type": "OCC::OwncloudWizard", "visible": 1}
owncloudWizard_label_2_QLabel = {"name": "label_2", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard}
leUrl_OCC_PostfixLineEdit = {"buddy": owncloudWizard_label_2_QLabel, "name": "leUrl", "type": "OCC::PostfixLineEdit", "visible": 1}
Expand All @@ -24,7 +23,6 @@
settings_stack_QStackedWidget = {"name": "stack", "type": "QStackedWidget", "visible": 1, "window": settings_OCC_SettingsDialog}
stack_accountToolbox_QToolButton = {"container": settings_stack_QStackedWidget, "name": "_accountToolbox", "type": "QToolButton", "visible": 1}
settings_QMenu = {"type": "QMenu", "unnamed": 1, "visible": 1, "window": settings_OCC_SettingsDialog}
stack_Remove_connection_QPushButton = {"container": settings_stack_QStackedWidget, "text": "Remove connection", "type": "QPushButton", "unnamed": 1, "visible": 1}
owncloudWizard_usernameLabel_QLabel = {"name": "usernameLabel", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard}
owncloudWizard_passwordLabel_QLabel = {"name": "passwordLabel", "type": "QLabel", "visible": 1, "window": owncloudWizard_OCC_OwncloudWizard}
qFileDialog_fileNameLabel_QLabel = {"name": "fileNameLabel", "type": "QLabel", "visible": 1, "window": qFileDialog_QFileDialog}
Expand Down
48 changes: 48 additions & 0 deletions test/gui/shared/scripts/pageObjects/AccountStatus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import names
import squish


class AccountStatus:
ACCOUNT_BUTTON = {
"container": names.settings_stack_QStackedWidget,
"name": "_accountToolbox",
"type": "QToolButton",
"visible": 1,
}
ACCOUNT_MENU = {
"type": "QMenu",
"unnamed": 1,
"visible": 1,
"window": names.settings_OCC_SettingsDialog,
}
SIGNED_OUT_TEXT_BAR = {
"container": names.settings_stack_QStackedWidget,
"name": "connectLabel",
"type": "QLabel",
"visible": 1,
}

REMOVE_CONNECTION_BUTTON = {
"container": names.settings_stack_QStackedWidget,
"text": "Remove connection",
"type": "QPushButton",
"unnamed": 1,
"visible": 1,
}

def accountAction(self, action):
squish.sendEvent(
"QMouseEvent",
squish.waitForObject(self.ACCOUNT_BUTTON),
squish.QEvent.MouseButtonPress,
0,
0,
squish.Qt.LeftButton,
0,
0,
)
squish.activateItem(squish.waitForObjectItem(self.ACCOUNT_MENU, action))

def removeConnection(self):
self.accountAction("Remove")
squish.clickButton(squish.waitForObject(self.REMOVE_CONNECTION_BUTTON))
50 changes: 13 additions & 37 deletions test/gui/shared/scripts/pageObjects/Toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,26 @@ class Toolbar:
"visible": 1,
"window": names.settings_OCC_SettingsDialog,
}
ACCOUNT_BUTTON = {
"container": names.settings_stack_QStackedWidget,
"name": "_accountToolbox",
ADD_ACCOUNT_BUTTON = {
"name": "settingsdialog_toolbutton_Add account",
"type": "QToolButton",
"visible": 1,
}
ACCOUNT_MENU = {
"type": "QMenu",
"unnamed": 1,
"visible": 1,
"window": names.settings_OCC_SettingsDialog,
}
SIGNED_OUT_TEXT_BAR = {
"container": names.settings_stack_QStackedWidget,
"name": "connectLabel",
"type": "QLabel",
"visible": 1,
}

def clickActivity(self):
squish.clickButton(squish.waitForObject(self.ACTIVITY_BUTTON))

def userLogout(self):
squish.sendEvent(
"QMouseEvent",
squish.waitForObject(self.ACCOUNT_BUTTON),
squish.QEvent.MouseButtonPress,
0,
0,
squish.Qt.LeftButton,
0,
0,
)
squish.activateItem(squish.waitForObjectItem(self.ACCOUNT_MENU, "Log out"))
def clickAddAccount(self):
squish.clickButton(squish.waitForObject(self.ADD_ACCOUNT_BUTTON))

def userLogsIn(self):
squish.sendEvent(
"QMouseEvent",
squish.waitForObject(self.ACCOUNT_BUTTON),
squish.QEvent.MouseButtonPress,
0,
0,
squish.Qt.LeftButton,
0,
0,
def getDisplayedAccountText(self, displayname, host):
return str(
squish.waitForObjectExists(
{
"name": "settingsdialog_toolbutton_" + displayname + "@" + host,
"type": "QToolButton",
"visible": 1,
}
).text
)
squish.activateItem(squish.waitForObjectItem(self.ACCOUNT_MENU, "Log in"))
82 changes: 68 additions & 14 deletions test/gui/shared/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pageObjects.SyncWizard import SyncWizard
from pageObjects.Toolbar import Toolbar
from pageObjects.Activity import Activity

from pageObjects.AccountStatus import AccountStatus

# the script needs to use the system wide python
# to switch from the built-in interpreter see https://kb.froglogic.com/squish/howto/using-external-python-interpreter-squish-6-6/
Expand Down Expand Up @@ -67,6 +67,15 @@ def hook(context):
pass


@Given('the user has added an account with')
def step(context):
toolbar = Toolbar()
toolbar.clickAddAccount()

newAccount = AccountConnectionWizard()
newAccount.addAccount(context)


@When('the user adds the first account with')
def step(context):
newAccount = AccountConnectionWizard()
Expand Down Expand Up @@ -117,9 +126,8 @@ def step(context):

@When('the user adds an account with')
def step(context):
clickButton(
waitForObject(names.settings_settingsdialog_toolbutton_Add_account_QToolButton)
)
toolbar = Toolbar()
toolbar.clickAddAccount()

newAccount = AccountConnectionWizard()
newAccount.addAccount(context)
Expand Down Expand Up @@ -516,16 +524,16 @@ def step(context, resource, role):

@When('the user logs out of the client-UI')
swoichha marked this conversation as resolved.
Show resolved Hide resolved
def step(context):
toolbar = Toolbar()
toolbar.userLogout()
accountStatus = AccountStatus()
accountStatus.accountAction("Log out")


def isUserSignedOut(context, username):
displayname = getDisplayname(username)
server = context.userData['localBackendUrl']
toolbar = Toolbar()
accountStatus = AccountStatus()
test.compare(
str(waitForObjectExists(toolbar.SIGNED_OUT_TEXT_BAR).text),
str(waitForObjectExists(accountStatus.SIGNED_OUT_TEXT_BAR).text),
'Signed out from <a href="'
+ server
+ '">'
Expand All @@ -539,10 +547,10 @@ def isUserSignedOut(context, username):
def isUserSignedIn(context, username):
displayname = getDisplayname(username)
server = context.userData['localBackendUrl']
toolbar = Toolbar()
accountStatus = AccountStatus()

test.compare(
str(waitForObjectExists(toolbar.SIGNED_OUT_TEXT_BAR).text),
str(waitForObjectExists(accountStatus.SIGNED_OUT_TEXT_BAR).text),
'Connected '
+ 'to <a href="'
+ server
Expand All @@ -568,15 +576,15 @@ def step(context, username):
# TODO: find some way to dynamically to check if files are synced
# It might take some time for all files to sync
snooze(5)
toolbar = Toolbar()
toolbar.userLogout()
accountStatus = AccountStatus()
accountStatus.accountAction("Log out")
isUserSignedOut(context, username)


@When('user "|any|" logs in to the client-UI')
def step(context, username):
toolbar = Toolbar()
toolbar.userLogsIn()
accountStatus = AccountStatus()
accountStatus.accountAction("Log in")
password = getPasswordForUser(username)
enterUserPassword = EnterPassword()
enterUserPassword.enterPassword(password)
Expand All @@ -588,3 +596,49 @@ def step(context, username):
# It might take some time for all files to sync and connect to ther server
snooze(5)
isUserSignedIn(context, username)


@When('the user removes the connection for user "|any|" and host |any|')
def step(context, username, host):
displayname = getDisplayname(username)
displayname = substituteInLineCodes(context, displayname)
host = substituteInLineCodes(context, host)

clickButton(
waitForObject(
{
"name": "settingsdialog_toolbutton_" + displayname + "@" + host,
"type": "QToolButton",
"visible": 1,
}
)
)

waitFor(
lambda: isFolderSynced(context.userData['clientSyncPath']),
context.userData['clientSyncTimeout'] * 1000,
)
accountStatus = AccountStatus()
accountStatus.removeConnection()


@Then('an account with the displayname |any| and host |any| should not be displayed')
def step(context, displayname, host):
displayname = substituteInLineCodes(context, displayname)
host = substituteInLineCodes(context, host)
toolbar = Toolbar()
displayedAccountText = toolbar.getDisplayedAccountText(displayname, host)

test.compare(
displayedAccountText,
displayname + "\n" + host,
)


@Then('connection wizard should be visible')
def step(context):
test.compare(
str(waitForObjectExists(names.owncloudWizard_label_2_QLabel).text),
'Ser&ver Address',
)
waitForObject(AccountConnectionWizard.SERVER_ADDRESS_BOX)
2 changes: 1 addition & 1 deletion test/gui/suite.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAPSTYLE=script
TEST_CASES=tst_addAccount tst_sharing tst_syncing tst_loginLogout
TEST_CASES=tst_addAccount tst_sharing tst_syncing tst_loginLogout tst_removeAccountConnection
VERSION=3
WRAPPERS=Qt
25 changes: 25 additions & 0 deletions test/gui/tst_removeAccountConnection/test.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: remove account connection

As a user
I want to remove my account
So that I won't be using any client-UI services


Scenario: remove an account connection
Given user "Alice" has been created on the server with default attributes and without skeleton files
And user "Brian" has been created on the server with default attributes and without skeleton files
And user "Alice" has set up a client with default settings
And the user has added an account with
| server | %local_server% |
| user | Brian |
| password | AaBb2Cc3Dd4 |
| localfolder | %client_sync_path% |
When the user removes the connection for user "Brian" and host %local_server_hostname%
Then an account should be displayed with the displayname Alice Hansen and host %local_server_hostname%


Scenario: remove the only account connection
Given user "Alice" has been created on the server with default attributes and without skeleton files
And user "Alice" has set up a client with default settings
When the user removes the connection for user "Alice" and host %local_server_hostname%
Then connection wizard should be visible
9 changes: 9 additions & 0 deletions test/gui/tst_removeAccountConnection/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source(findFile('scripts', 'python/bdd.py'))

setupHooks('../shared/scripts/bdd_hooks.py')
collectStepDefinitions('./steps', '../shared/steps')


def main():
testSettings.throwOnFailure = True
runFeatureFile('test.feature')