@@ -51,7 +51,7 @@ export function openFixture(
5151 ...( fixture . launchUrl ? [ '--launch-url' , fixture . launchUrl ] : [ ] ) ,
5252 '--foreground' ,
5353 ] ) ;
54- if ( ! fixture . launchUrl || ! hasDeepLinkConfirmation ( opened . payload ) ) return opened ;
54+ if ( ! fixture . launchUrl || ! deepLinkConfirmationShown ( context , opened ) ) return opened ;
5555 const accepted = pressFixtureTarget ( context , 'label="Open"' ) ;
5656 if ( accepted . ok ) return opened ;
5757 return {
@@ -78,7 +78,7 @@ export function firstInteractionAfterOpen(context: CliContext, fixture: ScreenFi
7878 ] ) ;
7979 if ( ! opened . ok ) return opened ;
8080 const selector =
81- fixture . launchUrl && hasDeepLinkConfirmation ( opened . payload )
81+ fixture . launchUrl && deepLinkConfirmationShown ( context , opened )
8282 ? 'label="Open"'
8383 : `text=${ JSON . stringify ( fixture . anchorText ) } ` ;
8484 return pressFixtureTarget ( context , selector ) ;
@@ -96,7 +96,15 @@ export async function openFixtureAsync(
9696 ...( fixture . launchUrl ? [ '--launch-url' , fixture . launchUrl ] : [ ] ) ,
9797 '--foreground' ,
9898 ] ) ;
99- if ( ! fixture . launchUrl || ! hasDeepLinkConfirmation ( opened . payload ) ) return opened ;
99+ if (
100+ ! fixture . launchUrl ||
101+ ! (
102+ hasDeepLinkConfirmation ( opened . payload ) ||
103+ hasDeepLinkConfirmation ( ( await snapshotFixtureAsync ( context ) ) . payload )
104+ )
105+ ) {
106+ return opened ;
107+ }
100108 const accepted = await pressFixtureTargetAsync ( context , 'label="Open"' ) ;
101109 if ( accepted . ok ) return opened ;
102110 return {
@@ -154,12 +162,23 @@ export function snapshotHasAnchor(payload: unknown, anchorText: string): boolean
154162
155163export function hasDeepLinkConfirmation ( payload : unknown ) : boolean {
156164 return snapshotNodes ( payload ) . some ( ( record ) => {
157- const role = readString ( record . role ) ;
165+ // Regular snapshots publish the node `type` ('Alert'); older projections used `role`.
166+ const role = ( readString ( record . role ) ?? readString ( record . type ) ) ?. toLowerCase ( ) ;
158167 const label = readString ( record . label ) ;
159168 return role === 'alert' && label ?. startsWith ( 'Open in ' ) === true ;
160169 } ) ;
161170}
162171
172+ /**
173+ * Whether iOS is asking to confirm the deep link the open just raised. The open response carries
174+ * no tree, so the dialog is read from a snapshot; the caller decides whether that read is setup or
175+ * the measured first interaction.
176+ */
177+ function deepLinkConfirmationShown ( context : CliContext , opened : CliResult ) : boolean {
178+ if ( hasDeepLinkConfirmation ( opened . payload ) ) return true ;
179+ return hasDeepLinkConfirmation ( snapshotFixture ( context ) . payload ) ;
180+ }
181+
163182function snapshotNodes ( payload : unknown ) : Record < string , unknown > [ ] {
164183 const snapshot = readSnapshotRecord ( payload ) ;
165184 if ( ! snapshot || ! Array . isArray ( snapshot . nodes ) ) return [ ] ;
0 commit comments