@@ -422,3 +422,115 @@ test('resolution digest and settle digest compose independently', () => {
422422 expect ( ( digest . resolution as { alternatives ?: unknown [ ] } ) . alternatives ) . toBeUndefined ( ) ;
423423 expect ( ( digest . settle as { diff ?: { lines ?: unknown [ ] } } ) . diff ?. lines ) . toBeUndefined ( ) ;
424424} ) ;
425+
426+ const networkView = RESPONSE_VIEWS . network ;
427+
428+ const NETWORK_DATA : DaemonResponseData = {
429+ path : '/tmp/app.log' ,
430+ exists : true ,
431+ active : true ,
432+ state : 'active' ,
433+ backend : 'ios-simulator' ,
434+ include : 'all' ,
435+ scannedLines : 4000 ,
436+ matchedLines : 2 ,
437+ limits : { maxEntries : 25 , maxPayloadChars : 2048 , maxScanLines : 4000 } ,
438+ entries : [
439+ {
440+ method : 'POST' ,
441+ url : 'https://api.example.test/checkout/1' ,
442+ status : 503 ,
443+ timestamp : '2026-07-02T12:00:00.000Z' ,
444+ durationMs : 120 ,
445+ packetId : 'packet-1' ,
446+ line : 3900 ,
447+ metadata : { requestId : 'request-1' } ,
448+ headers : 'authorization: <redacted>\ncontent-type: application/json' ,
449+ requestHeaders : { authorization : '<redacted>' } ,
450+ responseHeaders : { 'x-retry-after-ms' : '500' } ,
451+ requestBody : '{"cartId":"cart-1"}' ,
452+ responseBody : '{"error":"service unavailable"}' ,
453+ raw : 'network capture 1: {"error":"service unavailable"}' ,
454+ } ,
455+ {
456+ method : 'GET' ,
457+ url : 'https://api.example.test/checkout/2' ,
458+ status : 200 ,
459+ timestamp : '2026-07-02T12:00:01.000Z' ,
460+ durationMs : 137 ,
461+ packetId : 'packet-2' ,
462+ line : 3901 ,
463+ headers : 'content-type: application/json' ,
464+ requestBody : '' ,
465+ responseBody : 'ok' ,
466+ raw : 'network capture 2: ok' ,
467+ } ,
468+ ] ,
469+ notes : [ 'The first checkout request returned 503. Retry after the service recovery window.' ] ,
470+ warnings : [ 'Network capture omitted one malformed log line.' ] ,
471+ artifacts : [ { field : 'path' , artifactType : 'app-log' , artifactId : 'artifact-network-log' } ] ,
472+ } ;
473+
474+ test ( 'network view is registered' , ( ) => {
475+ expect ( typeof networkView ) . toBe ( 'function' ) ;
476+ } ) ;
477+
478+ test ( 'network digest keeps the whole dump + every entry identity, dropping only payload material' , ( ) => {
479+ const digest = networkView ! ( NETWORK_DATA , 'digest' ) ;
480+ // Top-level dump is preserved verbatim.
481+ for ( const key of [
482+ 'path' ,
483+ 'exists' ,
484+ 'active' ,
485+ 'state' ,
486+ 'backend' ,
487+ 'include' ,
488+ 'scannedLines' ,
489+ 'matchedLines' ,
490+ 'limits' ,
491+ 'notes' ,
492+ 'warnings' ,
493+ 'artifacts' ,
494+ ] as const ) {
495+ expect ( digest [ key ] ) . toEqual ( NETWORK_DATA [ key ] ) ;
496+ }
497+ const entries = digest . entries as Record < string , unknown > [ ] ;
498+ // No entry is dropped or reordered.
499+ expect ( entries ) . toHaveLength ( 2 ) ;
500+ // The failed request stays fully diagnosable.
501+ expect ( entries [ 0 ] ) . toEqual ( {
502+ method : 'POST' ,
503+ url : 'https://api.example.test/checkout/1' ,
504+ status : 503 ,
505+ timestamp : '2026-07-02T12:00:00.000Z' ,
506+ durationMs : 120 ,
507+ packetId : 'packet-1' ,
508+ line : 3900 ,
509+ metadata : { requestId : 'request-1' } ,
510+ } ) ;
511+ // Verbose payload material is gone from every entry.
512+ for ( const entry of entries ) {
513+ for ( const dropped of [
514+ 'headers' ,
515+ 'requestHeaders' ,
516+ 'responseHeaders' ,
517+ 'requestBody' ,
518+ 'responseBody' ,
519+ 'raw' ,
520+ ] ) {
521+ expect ( dropped in entry ) . toBe ( false ) ;
522+ }
523+ }
524+ } ) ;
525+
526+ test ( 'network default and full return today’s shape unchanged (same reference)' , ( ) => {
527+ expect ( networkView ! ( NETWORK_DATA , 'default' ) ) . toBe ( NETWORK_DATA ) ;
528+ expect ( networkView ! ( NETWORK_DATA , 'full' ) ) . toBe ( NETWORK_DATA ) ;
529+ } ) ;
530+
531+ test ( 'network digest tolerates a missing/empty entries list' , ( ) => {
532+ const empty : DaemonResponseData = { path : '/tmp/app.log' , exists : false } ;
533+ expect ( networkView ! ( empty , 'digest' ) ) . toBe ( empty ) ;
534+ const emptyList : DaemonResponseData = { path : '/tmp/app.log' , entries : [ ] } ;
535+ expect ( networkView ! ( emptyList , 'digest' ) ) . toEqual ( { path : '/tmp/app.log' , entries : [ ] } ) ;
536+ } ) ;
0 commit comments