test: Add minimal UT infrastructure and fix Issue #227

This commit sets up a minimal, KISS-principle testing infrastructure
for both backend and frontend, and includes the fix for Issue #227.
Backend Changes:
- Add Makefile with test commands (test, test-backend, test-frontend, test-coverage)
- Add example test: config/database_test.go
- Fix Go 1.25 printf format string warnings in trader/auto_trader.go
  (Changed log.Printf to log.Print for non-format strings)
- All backend tests pass ✓
Frontend Changes:
- Add Vitest configuration: web/vitest.config.ts (minimal setup)
- Add test utilities: web/src/test/test-utils.tsx
- Add example test: web/src/App.test.tsx
- Add dependencies: vitest, jsdom, @testing-library/react
- All frontend tests pass ✓
Issue #227 Fix:
- Fix AITradersPage to allow editing traders with disabled models/exchanges
- Change validation to use allModels/allExchanges instead of enabledModels/enabledExchanges
- Add comprehensive tests in web/src/components/AITradersPage.test.tsx
- Fixes: https://github.com/tinkle-community/nofx/issues/227
CI/CD:
- Add GitHub Actions workflow: .github/workflows/test.yml
- Non-blocking tests (continue-on-error: true)
- Runs on push/PR to main and dev branches
Test Results:
- Backend: 1 test passing
- Frontend: 5 tests passing (including 4 for Issue #227)
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
Liu Xiang Qian
2025-11-02 10:58:31 +08:00
parent 6789b22609
commit cf12be74f5
11 changed files with 3776 additions and 13 deletions

View File

@@ -257,9 +257,9 @@ func (at *AutoTrader) Stop() {
func (at *AutoTrader) runCycle() error {
at.callCount++
log.Printf("\n" + strings.Repeat("=", 70))
log.Print("\n" + strings.Repeat("=", 70))
log.Printf("⏰ %s - AI决策周期 #%d", time.Now().Format("2006-01-02 15:04:05"), at.callCount)
log.Printf(strings.Repeat("=", 70))
log.Print(strings.Repeat("=", 70))
// 创建决策记录
record := &logger.DecisionRecord{
@@ -346,19 +346,19 @@ func (at *AutoTrader) runCycle() error {
// 打印系统提示词和AI思维链即使有错误也要输出以便调试
if decision != nil {
if decision.SystemPrompt != "" {
log.Printf("\n" + strings.Repeat("=", 70))
log.Print("\n" + strings.Repeat("=", 70))
log.Printf("📋 系统提示词 [模板: %s] (错误情况)", at.systemPromptTemplate)
log.Println(strings.Repeat("=", 70))
log.Println(decision.SystemPrompt)
log.Printf(strings.Repeat("=", 70) + "\n")
log.Print(strings.Repeat("=", 70) + "\n")
}
if decision.CoTTrace != "" {
log.Printf("\n" + strings.Repeat("-", 70))
log.Print("\n" + strings.Repeat("-", 70))
log.Println("💭 AI思维链分析错误情况:")
log.Println(strings.Repeat("-", 70))
log.Println(decision.CoTTrace)
log.Printf(strings.Repeat("-", 70) + "\n")
log.Print(strings.Repeat("-", 70) + "\n")
}
}