@@ -215,6 +215,64 @@ void main() {
215215 expect (DateTime .tryParse (logs.first['timestamp' ] as String ), isNotNull);
216216 });
217217
218+ test ('a network call carries what the live inspector renders' , () async {
219+ // Live frames never pass through ingest, so the promotion ingest does —
220+ // method, url, status_code out of the metadata — has to happen at the
221+ // socket. Without it every network row on the live screen has a phase
222+ // and nothing else to show.
223+ expect (await start ('4K7Q2P' ), isTrue);
224+
225+ LiveSessionClient .i.publish (LogEntry (
226+ level: LogLevel .debug,
227+ message: 'Network Response' ,
228+ sessionID: 'launch-1' ,
229+ isNetworkCall: true ,
230+ requestId: 'req-1' ,
231+ callPhase: NetworkCallPhase .response,
232+ metadata: {
233+ 'method' : 'POST' ,
234+ 'url' : 'https://api.shop.dev/v2/pay' ,
235+ 'status_code' : 402 ,
236+ 'body' : {'error' : 'card_declined' },
237+ },
238+ ));
239+
240+ await _until (() => frames.any ((f) => (f['logs' ] as List ? )? .isNotEmpty ?? false ));
241+ final log = frames
242+ .expand ((f) => (f['logs' ] as List ? ?? const []).cast <Map <String , dynamic >>())
243+ .single;
244+
245+ expect (log['is_network_call' ], isTrue);
246+ expect (log['request_id' ], 'req-1' );
247+ expect (log['call_phase' ], 'response' );
248+ expect (log['method' ], 'POST' );
249+ expect (log['url' ], 'https://api.shop.dev/v2/pay' );
250+ expect (log['status_code' ], 402 );
251+ // The whole metadata rides along for the inspector's bodies and headers.
252+ expect ((log['metadata' ] as Map )['body' ], {'error' : 'card_declined' });
253+ });
254+
255+ test ('an ordinary log does not drag its metadata onto the wire' , () async {
256+ expect (await start ('4K7Q2P' ), isTrue);
257+
258+ LiveSessionClient .i.publish (LogEntry (
259+ level: LogLevel .info,
260+ message: 'cart viewed' ,
261+ sessionID: 'launch-1' ,
262+ metadata: {'items' : 3 },
263+ ));
264+
265+ await _until (() => frames.any ((f) => (f['logs' ] as List ? )? .isNotEmpty ?? false ));
266+ final log = frames
267+ .expand ((f) => (f['logs' ] as List ? ?? const []).cast <Map <String , dynamic >>())
268+ .single;
269+
270+ // Nothing on the logs pane reads it, and a chatty app's metadata would
271+ // be pure frame weight on every single row.
272+ expect (log.containsKey ('metadata' ), isFalse);
273+ expect (log.containsKey ('method' ), isFalse);
274+ });
275+
218276 test ('nothing is sent once the session is stopped' , () async {
219277 expect (await start ('4K7Q2P' ), isTrue);
220278 await LiveSessionClient .i.stop ();
0 commit comments