File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -435,6 +435,10 @@ it.effect("bounds the snapshot text even when nothing but logs and the title are
435435 } ;
436436 expect ( parsed . title . length ) . toBe ( 2_049 ) ;
437437 expect ( parsed . consoleEntries [ 0 ] ?. text . length ) . toBe ( 501 ) ;
438+ const notice = snapshot . content [ 1 ] ;
439+ const noticeText = notice ?. type === "text" ? notice . text : "" ;
440+ expect ( noticeText ) . toContain ( "url or title after 2048 characters" ) ;
441+ expect ( noticeText ) . toContain ( "console entries text after 500 characters" ) ;
438442 } ) ,
439443 ) . pipe ( Effect . provide ( TestLayer ) ) ,
440444) ;
Original file line number Diff line number Diff line change @@ -130,6 +130,11 @@ const cutEntryStrings = <A>(entry: A): A =>
130130 ) as A )
131131 : entry ;
132132
133+ const hasLongString = ( entry : unknown , max : number ) =>
134+ typeof entry === "object" &&
135+ entry !== null &&
136+ Object . values ( entry ) . some ( ( value ) => typeof value === "string" && value . length > max ) ;
137+
133138type SnapshotMetadata = {
134139 readonly url : string ;
135140 readonly title : string ;
@@ -162,8 +167,18 @@ const boundSnapshotMetadata = (
162167 if ( entries . length > MAX_SNAPSHOT_LOG_ENTRIES ) {
163168 omitted . push ( `${ entries . length - MAX_SNAPSHOT_LOG_ENTRIES } older ${ label } ` ) ;
164169 }
165- return entries . slice ( - MAX_SNAPSHOT_LOG_ENTRIES ) . map ( cutEntryStrings ) ;
170+ const kept = entries . slice ( - MAX_SNAPSHOT_LOG_ENTRIES ) ;
171+ if ( kept . some ( ( entry ) => hasLongString ( entry , MAX_SNAPSHOT_LOG_TEXT_CHARS ) ) ) {
172+ omitted . push ( `${ label } text after ${ MAX_SNAPSHOT_LOG_TEXT_CHARS } characters` ) ;
173+ }
174+ return kept . map ( cutEntryStrings ) ;
166175 } ;
176+ if (
177+ metadata . url . length > MAX_SNAPSHOT_IDENTIFIER_CHARS ||
178+ metadata . title . length > MAX_SNAPSHOT_IDENTIFIER_CHARS
179+ ) {
180+ omitted . push ( `url or title after ${ MAX_SNAPSHOT_IDENTIFIER_CHARS } characters` ) ;
181+ }
167182 if (
168183 metadata . interactiveElements . some (
169184 ( element ) => element . name . length > MAX_SNAPSHOT_ELEMENT_NAME_CHARS ,
You can’t perform that action at this time.
0 commit comments