@@ -4644,7 +4644,8 @@ describe("capDirectTextContent", () => {
46444644 const capped = testing . capDirectTextContent ( longText ) ;
46454645
46464646 expect ( capped . length ) . toBeLessThanOrEqual ( 4000 ) ;
4647- expect ( capped ) . toContain ( "... [truncated 1000 chars] ..." ) ;
4647+ // 5000 chars - 2600 head - 1000 tail = 1400 omitted (not 1000)
4648+ expect ( capped ) . toContain ( "... [truncated 1400 chars] ..." ) ;
46484649 expect ( capped . startsWith ( "x" . repeat ( 2600 ) ) ) . toBe ( true ) ;
46494650 expect ( capped . endsWith ( "x" . repeat ( 1000 ) ) ) . toBe ( true ) ;
46504651 } ) ;
@@ -4659,7 +4660,8 @@ describe("capDirectTextContent", () => {
46594660 const text = "z" . repeat ( 3000 ) ;
46604661 const capped = testing . capDirectTextContent ( text , 2000 ) ;
46614662 expect ( capped . length ) . toBeLessThanOrEqual ( 2000 ) ;
4662- expect ( capped ) . toContain ( "... [truncated 1000 chars] ..." ) ;
4663+ // 3000 chars - 1300 head (0.65*2000) - 500 tail (0.25*2000) = 1200 omitted
4664+ expect ( capped ) . toContain ( "... [truncated 1200 chars] ..." ) ;
46634665 } ) ;
46644666
46654667 it ( "handles edge case of exactly maxChars" , ( ) => {
@@ -4668,6 +4670,16 @@ describe("capDirectTextContent", () => {
46684670 expect ( capped ) . toBe ( text ) ;
46694671 expect ( capped . length ) . toBe ( 4000 ) ;
46704672 } ) ;
4673+
4674+ it ( "reports accurate omitted count for head+tail cap (regression for misleading marker)" , ( ) => {
4675+ // 5000 chars, cap 4000 → head 2600 + tail 1000 = 3600 kept, 1400 omitted.
4676+ const text = "z" . repeat ( 5000 ) ;
4677+ const capped = testing . capDirectTextContent ( text ) ;
4678+ const match = capped . match ( / \[ t r u n c a t e d ( \d + ) c h a r s \] / ) ;
4679+ expect ( match ) . not . toBeNull ( ) ;
4680+ const reported = Number ( match ?. [ 1 ] ) ;
4681+ expect ( reported ) . toBe ( 1400 ) ;
4682+ } ) ;
46714683} ) ;
46724684
46734685/**
@@ -4860,7 +4872,7 @@ describe("active wake failure fallback", () => {
48604872
48614873 expect ( sendMessage ) . toHaveBeenCalledWith (
48624874 expect . objectContaining ( {
4863- content : expect . stringContaining ( "... [truncated 2000 chars] ..." ) ,
4875+ content : expect . stringContaining ( "... [truncated 2400 chars] ..." ) ,
48644876 } ) ,
48654877 ) ;
48664878 } ) ;
0 commit comments