Align console behavior with operator routing and image workflow expectations
Constraint: Must preserve current exchange-rate logic, same-group routing boundary, and temporary image-file behavior while fixing UX-visible inconsistencies. Rejected: Large frontend chunk refactor | introduced risky circular chunking and did not improve deliverability for this rollout. Confidence: medium Scope-risk: moderate Directive: Keep channel failover constrained to the selected group and preserve Beijing-day semantics for user cache dashboard metrics. Tested: go test ./controller ./model ./service ./common -count=1; npm run build; remote smoke on source deployment at http://38.76.218.56:18081/ plus /api/status and /api/image-studio/settings. Not-tested: Browser-driven end-to-end verification of every console page interaction.
This commit is contained in:
40
model/log_dashboard_metrics_test.go
Normal file
40
model/log_dashboard_metrics_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGetDashboardDayStartUnixUsesShanghai(t *testing.T) {
|
||||
utcTime := time.Date(2026, 5, 5, 0, 30, 0, 0, time.UTC)
|
||||
got := getDashboardDayStartUnix(utcTime)
|
||||
|
||||
want := time.Date(2026, 5, 5, 0, 0, 0, 0, dashboardMetricsLocation).Unix()
|
||||
if got != want {
|
||||
t.Fatalf("expected Shanghai day start %d, got %d", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAccumulateCacheMetrics(t *testing.T) {
|
||||
row := cacheMetricRow{
|
||||
PromptTokens: 100,
|
||||
Other: `{"cache_read_tokens":40,"cache_write_tokens":10}`,
|
||||
}
|
||||
metrics := CacheDashboardMetrics{}
|
||||
|
||||
accumulateCacheMetrics(&metrics, row)
|
||||
finalizeCacheMetrics(&metrics)
|
||||
|
||||
if metrics.CacheReadTokens != 40 {
|
||||
t.Fatalf("expected cache read 40, got %d", metrics.CacheReadTokens)
|
||||
}
|
||||
if metrics.CacheWriteTokens != 10 {
|
||||
t.Fatalf("expected cache write 10, got %d", metrics.CacheWriteTokens)
|
||||
}
|
||||
if metrics.CacheTokens != 50 {
|
||||
t.Fatalf("expected cache tokens 50, got %d", metrics.CacheTokens)
|
||||
}
|
||||
if metrics.CacheHitRate <= 0 {
|
||||
t.Fatalf("expected positive hit rate, got %f", metrics.CacheHitRate)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user