feat(player): 评论发布成功提示
This commit is contained in:
1 parent
9c0c1b8982
commit
e86daf559a
10 files changed
+138
-47
No files matched your search
@@ -234,7 +234,11 @@ void main() {
|
||||
publishError: const ApiException(400, '评论包含敏感词'),
|
||||
);
|
||||
|
||||
await _pumpSheet(tester, repository: repository);
|
||||
await _pumpSheet(
|
||||
tester,
|
||||
repository: repository,
|
||||
locale: const Locale('zh'),
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('comment-input-placeholder')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
@@ -250,6 +254,7 @@ void main() {
|
||||
find.byKey(const Key('comment-composer-input')),
|
||||
);
|
||||
expect(field.controller?.text, 'blocked text');
|
||||
expect(find.text('发表成功'), findsNothing);
|
||||
// 发送失败时保留输入与焦点,用户可以直接改完再发。
|
||||
expect(field.focusNode?.hasFocus, isTrue);
|
||||
},
|
||||
@@ -263,7 +268,11 @@ void main() {
|
||||
countResult: 1,
|
||||
);
|
||||
|
||||
await _pumpSheet(tester, repository: repository);
|
||||
await _pumpSheet(
|
||||
tester,
|
||||
repository: repository,
|
||||
locale: const Locale('zh'),
|
||||
);
|
||||
final input = find.byKey(const Key('comment-composer-input'));
|
||||
tester.view.viewInsets = const FakeViewPadding(bottom: 180);
|
||||
await tester.tap(find.byKey(const Key('comment-input-placeholder')));
|
||||
@@ -278,9 +287,25 @@ void main() {
|
||||
isNotNull,
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('comment-composer-post')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
expect(find.byKey(const Key('comment-composer-sheet')), findsNothing);
|
||||
final successSnackBar = find.byKey(
|
||||
const Key('comment-post-success-snackbar'),
|
||||
);
|
||||
expect(successSnackBar, findsOneWidget);
|
||||
expect(find.text('发表成功'), findsOneWidget);
|
||||
final snackBar = tester.widget<SnackBar>(successSnackBar);
|
||||
expect(snackBar.action, isNull);
|
||||
expect(snackBar.behavior, SnackBarBehavior.floating);
|
||||
expect(snackBar.duration, const Duration(milliseconds: 1500));
|
||||
expect(
|
||||
tester.getRect(find.text('发表成功')).bottom,
|
||||
lessThanOrEqualTo(
|
||||
tester.getRect(find.byKey(const Key('player-comments-sheet'))).top,
|
||||
),
|
||||
);
|
||||
expect(find.byKey(const Key('comment-list')), findsOneWidget);
|
||||
expect(find.byKey(const Key('comment-count-label')), findsOneWidget);
|
||||
expect(find.byKey(const Key('comment-input-placeholder')), findsOneWidget);
|
||||
@@ -669,6 +694,7 @@ Future<AuthController> _pumpSheet(
|
||||
WidgetTester tester, {
|
||||
required FakeCommentRepository repository,
|
||||
FakeHaptics? haptics,
|
||||
Locale locale = const Locale('en'),
|
||||
}) async {
|
||||
final auth = await _auth();
|
||||
await tester.pumpWidget(
|
||||
@@ -682,7 +708,7 @@ Future<AuthController> _pumpSheet(
|
||||
Provider<Haptics>.value(value: haptics ?? FakeHaptics()),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
locale: locale,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
initialRoute: '/comments',
|
||||
|
||||
Reference in new issue
Block a user