@@ -58,10 +58,18 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
58
58
delete process . env . JIRA_TOKEN
59
59
delete process . env . JIRA_URL
60
60
61
- // Clean up any .buddy files that might exist
61
+ // Clean up any .buddy files that might exist (critical for plugin detection)
62
62
if ( fs . existsSync ( '.buddy' ) ) {
63
63
fs . rmSync ( '.buddy' , { recursive : true , force : true } )
64
64
}
65
+
66
+ // Also clean up specific plugin trigger files that might exist in the working directory
67
+ const pluginFiles = [ '.buddy/slack-webhook' , '.buddy/jira-config.json' , '.buddy/discord-webhook' ]
68
+ pluginFiles . forEach ( ( file ) => {
69
+ if ( fs . existsSync ( file ) ) {
70
+ fs . rmSync ( file , { force : true } )
71
+ }
72
+ } )
65
73
} )
66
74
67
75
afterEach ( ( ) => {
@@ -70,6 +78,14 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
70
78
fs . rmSync ( '.buddy' , { recursive : true , force : true } )
71
79
}
72
80
81
+ // Clean up specific plugin trigger files
82
+ const pluginFiles = [ '.buddy/slack-webhook' , '.buddy/jira-config.json' , '.buddy/discord-webhook' ]
83
+ pluginFiles . forEach ( ( file ) => {
84
+ if ( fs . existsSync ( file ) ) {
85
+ fs . rmSync ( file , { force : true } )
86
+ }
87
+ } )
88
+
73
89
// Restore original environment variables
74
90
if ( originalEnv . SLACK_WEBHOOK_URL !== undefined ) {
75
91
process . env . SLACK_WEBHOOK_URL = originalEnv . SLACK_WEBHOOK_URL
@@ -135,6 +151,9 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
135
151
console . log ( ` - JIRA_PROJECT_KEY: ${ process . env . JIRA_PROJECT_KEY ? 'SET' : 'UNSET' } ` )
136
152
console . log ( 'File system check:' )
137
153
console . log ( ` - .buddy exists: ${ fs . existsSync ( '.buddy' ) } ` )
154
+ console . log ( ` - .buddy/slack-webhook exists: ${ fs . existsSync ( '.buddy/slack-webhook' ) } ` )
155
+ console . log ( ` - .buddy/jira-config.json exists: ${ fs . existsSync ( '.buddy/jira-config.json' ) } ` )
156
+ console . log ( ` - .buddy/discord-webhook exists: ${ fs . existsSync ( '.buddy/discord-webhook' ) } ` )
138
157
if ( fs . existsSync ( '.buddy' ) ) {
139
158
try {
140
159
const buddyFiles = fs . readdirSync ( '.buddy' , { recursive : true } )
@@ -211,7 +230,7 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
211
230
expect ( process . env . DISCORD_WEBHOOK_URL ) . toBeUndefined ( )
212
231
expect ( process . env . JIRA_API_TOKEN ) . toBeUndefined ( )
213
232
214
- // Create custom plugin configuration
233
+ // Create custom plugin configuration (without handler function since it can't be serialized)
215
234
fs . mkdirSync ( '.buddy/plugins' , { recursive : true } )
216
235
const customPlugin = {
217
236
name : 'custom-integration' ,
@@ -223,18 +242,20 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
223
242
name : 'custom-hook' ,
224
243
priority : 15 ,
225
244
async : false ,
226
- handler ( ) {
227
- console . log ( 'Custom hook executed' )
228
- } ,
245
+ // Note: handler function would be loaded dynamically in real usage
229
246
} ,
230
247
] ,
231
248
configuration : { custom_setting : 'value' } ,
232
249
}
233
250
234
- fs . writeFileSync (
235
- path . join ( '.buddy/plugins' , 'custom.json' ) ,
236
- JSON . stringify ( customPlugin ) ,
237
- )
251
+ const customPluginPath = path . join ( '.buddy/plugins' , 'custom.json' )
252
+ fs . writeFileSync ( customPluginPath , JSON . stringify ( customPlugin ) )
253
+
254
+ // Verify the file was written correctly
255
+ expect ( fs . existsSync ( customPluginPath ) ) . toBe ( true )
256
+ const writtenContent = fs . readFileSync ( customPluginPath , 'utf8' )
257
+ const parsedContent = JSON . parse ( writtenContent )
258
+ expect ( parsedContent ) . toEqual ( customPlugin )
238
259
239
260
// Create a fresh PluginManager instance to avoid state pollution
240
261
const freshPluginManager = new PluginManager ( )
@@ -254,13 +275,25 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
254
275
const files = fs . readdirSync ( '.buddy/plugins' )
255
276
files . forEach ( f => console . log ( ` - ${ f } ` ) )
256
277
257
- // Read the custom plugin file to verify its contents
258
- const content = fs . readFileSync ( '.buddy/plugins/custom-integration.json' , 'utf8' )
259
- console . log ( 'Custom plugin file content:' , content )
278
+ // Read the custom plugin file to verify its contents (use correct filename)
279
+ const content = fs . readFileSync ( '.buddy/plugins/custom.json' , 'utf8' )
280
+ console . log ( 'Custom plugin file content:' , content . substring ( 0 , 200 ) )
281
+ const parsed = JSON . parse ( content )
282
+ console . log ( 'Parsed plugin name:' , parsed . name )
260
283
}
261
284
catch ( err ) {
262
285
console . log ( 'Error reading .buddy/plugins:' , err )
263
286
}
287
+
288
+ // Test the loadCustomPlugins method directly
289
+ try {
290
+ const directPlugins = await freshPluginManager . loadCustomPlugins ( )
291
+ console . log ( 'Direct loadCustomPlugins result:' , directPlugins . length )
292
+ directPlugins . forEach ( p => console . log ( ` Direct: ${ p . name } ` ) )
293
+ }
294
+ catch ( err ) {
295
+ console . log ( 'Direct loadCustomPlugins error:' , err )
296
+ }
264
297
}
265
298
266
299
expect ( customPlugins ) . toHaveLength ( 1 )
0 commit comments