A discovered-but-unsummarized video whose caption fetch was rate-limited now shows a passive ⏳ "Retrying later" chip (dim CharmDim styling, not the accent) instead of the Summarize button — the user cannot fix a 429, the runner retries automatically once the backoff window expires. Regenerated views_templ.go. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 the passive "Retrying later" badge and
|
|
// hides the Summarize button — the user can't fix it, retry is automatic.
|
|
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, "Retrying later") {
|
|
t.Errorf("expected a 'Retrying later' badge, got:\n%s", html)
|
|
}
|
|
if !strings.Contains(html, "chip-retry") {
|
|
t.Errorf("expected the passive chip-retry styling, 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)
|
|
}
|
|
}
|