1+ import { readFileSync } from "node:fs" ;
12import { describe , it , expect , beforeEach } from "vitest" ;
23
34describe ( "missing_messages_helper.cjs" , ( ) => {
@@ -9,6 +10,14 @@ describe("missing_messages_helper.cjs", () => {
910 helper . setCollectedMissings ( null ) ;
1011 } ) ;
1112
13+ describe ( "source metadata" , ( ) => {
14+ it ( "should keep TypeScript checking enabled" , ( ) => {
15+ const source = readFileSync ( new URL ( "./missing_messages_helper.cjs" , import . meta. url ) , "utf8" ) ;
16+
17+ expect ( source . split ( / \r ? \n / , 1 ) [ 0 ] ) . toBe ( "// @ts-check" ) ;
18+ } ) ;
19+ } ) ;
20+
1221 describe ( "setCollectedMissings and getCollectedMissings" , ( ) => {
1322 it ( "should store and retrieve missing messages" , ( ) => {
1423 const { setCollectedMissings, getCollectedMissings } = helper ;
@@ -115,5 +124,68 @@ describe("missing_messages_helper.cjs", () => {
115124 expect ( result ) . toContain ( "Missing Data" ) ;
116125 expect ( result ) . toContain ( "config" ) ;
117126 } ) ;
127+
128+ it ( "should handle noopMessages" , ( ) => {
129+ const { setCollectedMissings, getMissingInfoSections } = helper ;
130+ const missings = {
131+ missingTools : [ ] ,
132+ missingData : [ ] ,
133+ noopMessages : [ { message : "No action needed" } ] ,
134+ reportIncomplete : [ ] ,
135+ } ;
136+
137+ setCollectedMissings ( missings ) ;
138+ const result = getMissingInfoSections ( ) ;
139+
140+ expect ( result ) . toContain ( "No action needed" ) ;
141+ } ) ;
142+
143+ it ( "should handle reportIncomplete messages" , ( ) => {
144+ const { setCollectedMissings, getMissingInfoSections } = helper ;
145+ const missings = {
146+ missingTools : [ ] ,
147+ missingData : [ ] ,
148+ reportIncomplete : [ { reason : "Task not finished" } ] ,
149+ } ;
150+
151+ setCollectedMissings ( missings ) ;
152+ const result = getMissingInfoSections ( ) ;
153+
154+ expect ( result ) . toContain ( "Task not finished" ) ;
155+ } ) ;
156+
157+ it ( "should handle all fields simultaneously" , ( ) => {
158+ const { setCollectedMissings, getMissingInfoSections } = helper ;
159+ const missings = {
160+ missingTools : [ { tool : "docker" , reason : "Containers needed" } ] ,
161+ missingData : [ { data_type : "token" , reason : "Auth required" } ] ,
162+ noopMessages : [ { message : "Skipped step" } ] ,
163+ reportIncomplete : [ { reason : "Partial completion" } ] ,
164+ } ;
165+
166+ setCollectedMissings ( missings ) ;
167+ const result = getMissingInfoSections ( ) ;
168+
169+ expect ( result ) . toContain ( "Missing Tools" ) ;
170+ expect ( result ) . toContain ( "Missing Data" ) ;
171+ expect ( result ) . toContain ( "No-Op Messages" ) ;
172+ expect ( result ) . toContain ( "Incomplete Signals" ) ;
173+ expect ( result ) . toContain ( "docker" ) ;
174+ expect ( result ) . toContain ( "token" ) ;
175+ expect ( result ) . toContain ( "Skipped step" ) ;
176+ expect ( result ) . toContain ( "Partial completion" ) ;
177+ } ) ;
178+
179+ it ( "should reflect updates after setCollectedMissings is called again" , ( ) => {
180+ const { setCollectedMissings, getMissingInfoSections } = helper ;
181+
182+ setCollectedMissings ( { missingTools : [ { tool : "npm" , reason : "Build tool" } ] , missingData : [ ] } ) ;
183+ const first = getMissingInfoSections ( ) ;
184+ expect ( first ) . toContain ( "npm" ) ;
185+
186+ setCollectedMissings ( { missingTools : [ ] , missingData : [ ] } ) ;
187+ const second = getMissingInfoSections ( ) ;
188+ expect ( second ) . toBe ( "" ) ;
189+ } ) ;
118190 } ) ;
119191} ) ;
0 commit comments