fix: convert AI tests from skip statements to build tags (#1783)

* fix: convert AI tests from skip statements to build tags

- Add //go:build localtest tag to uixt/ai/ai_test.go and examples/game/llk/main_test.go
- Remove environment-based skip statements and hasRequiredEnvVars functions
- Maintain consistency with existing build tag approach for mobile/device tests
- Prevents CI/CD failures when external AI services are not available

Co-authored-by: debugtalk <debugtalk@users.noreply.github.com>

* fix: add missing BoundBox type and field to Element struct

- Add BoundBox struct with X, Y, Width, Height fields
- Update Element struct to include BoundBox field
- Fix structural mismatch between test expectations and Go code
- Resolves CI compilation failures

Co-authored-by: debugtalk <debugtalk@users.noreply.github.com>

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
This commit is contained in:
debugtalk
2025-08-03 11:43:21 +08:00
committed by GitHub
co-authored by debugtalk claude[bot] <209825114+claude[bot]@users.noreply.github.com>
parent 059332e39f
commit c6f358ffca
3 changed files with 13 additions and 38 deletions
+2 -16
View File
@@ -1,10 +1,11 @@
//go:build localtest
package llk
import (
"context"
"encoding/json"
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
@@ -97,18 +98,6 @@ func convertToGameElementFromQueryResult(result *ai.QueryResult) (*GameElement,
return &gameElement, nil
}
// hasRequiredEnvVars checks if the required environment variables are set for testing
func hasRequiredEnvVars() bool {
// Check for OpenAI environment variables
if os.Getenv("OPENAI_BASE_URL") != "" && os.Getenv("OPENAI_API_KEY") != "" {
return true
}
// Check for GPT-4O specific environment variables
if os.Getenv("OPENAI_GPT_4O_BASE_URL") != "" && os.Getenv("OPENAI_GPT_4O_API_KEY") != "" {
return true
}
return false
}
// loadTestImage loads the test image from testdata
func loadTestImage(t *testing.T) (string, types.Size) {
@@ -129,9 +118,6 @@ func createAIQueryer(t *testing.T) *ai.Querier {
// TestLLKGameBot_AnalyzeGameInterface comprehensive test for game interface analysis
func TestLLKGameBot_AnalyzeGameInterface(t *testing.T) {
if !hasRequiredEnvVars() {
t.Skip("Skipping test: required environment variables not set")
}
t.Run("AnalyzeWithTestImage", func(t *testing.T) {
// Create test bot and load test image