11import { describe , it , expect , beforeEach , afterEach , vi } from "vitest" ;
22import fs from "fs" ;
3- import os from "os" ;
4- import path from "path" ;
53
64// Mock the global objects that GitHub Actions provides
75const mockCore = {
@@ -22,9 +20,7 @@ global.core = mockCore;
2220
2321describe ( "generate_workflow_overview.cjs" , ( ) => {
2422 let generateWorkflowOverview ;
25- let tmpDir ;
2623 let awInfoPath ;
27- let originalRequireCache ;
2824
2925 beforeEach ( async ( ) => {
3026 // Reset mocks
@@ -54,6 +50,7 @@ describe("generate_workflow_overview.cjs", () => {
5450 engine_id : "copilot" ,
5551 engine_name : "GitHub Copilot" ,
5652 model : "gpt-4" ,
53+ version : "v1.2.3" ,
5754 firewall_enabled : true ,
5855 awf_version : "1.0.0" ,
5956 allowed_domains : [ ] ,
@@ -67,19 +64,22 @@ describe("generate_workflow_overview.cjs", () => {
6764
6865 const summaryArg = mockCore . summary . addRaw . mock . calls [ 0 ] [ 0 ] ;
6966 expect ( summaryArg ) . toContain ( "<details>" ) ;
70- expect ( summaryArg ) . toContain ( "<summary>Run details</summary>" ) ;
71- expect ( summaryArg ) . toContain ( "#### Engine Configuration" ) ;
72- expect ( summaryArg ) . toContain ( "| Engine ID | copilot |" ) ;
73- expect ( summaryArg ) . toContain ( "| Engine Name | GitHub Copilot |" ) ;
74- expect ( summaryArg ) . toContain ( "| Model | gpt-4 |" ) ;
75- expect ( summaryArg ) . toContain ( "#### Network Configuration" ) ;
76- expect ( summaryArg ) . toContain ( "| Firewall | ✅ Enabled |" ) ;
77- expect ( summaryArg ) . toContain ( "| Firewall Version | 1.0.0 |" ) ;
67+ // engine_id and version should appear in the summary label
68+ expect ( summaryArg ) . toContain ( "<summary>Run details - copilot v1.2.3</summary>" ) ;
69+ // All fields should be rendered as bullet points with humanified keys
70+ expect ( summaryArg ) . toContain ( "- **engine id**: copilot" ) ;
71+ expect ( summaryArg ) . toContain ( "- **engine name**: GitHub Copilot" ) ;
72+ expect ( summaryArg ) . toContain ( "- **model**: gpt-4" ) ;
73+ expect ( summaryArg ) . toContain ( "- **version**: v1.2.3" ) ;
74+ expect ( summaryArg ) . toContain ( "- **firewall enabled**: true" ) ;
75+ expect ( summaryArg ) . toContain ( "- **awf version**: 1.0.0" ) ;
7876 expect ( summaryArg ) . toContain ( "</details>" ) ;
77+ // Ensure no table syntax is present
78+ expect ( summaryArg ) . not . toContain ( "| Property | Value |" ) ;
79+ expect ( summaryArg ) . not . toContain ( "|----------|-------|" ) ;
7980 } ) ;
8081
81- it ( "should handle missing optional fields with defaults" , async ( ) => {
82- // Create test aw_info.json with minimal fields
82+ it ( "should show only engine_id in summary label when version is missing" , async ( ) => {
8383 const awInfo = {
8484 engine_id : "claude" ,
8585 engine_name : "Claude" ,
@@ -90,62 +90,41 @@ describe("generate_workflow_overview.cjs", () => {
9090 await generateWorkflowOverview ( mockCore ) ;
9191
9292 const summaryArg = mockCore . summary . addRaw . mock . calls [ 0 ] [ 0 ] ;
93- expect ( summaryArg ) . toContain ( "| Model | (default) |" ) ;
94- expect ( summaryArg ) . toContain ( "| Firewall | ❌ Disabled |" ) ;
95- expect ( summaryArg ) . toContain ( "| Firewall Version | (latest) |" ) ;
96- } ) ;
97-
98- it ( "should include allowed domains when present (up to 10)" , async ( ) => {
99- const awInfo = {
100- engine_id : "copilot" ,
101- engine_name : "GitHub Copilot" ,
102- firewall_enabled : true ,
103- allowed_domains : [ "example.com" , "github.com" , "api.github.com" ] ,
104- } ;
105- fs . writeFileSync ( awInfoPath , JSON . stringify ( awInfo ) ) ;
106-
107- await generateWorkflowOverview ( mockCore ) ;
108-
109- const summaryArg = mockCore . summary . addRaw . mock . calls [ 0 ] [ 0 ] ;
110- expect ( summaryArg ) . toContain ( "##### Allowed Domains" ) ;
111- expect ( summaryArg ) . toContain ( " - example.com" ) ;
112- expect ( summaryArg ) . toContain ( " - github.com" ) ;
113- expect ( summaryArg ) . toContain ( " - api.github.com" ) ;
93+ expect ( summaryArg ) . toContain ( "<summary>Run details - claude</summary>" ) ;
94+ expect ( summaryArg ) . toContain ( "- **engine id**: claude" ) ;
95+ expect ( summaryArg ) . toContain ( "- **firewall enabled**: false" ) ;
11496 } ) ;
11597
116- it ( "should truncate allowed domains list when more than 10" , async ( ) => {
117- const domains = Array . from ( { length : 15 } , ( _ , i ) => `domain${ i + 1 } .com` ) ;
98+ it ( "should show plain 'Run details' in summary label when both engine_id and version are missing" , async ( ) => {
11899 const awInfo = {
119- engine_id : "copilot" ,
120- engine_name : "GitHub Copilot" ,
121- firewall_enabled : true ,
122- allowed_domains : domains ,
100+ engine_name : "Unknown Engine" ,
123101 } ;
124102 fs . writeFileSync ( awInfoPath , JSON . stringify ( awInfo ) ) ;
125103
126104 await generateWorkflowOverview ( mockCore ) ;
127105
128106 const summaryArg = mockCore . summary . addRaw . mock . calls [ 0 ] [ 0 ] ;
129- expect ( summaryArg ) . toContain ( "##### Allowed Domains" ) ;
130- expect ( summaryArg ) . toContain ( " - domain1.com" ) ;
131- expect ( summaryArg ) . toContain ( " - domain10.com" ) ;
132- expect ( summaryArg ) . toContain ( " - ... and 5 more" ) ;
133- expect ( summaryArg ) . not . toContain ( "domain11.com" ) ;
107+ expect ( summaryArg ) . toContain ( "<summary>Run details</summary>" ) ;
134108 } ) ;
135109
136- it ( "should not include Allowed Domains section when empty " , async ( ) => {
110+ it ( "should render all fields from aw_info including nested objects and arrays " , async ( ) => {
137111 const awInfo = {
138112 engine_id : "copilot" ,
139- engine_name : "GitHub Copilot " ,
140- firewall_enabled : false ,
141- allowed_domains : [ ] ,
113+ version : "v2.0.0 " ,
114+ allowed_domains : [ "example.com" , "github.com" ] ,
115+ steps : { firewall : "iptables" } ,
142116 } ;
143117 fs . writeFileSync ( awInfoPath , JSON . stringify ( awInfo ) ) ;
144118
145119 await generateWorkflowOverview ( mockCore ) ;
146120
147121 const summaryArg = mockCore . summary . addRaw . mock . calls [ 0 ] [ 0 ] ;
148- expect ( summaryArg ) . not . toContain ( "##### Allowed Domains" ) ;
122+ expect ( summaryArg ) . toContain ( "- **engine id**: copilot" ) ;
123+ expect ( summaryArg ) . toContain ( "- **allowed domains**:" ) ;
124+ expect ( summaryArg ) . toContain ( " - example.com" ) ;
125+ expect ( summaryArg ) . toContain ( " - github.com" ) ;
126+ expect ( summaryArg ) . toContain ( "- **steps**:" ) ;
127+ expect ( summaryArg ) . toContain ( " - **firewall**: iptables" ) ;
149128 } ) ;
150129
151130 it ( "should log success message" , async ( ) => {
0 commit comments