feat(flutter): 播放页互动数量与评论面板收紧

This commit is contained in:
Zhou Weidong committed 2026-10-20 12:06:21 +08:00
1 parent e39aa766ac
commit bed6bbb75b
13 files changed
+265 -59

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
// Author: fruit.com.cn
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/formatting/count_format.dart';
void main() {
test('should_keep_raw_number_below_ten_thousand', () {
expect(formatInteractionCount(0), '0');
expect(formatInteractionCount(96), '96');
expect(formatInteractionCount(9999), '9999');
});
test('should_use_one_decimal_wan_from_ten_thousand', () {
expect(formatInteractionCount(10000), '1.0万');
expect(formatInteractionCount(12400), '1.2万');
expect(formatInteractionCount(123456), '12.3万');
});
}
+21 -2
View File
@@ -46,10 +46,18 @@ void main() {
});
test('should_parse_view_count_when_backend_sends_number', () {
final drama = Drama.fromCardJson({'id': 5, 'title': 'T', 'viewCount': 1200});
final drama = Drama.fromCardJson({
'id': 5,
'title': 'T',
'viewCount': 1200,
});
expect(drama.id, '5');
expect(drama.viewCount, 1200);
// 卡片没有互动数量时保持未知,界面才回退到文字标签。
expect(drama.likeCount, isNull);
expect(drama.favoriteCount, isNull);
expect(drama.commentCount, isNull);
});
test('should_parse_detail_payload_when_ids_are_strings', () {
@@ -59,14 +67,25 @@ void main() {
'totalEpisodes': 12,
'freeEpisodes': 3,
'viewCount': '99',
'likeCount': '12400',
'favoriteCount': '3200',
'commentCount': '96',
'episodes': [
{'id': '2111012753262120963', 'number': 1, 'title': 'E1', 'isFree': true},
{
'id': '2111012753262120963',
'number': 1,
'title': 'E1',
'isFree': true,
},
],
});
expect(drama.id, '2111012753262120962');
expect(drama.freeEpisodes, 3);
expect(drama.viewCount, 99);
expect(drama.likeCount, 12400);
expect(drama.favoriteCount, 3200);
expect(drama.commentCount, 96);
expect(drama.episodes.first.id, '2111012753262120963');
expect(drama.episodes.first.number, 1);
});