- gitea.GetRepo returns FullName + UpdatedAt for the stale-card probe - dashboard collectStale: mai-managed items + linked-repo updated_at >60d + zero open tasks + zero open issues. Sorted longest-stale first, ≤20. Multi-repo items need ALL repos quiet to count as stale. Reuses the 4-worker pool + the already-aggregated task/issue counts from the Tasks / Issues cards (no extra DAV/Gitea fetches). - dashboardCache.invalidate(key) busts a single filter's cache entry; ?refresh=1 routes through it so ↻ button gets fresh data. - "updated Nm ago · cached/fresh" label + ↻ refresh link in dashboard chrome. - Empty-card collapse: with no filter + zero rows the card renders as a one-line muted note instead of full chrome. Filter-active cards keep chrome so m can tell "filter hid it" from "nothing there". - design.md §"Dashboard / daily-driver view" extended with the 4 new surfaces; the 3e "stale (3f)" out-of-scope line dropped. - 5 new tests: stale-surface, stale-skip-recent, refresh-busts-cache, empty-collapse, filter-keeps-chrome. 2 unit tests for gitea.GetRepo.
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package gitea
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestGetRepoParse(t *testing.T) {
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("/api/v1/repos/m/projax", func(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(200)
|
|
_, _ = io.WriteString(w, `{
|
|
"full_name": "m/projax",
|
|
"updated_at": "2025-12-15T08:00:00Z",
|
|
"empty": false
|
|
}`)
|
|
})
|
|
srv := httptest.NewServer(mux)
|
|
defer srv.Close()
|
|
|
|
c := New(srv.URL, "tok")
|
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
defer cancel()
|
|
|
|
r, err := c.GetRepo(ctx, "m", "projax")
|
|
if err != nil {
|
|
t.Fatalf("GetRepo: %v", err)
|
|
}
|
|
if r.FullName != "m/projax" {
|
|
t.Errorf("FullName = %q", r.FullName)
|
|
}
|
|
want := time.Date(2025, 12, 15, 8, 0, 0, 0, time.UTC)
|
|
if !r.UpdatedAt.Equal(want) {
|
|
t.Errorf("UpdatedAt = %v, want %v", r.UpdatedAt, want)
|
|
}
|
|
}
|
|
|
|
func TestGetRepoNotFound(t *testing.T) {
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
http.Error(w, "{}", http.StatusNotFound)
|
|
}))
|
|
defer srv.Close()
|
|
c := New(srv.URL, "tok")
|
|
if _, err := c.GetRepo(context.Background(), "ghost", "repo"); err != ErrNotFound {
|
|
t.Errorf("expected ErrNotFound, got %v", err)
|
|
}
|
|
}
|