Skip to content

Commit 7d94fd5

Browse files
authored
test: sso devce backup critical flow test(WPB-20253) (#4317)
1 parent 25dc63f commit 7d94fd5

29 files changed

+1350
-82
lines changed

tests/testsCore/src/androidTest/kotlin/com/wire/android/tests/core/criticalFlows/AccountManagement.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ class AccountManagement : KoinTest {
9999
assertEmailWelcomePage()
100100
}
101101
pages.loginPage.apply {
102-
enterPersonalUserLoggingEmail(teamMember.email ?: "")
102+
enterTeamMemberLoggingEmail(teamMember.email ?: "")
103103
clickLoginButton()
104-
enterPersonalUserLoginPassword(teamMember.password ?: "")
104+
enterTeamMemberLoggingPassword(teamMember.password ?: "")
105105
clickLoginButton()
106106
}
107107
pages.registrationPage.apply {
108-
waitUntilLoginFlowIsComplete()
108+
waitUntilLoginFlowIsCompleted()
109109
clickAllowNotificationButton()
110110
clickDeclineShareDataAlert()
111111
}
112112
pages.conversationListPage.apply {
113113
assertGroupConversationVisible("MyTeam")
114-
clickMainMenuButtonOnConversationPage()
114+
clickConversationsMenuEntry()
115115
clickSettingsButtonOnMenuEntry()
116116
pages.settingsPage.apply {
117117
clickDebugSettingsButton()

tests/testsCore/src/androidTest/kotlin/com/wire/android/tests/core/criticalFlows/FileSharing.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import backendUtils.team.deleteTeam
2929
import com.wire.android.tests.support.UiAutomatorSetup
3030
import com.wire.android.tests.core.di.testModule
3131
import com.wire.android.tests.core.pages.AllPages
32-
import deleteDownloadedFilesContainingFileWord
32+
import deleteDownloadedFilesContaining
3333
import kotlinx.coroutines.runBlocking
3434
import org.junit.After
3535
import org.junit.Before
@@ -66,7 +66,7 @@ class FileSharing : KoinTest {
6666
context = InstrumentationRegistry.getInstrumentation().context
6767
// device = UiAutomatorSetup.start(UiAutomatorSetup.APP_DEV)
6868
device = UiAutomatorSetup.start(UiAutomatorSetup.APP_INTERNAL)
69-
// device = UiAutomatorSetup.start(UiAutomatorSetup.APP_STAGING)
69+
// device = UiAutomatorSetup.start(UiAutomatorSetup.APP_STAGING)
7070
backendClient = BackendClient.loadBackend("STAGING")
7171
teamHelper = TeamHelper()
7272
}
@@ -75,9 +75,9 @@ class FileSharing : KoinTest {
7575
fun tearDown() {
7676
// UiAutomatorSetup.stopApp()
7777
// To delete team
78-
teamOwner2?.deleteTeam(backendClient!!)
78+
teamOwner2?.deleteTeam(backendClient!!)
7979
teamOwner1?.deleteTeam(backendClient!!)
80-
deleteDownloadedFilesContainingFileWord()
80+
deleteDownloadedFilesContaining("File")
8181
}
8282

8383
@Suppress("CyclomaticComplexMethod", "LongMethod")
@@ -145,7 +145,7 @@ class FileSharing : KoinTest {
145145
}
146146
pages.registrationPage.apply {
147147

148-
waitUntilLoginFlowIsComplete()
148+
waitUntilLoginFlowIsCompleted()
149149
clickAllowNotificationButton()
150150
clickDeclineShareDataAlert()
151151
testServiceHelper.apply {

tests/testsCore/src/androidTest/kotlin/com/wire/android/tests/core/criticalFlows/GroupMessaging.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class GroupMessaging : KoinTest {
118118
clickLoginButton()
119119
}
120120
pages.registrationPage.apply {
121-
waitUntilLoginFlowIsComplete()
121+
waitUntilLoginFlowIsCompleted()
122122
clickAllowNotificationButton()
123123
clickDeclineShareDataAlert()
124124
}
@@ -139,7 +139,7 @@ class GroupMessaging : KoinTest {
139139
typeMessageInInputField("Hello Team Members")
140140
clickSendButton()
141141
assertSentMessageIsVisibleInCurrentConversation("Hello Team Members")
142-
tapBackButtonOnConversationViewPage()
142+
tapBackButtonToCloseConversationViewPage()
143143
}
144144
testServiceHelper.apply {
145145
addDevice("user2Name", null, "Device1")

tests/testsCore/src/androidTest/kotlin/com/wire/android/tests/core/criticalFlows/NewMemberMessaging.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ class NewMemberMessaging : KoinTest {
122122
clickProceedButtonOnDeeplinkOverlay()
123123
}
124124
pages.loginPage.apply {
125-
enterTeamOwnerLoggingEmail(member1?.email ?: "")
125+
enterTeamMemberLoggingEmail(member1?.email ?: "")
126126
clickLoginButton()
127-
enterTeamOwnerLoggingPassword(member1?.password ?: "")
127+
enterTeamMemberLoggingPassword(member1?.password ?: "")
128128
clickLoginButton()
129129
}
130130
pages.registrationPage.apply {
131-
waitUntilLoginFlowIsComplete()
131+
waitUntilLoginFlowIsCompleted()
132132
clickAllowNotificationButton()
133133
clickDeclineShareDataAlert()
134134
}
@@ -152,7 +152,7 @@ class NewMemberMessaging : KoinTest {
152152
typeMessageInInputField("Hello Team Owner")
153153
clickSendButton()
154154
assertSentMessageIsVisibleInCurrentConversation("Hello Team Owner")
155-
tapBackButtonOnConversationViewPage()
155+
tapBackButtonToCloseConversationViewPage()
156156
}
157157
pages.connectedUserProfilePage.apply {
158158
tapCloseButtonOnConnectedUserProfilePage()
@@ -182,7 +182,7 @@ class NewMemberMessaging : KoinTest {
182182
}
183183

184184
pages.conversationViewPage.apply {
185-
tapBackButtonOnConversationViewPage()
185+
tapBackButtonToCloseConversationViewPage()
186186
}
187187

188188
pages.conversationListPage.apply {

tests/testsCore/src/androidTest/kotlin/com/wire/android/tests/core/criticalFlows/PersonalAccountLifeCycle.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class PersonalAccountLifeCycle : KoinTest {
135135
assertUserNameHelpText()
136136
setUserName(personalUser?.uniqueUsername.orEmpty())
137137
clickConfirmButton()
138-
waitUntilRegistrationFlowIsComplete()
138+
waitUntilRegistrationFlowIsCompleted()
139139
clickAllowNotificationButton()
140140
clickDeclineShareDataAlert()
141141
assertConversationPageVisible()
@@ -200,10 +200,10 @@ class PersonalAccountLifeCycle : KoinTest {
200200
assertUnblockUserButtonVisible()
201201
tapCloseButtonOnConnectedUserProfilePage()
202202
pages.conversationViewPage.apply {
203-
tapBackButtonOnConversationViewPage()
203+
tapBackButtonToCloseConversationViewPage()
204204
}
205205
pages.conversationListPage.apply {
206-
clickMainMenuButtonOnConversationPage()
206+
clickConversationsMenuEntry()
207207
clickSettingsButtonOnMenuEntry()
208208
}
209209
waitFor(1)
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2025 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*/
18+
package com.wire.android.tests.core.criticalFlows
19+
20+
import SSOServiceHelper.thereIsASSOTeamOwnerForOkta
21+
import SSOServiceHelper.userAddsOktaUser
22+
import SSOServiceHelper.userXIsMe
23+
import androidx.test.ext.junit.runners.AndroidJUnit4
24+
import org.junit.runner.RunWith
25+
import android.content.Context
26+
import androidx.test.platform.app.InstrumentationRegistry
27+
import androidx.test.uiautomator.UiDevice
28+
import backendUtils.BackendClient
29+
import backendUtils.team.TeamHelper
30+
import backendUtils.team.deleteTeam
31+
import com.wire.android.tests.core.di.testModule
32+
import com.wire.android.tests.core.pages.AllPages
33+
import com.wire.android.tests.support.UiAutomatorSetup
34+
import deleteDownloadedFilesContaining
35+
import kotlinx.coroutines.runBlocking
36+
import okta.OktaApiClient
37+
import org.junit.After
38+
import org.junit.Before
39+
import org.junit.Rule
40+
import org.junit.Test
41+
import org.koin.test.KoinTest
42+
import org.koin.test.KoinTestRule
43+
import org.koin.test.inject
44+
import service.TestServiceHelper
45+
import uiautomatorutils.UiWaitUtils.WaitUtils.waitFor
46+
import user.usermanager.ClientUserManager
47+
import user.utils.ClientUser
48+
import kotlin.getValue
49+
50+
@RunWith(AndroidJUnit4::class)
51+
class SSODeviceBackup : KoinTest {
52+
53+
@get:Rule
54+
val koinTestRule = KoinTestRule.Companion.create {
55+
modules(testModule)
56+
}
57+
private val pages: AllPages by inject()
58+
private lateinit var device: UiDevice
59+
60+
lateinit var context: Context
61+
var teamOwner: ClientUser? = null
62+
var member1: ClientUser? = null
63+
private lateinit var oktaApiClient: OktaApiClient
64+
65+
var backendClient: BackendClient? = null
66+
val teamServiceHelper by lazy {
67+
TestServiceHelper()
68+
}
69+
val teamHelper by lazy {
70+
TeamHelper()
71+
}
72+
73+
@Before
74+
fun setUp() {
75+
context = InstrumentationRegistry.getInstrumentation().context
76+
device = UiAutomatorSetup.start(UiAutomatorSetup.APP_INTERNAL)
77+
backendClient = BackendClient.loadBackend("STAGING")
78+
oktaApiClient = OktaApiClient()
79+
}
80+
81+
@After
82+
fun tearDown() {
83+
teamOwner?.deleteTeam(backendClient!!)
84+
deleteDownloadedFilesContaining("Wire")
85+
oktaApiClient.cleanUp()
86+
}
87+
88+
@Suppress("CyclomaticComplexMethod", "LongMethod")
89+
@Test
90+
fun givenSSOTeamWithOkta_whenSettingUpNewDeviceAndRestoringBackup_thenMessageIsRestored() {
91+
92+
runBlocking {
93+
94+
teamServiceHelper.thereIsASSOTeamOwnerForOkta(
95+
context,
96+
"user1Name",
97+
"Messaging",
98+
oktaApiClient
99+
)
100+
101+
teamServiceHelper.userAddsOktaUser("user1Name", "user2Name", oktaApiClient)
102+
103+
teamServiceHelper.userXIsMe("user2Name")
104+
105+
teamOwner = teamHelper.usersManager.findUserBy(
106+
"user1Name",
107+
ClientUserManager.FindBy.NAME_ALIAS
108+
)
109+
member1 = teamHelper.usersManager.findUserBy(
110+
"user2Name",
111+
ClientUserManager.FindBy.NAME_ALIAS
112+
)
113+
114+
val ssoCode = SSOServiceHelper.getSSOCode()
115+
waitFor(20) // Delay added to allow Okta app assignment to fully sync and avoid 403 error
116+
pages.registrationPage.apply {
117+
assertEmailWelcomePage()
118+
}
119+
pages.loginPage.apply {
120+
clickStagingDeepLink()
121+
clickProceedButtonOnDeeplinkOverlay()
122+
}
123+
pages.loginPage.apply {
124+
enterSSOCodeOnSSOLoginTab(ssoCode)
125+
clickLoginButton()
126+
}
127+
pages.ssoPage.apply {
128+
enterOktaEmail(member1?.email ?: "")
129+
enterOktaPassword(member1?.password ?: "")
130+
tapOktaSignIn()
131+
}
132+
pages.registrationPage.apply {
133+
clickAllowNotificationButton()
134+
setUserName(member1?.uniqueUsername.orEmpty())
135+
clickConfirmButton()
136+
waitUntilLoginFlowIsCompleted()
137+
clickDeclineShareDataAlert()
138+
}
139+
pages.conversationListPage.apply {
140+
tapStartNewConversationButton()
141+
}
142+
pages.searchPage.apply {
143+
tapSearchPeopleField()
144+
typeUserNameInSearchField("user1Name")
145+
assertUsernameInSearchResultIs(teamOwner?.name ?: "")
146+
tapUsernameInSearchResult(teamOwner?.name ?: "")
147+
}
148+
pages.connectedUserProfilePage.apply {
149+
assertStartConversationButtonVisible()
150+
clickStartConversationButton()
151+
}
152+
pages.conversationViewPage.apply {
153+
assertConversationScreenVisible()
154+
typeMessageInInputField("Testing of the backup functionality")
155+
clickSendButton()
156+
assertSentMessageIsVisibleInCurrentConversation("Testing of the backup functionality")
157+
tapBackButtonToCloseConversationViewPage()
158+
}
159+
pages.connectedUserProfilePage.apply {
160+
tapCloseButtonOnConnectedUserProfilePage()
161+
}
162+
pages.conversationListPage.apply {
163+
clickCloseButtonOnNewConversationScreen()
164+
assertConversationListVisible()
165+
}
166+
pages.conversationListPage.apply {
167+
clickConversationsMenuEntry()
168+
clickSettingsButtonOnMenuEntry()
169+
}
170+
pages.settingsPage.apply {
171+
openBackupAndRestoreConversationsMenu()
172+
iSeeBackupPageHeading()
173+
clickCreateBackupButton()
174+
clickBackUpNowButton()
175+
iSeeBackupConfirmation("Conversations successfully saved")
176+
iTapSaveFileButton()
177+
iTapSaveInOSMenuButton()
178+
iSeeBackupPageHeading()
179+
clickBackButtonOnSettingsPage()
180+
}
181+
pages.conversationListPage.apply {
182+
clickConversationsMenuEntry()
183+
clickConversationsButtonOnMenuEntry()
184+
clickUserProfileButton()
185+
}
186+
pages.selfUserProfilePage.apply {
187+
iSeeUserProfilePage()
188+
tapLogoutButton()
189+
iSeeClearDataOnLogOutAlert()
190+
iSeeInfoTextCheckbox("Delete all your personal information and conversations on this device")
191+
tapInfoTextCheckbox()
192+
tapLogoutButton()
193+
}
194+
pages.registrationPage.apply {
195+
assertEmailWelcomePage()
196+
}
197+
pages.loginPage.apply {
198+
clickStagingDeepLink()
199+
clickProceedButtonOnDeeplinkOverlay()
200+
}
201+
pages.loginPage.apply {
202+
enterSSOCodeOnSSOLoginTab(ssoCode)
203+
clickLoginButton()
204+
}
205+
pages.registrationPage.apply {
206+
waitUntilLoginFlowIsCompleted()
207+
clickDeclineShareDataAlert()
208+
}
209+
pages.conversationListPage.apply {
210+
assertConversationIsVisibleWithTeamOwner(teamOwner?.name ?: "")
211+
tapConversationNameInConversationList(teamOwner?.name ?: "")
212+
}
213+
pages.conversationViewPage.apply {
214+
assertMessageNotVisible("Testing of the backup functionality")
215+
tapBackButtonToCloseConversationViewPage()
216+
}
217+
pages.conversationListPage.apply {
218+
219+
clickConversationsMenuEntry()
220+
clickSettingsButtonOnMenuEntry()
221+
}
222+
pages.settingsPage.apply {
223+
openBackupAndRestoreConversationsMenu()
224+
iSeeBackupPageHeading()
225+
clickRestoreBackupButton()
226+
clickChooseBackupFileButton()
227+
selectBackupFileInDocumentsUI(teamHelper, "user2Name")
228+
waitUntilThisTextIsDisplayedOnBackupAlert("Conversations have been restored")
229+
clickOkButtonOnBackupAlert()
230+
}
231+
pages.conversationListPage.apply {
232+
assertConversationListVisible()
233+
assertConversationIsVisibleWithTeamOwner(teamOwner?.name ?: "")
234+
tapConversationNameInConversationList(teamOwner?.name ?: "")
235+
}
236+
pages.conversationViewPage.apply {
237+
assertMessageNotVisible("Testing of the backup functionality")
238+
}
239+
}
240+
}
241+
}

tests/testsCore/src/androidTest/kotlin/com/wire/android/tests/core/pages/AllPages.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@ class AllPages(val device: UiDevice) {
3636
val groupConversationDetailsPage = GroupConversationDetailsPage(device)
3737

3838
val searchPage = SearchPage(device)
39+
40+
val ssoPage = SSOPage(device)
41+
42+
val chromePage = ChromePage(device)
43+
44+
val selfUserProfilePage = SelfUserProfilePage(device)
3945
}

0 commit comments

Comments
 (0)