@@ -21,6 +21,12 @@ const LAUNCH_PENDING = result(1, {
2121const WRONG_ROUTE = result ( 1 , {
2222 error : { code : 'COMMAND_FAILED' , details : { reason : 'wait_target_absent' } } ,
2323} ) ;
24+ const READABLE_TIMEOUT = result ( 1 , {
25+ error : {
26+ code : 'COMMAND_FAILED' ,
27+ details : { reason : 'wait_deadline_exceeded' , readableCaptures : 5 , captureTruncated : true } ,
28+ } ,
29+ } ) ;
2430const OPEN_PROMPT = result ( 0 , {
2531 data : { message : 'Open in “Agent Device Tester”?' , items : [ 'Cancel' , 'Open' ] } ,
2632} ) ;
@@ -56,7 +62,47 @@ test('a destination that arrives never probes for the confirmation', async () =>
5662
5763 await answerDeepLinkConfirmation ( device ) ;
5864
59- assert . deepEqual ( log , [ 'wait for the deep-link destination (1/4)' ] ) ;
65+ assert . deepEqual ( log , [ 'wait for the deep-link destination (1/5)' ] ) ;
66+ } ) ;
67+
68+ test ( 'a readable destination timeout still answers a real Open confirmation' , async ( ) => {
69+ const { device, log } = simulator ( [ READABLE_TIMEOUT , LANDED ] ) ;
70+
71+ await answerDeepLinkConfirmation ( device ) ;
72+
73+ assert . deepEqual ( log , [
74+ 'wait for the deep-link destination (1/5)' ,
75+ 'alert get' ,
76+ 'alert accept' ,
77+ 'wait for the deep-link destination (2/5)' ,
78+ ] ) ;
79+ } ) ;
80+
81+ test ( 'a readable no-match that answers Open waits for the released launch' , async ( ) => {
82+ const { device, log } = simulator ( [ WRONG_ROUTE , LAUNCH_PENDING , LANDED ] ) ;
83+
84+ await answerDeepLinkConfirmation ( device ) ;
85+
86+ assert . deepEqual ( log , [
87+ 'wait for the deep-link destination (1/5)' ,
88+ 'alert get' ,
89+ 'alert accept' ,
90+ 'wait for the deep-link destination (2/5)' ,
91+ 'wait for the deep-link destination (3/5)' ,
92+ ] ) ;
93+ } ) ;
94+
95+ test ( 'a truncated capture retries for four bounded waits without accepting a missing alert' , async ( ) => {
96+ const { device, log } = simulator (
97+ [ READABLE_TIMEOUT , READABLE_TIMEOUT , READABLE_TIMEOUT , READABLE_TIMEOUT , LANDED ] ,
98+ [ NO_ALERT , NO_ALERT , NO_ALERT , NO_ALERT ] ,
99+ ) ;
100+
101+ await answerDeepLinkConfirmation ( device ) ;
102+
103+ assert . equal ( waits ( log ) , 5 ) ;
104+ assert . equal ( log . filter ( ( step ) => step === 'alert get' ) . length , 4 ) ;
105+ assert . equal ( log . includes ( 'alert accept' ) , false ) ;
60106} ) ;
61107
62108test ( 'the launch an accepted confirmation releases is waited for until it lands' , async ( ) => {
@@ -66,29 +112,29 @@ test('the launch an accepted confirmation releases is waited for until it lands'
66112 await answerDeepLinkConfirmation ( device ) ;
67113
68114 assert . deepEqual ( log , [
69- 'wait for the deep-link destination (1/4 )' ,
115+ 'wait for the deep-link destination (1/5 )' ,
70116 'alert get' ,
71117 'alert accept' ,
72- 'wait for the deep-link destination (2/4 )' ,
73- 'wait for the deep-link destination (3/4 )' ,
74- 'wait for the deep-link destination (4/4 )' ,
118+ 'wait for the deep-link destination (2/5 )' ,
119+ 'wait for the deep-link destination (3/5 )' ,
120+ 'wait for the deep-link destination (4/5 )' ,
75121 ] ) ;
76122} ) ;
77123
78- test ( 'a miss that is not a pending launch neither probes nor waits again ' , async ( ) => {
79- const { device, log } = simulator ( [ WRONG_ROUTE ] ) ;
124+ test ( 'a readable miss probes once and leaves a wrong route to the caller ' , async ( ) => {
125+ const { device, log } = simulator ( [ WRONG_ROUTE ] , [ NO_ALERT ] ) ;
80126
81127 await answerDeepLinkConfirmation ( device ) ;
82128
83- assert . deepEqual ( log , [ 'wait for the deep-link destination (1/4) ' ] ) ;
129+ assert . deepEqual ( log , [ 'wait for the deep-link destination (1/5)' , 'alert get '] ) ;
84130} ) ;
85131
86- test ( 'after the accept, a miss that is not a pending launch earns no further wait' , async ( ) => {
87- const { device, log } = simulator ( [ LAUNCH_PENDING , WRONG_ROUTE ] ) ;
132+ test ( 'after the accept, a readable no-match still gets a bounded launch wait' , async ( ) => {
133+ const { device, log } = simulator ( [ LAUNCH_PENDING , WRONG_ROUTE , LANDED ] ) ;
88134
89135 await answerDeepLinkConfirmation ( device ) ;
90136
91- assert . equal ( waits ( log ) , 2 ) ;
137+ assert . equal ( waits ( log ) , 3 ) ;
92138} ) ;
93139
94140test ( 'a confirmation that appears late is still answered once' , async ( ) => {
@@ -110,7 +156,7 @@ test('the wait budget is bounded when the app never starts', async () => {
110156
111157 await answerDeepLinkConfirmation ( device ) ;
112158
113- assert . equal ( waits ( log ) , 4 ) ;
159+ assert . equal ( waits ( log ) , 5 ) ;
114160} ) ;
115161
116162test ( 'a prompt that is not the deep-link confirmation is never accepted' , async ( ) => {
0 commit comments