f873acf9a3
CI / flutter-gates (push) Failing after 20s
- post_detail_page 整页重写:内存副本先渲染 + getPost 拉新、四态 (loading/error+重试/ready/40403 提示后返回 Feed 并刷新);媒体全量 ——单图原比例(高度钳制 [0.75w,1.33w])、多图真九宫格(D11 轮播 弃用,本单裁定)+ InteractiveViewer 全屏大图(03 号拍板 E) - 评论区:游标列表触底补页 + 底部输入条创建(幂等键在数据层)+ 仅本人评论渲染删除入口(40301/40404 服务端兜底);成败埋点对 (durationMs 取输入会话起点、attemptSeq 会话内递增);CommentTile 升共享组件(@ 回复前缀呈现、降级作者「宠友」占位) - 关注双态钮(tonal +关注 / Outlined 已关注 + 取关确认)乐观翻转、 回滚零动画 + SnackBar,user_followed/unfollowed(post_detail) 挂接; 本人帖不渲染 - Feed 接通:整卡与评论钮导航详情(T3-14 占位提示移除)、点赞/收藏 接共享 ToggleSync(详情与卡片同一实例跨页一致)、toggleError 一次性 SnackBar 消费 - 主壳/装配:openPost 按 postId push;create demo 流不再导航已退役的 demo 详情(发布页真实化留 T3-17);AppState 在 post_detail/Feed 面 消费清零 - compose 冒烟(env 门控默认跳过):真链路发帖/点赞幂等/收藏/评论/ 删评一轮 + 断网点赞回滚(生产 ApiClient 异常链) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
308 lines
8.5 KiB
Dart
308 lines
8.5 KiB
Dart
import 'package:patbond_flutter/features/community/community_models.dart';
|
|
import 'package:patbond_flutter/features/community/community_repository.dart';
|
|
|
|
/// community 域测试样本 JSON(字段与契约 v1.3.0 逐字一致)。
|
|
|
|
Map<String, dynamic> sampleAuthorJson({
|
|
String userId = 'u-1',
|
|
String? nickname = '毛毛的铲屎官',
|
|
String? avatarUrl = 'https://minio.local/avatar.jpg?X-Amz-Signature=sig',
|
|
}) => {'userId': userId, 'nickname': nickname, 'avatarUrl': avatarUrl};
|
|
|
|
Map<String, dynamic> samplePostMediaItemJson({
|
|
String assetId = 'a-1',
|
|
int position = 0,
|
|
bool isCover = true,
|
|
}) => {
|
|
'assetId': assetId,
|
|
'position': position,
|
|
'isCover': isCover,
|
|
'url': 'https://minio.local/p.jpg?X-Amz-Signature=sig',
|
|
'widthPx': 1080,
|
|
'heightPx': 810,
|
|
'caption': '晒太阳',
|
|
};
|
|
|
|
Map<String, dynamic> samplePostJson({
|
|
String id = 'p-1',
|
|
String status = 'published',
|
|
bool likedByMe = false,
|
|
int likeCount = 6,
|
|
bool bookmarkedByMe = false,
|
|
int bookmarkCount = 2,
|
|
int version = 1,
|
|
}) => {
|
|
'id': id,
|
|
'author': sampleAuthorJson(),
|
|
'petId': 'pet-1',
|
|
'category': 'general',
|
|
'title': '今天的豆豆',
|
|
'content': '晒了一下午太阳。',
|
|
'status': status,
|
|
'visibility': 'public',
|
|
'media': [samplePostMediaItemJson()],
|
|
'likeCount': likeCount,
|
|
'commentCount': 3,
|
|
'bookmarkCount': bookmarkCount,
|
|
'likedByMe': likedByMe,
|
|
'bookmarkedByMe': bookmarkedByMe,
|
|
'createdAt': '2026-09-08T10:00:00.000Z',
|
|
'updatedAt': '2026-09-08T10:05:00.000Z',
|
|
'publishedAt': status == 'published' ? '2026-09-08T10:05:00.000Z' : null,
|
|
'version': version,
|
|
};
|
|
|
|
Map<String, dynamic> sampleFeedCardJson({
|
|
String id = 'p-1',
|
|
bool likedByMe = false,
|
|
int likeCount = 6,
|
|
bool bookmarkedByMe = false,
|
|
int bookmarkCount = 2,
|
|
}) => {
|
|
'id': id,
|
|
'author': sampleAuthorJson(),
|
|
'category': 'general',
|
|
'title': '今天的豆豆',
|
|
'contentPreview': '晒了一下午太阳。',
|
|
'coverImage': samplePostMediaItemJson(),
|
|
'mediaCount': 1,
|
|
'likeCount': likeCount,
|
|
'commentCount': 3,
|
|
'bookmarkCount': bookmarkCount,
|
|
'likedByMe': likedByMe,
|
|
'bookmarkedByMe': bookmarkedByMe,
|
|
'publishedAt': '2026-09-08T10:05:00.000Z',
|
|
};
|
|
|
|
Map<String, dynamic> sampleCommentJson({
|
|
String id = 'c-1',
|
|
Map<String, dynamic>? author,
|
|
Map<String, dynamic>? replyToUser,
|
|
String content = '好可爱!',
|
|
}) => {
|
|
'id': id,
|
|
'postId': 'p-1',
|
|
'author': author ?? sampleAuthorJson(),
|
|
'replyToUser': replyToUser,
|
|
'content': content,
|
|
'createdAt': '2026-09-08T11:00:00.000Z',
|
|
};
|
|
|
|
Map<String, dynamic> sampleUploadCredentialsJson() => {
|
|
'assetId': 'a-1',
|
|
'uploadUrl':
|
|
'https://minio.local/patbond-media/post_image/a-1?X-Amz-Signature=sig',
|
|
'method': 'PUT',
|
|
'requiredHeaders': {'Content-Type': 'image/jpeg'},
|
|
'expiresAt': '2026-09-08T10:10:00.000Z',
|
|
};
|
|
|
|
Map<String, dynamic> sampleMediaAssetJson({String status = 'ready'}) => {
|
|
'id': 'a-1',
|
|
'kind': 'image',
|
|
'purpose': 'post_image',
|
|
'mimeType': 'image/jpeg',
|
|
'byteSize': 204800,
|
|
'widthPx': 1080,
|
|
'heightPx': 810,
|
|
'status': status,
|
|
'url': status == 'ready'
|
|
? 'https://minio.local/p.jpg?X-Amz-Signature=sig'
|
|
: null,
|
|
'readyAt': status == 'ready' ? '2026-09-08T10:06:00.000Z' : null,
|
|
'createdAt': '2026-09-08T10:00:00.000Z',
|
|
};
|
|
|
|
Map<String, Object?> cursorPageJson(
|
|
List<Map<String, dynamic>> items, {
|
|
String? nextCursor,
|
|
bool hasMore = false,
|
|
}) => {'items': items, 'nextCursor': nextCursor, 'hasMore': hasMore};
|
|
|
|
FeedCard sampleFeedCard({
|
|
String id = 'p-1',
|
|
bool likedByMe = false,
|
|
int likeCount = 6,
|
|
}) => FeedCard.fromJson(
|
|
sampleFeedCardJson(id: id, likedByMe: likedByMe, likeCount: likeCount),
|
|
);
|
|
|
|
CursorPage<FeedCard> feedPage(
|
|
List<FeedCard> items, {
|
|
String? nextCursor,
|
|
bool hasMore = false,
|
|
}) => CursorPage(items: items, nextCursor: nextCursor, hasMore: hasMore);
|
|
|
|
Post samplePost({
|
|
String id = 'p-1',
|
|
bool likedByMe = false,
|
|
int likeCount = 6,
|
|
bool bookmarkedByMe = false,
|
|
int bookmarkCount = 2,
|
|
}) => Post.fromJson(
|
|
samplePostJson(
|
|
id: id,
|
|
likedByMe: likedByMe,
|
|
likeCount: likeCount,
|
|
bookmarkedByMe: bookmarkedByMe,
|
|
bookmarkCount: bookmarkCount,
|
|
),
|
|
);
|
|
|
|
PostComment sampleComment({
|
|
String id = 'c-1',
|
|
Map<String, dynamic>? author,
|
|
Map<String, dynamic>? replyToUser,
|
|
String content = '好可爱!',
|
|
}) => PostComment.fromJson(
|
|
sampleCommentJson(
|
|
id: id,
|
|
author: author,
|
|
replyToUser: replyToUser,
|
|
content: content,
|
|
),
|
|
);
|
|
|
|
CursorPage<PostComment> commentPage(
|
|
List<PostComment> items, {
|
|
String? nextCursor,
|
|
bool hasMore = false,
|
|
}) => CursorPage(items: items, nextCursor: nextCursor, hasMore: hasMore);
|
|
|
|
/// 假仓库:controller 测试注入行为并记录调用(Completer 控时序)。
|
|
/// 未注入 handler 的方法一律 UnimplementedError(误触发即测试失败)。
|
|
class FakeCommunityRepository implements CommunityRepository {
|
|
/// 调用日志,如 `feed:cursor=null`、`like:p-1`、`unlike:p-1`。
|
|
final List<String> calls = [];
|
|
|
|
Future<CursorPage<FeedCard>> Function(int? limit, String? cursor)? onFeed;
|
|
Future<LikeState> Function(String postId, bool target)? onLikeToggle;
|
|
Future<BookmarkState> Function(String postId, bool target)? onBookmarkToggle;
|
|
Future<Post> Function(String postId)? onGetPost;
|
|
Future<CursorPage<PostComment>> Function(String postId, String? cursor)?
|
|
onListComments;
|
|
Future<PostComment> Function(String postId, CreateCommentRequest request)?
|
|
onCreateComment;
|
|
Future<void> Function(String commentId)? onDeleteComment;
|
|
Future<FollowState> Function(String userId, bool target)? onFollowToggle;
|
|
Future<FollowStats> Function(String userId)? onGetFollowStats;
|
|
Future<MediaUploadCredentials> Function(CreateMediaUploadRequest request)?
|
|
onCreateMediaUpload;
|
|
Future<MediaAsset> Function(String assetId)? onCompleteMediaUpload;
|
|
|
|
@override
|
|
Future<CursorPage<FeedCard>> getFeed({int? limit, String? cursor}) {
|
|
calls.add('feed:cursor=$cursor');
|
|
return onFeed!(limit, cursor);
|
|
}
|
|
|
|
@override
|
|
Future<LikeState> likePost(String postId) {
|
|
calls.add('like:$postId');
|
|
return onLikeToggle!(postId, true);
|
|
}
|
|
|
|
@override
|
|
Future<LikeState> unlikePost(String postId) {
|
|
calls.add('unlike:$postId');
|
|
return onLikeToggle!(postId, false);
|
|
}
|
|
|
|
@override
|
|
Future<BookmarkState> bookmarkPost(String postId) {
|
|
calls.add('bookmark:$postId');
|
|
return onBookmarkToggle!(postId, true);
|
|
}
|
|
|
|
@override
|
|
Future<BookmarkState> unbookmarkPost(String postId) {
|
|
calls.add('unbookmark:$postId');
|
|
return onBookmarkToggle!(postId, false);
|
|
}
|
|
|
|
@override
|
|
Future<Post> getPost(String postId) {
|
|
calls.add('getPost:$postId');
|
|
return onGetPost!(postId);
|
|
}
|
|
|
|
@override
|
|
Future<MediaUploadCredentials> createMediaUpload(
|
|
CreateMediaUploadRequest request,
|
|
) {
|
|
calls.add('createUpload:${request.mimeType}:${request.byteSize}');
|
|
return onCreateMediaUpload!(request);
|
|
}
|
|
|
|
@override
|
|
Future<MediaAsset> completeMediaUpload(String assetId) {
|
|
calls.add('complete:$assetId');
|
|
return onCompleteMediaUpload!(assetId);
|
|
}
|
|
|
|
@override
|
|
Future<Post> createPost(CreatePostRequest request) =>
|
|
throw UnimplementedError();
|
|
|
|
@override
|
|
Future<Post> updatePost(String postId, UpdatePostRequest request) =>
|
|
throw UnimplementedError();
|
|
|
|
@override
|
|
Future<void> deletePost(String postId) => throw UnimplementedError();
|
|
|
|
@override
|
|
Future<CursorPage<Post>> listMyPosts({
|
|
int? limit,
|
|
String? cursor,
|
|
PostStatus? status,
|
|
}) => throw UnimplementedError();
|
|
|
|
@override
|
|
Future<CursorPage<PostComment>> listComments(
|
|
String postId, {
|
|
int? limit,
|
|
String? cursor,
|
|
}) {
|
|
calls.add('comments:$postId:cursor=$cursor');
|
|
return onListComments!(postId, cursor);
|
|
}
|
|
|
|
@override
|
|
Future<PostComment> createComment(
|
|
String postId,
|
|
CreateCommentRequest request,
|
|
) {
|
|
calls.add('createComment:$postId:${request.content}');
|
|
return onCreateComment!(postId, request);
|
|
}
|
|
|
|
@override
|
|
Future<void> deleteComment(String commentId) {
|
|
calls.add('deleteComment:$commentId');
|
|
return onDeleteComment!(commentId);
|
|
}
|
|
|
|
@override
|
|
Future<FollowState> followUser(String userId) {
|
|
calls.add('follow:$userId');
|
|
return onFollowToggle!(userId, true);
|
|
}
|
|
|
|
@override
|
|
Future<FollowState> unfollowUser(String userId) {
|
|
calls.add('unfollow:$userId');
|
|
return onFollowToggle!(userId, false);
|
|
}
|
|
|
|
@override
|
|
Future<FollowStats> getFollowStats(String userId) {
|
|
calls.add('followStats:$userId');
|
|
return onGetFollowStats!(userId);
|
|
}
|
|
|
|
@override
|
|
Future<CursorPage<FeedCard>> listMyBookmarks({int? limit, String? cursor}) =>
|
|
throw UnimplementedError();
|
|
}
|