1
+ /* eslint-disable no-console */
1
2
import type { SetupContext , SetupPlugin } from '../src/setup'
2
3
import { afterEach , beforeEach , describe , expect , it } from 'bun:test'
3
4
import fs from 'node:fs'
@@ -44,12 +45,23 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
44
45
JIRA_PROJECT_KEY : process . env . JIRA_PROJECT_KEY ,
45
46
}
46
47
47
- // Clean up test environment variables
48
+ // Clean up test environment variables aggressively
48
49
delete process . env . SLACK_WEBHOOK_URL
49
50
delete process . env . DISCORD_WEBHOOK_URL
50
51
delete process . env . JIRA_API_TOKEN
51
52
delete process . env . JIRA_BASE_URL
52
53
delete process . env . JIRA_PROJECT_KEY
54
+
55
+ // Also check for any variations that might exist in CI
56
+ delete process . env . SLACK_WEBHOOK
57
+ delete process . env . DISCORD_WEBHOOK
58
+ delete process . env . JIRA_TOKEN
59
+ delete process . env . JIRA_URL
60
+
61
+ // Clean up any .buddy files that might exist
62
+ if ( fs . existsSync ( '.buddy' ) ) {
63
+ fs . rmSync ( '.buddy' , { recursive : true , force : true } )
64
+ }
53
65
} )
54
66
55
67
afterEach ( ( ) => {
@@ -98,21 +110,40 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
98
110
// In CI environments, there might be unexpected environment variables
99
111
// So instead of expecting specific counts, check that no built-in integration plugins exist
100
112
const integrationPlugins = plugins . filter ( p =>
101
- p . name === 'slack-integration' ||
102
- p . name === 'discord-integration' ||
103
- p . name === 'jira-integration'
113
+ p . name === 'slack-integration'
114
+ || p . name === 'discord-integration'
115
+ || p . name === 'jira-integration' ,
104
116
)
105
117
106
118
// Debug info for CI troubleshooting
107
119
if ( integrationPlugins . length > 0 ) {
108
120
console . log ( '🚨 Unexpected plugins found in clean environment:' )
109
- integrationPlugins . forEach ( p => {
121
+ console . log ( `Total plugins discovered: ${ plugins . length } ` )
122
+ console . log ( 'All discovered plugins:' )
123
+ plugins . forEach ( ( p , i ) => {
124
+ console . log ( ` ${ i + 1 } . ${ p . name } : enabled=${ p . enabled } , version=${ p . version } ` )
125
+ } )
126
+ console . log ( 'Integration plugins (should be 0):' )
127
+ integrationPlugins . forEach ( ( p ) => {
110
128
console . log ( ` - ${ p . name } : enabled=${ p . enabled } ` )
111
129
} )
112
130
console . log ( 'Environment check:' )
113
131
console . log ( ` - SLACK_WEBHOOK_URL: ${ process . env . SLACK_WEBHOOK_URL ? 'SET' : 'UNSET' } ` )
114
132
console . log ( ` - DISCORD_WEBHOOK_URL: ${ process . env . DISCORD_WEBHOOK_URL ? 'SET' : 'UNSET' } ` )
115
133
console . log ( ` - JIRA_API_TOKEN: ${ process . env . JIRA_API_TOKEN ? 'SET' : 'UNSET' } ` )
134
+ console . log ( ` - JIRA_BASE_URL: ${ process . env . JIRA_BASE_URL ? 'SET' : 'UNSET' } ` )
135
+ console . log ( ` - JIRA_PROJECT_KEY: ${ process . env . JIRA_PROJECT_KEY ? 'SET' : 'UNSET' } ` )
136
+ console . log ( 'File system check:' )
137
+ console . log ( ` - .buddy exists: ${ fs . existsSync ( '.buddy' ) } ` )
138
+ if ( fs . existsSync ( '.buddy' ) ) {
139
+ try {
140
+ const buddyFiles = fs . readdirSync ( '.buddy' , { recursive : true } )
141
+ console . log ( ' - .buddy contents:' , buddyFiles )
142
+ }
143
+ catch {
144
+ console . log ( ' - .buddy contents: error reading' )
145
+ }
146
+ }
116
147
}
117
148
118
149
expect ( integrationPlugins ) . toHaveLength ( 0 )
@@ -193,7 +224,6 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
193
224
priority : 15 ,
194
225
async : false ,
195
226
handler ( ) {
196
- // eslint-disable-next-line no-console
197
227
console . log ( 'Custom hook executed' )
198
228
} ,
199
229
} ,
@@ -216,7 +246,7 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
216
246
// Debug info for CI troubleshooting
217
247
if ( customPlugins . length === 0 ) {
218
248
console . log ( '🚨 Custom plugin not found. All discovered plugins:' )
219
- plugins . forEach ( p => {
249
+ plugins . forEach ( ( p ) => {
220
250
console . log ( ` - ${ p . name } : version=${ p . version } , enabled=${ p . enabled } ` )
221
251
} )
222
252
console . log ( 'Files in .buddy/plugins:' )
@@ -227,7 +257,8 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
227
257
// Read the custom plugin file to verify its contents
228
258
const content = fs . readFileSync ( '.buddy/plugins/custom-integration.json' , 'utf8' )
229
259
console . log ( 'Custom plugin file content:' , content )
230
- } catch ( err ) {
260
+ }
261
+ catch ( err ) {
231
262
console . log ( 'Error reading .buddy/plugins:' , err )
232
263
}
233
264
}
@@ -309,15 +340,15 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
309
340
310
341
// Filter out any plugins that might exist in CI environment, only check for integration plugins
311
342
const integrationPlugins = plugins . filter ( p =>
312
- p . name === 'slack-integration' ||
313
- p . name === 'discord-integration' ||
314
- p . name === 'jira-integration'
343
+ p . name === 'slack-integration'
344
+ || p . name === 'discord-integration'
345
+ || p . name === 'jira-integration' ,
315
346
)
316
347
317
348
// Debug info for CI troubleshooting
318
349
if ( integrationPlugins . length > 0 ) {
319
350
console . log ( '🚨 Unexpected plugins found after malformed plugin test:' )
320
- integrationPlugins . forEach ( p => {
351
+ integrationPlugins . forEach ( ( p ) => {
321
352
console . log ( ` - ${ p . name } : enabled=${ p . enabled } ` )
322
353
} )
323
354
}
0 commit comments