Files
arcrun-collector/cmd/arcrun-app/quota_card_test.go
T
Leo ef8126201c P8 短板齊平:模型品質實測(granite 否決、qwen3-30b 定案)+額度撞牆三句話接上畫面
① docs/benchmarks/p8-extractor-quality/:leo 真筆記 8 篇 × 5 模型可複驗實測
   (production 同 prompt/參數、CF 原生 usage.neurons 計量)——
   scout 84 n/檔(119 檔/日)→ qwen3-30b 43 n/檔(232 檔/日)品質不降反升;
   granite 最便宜(858 檔/日)但 5/8 缺段、三元組全滅=否決。
   誠實結論:免金鑰路物理撐不起「幾千篇當天匯入」(差 13 倍),
   正解=消化節奏(3,000 篇約 13 天背景跑完、新筆記優先)+出口(Gemini/付費/ollama)。
② 撞牆體驗:quota_message 08-07 就在 status.json,App 從來沒接——
   app.go pickQuotaNotice(過期快照不說謊)+ main.js cardQuota(三句話卡)+
   progress.go ClassifyFailure 補認三句話(原本掉「其他」)。
   Go 兩 module 全綠;瀏覽器實載 dist 深淺兩主題截圖、console 0 錯。
③ 公開鏡像排除 docs/benchmarks(輸入是 leo 私人筆記)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 00:44:34 +08:00

72 lines
2.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
// quota_card_test.go — P82026-08-09):額度三句話從 status.json 到首頁那張卡的佈線測試。
//
// 背景:collector 08-07 就把 QuotaNotice 寫進 status.jsonaccount_details[].quota_message),
// 但 App 端從來沒接——使用者撞額度只看得到「送不上去 N 份」。這裡釘住 pickQuotaNotice 的
// 三個行為:有效冷卻要撿到、過期快照不准顯示(不然會說「明天早上 8 點恢復」的謊)、
// 多帳號挑最早恢復的那份。
import (
"testing"
"time"
collector "arcrun-rag/collector"
)
func mkNotice(resumeAt time.Time, n int) *collector.QuotaNotice {
return &collector.QuotaNotice{
Achievement: "今天已經幫你整理了 105 份",
ExitOptions: "可以換一個模型,或升級 Cloudflare(每月 5 美元)",
Guarantee: "不花錢也沒關係,明天早上 8:00 會自動恢復、會接著跑",
ResumeAt: resumeAt.Format(time.RFC3339),
}
}
func TestPickQuotaNotice_ActiveCooldownIsShown(t *testing.T) {
now := time.Date(2026, 8, 9, 12, 0, 0, 0, time.UTC)
s := syncStatus{AccountDetails: map[string]collector.AccountSyncStatus{
"youlin.example": {QuotaMessage: mkNotice(now.Add(3*time.Hour), 105)},
}}
q := pickQuotaNotice(s, now)
if q == nil {
t.Fatal("冷卻還沒到期,首頁應該要拿到三句話")
}
if q.Achievement == "" || q.ExitOptions == "" || q.Guarantee == "" {
t.Fatalf("三句話缺一不可(leo 08-07 骨架):%+v", q)
}
}
func TestPickQuotaNotice_StaleSnapshotIsHidden(t *testing.T) {
// daemon 整夜沒跑(電腦闔蓋),status.json 停在昨天的快照——額度其實已恢復。
// 這時再顯示「明天早上 8 點恢復」就是在說謊 ⇒ 過期=不畫。
now := time.Date(2026, 8, 9, 12, 0, 0, 0, time.UTC)
s := syncStatus{AccountDetails: map[string]collector.AccountSyncStatus{
"youlin.example": {QuotaMessage: mkNotice(now.Add(-time.Hour), 105)},
}}
if q := pickQuotaNotice(s, now); q != nil {
t.Fatalf("過期快照不准顯示,got %+v", q)
}
// ResumeAt 解析不了 ⇒ 同樣不畫(寧可少顯示,不顯示錯的承諾)
bad := mkNotice(now.Add(time.Hour), 1)
bad.ResumeAt = "not-a-time"
s.AccountDetails["youlin.example"] = collector.AccountSyncStatus{QuotaMessage: bad}
if q := pickQuotaNotice(s, now); q != nil {
t.Fatalf("ResumeAt 壞掉不准顯示,got %+v", q)
}
}
func TestPickQuotaNotice_MultiAccountPicksEarliestResume(t *testing.T) {
now := time.Date(2026, 8, 9, 12, 0, 0, 0, time.UTC)
early := mkNotice(now.Add(1*time.Hour), 40)
late := mkNotice(now.Add(5*time.Hour), 80)
s := syncStatus{AccountDetails: map[string]collector.AccountSyncStatus{
"b.example": {QuotaMessage: late},
"a.example": {QuotaMessage: early},
}}
q := pickQuotaNotice(s, now)
if q == nil || q.ResumeAt != early.ResumeAt {
t.Fatalf("多帳號應挑最早恢復的那份,got %+v", q)
}
}