From 29e357eeb959f3125608eef86d35685561fc59a2 Mon Sep 17 00:00:00 2001 From: Salipa-Gurung Date: Mon, 18 Sep 2023 12:58:04 +0545 Subject: [PATCH] add step implementation for oauth2 login --- test/gui/shared/scripts/names.py | 3 +- .../scripts/pageObjects/EnterPassword.py | 2 +- .../gui/shared/scripts/pageObjects/Toolbar.py | 16 +++++++++ test/gui/shared/steps/account_context.py | 33 ++++++++++++------- test/gui/tst_loginLogout/test.feature | 4 +-- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/test/gui/shared/scripts/names.py b/test/gui/shared/scripts/names.py index 84218565179..0b6937608f2 100644 --- a/test/gui/shared/scripts/names.py +++ b/test/gui/shared/scripts/names.py @@ -48,4 +48,5 @@ o_folderList_ownCloud_QModelIndex = {"column": 0, "container": stack_folderList_QTreeView, "text": "ownCloud", "type": "QModelIndex"} contentWidget_contentWidget_QStackedWidget = {"container": setupWizardWindow_contentWidget_QStackedWidget, "name": "contentWidget", "type": "QStackedWidget", "visible": 1} o_folderList_Personal_QModelIndex = {"column": 0, "container": stack_folderList_QTreeView, "text": "Personal", "type": "QModelIndex"} -add_Folder_Sync_Connection_tableView_QTableView = {"name": "tableView","type": "QTableView","visible": 1,"window": add_Folder_Sync_Connection_OCC_FolderWizard} \ No newline at end of file +add_Folder_Sync_Connection_tableView_QTableView = {"name": "tableView","type": "QTableView","visible": 1,"window": add_Folder_Sync_Connection_OCC_FolderWizard} +quit_ownCloud_QMessageBox = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Quit ownCloud"} diff --git a/test/gui/shared/scripts/pageObjects/EnterPassword.py b/test/gui/shared/scripts/pageObjects/EnterPassword.py index 8b33b01b824..1fea7d7a8f7 100644 --- a/test/gui/shared/scripts/pageObjects/EnterPassword.py +++ b/test/gui/shared/scripts/pageObjects/EnterPassword.py @@ -35,7 +35,7 @@ def enterPassword(password): squish.clickButton(squish.waitForObject(EnterPassword.LOGIN_BUTTON)) @staticmethod - def oidcReLogin(username, password, login_type=None): + def oidcReLogin(username, password, login_type='oidc'): # wait 500ms for copy button to fully load squish.snooze(1 / 2) squish.clickButton( diff --git a/test/gui/shared/scripts/pageObjects/Toolbar.py b/test/gui/shared/scripts/pageObjects/Toolbar.py index 6f026e3345d..a9f434af11a 100644 --- a/test/gui/shared/scripts/pageObjects/Toolbar.py +++ b/test/gui/shared/scripts/pageObjects/Toolbar.py @@ -1,7 +1,16 @@ import squish +import names class Toolbar: + QUIT_OWNCLOUD_YES_QPUSHBUTTON = { + "text": "Yes", + "type": "QPushButton", + "unnamed": 1, + "visible": 1, + "window": names.quit_ownCloud_QMessageBox, + } + @staticmethod def getItemSelector(item_name): return { @@ -31,3 +40,10 @@ def getDisplayedAccountText(displayname, host): Toolbar.getItemSelector(displayname + "@" + host) ).text ) + + @staticmethod + def quitOwncloud(): + squish.clickButton( + squish.waitForObject(Toolbar.getItemSelector("Quit ownCloud")) + ) + squish.clickButton(squish.waitForObject(Toolbar.QUIT_OWNCLOUD_YES_QPUSHBUTTON)) diff --git a/test/gui/shared/steps/account_context.py b/test/gui/shared/steps/account_context.py index d3bf4ea1700..5aac1179255 100644 --- a/test/gui/shared/steps/account_context.py +++ b/test/gui/shared/steps/account_context.py @@ -65,6 +65,12 @@ def step(context): startClient() +@When('the user starts the client') +def step(context): + squish.snooze(1) + startClient() + + @When(r'^the user adds (the first|another) account with$', regexp=True) def step(context, accountType): if accountType == 'another': @@ -79,6 +85,11 @@ def step(context): AccountConnectionWizard.addAccountInformation(account_details) +@Given('the user "|any|" has logged out of the client-UI') +def step(context, username): + AccountSetting.logout() + + @When('the user "|any|" logs out of the client-UI') def step(context, username): AccountSetting.logout() @@ -239,6 +250,12 @@ def step(context): test.compare(True, AccountSetting.isLogDialogVisible(), "Log dialog is opened") +@Given('the user has added the following account with oauth2 enabled:') +def step(context): + AccountConnectionWizard.addAccountWithOauth2(context) + # squish.snooze(1) + + @When('the user adds the following account with oauth2 enabled:') def step(context): AccountConnectionWizard.addAccountWithOauth2(context) @@ -254,20 +271,14 @@ def step(context): test.vp("empty_sync_connection") -@Given('the user has added the following account with oauth2 enabled:') -def step(context): - AccountConnectionWizard.addAccountWithOauth2(context) - squish.snooze(1) - - -@Given('the user "|any|" has logged out of the client-UI') -def step(context, username): - AccountSetting.logout() - - @When('user "|any|" logs in with oauth2 to the client-UI') def step(context, username): AccountSetting.login() EnterPassword.oidcReLogin( username, getPasswordForUser(username), login_type='oauth' ) + + +@Given("the user has quitted the client") +def step(context): + Toolbar.quitOwncloud() diff --git a/test/gui/tst_loginLogout/test.feature b/test/gui/tst_loginLogout/test.feature index 25b93925166..d6ec57e4397 100644 --- a/test/gui/tst_loginLogout/test.feature +++ b/test/gui/tst_loginLogout/test.feature @@ -49,6 +49,6 @@ Feature: Logout users | server | %local_server% | | user | Alice | | password | 1234 | - When user quits the client - And user starts the client + And the user has quitted the client + When the user starts the client Then user "Alice" should be connect to the client-UI