Three UX improvements for the pending-transcript state:
1. Summarized videos sort to top (ORDER BY (s.id IS NOT NULL) DESC, seen_at DESC)
so completed summaries are always immediately visible without filtering.
ListVideos default limit raised from 50 to 500 to show the full backlog.
2. Pipeline stats bar above the video list: '2 summarized · 256 fetching soon · 12
no captions' — computed from the unfiltered row set, hidden when everything is
summarized.
3. 'Try now' button on rate-limited cards replaces the passive 'Retrying later'
chip. POST /v/{id}/retry-now clears rate_limited_at then calls ProcessVideo
through the shared globalFetchGate — same rate limiting as the scheduler, safe
under concurrent use.
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package web
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.d-ma.be/mathias/tapir/internal/adapters/store"
|
|
)
|
|
|
|
func renderVideoCard(t *testing.T, r store.SummaryRow) string {
|
|
t.Helper()
|
|
var sb strings.Builder
|
|
if err := VideoCard(r).Render(context.Background(), &sb); err != nil {
|
|
t.Fatalf("render VideoCard: %v", err)
|
|
}
|
|
return sb.String()
|
|
}
|
|
|
|
// A rate-limited, unsummarized video shows an active "Try now" button so the user
|
|
// can manually trigger an immediate fetch through the shared rate gate.
|
|
func TestVideoCard_RateLimitedShowsRetryingBadge(t *testing.T) {
|
|
html := renderVideoCard(t, store.SummaryRow{
|
|
VideoID: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
|
|
Title: "Throttled Video",
|
|
Summarized: false,
|
|
TranscriptStatus: "rate_limited",
|
|
})
|
|
|
|
if !strings.Contains(html, "Try now") {
|
|
t.Errorf("expected a 'Try now' button, got:\n%s", html)
|
|
}
|
|
if !strings.Contains(html, "retry-now") {
|
|
t.Errorf("expected the retry-now route in the form action, got:\n%s", html)
|
|
}
|
|
if strings.Contains(html, ">Summarize<") {
|
|
t.Errorf("the Summarize button must be hidden for a rate-limited video, got:\n%s", html)
|
|
}
|
|
}
|
|
|
|
// An ordinary unsummarized video still offers the Summarize button.
|
|
func TestVideoCard_UnsummarizedShowsSummarize(t *testing.T) {
|
|
html := renderVideoCard(t, store.SummaryRow{
|
|
VideoID: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
|
|
Title: "Fresh Video",
|
|
Summarized: false,
|
|
})
|
|
|
|
if !strings.Contains(html, ">Summarize<") {
|
|
t.Errorf("expected a Summarize button, got:\n%s", html)
|
|
}
|
|
if strings.Contains(html, "Retrying later") {
|
|
t.Errorf("no retry badge for a non-rate-limited video, got:\n%s", html)
|
|
}
|
|
}
|