Test Cases

This commit is contained in:
2026-04-11 07:40:49 +08:00
parent f223d1f958
commit 7d8851a94a
14 changed files with 2171 additions and 92 deletions
+28 -2
View File
@@ -1,3 +1,5 @@
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -28,6 +30,29 @@ class _FakeProfileController implements ProfileController {
Future<void> updatePassword(String password) async {
lastPassword = password;
}
@override
Future<String> uploadAvatar({
required String userId,
required Uint8List bytes,
required String fileName,
}) async {
return 'https://example.com/avatar.jpg';
}
@override
Future<String> uploadFacePhoto({
required String userId,
required Uint8List bytes,
required String fileName,
}) async {
return 'https://example.com/face.jpg';
}
@override
Future<Uint8List?> downloadFacePhoto(String userId) async {
return null;
}
}
class _FakeUserOfficesController implements UserOfficesController {
@@ -118,15 +143,15 @@ void main() {
find.widgetWithText(TextFormField, 'Full name'),
'New Name',
);
await tester.ensureVisible(find.text('Save details'));
await tester.tap(find.text('Save details'));
await tester.pumpAndSettle();
expect(fake.lastFullName, equals('New Name'));
// should show a success snackbar using the awesome_snackbar_content package
// (AwesomeSnackbarContent uses its own SVG icons, not Material Icons)
expect(find.byType(AwesomeSnackbarContent), findsOneWidget);
// our helper adds a leading icon for even short messages
expect(find.byIcon(Icons.check_circle), findsOneWidget);
});
testWidgets('save offices assigns selected office', (tester) async {
@@ -198,6 +223,7 @@ void main() {
find.widgetWithText(TextFormField, 'Confirm password'),
'new-pass-123',
);
await tester.ensureVisible(find.text('Change password'));
await tester.tap(find.text('Change password'));
await tester.pumpAndSettle();