feat(flutter): 接入互动评论点赞举报
This commit is contained in:
1 parent
45f5f25640
commit
d361034226
39 files changed
+3298
-462
No files matched your search
@@ -0,0 +1,55 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/models/interaction.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/interaction/widgets/report_dialog.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_return_selected_reason_and_description_when_submitted', (
|
||||
tester,
|
||||
) async {
|
||||
ReportDialogResult? result;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Builder(
|
||||
builder: (context) => Scaffold(
|
||||
body: TextButton(
|
||||
key: const Key('open-report-dialog'),
|
||||
onPressed: () async {
|
||||
result = await showReportDialog(
|
||||
context,
|
||||
title: 'Report comment',
|
||||
);
|
||||
},
|
||||
child: const Text('Open'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('open-report-dialog')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Spam'), findsOneWidget);
|
||||
expect(find.text('Harassment'), findsOneWidget);
|
||||
expect(find.text('Sexual content'), findsOneWidget);
|
||||
expect(find.text('Advertising'), findsOneWidget);
|
||||
expect(find.text('Other'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('report-reason-AD')));
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('report-description')),
|
||||
'Repeat promotion',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('report-submit')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(result?.reason, ReportReason.ad);
|
||||
expect(result?.description, 'Repeat promotion');
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user