Skip to content

Commit

Permalink
[tests-only]logout user from client (#8663)
Browse files Browse the repository at this point in the history
* [tests-only]logout user from client

* add snooze
  • Loading branch information
swoichha authored Jun 3, 2021
1 parent 93cd546 commit a2c2a29
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 1 deletion.
44 changes: 44 additions & 0 deletions test/gui/shared/scripts/pageObjects/Toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,50 @@ class Toolbar:
"visible": 1,
"window": names.settings_OCC_SettingsDialog,
}
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,
}

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 userLogsIn(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 in"))
76 changes: 76 additions & 0 deletions test/gui/shared/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,79 @@ def step(context, resource):
)
def step(context, resource, role):
createPublicShareWithRole(context, resource, role)


@When('the user logs out of the client-UI')
def step(context):
toolbar = Toolbar()
toolbar.userLogout()


def isUserSignedOut(context, username):
displayname = getDisplayname(username)
server = context.userData['localBackendUrl']
toolbar = Toolbar()
test.compare(
str(waitForObjectExists(toolbar.SIGNED_OUT_TEXT_BAR).text),
'Signed out from <a href="'
+ server
+ '">'
+ server
+ '</a> as <i>'
+ displayname
+ '</i>.',
)


def isUserSignedIn(context, username):
displayname = getDisplayname(username)
server = context.userData['localBackendUrl']
toolbar = Toolbar()

test.compare(
str(waitForObjectExists(toolbar.SIGNED_OUT_TEXT_BAR).text),
'Connected '
+ 'to <a href="'
+ server
+ '">'
+ server
+ '</a> as <i>'
+ displayname
+ '</i>.',
)


@Then('user "|any|" should be signed out')
def step(context, username):
isUserSignedOut(context, username)


@Given('user "|any|" has logged out of the client-UI')
def step(context, username):
waitFor(
lambda: isFolderSynced(context.userData['clientSyncPath']),
context.userData['clientSyncTimeout'] * 1000,
)
# 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()
isUserSignedOut(context, username)


@When('user "|any|" logs in to the client-UI')
def step(context, username):
toolbar = Toolbar()
toolbar.userLogsIn()
password = getPasswordForUser(username)
enterUserPassword = EnterPassword()
enterUserPassword.enterPassword(password)


@Then('user "|any|" should be connect to the client-UI')
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 and connect to ther server
snooze(5)
isUserSignedIn(context, username)
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
TEST_CASES=tst_addAccount tst_sharing tst_syncing tst_loginLogout
VERSION=3
WRAPPERS=Qt
18 changes: 18 additions & 0 deletions test/gui/tst_loginLogout/test.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature: Logout users
As a user
I want to be able to login and logout of my account
So that I can protect my work and identity and be assured of privacy

Background:
Given user "Alice" has been created on the server with default attributes and without skeleton files

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

Scenario: login after loggin out
Given user "Alice" has set up a client with default settings
And user "Alice" has logged out of the client-UI
When user "Alice" logs in to the client-UI
Then user "Alice" should be connect to the client-UI
9 changes: 9 additions & 0 deletions test/gui/tst_loginLogout/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')

0 comments on commit a2c2a29

Please sign in to comment.