web: unify mobile back and audit controls and link pipeline run history
This commit is contained in:
@@ -3,11 +3,13 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -30,13 +32,40 @@ func TestRunAdmissionBrowserLostResponse(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
items, _ := store.List(ctx)
|
||||
// A second pipeline/run proves the Runs button applies a real filter, not
|
||||
// merely navigation to a list that coincidentally has one row.
|
||||
if _, err := store.Submit(ctx, "Other fixture", pipeline.Template([]string{"other"}, true)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
all, _ := store.List(ctx)
|
||||
for _, item := range all {
|
||||
if item.ID != items[0].ID {
|
||||
definition, _ := store.Get(ctx, item.ID, 1)
|
||||
if _, _, err := store.CreateRun(ctx, definition, "unrelated-fixture", t.TempDir(), false, nil, map[string]any{"prompt": "unrelated"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
handler := Handler(ctx, store).(*runHandler)
|
||||
defer func() { cancel(); WaitRuns(handler) }()
|
||||
finish := make(chan struct{})
|
||||
var once sync.Once
|
||||
handler.runner.execute = func(ctx context.Context, _ stage.Definition, _ stage.Values) (stage.Result, error) {
|
||||
<-ctx.Done()
|
||||
return stage.Result{}, ctx.Err()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return stage.Result{}, ctx.Err()
|
||||
case <-finish:
|
||||
return stage.Result{Outcome: "success", Output: stage.Values{"markdown": "# Scratch report\n\nVerified fixture output."}}, nil
|
||||
}
|
||||
}
|
||||
srv := httptest.NewServer(handler)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.Path == "/complete-fixture" && req.Method == http.MethodPost {
|
||||
once.Do(func() { close(finish) })
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
handler.ServeHTTP(w, req)
|
||||
}))
|
||||
defer srv.Close()
|
||||
cmd := exec.CommandContext(ctx, "node", "../../web/test/run-admission-probe.mjs", strings.TrimPrefix(srv.URL, "http://"), fmt.Sprint(items[0].ID), t.TempDir())
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
@@ -45,7 +74,13 @@ func TestRunAdmissionBrowserLostResponse(t *testing.T) {
|
||||
t.Log(string(output))
|
||||
}
|
||||
runs, err := store.ListRuns(ctx)
|
||||
if err != nil || len(runs) != 1 {
|
||||
t.Fatalf("lost response duplicated run: %d %v", len(runs), err)
|
||||
count := 0
|
||||
for _, run := range runs {
|
||||
if run.PipelineID == items[0].ID {
|
||||
count++
|
||||
}
|
||||
}
|
||||
if err != nil || count != 1 {
|
||||
t.Fatalf("lost response duplicated run: %d %v", count, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user