mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-09-03 22:59:58 +08:00
fix(batch): show total size in progress header again
The #228 progress redesign dropped the total size that the old batch progress message displayed. Add a TotalSize data field (actual known sizes, formatted via dlutil.FormatSize) to the batch status header template in both locales.
This commit is contained in:
@@ -152,6 +152,7 @@ func buildBatchProgressMessage(info TaskInfo, skipped []string, activeLimit int)
|
||||
uploadSpeedText := formatSpeed(uploadSpeed)
|
||||
header := localizedProgressMarkup(i18nk.BotMsgProgressBatchStatusHeader, map[string]any{
|
||||
"Total": total,
|
||||
"TotalSize": dlutil.FormatSize(info.ActualTotalSize()),
|
||||
"Completed": completed,
|
||||
"Downloaded": downloaded,
|
||||
"Waiting": waiting,
|
||||
|
||||
@@ -95,6 +95,30 @@ func TestBatchProgressShowsTransferSpeedAndSize(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBatchProgressHeaderShowsTotalSize(t *testing.T) {
|
||||
useProgressRegressionLocale(t)
|
||||
task := newProgressRegressionTask(nil,
|
||||
progressRegressionFile{"first", 1024},
|
||||
progressRegressionFile{"second", 1024},
|
||||
)
|
||||
message := buildBatchProgressMessage(task, nil, 2)
|
||||
if message.Err != nil {
|
||||
t.Fatalf("buildBatchProgressMessage() failed: %v", message.Err)
|
||||
}
|
||||
assertProgressRegressionContains(t, message.Text,
|
||||
"文件:2 | 总大小:2.00 KB",
|
||||
)
|
||||
|
||||
i18n.Init("en")
|
||||
english := buildBatchProgressMessage(task, nil, 2)
|
||||
if english.Err != nil {
|
||||
t.Fatalf("English batch template failed: %v", english.Err)
|
||||
}
|
||||
assertProgressRegressionContains(t, english.Text,
|
||||
"Files: 2 | Total size: 2.00 KB",
|
||||
)
|
||||
}
|
||||
|
||||
func TestBatchProgressLimitsRowsWithoutHidingActiveUpload(t *testing.T) {
|
||||
useProgressRegressionLocale(t)
|
||||
task := newProgressRegressionTask(nil,
|
||||
|
||||
Reference in New Issue
Block a user