@@ -92,7 +92,7 @@ func GenerateGitHubSummaryMarkdown(w io.Writer, testReport *TestReport, maxPassR
9292 }
9393
9494 settingsTable := buildSettingsTable (testReport , maxPassRatio )
95- printTable (w , settingsTable )
95+ printTable (w , settingsTable , false )
9696 fmt .Fprintln (w )
9797
9898 summary := GenerateSummaryData (testReport .Results , maxPassRatio )
@@ -102,14 +102,20 @@ func GenerateGitHubSummaryMarkdown(w io.Writer, testReport *TestReport, maxPassR
102102 fmt .Fprintln (w , "## No Flakes Found :white_check_mark:" )
103103 }
104104
105- RenderResults (w , testReport .Results , maxPassRatio , true )
105+ RenderResults (w , testReport .Results , maxPassRatio , true , false )
106106
107107 if artifactLink != "" {
108108 renderArtifactSection (w , artifactName , artifactLink )
109109 }
110110}
111111
112- func GeneratePRCommentMarkdown (w io.Writer , testReport * TestReport , maxPassRatio float64 , baseBranch , currentBranch , currentCommitSHA , repoURL , actionRunID , artifactName , artifactLink string ) {
112+ // GeneratePRCommentMarkdown generates a markdown summary of the test results for a GitHub PR comment.
113+ func GeneratePRCommentMarkdown (
114+ w io.Writer ,
115+ testReport * TestReport ,
116+ maxPassRatio float64 ,
117+ baseBranch , currentBranch , currentCommitSHA , repoURL , actionRunID , artifactName , artifactLink string ,
118+ ) {
113119 fmt .Fprint (w , "# Flakeguard Summary\n \n " )
114120
115121 if len (testReport .Results ) == 0 {
@@ -146,7 +152,7 @@ func GeneratePRCommentMarkdown(w io.Writer, testReport *TestReport, maxPassRatio
146152 }
147153
148154 resultsTable := GenerateFlakyTestsTable (testReport .Results , maxPassRatio , true )
149- renderTestResultsTable (w , resultsTable )
155+ renderTestResultsTable (w , resultsTable , true )
150156
151157 if artifactLink != "" {
152158 renderArtifactSection (w , artifactName , artifactLink )
@@ -170,19 +176,24 @@ func buildSettingsTable(testReport *TestReport, maxPassRatio float64) [][]string
170176 return rows
171177}
172178
179+ // RenderResults renders the test results into a console or markdown format.
180+ // If in markdown mode, the table results can also be made collapsible.
173181func RenderResults (
174182 w io.Writer ,
175183 tests []TestResult ,
176184 maxPassRatio float64 ,
177185 markdown bool ,
186+ collapsible bool ,
178187) {
179188 resultsTable := GenerateFlakyTestsTable (tests , maxPassRatio , markdown )
180189 summary := GenerateSummaryData (tests , maxPassRatio )
181- renderSummaryTable (w , summary , markdown )
182- renderTestResultsTable (w , resultsTable )
190+ renderSummaryTable (w , summary , markdown , false ) // Don't make the summary collapsible
191+ renderTestResultsTable (w , resultsTable , collapsible )
183192}
184193
185- func renderSummaryTable (w io.Writer , summary SummaryData , markdown bool ) {
194+ // renderSummaryTable renders a summary table with the given data into a console or markdown format.
195+ // If in markdown mode, the table can also be made collapsible.
196+ func renderSummaryTable (w io.Writer , summary SummaryData , markdown bool , collapsible bool ) {
186197 summaryData := [][]string {
187198 {"Category" , "Total" },
188199 {"Tests" , fmt .Sprintf ("%d" , summary .TotalTests )},
@@ -205,16 +216,16 @@ func renderSummaryTable(w io.Writer, summary SummaryData, markdown bool) {
205216 }
206217 }
207218 }
208- printTable (w , summaryData )
219+ printTable (w , summaryData , collapsible && markdown )
209220 fmt .Fprintln (w )
210221}
211222
212- func renderTestResultsTable (w io.Writer , table [][]string ) {
223+ func renderTestResultsTable (w io.Writer , table [][]string , collapsible bool ) {
213224 if len (table ) <= 1 {
214225 fmt .Fprintln (w , "No tests found under the specified pass ratio threshold." )
215226 return
216227 }
217- printTable (w , table )
228+ printTable (w , table , collapsible )
218229}
219230
220231func renderArtifactSection (w io.Writer , artifactName , artifactLink string ) {
@@ -226,16 +237,27 @@ func renderArtifactSection(w io.Writer, artifactName, artifactLink string) {
226237 }
227238}
228239
229- func printTable (w io.Writer , table [][]string ) {
240+ // printTable prints a markdown table to the given writer in a pretty format.
241+ func printTable (w io.Writer , table [][]string , collapsible bool ) {
230242 colWidths := calculateColumnWidths (table )
231243 separator := buildSeparator (colWidths )
232244
245+ if collapsible {
246+ numResults := len (table ) - 1
247+ fmt .Fprintln (w , "<details>" )
248+ fmt .Fprintf (w , "<summary>%d Results</summary>\n \n " , numResults )
249+ }
250+
233251 for i , row := range table {
234252 printRow (w , row , colWidths )
235253 if i == 0 {
236254 fmt .Fprintln (w , separator )
237255 }
238256 }
257+
258+ if collapsible {
259+ fmt .Fprintln (w , "</details>" )
260+ }
239261}
240262
241263func calculateColumnWidths (table [][]string ) []int {
0 commit comments