@@ -449,12 +449,6 @@ export async function tapNotification(title: string, timeoutMs = 30_000) {
449449 }
450450}
451451
452- export async function hasLogView ( ) : Promise < boolean > {
453- return $ ( byTestIdSelector ( 'log_view' ) )
454- . isExisting ( )
455- . catch ( ( ) => false ) ;
456- }
457-
458452/**
459453 * Text of the demo's log entries, oldest first. Native Android only sees
460454 * entries on screen, so counts can miss older matches that scrolled away.
@@ -502,24 +496,21 @@ async function latestUserChange(externalId: string | null) {
502496/**
503497 * Wait for a login/logout to settle: the demo logs a "User changed" for `externalId` (null = anonymous),
504498 * then the backend has that user. Settling first avoids racing the SDK's user switch on the next call
505- * (e.g. a fast logout then login on iOS never fires the user observer). Demos without that log
506- * just get `timeoutMs` as a grace period.
499+ * (e.g. a fast logout then login on iOS never fires the user observer).
507500 */
508501export async function waitForIdentityChange (
509502 { externalId } : { externalId : string | null } ,
510503 timeoutMs = 10_000 ,
511504) {
512- let onesignalId : string | undefined ;
513- await driver
514- . waitUntil ( async ( ) => Boolean ( ( onesignalId = await latestUserChange ( externalId ) ) ) , {
505+ let onesignalId = '' ;
506+ await driver . waitUntil (
507+ async ( ) => Boolean ( ( onesignalId = ( await latestUserChange ( externalId ) ) ?? '' ) ) ,
508+ {
515509 timeout : timeoutMs ,
516510 interval : 500 ,
517- } )
518- . catch ( ( ) => undefined ) ;
519- if ( ! onesignalId ) {
520- console . info ( `No "User changed" log for external_id ${ externalId ?? 'null' } ` ) ;
521- return undefined ;
522- }
511+ timeoutMsg : `No "User changed" log for external_id ${ externalId ?? 'null' } ` ,
512+ } ,
513+ ) ;
523514 await waitForBackendUser ( onesignalId , externalId ) ;
524515 return onesignalId ;
525516}
@@ -686,10 +677,10 @@ export async function checkNotification(opts: {
686677
687678 const displayLog = [ 'Notification foregroundWillDisplay:' , opts . title ] ;
688679 const clickLog = [ 'Notification click:' , opts . title ] ;
689- const logged = await hasLogView ( ) ;
690- const [ displaysBefore , clicksBefore ] = logged
691- ? await Promise . all ( [ countLogMessages ( ...displayLog ) , countLogMessages ( ... clickLog ) ] )
692- : [ 0 , 0 ] ;
680+ const [ displaysBefore , clicksBefore ] = await Promise . all ( [
681+ countLogMessages ( ... displayLog ) ,
682+ countLogMessages ( ...clickLog ) ,
683+ ] ) ;
693684
694685 await button . click ( ) ;
695686 await waitForNotification ( {
@@ -698,8 +689,6 @@ export async function checkNotification(opts: {
698689 expectImage : opts . expectImage ,
699690 } ) ;
700691
701- // Demos without the log view can't report JS events yet.
702- if ( ! logged ) return ;
703692 await expectOneNewLog ( displayLog , displaysBefore ) ;
704693 await expectOneNewLog ( clickLog , clicksBefore ) ;
705694}
0 commit comments