@@ -98,38 +98,29 @@ void runFirestoreTests(
9898 await client.deleteDocument ('users/$testUserId ' );
9999 print ('✓ Document deleted successfully' );
100100
101- // Wait for trigger to fire and write result
101+ // Wait for trigger to fire
102102 await Future <void >.delayed (const Duration (seconds: 2 ));
103103
104104 // Verify document no longer exists
105105 final doc = await client.getDocument ('users/$testUserId ' );
106106 expect (doc, isNull, reason: 'Document should not exist after deletion' );
107107 print ('✓ Document deletion verified' );
108108
109- // Poll for the side-channel result doc written by the handler
110- // (up to 5 attempts × 500ms = 2.5s extra headroom)
111- Map <String , dynamic >? result;
112- for (var i = 0 ; i < 5 ; i++ ) {
113- result = await client.getDocument (
114- 'trigger_results/deleted_$testUserId ' ,
115- );
116- if (result != null ) break ;
117- await Future <void >.delayed (const Duration (milliseconds: 500 ));
118- }
119-
120- expect (
121- result,
122- isNotNull,
123- reason: 'trigger_results doc should have been written by handler' ,
124- );
109+ // Verify handler received the pre-deletion document data by checking
110+ // the structured log line emitted by the handler.
111+ final emulator = getEmulator ();
112+ final allLogs = [
113+ ...emulator.outputLines,
114+ ...emulator.errorLines,
115+ ].join ('\n ' );
125116 expect (
126- result ! [ 'fields' ][ 'hasData' ][ 'booleanValue' ] ,
127- isTrue ,
117+ allLogs ,
118+ contains ( '[onDocumentDeleted] hasData=true' ) ,
128119 reason: 'event.data should be non-null for delete events' ,
129120 );
130- expect (result[ 'fields' ][ 'name' ][ 'stringValue' ], ' To Be Deleted' );
131- expect (result[ 'fields' ][ 'email' ][ 'stringValue' ], ' delete@example.com' );
132- expect (result[ 'fields' ][ 'finalMessage' ][ 'stringValue' ], ' goodbye' );
121+ expect (allLogs, contains ( 'name= To Be Deleted') );
122+ expect (allLogs, contains ( 'email= delete@example.com') );
123+ expect (allLogs, contains ( 'finalMessage= goodbye') );
133124 print ('✓ Handler received correct pre-deletion document data' );
134125 });
135126
@@ -309,12 +300,6 @@ void runFirestoreTests(
309300 } catch (e) {
310301 // Ignore errors during cleanup
311302 }
312- // Clean up side-channel result doc written by the onDocumentDeleted handler
313- try {
314- await client.deleteDocument ('trigger_results/deleted_$testUserId ' );
315- } catch (e) {
316- // Ignore errors during cleanup
317- }
318303 });
319304 });
320305}
0 commit comments