Skip to content

Commit ce053ce

Browse files
committed
chore: wip
1 parent 72e2aca commit ce053ce

File tree

2 files changed

+70
-25
lines changed

2 files changed

+70
-25
lines changed

test/plugin-architecture.test.ts

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
import type { SetupContext, SetupPlugin } from '../src/setup'
23
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
34
import fs from 'node:fs'
@@ -44,12 +45,23 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
4445
JIRA_PROJECT_KEY: process.env.JIRA_PROJECT_KEY,
4546
}
4647

47-
// Clean up test environment variables
48+
// Clean up test environment variables aggressively
4849
delete process.env.SLACK_WEBHOOK_URL
4950
delete process.env.DISCORD_WEBHOOK_URL
5051
delete process.env.JIRA_API_TOKEN
5152
delete process.env.JIRA_BASE_URL
5253
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+
}
5365
})
5466

5567
afterEach(() => {
@@ -98,21 +110,40 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
98110
// In CI environments, there might be unexpected environment variables
99111
// So instead of expecting specific counts, check that no built-in integration plugins exist
100112
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',
104116
)
105117

106118
// Debug info for CI troubleshooting
107119
if (integrationPlugins.length > 0) {
108120
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) => {
110128
console.log(` - ${p.name}: enabled=${p.enabled}`)
111129
})
112130
console.log('Environment check:')
113131
console.log(` - SLACK_WEBHOOK_URL: ${process.env.SLACK_WEBHOOK_URL ? 'SET' : 'UNSET'}`)
114132
console.log(` - DISCORD_WEBHOOK_URL: ${process.env.DISCORD_WEBHOOK_URL ? 'SET' : 'UNSET'}`)
115133
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+
}
116147
}
117148

118149
expect(integrationPlugins).toHaveLength(0)
@@ -193,7 +224,6 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
193224
priority: 15,
194225
async: false,
195226
handler() {
196-
// eslint-disable-next-line no-console
197227
console.log('Custom hook executed')
198228
},
199229
},
@@ -216,7 +246,7 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
216246
// Debug info for CI troubleshooting
217247
if (customPlugins.length === 0) {
218248
console.log('🚨 Custom plugin not found. All discovered plugins:')
219-
plugins.forEach(p => {
249+
plugins.forEach((p) => {
220250
console.log(` - ${p.name}: version=${p.version}, enabled=${p.enabled}`)
221251
})
222252
console.log('Files in .buddy/plugins:')
@@ -227,7 +257,8 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
227257
// Read the custom plugin file to verify its contents
228258
const content = fs.readFileSync('.buddy/plugins/custom-integration.json', 'utf8')
229259
console.log('Custom plugin file content:', content)
230-
} catch (err) {
260+
}
261+
catch (err) {
231262
console.log('Error reading .buddy/plugins:', err)
232263
}
233264
}
@@ -309,15 +340,15 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
309340

310341
// Filter out any plugins that might exist in CI environment, only check for integration plugins
311342
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',
315346
)
316347

317348
// Debug info for CI troubleshooting
318349
if (integrationPlugins.length > 0) {
319350
console.log('🚨 Unexpected plugins found after malformed plugin test:')
320-
integrationPlugins.forEach(p => {
351+
integrationPlugins.forEach((p) => {
321352
console.log(` - ${p.name}: enabled=${p.enabled}`)
322353
})
323354
}

test/respect-latest.test.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
import type { BuddyBotConfig } from '../src/types'
23
import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
34
import fs from 'node:fs'
@@ -120,26 +121,39 @@ devDependencies:
120121
originalContent = depsYaml
121122
}
122123

124+
// Debug info for CI troubleshooting - Check before calling updateDependencyFile
125+
console.log('🔍 Test setup verification:')
126+
console.log(' - File path:', depsPath)
127+
console.log(' - File exists:', fs.existsSync(depsPath))
128+
console.log(' - Original content preview:', originalContent.substring(0, 100))
129+
// eslint-disable-next-line ts/no-require-imports
130+
console.log(' - isDependencyFile result:', require('../src/utils/dependency-file-parser').isDependencyFile(depsPath))
131+
123132
// Test that dynamic versions are respected (not updated)
124133
const updatedContent = await updateDependencyFile(depsPath, originalContent, updates)
125134

126135
// Debug info for CI troubleshooting
127136
if (!updatedContent.includes('python.org: "*"')) {
128137
console.log('🚨 Expected deps.yaml format, but got different format:')
129-
console.log('File path:', depsPath)
130-
console.log('Original content length:', originalContent.length)
131-
console.log('Original content:', originalContent.substring(0, 200))
132138
console.log('Updated content length:', updatedContent.length)
133-
console.log('Updated content:', updatedContent.substring(0, 500))
134-
console.log('File exists:', fs.existsSync(depsPath))
135-
136-
// Check if ts-pkgx can resolve this file
137-
try {
138-
const { resolveDependencyFile } = await import('ts-pkgx')
139-
const resolved = await resolveDependencyFile(depsPath)
140-
console.log('ts-pkgx resolved:', resolved ? 'SUCCESS' : 'NULL')
141-
} catch (err) {
142-
console.log('ts-pkgx error:', err)
139+
console.log('Updated content preview:', updatedContent.substring(0, 500))
140+
141+
// Check if the file path is being resolved correctly
142+
// eslint-disable-next-line ts/no-require-imports
143+
const absolutePath = require('node:path').resolve(depsPath)
144+
console.log('Absolute path:', absolutePath)
145+
console.log('Working directory:', process.cwd())
146+
147+
// Check if there are any interfering files
148+
console.log('Files in test directory:')
149+
const testDirFiles = fs.readdirSync(testDir)
150+
testDirFiles.forEach(f => console.log(` - ${f}`))
151+
152+
// Check if there are any composer files in the working directory
153+
const workingDirFiles = fs.readdirSync(process.cwd())
154+
const composerFiles = workingDirFiles.filter(f => f.includes('composer'))
155+
if (composerFiles.length > 0) {
156+
console.log('Composer files in working directory:', composerFiles)
143157
}
144158
}
145159

0 commit comments

Comments
 (0)