Files
magpie/internal/gui/trayusage_wallet_test.go
T
yetone 51eb1ae4b6 panel: an allowance card says its booster's balance under its rings
apple_test_src on X: Kimi Code's booster (加油包) balance showed only on
the Usage page. The tray panel's Allowances card drew a balance window's
text line only when the card had no rings, so a card with 5-hour and
Week rings dropped "Extra usage"; the menu bar's tooltip left out every
Balance window. Now panelQuotaCard draws "Extra usage ¥X left" (in the
card's language) in a pq-sub line under the rings, sharing one filter
with the text line, and trayCardText adds the same line to the tooltip.
The menu bar's label is unchanged (its two percentages).

Budgets: app.js and core +17 each, reason in the constants.

Run (at 9227c83ab's tree, rebased on 22f8db6c9):
- Red on the old code: panel-quota-wallet.test.cjs (20 cases, chromium
  + webkit, en/zh/zh-TW/ja/de, 440 and 360 px) all fail against the old
  app.js; TestTrayTipSaysWalletLeft fails on the en tip against the old
  trayusage.go. Both green with the change.
- mote: go test ./internal/gui -run Tray|Budget ok after the rebase;
  panel-quota-wallet, panel-quota-kept, i18n-keys 44/44. go vet
  darwin, windows, linux nogui on ./internal/gui ok. gofmt clean.
- mica (before the rebase, at cd030691a): go test ./internal/gui ok.
- mote, 96 GUI files the change can reach (panel*, quota*, tray*, every
  file touching pq-card/pq-sub/panelQuota, i18n*), both engines:
  1503 tests, 84 fail in 11 files; the same 11 files fail the same way
  at base cd030691a: claude-quota-onboarding (#6179), codex-auto-reset
  (#3293), grip-inset (#6293), key-balance-card (#6414), panel-fold
  (#5796), panel-shortcut (#6606), quota-bars-alike (#6700, filed now),
  quota-curve (#4768), quota-refresh-order (#6180), tray-cell-click
  (#5215), usage-fold (#6003).

Not run: the whole GUI suite and go test ./... (mote and mica were each
running another session's full suite). Not tried in the real app with a
real Kimi booster; the window's shape is the one the Kimi probe returned
earlier (balance, unit CNY).
2026-11-15 01:29:18 +08:00

36 lines
1.2 KiB
Go

package gui
import (
"strings"
"testing"
"time"
"github.com/yetone/magpie/internal/provider"
)
// Kimi Code's booster (加油包) is a wallet window set aside beside the plan's
// windows. The menu bar's tooltip says what is left on it, as the panel's
// card does under its rings (apple_test_src on X: it showed only on the
// Usage page); the label stays the plan's percent.
func TestTrayTipSaysWalletLeft(t *testing.T) {
now := time.Now()
r5, r7 := now.Add(2*time.Hour), now.Add(72*time.Hour)
left := 98.5
q := provider.SubscriptionQuota{Provider: "kimi-code", Name: "Kimi Code", User: "k@example.com", Windows: []provider.QuotaWindow{
{Name: "5 hours", Used: 30, ResetsAt: &r5, Span: 5 * time.Hour},
{Name: "Week", Used: 50, ResetsAt: &r7, Span: 7 * 24 * time.Hour},
{Name: "Extra usage", Balance: &left, Unit: "CNY", Aside: true},
}}
label, tip := trayCardText("en", q, now, false, false, nil)
if label != "30% · 50%" {
t.Fatalf("label: %q", label)
}
if !strings.Contains(tip, "\nExtra usage 98.5 CNY left") {
t.Fatalf("en tip: %q", tip)
}
_, tip = trayCardText("zh", q, now, false, false, nil)
if strings.Contains(tip, "Extra usage") || !strings.Contains(tip, "剩余 98.5") {
t.Fatalf("zh tip: %q", tip)
}
}