新增:首页 Feed 接入真实数据——四态/尾部三态/聚合曝光埋点,社区 demo 消亡第一页(T3-14)
CI / flutter-gates (push) Successful in 2m41s
CI / flutter-gates (push) Successful in 2m41s
- home_page Feed segment 改接 CommunityController:骨架屏首载、空态 CTA、 错误横幅重试、下拉刷新(失败保留旧列表 + SnackBar)、触底游标翻页 (失败态只走显式重试,不随滚动风暴自动重打) - PostCard 三形态(单图通栏 4:3 / 多图折叠封面 +N 角标 / 纯文字 6 行)+ PostMediaGrid(列数规则 + ink 80% scrim 精算)+ LikeButton(error 族修订 Colors.red,T3-14 纯展示禁用态,ToggleSync 接线留 T3-15/16)+ FeedSkeleton (呼吸动效尊重减弱动态设置);降级作者统一「宠友」占位 - SignedNetworkImage:预签名 URL 缓存 key 剥离 X-Amz-* 签名参数, RemoteImage 全仓换用(同图不同签名命中同一缓存条目) - feed 域埋点:feed_viewed 聚合曝光(浏览段开/结算于切 Tab、切分段、 退后台、销毁;≥50% 可见 ≥500ms 段内按帖去重,postId 不上报)+ feed_load_failed(refresh/load_more 双路,会话失效不报) - integration_test/feed_live_test.dart:compose 六容器 Linux 桌面真链路 实测入口(PATBOND_FEED_LIVE=1 门控,默认跳过) - 测试 379 → 421(+42):四态/尾部三态/翻页不丢不重/降级作者/曝光结算 时机/缓存 key/事件属性全覆盖;analyze 0,format 无 diff Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:patbond_flutter/core/network/signed_network_image.dart';
|
||||
|
||||
void main() {
|
||||
group('presignedImageCacheKey', () {
|
||||
test('剥离全部 X-Amz-* 签名参数(大小写不敏感)', () {
|
||||
const url =
|
||||
'http://127.0.0.1:9000/patbond-media/post_image/a-1.jpg'
|
||||
'?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=cred'
|
||||
'&X-Amz-Date=20260909T000000Z&X-Amz-Expires=3600'
|
||||
'&X-Amz-SignedHeaders=host&x-amz-signature=deadbeef';
|
||||
expect(
|
||||
presignedImageCacheKey(url),
|
||||
'http://127.0.0.1:9000/patbond-media/post_image/a-1.jpg',
|
||||
);
|
||||
});
|
||||
|
||||
test('保留非签名 query 参数', () {
|
||||
const url = 'https://cdn.example.com/p.jpg?w=300&X-Amz-Signature=sig';
|
||||
expect(
|
||||
presignedImageCacheKey(url),
|
||||
'https://cdn.example.com/p.jpg?w=300',
|
||||
);
|
||||
});
|
||||
|
||||
test('无签名参数原样返回', () {
|
||||
expect(
|
||||
presignedImageCacheKey('https://cdn.example.com/p.jpg?w=300&q=80'),
|
||||
'https://cdn.example.com/p.jpg?w=300&q=80',
|
||||
);
|
||||
expect(
|
||||
presignedImageCacheKey('https://cdn.example.com/p.jpg'),
|
||||
'https://cdn.example.com/p.jpg',
|
||||
);
|
||||
});
|
||||
|
||||
test('非法 URL 不炸,退回原串', () {
|
||||
expect(presignedImageCacheKey('::not a url::'), '::not a url::');
|
||||
});
|
||||
});
|
||||
|
||||
group('SignedNetworkImage', () {
|
||||
test('同对象不同签名 → 判等(命中同一 ImageCache 条目)', () {
|
||||
final first = SignedNetworkImage(
|
||||
'http://127.0.0.1:9000/m/a.jpg?X-Amz-Signature=sig1&X-Amz-Date=d1',
|
||||
);
|
||||
final second = SignedNetworkImage(
|
||||
'http://127.0.0.1:9000/m/a.jpg?X-Amz-Signature=sig2&X-Amz-Date=d2',
|
||||
);
|
||||
expect(first, second);
|
||||
expect(first.hashCode, second.hashCode);
|
||||
});
|
||||
|
||||
test('不同对象 → 不判等', () {
|
||||
final first = SignedNetworkImage(
|
||||
'http://127.0.0.1:9000/m/a.jpg?X-Amz-Signature=sig',
|
||||
);
|
||||
final second = SignedNetworkImage(
|
||||
'http://127.0.0.1:9000/m/b.jpg?X-Amz-Signature=sig',
|
||||
);
|
||||
expect(first, isNot(second));
|
||||
});
|
||||
|
||||
test('scale 参与判等', () {
|
||||
final first = SignedNetworkImage('http://h/m/a.jpg');
|
||||
final second = SignedNetworkImage('http://h/m/a.jpg', scale: 2);
|
||||
expect(first, isNot(second));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user