Imrpoved image handling since the size of the image is about 5MB.
This commit is contained in:
@@ -12,6 +12,7 @@ import 'package:fotodocumentation/controller/customer_controller.dart';
|
||||
import 'package:fotodocumentation/controller/picture_controller.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
import 'package:flutter_image_test_utils/flutter_image_test_utils.dart';
|
||||
|
||||
import '../testing/test_utils.dart';
|
||||
import '../testing/test_utils.mocks.dart';
|
||||
@@ -31,16 +32,17 @@ void main() {
|
||||
|
||||
when(controller.get(id: 1)).thenAnswer((_) async => _dto);
|
||||
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
||||
verify(controller.get(id: 1)).called(1);
|
||||
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
||||
verify(controller.get(id: 1)).called(1);
|
||||
// Click on the first row (InkWell) to open the picture popup
|
||||
await tester.tap(find.byKey(Key("table_row_1")).first);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Click on the first row (InkWell) to open the picture popup
|
||||
await tester.tap(find.byKey(Key("table_row_1")).first);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify that the popup is shown by checking for the PictureWidget
|
||||
expect(find.byType(PictureWidget), findsOneWidget);
|
||||
// Verify that the popup is shown by checking for the PictureWidget
|
||||
expect(find.byType(PictureWidget), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Customer delete yes', (WidgetTester tester) async {
|
||||
@@ -55,22 +57,24 @@ void main() {
|
||||
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
||||
when(pictureController.delete(argThat(isA<PictureDto>()))).thenAnswer((_) async => true);
|
||||
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
||||
verify(controller.get(id: 1)).called(1);
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
||||
verify(controller.get(id: 1)).called(1);
|
||||
|
||||
// Click on the first row (InkWell) to open the picture popup
|
||||
await tester.tap(find.byKey(Key("table_row_delete_1")).first);
|
||||
await tester.pumpAndSettle();
|
||||
// Click on the first row (InkWell) to open the picture popup
|
||||
await tester.tap(find.byKey(Key("table_row_delete_1")).first);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify that the popup is shown by checking for the PictureWidget
|
||||
expect(find.byType(PictureDeleteDialog), findsOneWidget);
|
||||
// Verify that the popup is shown by checking for the PictureWidget
|
||||
expect(find.byType(PictureDeleteDialog), findsOneWidget);
|
||||
|
||||
// Click the yes button to confirm delete
|
||||
await tester.tap(find.byKey(Key("picture_delete_yes")));
|
||||
await tester.pumpAndSettle();
|
||||
// Click the yes button to confirm delete
|
||||
await tester.tap(find.byKey(Key("picture_delete_yes")));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify that the delete method was called on the picture controller
|
||||
verify(pictureController.delete(argThat(isA<PictureDto>()))).called(1);
|
||||
// Verify that the delete method was called on the picture controller
|
||||
verify(pictureController.delete(argThat(isA<PictureDto>()))).called(1);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Customer delete no', (WidgetTester tester) async {
|
||||
@@ -84,28 +88,39 @@ void main() {
|
||||
when(controller.get(id: 1)).thenAnswer((_) async => _dto);
|
||||
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
||||
verify(controller.get(id: 1)).called(1);
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
||||
verify(controller.get(id: 1)).called(1);
|
||||
|
||||
// Click on the first row (InkWell) to open the picture popup
|
||||
await tester.tap(find.byKey(Key("table_row_delete_1")).first);
|
||||
await tester.pumpAndSettle();
|
||||
// Click on the first row (InkWell) to open the picture popup
|
||||
await tester.tap(find.byKey(Key("table_row_delete_1")).first);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify that the popup is shown by checking for the PictureWidget
|
||||
expect(find.byType(PictureDeleteDialog), findsOneWidget);
|
||||
// Verify that the popup is shown by checking for the PictureWidget
|
||||
expect(find.byType(PictureDeleteDialog), findsOneWidget);
|
||||
|
||||
// Click the yes button to confirm delete
|
||||
await tester.tap(find.byKey(Key("picture_delete_no")));
|
||||
await tester.pumpAndSettle();
|
||||
// Click the yes button to confirm delete
|
||||
await tester.tap(find.byKey(Key("picture_delete_no")));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify that the delete method was called on the picture controller
|
||||
verifyNever(pictureController.delete(argThat(isA<PictureDto>())));
|
||||
// Verify that the delete method was called on the picture controller
|
||||
verifyNever(pictureController.delete(argThat(isA<PictureDto>())));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
CustomerDto _dto = CustomerDto(id: 1, customerNumber: "CODE1", name: "Customer 1", pictures: [
|
||||
PictureDto(id: 1, comment: "Some comment", category: "category", pictureDate: DateTime.now(), username: "username", imageUrl: "", evaluation: 1, normalSizeUrl: "", thumbnailSizeUrl: ""),
|
||||
]);
|
||||
PictureDto(
|
||||
id: 1,
|
||||
comment: "Some comment",
|
||||
category: "category",
|
||||
pictureDate: DateTime.now(),
|
||||
username: "username",
|
||||
imageUrl: "https://en.wikipedia.org/wiki/File:Keir_Starmer_meets_T%C3%B4_L%C3%A2m_29-10-2025_(6)_(cropped).jpg",
|
||||
evaluation: 1,
|
||||
normalSizeUrl: "https://en.wikipedia.org/wiki/File:Keir_Starmer_meets_T%C3%B4_L%C3%A2m_29-10-2025_(6)_(cropped).jpg",
|
||||
thumbnailSizeUrl: "https://en.wikipedia.org/wiki/File:Keir_Starmer_meets_T%C3%B4_L%C3%A2m_29-10-2025_(6)_(cropped).jpg"),
|
||||
]);
|
||||
|
||||
List<CustomerListDto> _list = [CustomerListDto(id: 1, customerNumber: "CODE1", name: "Customer 1"), CustomerListDto(id: 2, customerNumber: "CODE2", name: "Customer 2")];
|
||||
List<CustomerListDto> _list = [CustomerListDto(id: 1, customerNumber: "CODE1", name: "Customer 1"), CustomerListDto(id: 2, customerNumber: "CODE2", name: "Customer 2")];
|
||||
|
||||
Reference in New Issue
Block a user