diff --git a/test/gui/shared/scripts/pageObjects/Toolbar.py b/test/gui/shared/scripts/pageObjects/Toolbar.py index 6a46e534e13..6516cdbce35 100644 --- a/test/gui/shared/scripts/pageObjects/Toolbar.py +++ b/test/gui/shared/scripts/pageObjects/Toolbar.py @@ -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")) diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index 3cef9e9a4cd..50edc14bf99 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -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 ' + + server + + ' as ' + + displayname + + '.', + ) + + +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 ' + + server + + ' as ' + + displayname + + '.', + ) + + +@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) diff --git a/test/gui/suite.conf b/test/gui/suite.conf index 9433c6148e4..43ef4cf94a9 100644 --- a/test/gui/suite.conf +++ b/test/gui/suite.conf @@ -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 diff --git a/test/gui/tst_loginLogout/test.feature b/test/gui/tst_loginLogout/test.feature new file mode 100644 index 00000000000..21e3ddb23e7 --- /dev/null +++ b/test/gui/tst_loginLogout/test.feature @@ -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 diff --git a/test/gui/tst_loginLogout/test.py b/test/gui/tst_loginLogout/test.py new file mode 100644 index 00000000000..d6224b99e57 --- /dev/null +++ b/test/gui/tst_loginLogout/test.py @@ -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')