feat(player): 点赞与评论改为按集
This commit is contained in:
1 parent
e6f34977f5
commit
83822a0cbb
25 files changed
+337
-69
No files matched your search
@@ -55,12 +55,18 @@ void main() {
|
||||
ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter),
|
||||
);
|
||||
|
||||
final page = await api.page(dramaId: '5', cursor: '99', size: 20);
|
||||
final page = await api.page(
|
||||
dramaId: '5',
|
||||
episodeId: '7',
|
||||
cursor: '99',
|
||||
size: 20,
|
||||
);
|
||||
|
||||
expect(adapter.requests.single.method, 'GET');
|
||||
expect(adapter.requests.single.uri.path, '/app/comments');
|
||||
expect(adapter.requests.single.queryParameters, {
|
||||
'dramaId': '5',
|
||||
'episodeId': '7',
|
||||
'cursor': '99',
|
||||
'size': '20',
|
||||
});
|
||||
@@ -93,6 +99,7 @@ void main() {
|
||||
|
||||
final reply = await api.publish(
|
||||
dramaId: '5',
|
||||
episodeId: '7',
|
||||
content: 'great badword',
|
||||
parentId: '2111012753262120962',
|
||||
);
|
||||
@@ -101,6 +108,7 @@ void main() {
|
||||
expect(adapter.requests.single.uri.path, '/app/comments');
|
||||
expect(adapter.requests.single.data, {
|
||||
'dramaId': '5',
|
||||
'episodeId': '7',
|
||||
'content': 'great badword',
|
||||
'parentId': '2111012753262120962',
|
||||
});
|
||||
@@ -135,12 +143,15 @@ void main() {
|
||||
ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter),
|
||||
);
|
||||
|
||||
final count = await api.count('5');
|
||||
final count = await api.count('5', episodeId: '7');
|
||||
|
||||
expect(count, 17);
|
||||
expect(adapter.requests.single.method, 'GET');
|
||||
expect(adapter.requests.single.uri.path, '/app/comments/count');
|
||||
expect(adapter.requests.single.queryParameters, {'dramaId': '5'});
|
||||
expect(adapter.requests.single.queryParameters, {
|
||||
'dramaId': '5',
|
||||
'episodeId': '7',
|
||||
});
|
||||
});
|
||||
|
||||
test('should_parse_string_comment_count', () async {
|
||||
|
||||
@@ -12,10 +12,12 @@ void main() {
|
||||
CommentController controller(
|
||||
FakeCommentRepository comments, {
|
||||
FakeInteractionRepository? interactions,
|
||||
String? episodeId,
|
||||
}) => CommentController(
|
||||
comments: comments,
|
||||
interactions: interactions ?? FakeInteractionRepository(),
|
||||
dramaId: '5',
|
||||
episodeId: episodeId,
|
||||
);
|
||||
|
||||
test('should_append_next_page_with_cursor_when_has_more_is_true', () async {
|
||||
@@ -63,6 +65,42 @@ void main() {
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('should_pass_episode_id_to_every_page_and_publish_request', () async {
|
||||
final root = commentFixture(id: '10', replyCount: 1);
|
||||
final repository = FakeCommentRepository(
|
||||
pages: [
|
||||
CommentPage(
|
||||
comments: [root],
|
||||
nextCursor: '10',
|
||||
hasMore: true,
|
||||
),
|
||||
CommentPage(comments: [commentFixture(id: '9')]),
|
||||
CommentPage(
|
||||
comments: [commentFixture(id: '11', rootId: '10')],
|
||||
nextCursor: '11',
|
||||
hasMore: true,
|
||||
),
|
||||
CommentPage(comments: [commentFixture(id: '12', rootId: '10')]),
|
||||
],
|
||||
publishResult: commentFixture(id: '13', mine: true),
|
||||
);
|
||||
final model = controller(repository, episodeId: 'episode-7');
|
||||
|
||||
await model.load();
|
||||
await model.loadMore();
|
||||
await model.loadReplies('10');
|
||||
await model.loadMoreReplies('10');
|
||||
await model.publish('Nice episode');
|
||||
|
||||
expect(
|
||||
repository.pageCalls.map((call) => call.episodeId),
|
||||
everyElement('episode-7'),
|
||||
);
|
||||
expect(repository.pageCalls, hasLength(4));
|
||||
expect(repository.publishCalls.single.episodeId, 'episode-7');
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('should_use_server_content_and_pending_status_when_review_is_returned', () async {
|
||||
final repository = FakeCommentRepository(
|
||||
publishResult: commentFixture(
|
||||
|
||||
@@ -239,6 +239,36 @@ void main() {
|
||||
expect(repository.countCalls, ['5']);
|
||||
});
|
||||
|
||||
testWidgets('should_scope_list_count_and_publish_to_episode', (tester) async {
|
||||
final repository = FakeCommentRepository(
|
||||
pages: [const CommentPage()],
|
||||
countResult: 3,
|
||||
publishResult: commentFixture(
|
||||
id: '11',
|
||||
content: 'Episode comment',
|
||||
mine: true,
|
||||
),
|
||||
);
|
||||
|
||||
await _pumpSheet(tester, repository: repository, episodeId: 'episode-7');
|
||||
|
||||
expect(repository.pageCalls.single.episodeId, 'episode-7');
|
||||
expect(repository.countEpisodeCalls, ['episode-7']);
|
||||
|
||||
await tester.tap(find.byKey(const Key('comment-input-placeholder')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('comment-composer-input')),
|
||||
'Episode comment',
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(const Key('comment-composer-post')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(repository.publishCalls.single.episodeId, 'episode-7');
|
||||
expect(repository.countEpisodeCalls, ['episode-7', 'episode-7']);
|
||||
});
|
||||
|
||||
testWidgets('should_fall_back_to_exact_count_when_server_total_fails', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -964,6 +994,7 @@ Future<AuthController> _pumpSheet(
|
||||
required FakeCommentRepository repository,
|
||||
FakeHaptics? haptics,
|
||||
Locale locale = const Locale('en'),
|
||||
String? episodeId,
|
||||
}) async {
|
||||
final auth = await _auth();
|
||||
await tester.pumpWidget(
|
||||
@@ -983,12 +1014,12 @@ Future<AuthController> _pumpSheet(
|
||||
initialRoute: '/comments',
|
||||
routes: {
|
||||
'/': (_) => const Scaffold(backgroundColor: AppColors.ink),
|
||||
'/comments': (_) => const Scaffold(
|
||||
'/comments': (_) => Scaffold(
|
||||
backgroundColor: AppColors.ink,
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: DramaCommentsSheet(drama: _drama),
|
||||
child: DramaCommentsSheet(drama: _drama, episodeId: episodeId),
|
||||
),
|
||||
),
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user