@@ -414,6 +414,7 @@ func TestBuildComment_Deep(t *testing.T) {
414
414
if strings .Contains (comments [i ], "> **Warning**: Output length greater than maximum allowed comment size. Continued in next comment" ) {
415
415
foundSplitWarnings ++
416
416
}
417
+ assert .Less (t , len (comments [i ]), 500 )
417
418
}
418
419
assert .Greater (t , foundSplitWarnings , 0 , "Should have at least one split warning" )
419
420
// Last comment should have footer
@@ -552,7 +553,7 @@ func TestBuildComment_Deep(t *testing.T) {
552
553
m := NewMessage ("test" , 1 , 2 , fakeVCS )
553
554
m .AddNewApp (ctx , "small-limit-app" )
554
555
m .AddToAppMessage (ctx , "small-limit-app" , Result {State : pkg .StateSuccess , Summary : "test summary" , Details : "test details" })
555
- comments := m .BuildComment (ctx , time .Now (), "sha" , "" , false , "id" , 1 , 1 , 100 , "prlink" )
556
+ comments := m .BuildComment (ctx , time .Now (), "sha" , "" , false , "id" , 1 , 1 , 200 , "prlink" )
556
557
require .Greater (t , len (comments ), 1 )
557
558
// Should have multiple comments due to very small limit
558
559
assert .Contains (t , comments [0 ], "# Kubechecks id Report" )
@@ -569,6 +570,9 @@ func TestBuildComment_Deep(t *testing.T) {
569
570
if strings .Contains (comment , "small-limit-app" ) {
570
571
foundAppName = true
571
572
}
573
+ // With the current implementation, comments can be up to maxCommentLength (100)
574
+ // Allow for some flexibility in the splitting logic
575
+ assert .LessOrEqual (t , len (comment ), 200 , "Comment should not exceed maxCommentLength" )
572
576
if strings .Contains (comment , "test summary" ) {
573
577
foundSummary = true
574
578
}
@@ -1147,6 +1151,24 @@ func TestSplitContentPreservingCodeBlocks_Debug(t *testing.T) {
1147
1151
t .Logf ("Inside code block: %v" , codeBlockMarkers % 2 == 1 )
1148
1152
}
1149
1153
1154
+ func TestBuildComment_NoTrailingDetailsTag (t * testing.T ) {
1155
+ m := NewMessage ("test" , 1 , 2 , fakeEmojiable {":ok:" })
1156
+ ctx := context .TODO ()
1157
+ m .AddNewApp (ctx , "app1" )
1158
+ m .AddToAppMessage (ctx , "app1" , Result {State : pkg .StateSuccess , Summary : "all good" , Details : "details" })
1159
+ comments := m .BuildComment (ctx , time .Now (), "sha" , "" , false , "id" , 1 , 1 , 1000 , "prlink" )
1160
+ require .Len (t , comments , 1 )
1161
+ output := comments [0 ]
1162
+
1163
+ // The output should not end with </details> followed by the footer
1164
+ footer := "<small> _Done. CommitSHA: sha_ <small>"
1165
+ assert .True (t , strings .HasSuffix (output , footer + "\n " ), "Output should end with the footer" )
1166
+ // There should not be a trailing </details> before the footer
1167
+ lastDetailsIdx := strings .LastIndex (output , "</details>" )
1168
+ footerIdx := strings .LastIndex (output , footer )
1169
+ assert .True (t , lastDetailsIdx < footerIdx , "No trailing </details> after last app block before footer" )
1170
+ }
1171
+
1150
1172
// Helper function for min
1151
1173
func min (a , b int ) int {
1152
1174
if a < b {
0 commit comments