889d811858
The Artifacts view re-clamped its scroll offset to the selected row on every render, so the tail of the list - a trailing visit that recorded none (running or finished) and its capture summary - could never be brought on screen, and the image marker crowded out artifact names at narrow widths. - Decouple the scroll offset from the selection: add PgUp/PgDn (and ctrl+u/ ctrl+d) paging, and make G/end select the last artifact and scroll to the tail so a trailing visit stays reachable. - Share artifactContent/clampArtifactTop/revealArtifactSelection between selection and render so both agree on the same page. - Show the [img] marker only while the width still leaves room for a usable name, keeping columns aligned either way. - Advertise the scroll keys in the artifacts footer help. - Test the omitted-files capture wording, trailing-visit reachability via G/end and page scroll, and narrow-width no-overflow; render both the top and the scrolled tail in the env-gated live capture test. - Update the packaged operations reference for the A artifacts view.
64 lines
2.3 KiB
Go
64 lines
2.3 KiB
Go
package tui
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
|
"github.com/charmbracelet/x/ansi"
|
|
)
|
|
|
|
// TestLiveArtifactsFromCapture renders the artifacts view from real
|
|
// `pipelines inspect RUN_ID --json` captures. It is env-gated and skips unless
|
|
// PIPELINES_ARTIFACT_CAPTURES names one or more capture files, so it never
|
|
// depends on a running server in CI; the operator points it at real captures to
|
|
// re-confirm that mixed artifact types, a partial capture, a running visit and
|
|
// a finished visit with none all render.
|
|
func TestLiveArtifactsFromCapture(t *testing.T) {
|
|
list := os.Getenv("PIPELINES_ARTIFACT_CAPTURES")
|
|
if strings.TrimSpace(list) == "" {
|
|
t.Skip("set PIPELINES_ARTIFACT_CAPTURES to comma-separated `pipelines inspect RUN_ID --json` files")
|
|
}
|
|
m := New(context.Background(), "ws://127.0.0.1:8080/connect")
|
|
// Height chosen so artifactsViewHeight() is 50, keeping the view's page size
|
|
// and the model's scroll page size identical (as they are in the app).
|
|
m.width, m.height = 120, 54
|
|
var rendered strings.Builder
|
|
for _, path := range strings.Split(list, ",") {
|
|
path = strings.TrimSpace(path)
|
|
if path == "" {
|
|
continue
|
|
}
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var detail protocol.RunDetail
|
|
if err := json.Unmarshal(data, &detail); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m.runDetail = &detail
|
|
m.artifactsOpen = true
|
|
m.artifactIndex, m.artifactTop = 0, 0
|
|
top := ansi.Strip(m.artifactsView(m.artifactsViewHeight()))
|
|
t.Logf("capture %s (run #%d executing=%t) top:\n%s", path, detail.ID, detail.Executing, top)
|
|
rendered.WriteString(top)
|
|
// Scroll to the tail so a trailing running visit's capture summary is
|
|
// rendered regardless of how many artifacts precede it; a fixed top
|
|
// page used to clip it once a run accumulated enough artifacts.
|
|
m = artifactKey(m, 'G')
|
|
tail := ansi.Strip(m.artifactsView(m.artifactsViewHeight()))
|
|
t.Logf("capture %s (run #%d executing=%t) tail:\n%s", path, detail.ID, detail.Executing, tail)
|
|
rendered.WriteString(tail)
|
|
}
|
|
text := rendered.String()
|
|
for _, want := range []string{"[img]", "partial capture", "capture pending", "not recorded for this visit", "image/png", "KiB"} {
|
|
if !strings.Contains(text, want) {
|
|
t.Errorf("live captures did not render %q", want)
|
|
}
|
|
}
|
|
}
|