@@ -113,41 +113,92 @@ class RealBackendReleaseTest : ShellTestBase() {
113113 requireProduction()
114114 mark(" start" )
115115 try {
116- launchPlain(null , " google-webview" )
117- val button = waitFor(" sign_in_button" , 15_000 ) ? : skip(" no Sign in button" )
118- sleep(1_500 )
119- button.click()
120- if (waitFor(" web_sign_in_cancel" , 25_000 ) == null ) skip(" no web sign-in fallback" )
121- waitWebObject(" Sign in to OpenBot Cloud" , 30_000 )
122- sleep(1_500 )
123- screenshot(" 1-web-sign-in" )
124- waitWebObject(" Sign in or create an account" , 15_000 )?.click() ? : skip(" no 'Sign in or create an account'" )
125- val google = findInApp(pkg, " Google" , 30_000 ) ? : skip(" no Google button on OpenBot by CopilotKit's page" )
126- sleep(1_500 )
127- screenshot(" 2-identity-provider" )
128- google.click()
129- sleep(10_000 )
130- screenshot(" 3-google-in-webview" )
131- val refusal = googleRefusal(pkg)
132- if (refusal != null ) {
133- note(" Google refused the sign-in inside Android's WebView: the page says '$refusal '" )
134- skip(" refused: Google shows '$refusal ' inside Android's WebView; the Custom Tab path is the design" )
135- }
136- googleSteps(pkg, email, password, totp)
137- val home = waitForTab(Tab .HOME , 40_000 )
138- sleep(3_000 )
139- screenshot(" 4-after-google" )
140- note(" Google sign-in in the WebView reached the tabs: ${home != null } " )
141- if (home == null ) skip(" Google's sign-in in the WebView did not end signed in" )
142- // A short journey.
143- tab(Tab .BOTS )?.click()
144- sleep(4_000 )
145- screenshot(" 5-bots" )
146- tab(Tab .HOME )?.click()
147- sleep(3_000 )
148- screenshot(" 6-home" )
116+ googleWebViewJourney(email, password, totp)
117+ } catch (stop: org.junit.AssumptionViolatedException ) {
118+ // Any stop (Cloudflare, Google's refusal or challenge, an unexpected screen) ends here
119+ // with a picture and the screen's visible words; the recording keeps running to the end mark.
120+ screenshot(" stopped" )
121+ note(" stopped: ${stop.message} ; visible text: ${visibleText()} " )
122+ throw stop
149123 } finally {
150124 mark(" end" )
151125 }
152126 }
127+
128+ /* * The app's visible words (accessibility tree), addresses masked, at most 600 characters. */
129+ private fun visibleText (): String =
130+ device.findObjects(By .pkg(pkg)).flatMap { listOfNotNull(it.text, it.contentDescription) }
131+ .filter { it.isNotBlank() }.distinct().joinToString(" | " )
132+ .replace(Regex (" [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+" ), " <email>" ).take(600 )
133+
134+ private fun googleWebViewJourney (email : String , password : String , totp : ByteArray ) {
135+ launchPlain(null , " google-webview" )
136+ val button = waitFor(" sign_in_button" , 15_000 ) ? : skip(" no Sign in button" )
137+ sleep(1_500 )
138+ screenshot(" 0-first-screen" )
139+ button.click()
140+ if (waitFor(" web_sign_in_cancel" , 25_000 ) == null ) skip(" no web sign-in fallback" )
141+ sleep(4_000 )
142+ stopAtBotCheck(" web-sign-in" )
143+ waitWebObject(" Sign in to OpenBot Cloud" , 30_000 )
144+ stopAtBotCheck(" web-sign-in-page" )
145+ sleep(1_500 )
146+ screenshot(" 1-web-sign-in" )
147+ waitWebObject(" Sign in or create an account" , 15_000 )?.click() ? : skip(" no 'Sign in or create an account'" )
148+ sleep(3_000 )
149+ stopAtBotCheck(" identity-provider" )
150+ val google = findInApp(pkg, " Google" , 30_000 ) ? : skip(" no Google button on the identity provider's page" )
151+ sleep(1_500 )
152+ screenshot(" 2-identity-provider" )
153+ google.click()
154+ sleep(10_000 )
155+ screenshot(" 3-google-in-webview" )
156+ stopAtBotCheck(" google" )
157+ val refusal = googleRefusal(pkg)
158+ if (refusal != null ) {
159+ note(" Google refused the sign-in inside Android's WebView: the page says '$refusal '" )
160+ skip(" refused: Google shows '$refusal ' inside Android's WebView" )
161+ }
162+ googleSteps(pkg, email, password, totp)
163+ val home = waitForTab(Tab .HOME , 40_000 )
164+ sleep(3_000 )
165+ screenshot(" 8-after-google" )
166+ stopAtBotCheck(" after-google" )
167+ note(" Google sign-in in the WebView reached the tabs: ${home != null } " )
168+ if (home == null ) skip(" Google's sign-in in the WebView did not end signed in" )
169+
170+ // The journey, as the session-cookie test: a message and its streamed reply, the tabs,
171+ // the background and back. No sign-out.
172+ val box = waitComposerRect(30_000 )
173+ screenshot(" 9-home" )
174+ if (box != null ) {
175+ tapComposer(box)
176+ if (! waitKeyboard(true , 5_000 )) composerRect()?.let { tapComposer(it) }
177+ note(" software keyboard shown for the message: ${waitKeyboard(true , 5_000 )} " )
178+ shell(" input text Say%shello%sin%sthree%swords." )
179+ sleep(1_000 )
180+ screenshot(" 10-message-typed" )
181+ val before = visibleText()
182+ (device.findObject(By .desc(" Send message" )) ? : device.findObject(By .text(" Send message" )))?.click() ? : device.pressEnter()
183+ sleep(15_000 )
184+ screenshot(" 11-reply" )
185+ note(" the screen changed after sending: ${visibleText() != before} " )
186+ } else {
187+ note(" no message box found on Home" )
188+ }
189+ tab(Tab .CONVERSATIONS )?.click()
190+ sleep(4_000 )
191+ screenshot(" 12-chats" )
192+ tab(Tab .BOTS )?.click()
193+ sleep(4_000 )
194+ screenshot(" 13-bots" )
195+ tab(Tab .HOME )?.click()
196+ sleep(2_000 )
197+ device.pressHome()
198+ sleep(20_000 )
199+ bringBack()
200+ sleep(4_000 )
201+ screenshot(" 14-back-from-background" )
202+ note(" after the background: home tab ${tab(Tab .HOME ) != null } " )
203+ }
153204}
0 commit comments