@@ -84,12 +84,12 @@ test('diffSizeReports: notable is gated at exactly NOISE_THRESHOLD_BYTES', () =>
8484
8585test ( 'diffSizeReports: notable also triggers from ramDelta alone, and honors negative deltas via Math.abs' , ( ) => {
8686 const base = { MATEKF405 : { flash : 100000 , ram : 50000 } } ;
87- const pr = { MATEKF405 : { flash : 100000 , ram : 50000 - 40 } } ; // flash unchanged, ram shrank by 40
87+ const pr = { MATEKF405 : { flash : 100000 , ram : 50000 - 300 } } ; // flash unchanged, ram shrank by 300
8888 const row = diffSizeReports ( pr , base ) . find ( ( r ) => r . target === 'MATEKF405' ) ;
8989
9090 assert . equal ( row . flashDelta , 0 ) ;
91- assert . equal ( row . ramDelta , - 40 ) ;
92- assert . equal ( row . notable , true , 'a -40 ram delta exceeds the 32-byte threshold in magnitude' ) ;
91+ assert . equal ( row . ramDelta , - 300 ) ;
92+ assert . equal ( row . notable , true , 'a -300 ram delta exceeds NOISE_THRESHOLD_BYTES in magnitude' ) ;
9393} ) ;
9494
9595test ( 'diffSizeReports: target missing from PR report but present in baseline -> missing-from-pr' , ( ) => {
@@ -155,9 +155,9 @@ test('renderComment: baseline present, all 4 targets compared, mix of notable/no
155155 MATEKH743 : [ 530000 , 63000 ] ,
156156 } ) ;
157157 const prReport = fullReport ( {
158- MATEKF405 : [ 500100 , 60000 ] , // +100 flash -> notable
158+ MATEKF405 : [ 500300 , 60000 ] , // +300 flash -> notable
159159 MATEKF722 : [ 510010 , 61000 ] , // +10 flash -> not notable
160- MATEKF765 : [ 519960 , 62000 ] , // -40 flash -> notable
160+ MATEKF765 : [ 519700 , 62000 ] , // -300 flash -> notable
161161 MATEKH743 : [ 530000 , 63000 ] , // no change -> not notable
162162 } ) ;
163163
@@ -179,9 +179,9 @@ test('renderComment: baseline present, all 4 targets compared, mix of notable/no
179179 const matekf765Line = lines . find ( ( l ) => l . startsWith ( '| MATEKF765' ) ) ;
180180 const matekh743Line = lines . find ( ( l ) => l . startsWith ( '| MATEKH743' ) ) ;
181181
182- assert . ok ( matekf405Line . includes ( '⚠️' ) , 'MATEKF405 (+100 flash) should be flagged notable' ) ;
182+ assert . ok ( matekf405Line . includes ( '⚠️' ) , 'MATEKF405 (+300 flash) should be flagged notable' ) ;
183183 assert . ok ( ! matekf722Line . includes ( '⚠️' ) , 'MATEKF722 (+10 flash) should NOT be flagged notable' ) ;
184- assert . ok ( matekf765Line . includes ( '⚠️' ) , 'MATEKF765 (-40 flash) should be flagged notable' ) ;
184+ assert . ok ( matekf765Line . includes ( '⚠️' ) , 'MATEKF765 (-300 flash) should be flagged notable' ) ;
185185 assert . ok ( ! matekh743Line . includes ( '⚠️' ) , 'MATEKH743 (no change) should NOT be flagged notable' ) ;
186186
187187 // No "no baseline available" note when a baseline was supplied.
@@ -286,3 +286,72 @@ test('renderComment: result always ends with exactly one trailing newline', () =
286286 assert . ok ( body . endsWith ( '\n' ) ) ;
287287 assert . ok ( ! body . endsWith ( '\n\n' ) ) ;
288288} ) ;
289+
290+ // ---------------------------------------------------------------------------
291+ // renderComment: baseline-commit header
292+ // ---------------------------------------------------------------------------
293+
294+ test ( 'renderComment: baselineCommit supplied -> header names the baseline commit' , ( ) => {
295+ const body = renderComment ( {
296+ prReport : fullReport ( { MATEKF405 : [ 500000 , 60000 ] } ) ,
297+ baselineReport : fullReport ( { MATEKF405 : [ 499000 , 60000 ] } ) ,
298+ shortSha : 'abc1234' ,
299+ baselineCommit : '9e932ba' ,
300+ baselineIsNearest : false ,
301+ docLink : null ,
302+ marker : '<!-- marker -->' ,
303+ } ) ;
304+
305+ assert . ok ( body . includes ( 'vs. base commit `9e932ba`' ) , 'header should name the baseline commit' ) ;
306+ assert . ok ( body . includes ( 'commit `abc1234`' ) , 'header should still name the PR head commit' ) ;
307+ assert . ok ( ! body . includes ( 'vs. base branch' ) , 'exact baseline should not use the generic "base branch" wording' ) ;
308+ assert . ok ( ! body . includes ( 'nearest available size baseline' ) , 'exact baseline should not show the fallback note' ) ;
309+ assert . ok ( ! body . includes ( 'No size baseline is available yet' ) , 'baseline present means no "no baseline" note' ) ;
310+ } ) ;
311+
312+ test ( 'renderComment: baselineCommit + baselineIsNearest -> fallback note shown' , ( ) => {
313+ const body = renderComment ( {
314+ prReport : fullReport ( { MATEKF405 : [ 500000 , 60000 ] } ) ,
315+ baselineReport : fullReport ( { MATEKF405 : [ 499000 , 60000 ] } ) ,
316+ shortSha : 'abc1234' ,
317+ baselineCommit : '7f133b3' ,
318+ baselineIsNearest : true ,
319+ docLink : null ,
320+ marker : '<!-- marker -->' ,
321+ } ) ;
322+
323+ assert . ok ( body . includes ( 'vs. base commit `7f133b3`' ) , 'header should name the nearest baseline commit' ) ;
324+ assert . ok ( body . includes ( 'nearest available size baseline' ) , 'fallback note should explain the nearest-baseline choice' ) ;
325+ } ) ;
326+
327+ test ( 'renderComment: baselineCommit omitted -> generic "vs. base branch" wording kept' , ( ) => {
328+ const body = renderComment ( {
329+ prReport : fullReport ( { MATEKF405 : [ 500000 , 60000 ] } ) ,
330+ baselineReport : fullReport ( { MATEKF405 : [ 499000 , 60000 ] } ) ,
331+ shortSha : 'abc1234' ,
332+ docLink : null ,
333+ marker : '<!-- marker -->' ,
334+ } ) ;
335+
336+ assert . ok ( body . includes ( 'vs. base branch' ) , 'legacy callers without baselineCommit keep the old wording' ) ;
337+ assert . ok ( ! body . includes ( 'base commit `' ) , 'no baseline commit rendered when none supplied' ) ;
338+ } ) ;
339+
340+ test ( 'renderComment: baselineCommit supplied but no baseline report -> graceful note wins, no contradictory header' , ( ) => {
341+ // Defensive: the workflow only sets baselineCommit when a baseline was
342+ // found, so this combination should not occur; if it ever does, the
343+ // header must NOT claim a base commit was compared (no "vs. base
344+ // commit") and the "no baseline available" note must be present.
345+ const body = renderComment ( {
346+ prReport : fullReport ( { MATEKF405 : [ 500000 , 60000 ] } ) ,
347+ baselineReport : null ,
348+ shortSha : 'abc1234' ,
349+ baselineCommit : '9e932ba' ,
350+ docLink : null ,
351+ marker : '<!-- marker -->' ,
352+ } ) ;
353+
354+ assert . ok ( body . includes ( 'No size baseline is available yet' ) ) ;
355+ assert . ok ( ! body . includes ( 'vs. base commit `9e932ba`' ) , 'header must not name a baseline commit when no baseline exists' ) ;
356+ assert . ok ( body . includes ( 'vs. base branch' ) , 'header should fall back to the generic wording' ) ;
357+ } ) ;
0 commit comments