package panel import ( "bytes" "net/http/httptest" "os" "os/exec" "path/filepath" "regexp" "strconv" "strings" "testing" "time" ) // TestAppJSSyntax app.js 必须能通过 JS 解析器语法校验。 // // 为什么需要:app.js 是 go:embed 进二进制的静态资源,Go 编译器不检查其内容—— // 一次对象字面量键名未加引号(Model_chat_GLM5.2 被解析成属性访问 + 数字字面量) // 就让整个面板白屏,而所有 Go 测试依然全绿。此测试把语法校验前移到 CI。 // 无 node 环境时跳过(不阻塞无 Node 的构建机)。 func TestAppJSSyntax(t *testing.T) { node, err := exec.LookPath("node") if err != nil { t.Skip("node not available; skipping JS syntax check") } path, err := filepath.Abs("app.js") if err != nil { t.Fatal(err) } out, err := exec.Command(node, "--check", path).CombinedOutput() if err != nil { t.Fatalf("app.js syntax error:\n%s", out) } } // TestIndexHTMLNoInlineScript index.html 不得含内联