feat(interaction): 支持游客点赞收藏评论
This commit is contained in:
1 parent
188811fde6
commit
a3d50eb935
18 files changed
+364
-121
No files matched your search
@@ -135,7 +135,9 @@ void main() {
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
testWidgets('should_gate_guest_comment_input_without_focus', (tester) async {
|
||||
testWidgets('should_open_guest_comment_composer_without_login', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
final repository = FakeCommentRepository(pages: [const CommentPage()]);
|
||||
@@ -144,34 +146,20 @@ void main() {
|
||||
final placeholder = find.byKey(const Key('comment-input-placeholder'));
|
||||
|
||||
expect(placeholder, findsOneWidget);
|
||||
expect(find.text('Sign in to comment'), findsOneWidget);
|
||||
await tester.tap(placeholder);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Sign in to continue'), findsOneWidget);
|
||||
await tester.tap(find.text('Not now'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('comment-composer-sheet')), findsNothing);
|
||||
expect(placeholder, findsOneWidget);
|
||||
expect(find.byKey(const Key('comment-composer-sheet')), findsOneWidget);
|
||||
expect(find.byKey(const Key('auth-landing')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_focus_comment_input_after_successful_login', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_focus_guest_comment_input_immediately', (tester) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
final repository = FakeCommentRepository(pages: [const CommentPage()]);
|
||||
final auth = await _pumpSheet(tester, repository: repository);
|
||||
await _pumpSheet(tester, repository: repository);
|
||||
|
||||
await tester.tap(find.byKey(const Key('comment-input-placeholder')));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
await tester.tap(find.text('Sign In'));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
(auth as _TestAuthController).setSignedIn(true);
|
||||
await tester.pump();
|
||||
Navigator.of(tester.element(find.byKey(const Key('auth-landing')))).pop();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
@@ -218,9 +206,7 @@ void main() {
|
||||
expect(multilineField.style?.height, 1.4);
|
||||
});
|
||||
|
||||
testWidgets('should_gate_guest_post_without_creating_comment', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_publish_guest_comment_without_login', (tester) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
final repository = FakeCommentRepository(pages: [const CommentPage()]);
|
||||
@@ -229,8 +215,18 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('comment-post')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Sign in to continue'), findsOneWidget);
|
||||
expect(repository.publishCalls, isEmpty);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('comment-composer-input')),
|
||||
'Guest comment',
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(const Key('comment-composer-post')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('auth-landing')), findsNothing);
|
||||
expect(repository.publishCalls, hasLength(1));
|
||||
expect(repository.publishCalls.single.content, 'Guest comment');
|
||||
expect(find.text('Guest comment'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_show_server_comments_and_append_next_cursor_page', (
|
||||
|
||||
Reference in new issue
Block a user