feat: pantalla de tests en el dashboard TUI
Nueva seccion "Tests" en el menu principal del dashboard que permite ejecutar Go tests, E2E tests (headless y headed), y todos secuencialmente. - ScreenTests con menu de seleccion de tipo de test - TestKind enum para identificar el tipo de test ejecutado - Nuevos intents: IntentRunGoTests, IntentRunE2ETests, IntentRunE2EHeadTests, IntentRunAllTests - LastTestKind en Model para re-ejecucion con "r" - runGoTests, runE2ETests, runAllTests en adapter - "Run Tests" en Server menu reemplazado por navegacion a ScreenTests - Test output muestra tipo de test en titulo y vuelve a ScreenTests con "0" Issue: 0023 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+78
-5
@@ -59,7 +59,19 @@ func (a *Adapter) RunIntent(intent puretui.Intent) tea.Cmd {
|
||||
return a.rebuildRestart()
|
||||
|
||||
case puretui.IntentRunTests:
|
||||
return a.runTests()
|
||||
return a.runGoTests()
|
||||
|
||||
case puretui.IntentRunGoTests:
|
||||
return a.runGoTests()
|
||||
|
||||
case puretui.IntentRunE2ETests:
|
||||
return a.runE2ETests(false)
|
||||
|
||||
case puretui.IntentRunE2EHeadTests:
|
||||
return a.runE2ETests(true)
|
||||
|
||||
case puretui.IntentRunAllTests:
|
||||
return a.runAllTests()
|
||||
|
||||
case puretui.IntentTick:
|
||||
return a.tick()
|
||||
@@ -236,11 +248,10 @@ func (a *Adapter) loadLogs(id string) tea.Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Adapter) runTests() tea.Cmd {
|
||||
func (a *Adapter) runGoTests() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
goBin, err := exec.LookPath("go")
|
||||
if err != nil {
|
||||
// Fallback to known location
|
||||
goBin = "/usr/local/go/bin/go"
|
||||
}
|
||||
cmd := exec.Command(goBin, "test", "-tags", "goolm", "-count=1", "./...")
|
||||
@@ -252,9 +263,71 @@ func (a *Adapter) runTests() tea.Cmd {
|
||||
output = "Error: " + err.Error()
|
||||
}
|
||||
lines := strings.Split(output, "\n")
|
||||
passed := err == nil
|
||||
return puretui.MsgTestsDone{Kind: puretui.TestKindGo, Passed: err == nil, Output: lines}
|
||||
}
|
||||
}
|
||||
|
||||
return puretui.MsgTestsDone{Passed: passed, Output: lines}
|
||||
func (a *Adapter) runE2ETests(headed bool) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
args := []string{"./dev-scripts/e2e/run.sh"}
|
||||
if headed {
|
||||
args = append(args, "--headed")
|
||||
}
|
||||
cmd := exec.Command("bash", args...)
|
||||
cmd.Env = a.mgr.BuildEnv()
|
||||
out, err := cmd.CombinedOutput()
|
||||
|
||||
output := strings.TrimSpace(string(out))
|
||||
if output == "" && err != nil {
|
||||
output = "Error: " + err.Error()
|
||||
}
|
||||
lines := strings.Split(output, "\n")
|
||||
kind := puretui.TestKindE2E
|
||||
if headed {
|
||||
kind = puretui.TestKindE2EHead
|
||||
}
|
||||
return puretui.MsgTestsDone{Kind: kind, Passed: err == nil, Output: lines}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Adapter) runAllTests() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
var allLines []string
|
||||
|
||||
// Go tests first
|
||||
goBin, err := exec.LookPath("go")
|
||||
if err != nil {
|
||||
goBin = "/usr/local/go/bin/go"
|
||||
}
|
||||
goCmd := exec.Command(goBin, "test", "-tags", "goolm", "-count=1", "./...")
|
||||
goCmd.Env = a.mgr.BuildEnv()
|
||||
goOut, goErr := goCmd.CombinedOutput()
|
||||
|
||||
allLines = append(allLines, "═══ Go Tests ═══")
|
||||
goOutput := strings.TrimSpace(string(goOut))
|
||||
if goOutput == "" && goErr != nil {
|
||||
goOutput = "Error: " + goErr.Error()
|
||||
}
|
||||
allLines = append(allLines, strings.Split(goOutput, "\n")...)
|
||||
|
||||
if goErr != nil {
|
||||
allLines = append(allLines, "", "Go tests FAILED — skipping E2E")
|
||||
return puretui.MsgTestsDone{Kind: puretui.TestKindAll, Passed: false, Output: allLines}
|
||||
}
|
||||
|
||||
// E2E tests
|
||||
allLines = append(allLines, "", "═══ E2E Tests ═══")
|
||||
e2eCmd := exec.Command("bash", "./dev-scripts/e2e/run.sh")
|
||||
e2eCmd.Env = a.mgr.BuildEnv()
|
||||
e2eOut, e2eErr := e2eCmd.CombinedOutput()
|
||||
|
||||
e2eOutput := strings.TrimSpace(string(e2eOut))
|
||||
if e2eOutput == "" && e2eErr != nil {
|
||||
e2eOutput = "Error: " + e2eErr.Error()
|
||||
}
|
||||
allLines = append(allLines, strings.Split(e2eOutput, "\n")...)
|
||||
|
||||
return puretui.MsgTestsDone{Kind: puretui.TestKindAll, Passed: e2eErr == nil, Output: allLines}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user