Imrpoved image handling since the size of the image is about 5MB.
This commit is contained in:
@@ -75,6 +75,7 @@ dev_dependencies:
|
||||
flutter_lints: ^6.0.0
|
||||
mockito: ^5.4.5
|
||||
build_runner: ^2.4.14
|
||||
flutter_image_test_utils: ^1.1.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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,7 +32,7 @@ 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);
|
||||
|
||||
@@ -42,6 +43,7 @@ void main() {
|
||||
// Verify that the popup is shown by checking for the PictureWidget
|
||||
expect(find.byType(PictureWidget), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Customer delete yes', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
@@ -55,6 +57,7 @@ void main() {
|
||||
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
||||
when(pictureController.delete(argThat(isA<PictureDto>()))).thenAnswer((_) async => true);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
||||
verify(controller.get(id: 1)).called(1);
|
||||
|
||||
@@ -72,6 +75,7 @@ void main() {
|
||||
// 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 {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
@@ -84,6 +88,7 @@ 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);
|
||||
|
||||
@@ -102,10 +107,20 @@ void main() {
|
||||
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")];
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_image_test_utils/image_test/image_test_io.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fotodocumentation/controller/customer_controller.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart' show CustomerDto, CustomerListDto;
|
||||
@@ -78,6 +79,7 @@ void main() {
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -91,6 +93,7 @@ void main() {
|
||||
expect(find.text('KUNDENNUMMER'), findsOneWidget);
|
||||
expect(find.text('KOMMENTAR'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('displays picture comment', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
@@ -98,25 +101,28 @@ void main() {
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify the comment is displayed
|
||||
expect(find.text('First picture comment'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('displays empty string when comment is null', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The comment field should be empty but the label should exist
|
||||
expect(find.text('KOMMENTAR'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('shows both navigation buttons at bottom', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
@@ -124,6 +130,7 @@ void main() {
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -131,13 +138,14 @@ void main() {
|
||||
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
||||
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('shows both navigation buttons when on middle picture', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -145,13 +153,14 @@ void main() {
|
||||
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
||||
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('shows both navigation buttons on last picture', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -159,13 +168,14 @@ void main() {
|
||||
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
||||
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('navigates to next picture when right button is tapped', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -180,6 +190,7 @@ void main() {
|
||||
expect(find.text('Second picture comment'), findsOneWidget);
|
||||
expect(find.text('First picture comment'), findsNothing);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('navigates to previous picture when left button is tapped', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
@@ -187,6 +198,7 @@ void main() {
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/2");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -201,6 +213,7 @@ void main() {
|
||||
expect(find.text('First picture comment'), findsOneWidget);
|
||||
expect(find.text('Second picture comment'), findsNothing);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('shows disabled navigation buttons when only one picture', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 1024, 1024);
|
||||
@@ -215,6 +228,7 @@ void main() {
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => singlePictureCustomer);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -222,13 +236,14 @@ void main() {
|
||||
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
||||
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('opens fullscreen dialog when image is tapped', (WidgetTester tester) async {
|
||||
setScreenSize(tester, 2048, 2048);
|
||||
|
||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||
|
||||
provideMockedNetworkImages(() async {
|
||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -249,6 +264,7 @@ void main() {
|
||||
expect(find.byType(PictureFullscreenDialog), findsOneWidget);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
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