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
|
flutter_lints: ^6.0.0
|
||||||
mockito: ^5.4.5
|
mockito: ^5.4.5
|
||||||
build_runner: ^2.4.14
|
build_runner: ^2.4.14
|
||||||
|
flutter_image_test_utils: ^1.1.0
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
# 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/controller/picture_controller.dart';
|
||||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||||
import 'package:fotodocumentation/utils/di_container.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.dart';
|
||||||
import '../testing/test_utils.mocks.dart';
|
import '../testing/test_utils.mocks.dart';
|
||||||
@@ -31,16 +32,17 @@ void main() {
|
|||||||
|
|
||||||
when(controller.get(id: 1)).thenAnswer((_) async => _dto);
|
when(controller.get(id: 1)).thenAnswer((_) async => _dto);
|
||||||
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
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");
|
// Click on the first row (InkWell) to open the picture popup
|
||||||
verify(controller.get(id: 1)).called(1);
|
await tester.tap(find.byKey(Key("table_row_1")).first);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Click on the first row (InkWell) to open the picture popup
|
// Verify that the popup is shown by checking for the PictureWidget
|
||||||
await tester.tap(find.byKey(Key("table_row_1")).first);
|
expect(find.byType(PictureWidget), findsOneWidget);
|
||||||
await tester.pumpAndSettle();
|
});
|
||||||
|
|
||||||
// Verify that the popup is shown by checking for the PictureWidget
|
|
||||||
expect(find.byType(PictureWidget), findsOneWidget);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Customer delete yes', (WidgetTester tester) async {
|
testWidgets('Customer delete yes', (WidgetTester tester) async {
|
||||||
@@ -55,22 +57,24 @@ void main() {
|
|||||||
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
when(pictureController.delete(argThat(isA<PictureDto>()))).thenAnswer((_) async => true);
|
when(pictureController.delete(argThat(isA<PictureDto>()))).thenAnswer((_) async => true);
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
provideMockedNetworkImages(() async {
|
||||||
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
|
// Click on the first row (InkWell) to open the picture popup
|
||||||
await tester.tap(find.byKey(Key("table_row_delete_1")).first);
|
await tester.tap(find.byKey(Key("table_row_delete_1")).first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify that the popup is shown by checking for the PictureWidget
|
// Verify that the popup is shown by checking for the PictureWidget
|
||||||
expect(find.byType(PictureDeleteDialog), findsOneWidget);
|
expect(find.byType(PictureDeleteDialog), findsOneWidget);
|
||||||
|
|
||||||
// Click the yes button to confirm delete
|
// Click the yes button to confirm delete
|
||||||
await tester.tap(find.byKey(Key("picture_delete_yes")));
|
await tester.tap(find.byKey(Key("picture_delete_yes")));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify that the delete method was called on the picture controller
|
// Verify that the delete method was called on the picture controller
|
||||||
verify(pictureController.delete(argThat(isA<PictureDto>()))).called(1);
|
verify(pictureController.delete(argThat(isA<PictureDto>()))).called(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Customer delete no', (WidgetTester tester) async {
|
testWidgets('Customer delete no', (WidgetTester tester) async {
|
||||||
@@ -84,28 +88,39 @@ void main() {
|
|||||||
when(controller.get(id: 1)).thenAnswer((_) async => _dto);
|
when(controller.get(id: 1)).thenAnswer((_) async => _dto);
|
||||||
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
when(controller.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1");
|
provideMockedNetworkImages(() async {
|
||||||
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
|
// Click on the first row (InkWell) to open the picture popup
|
||||||
await tester.tap(find.byKey(Key("table_row_delete_1")).first);
|
await tester.tap(find.byKey(Key("table_row_delete_1")).first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify that the popup is shown by checking for the PictureWidget
|
// Verify that the popup is shown by checking for the PictureWidget
|
||||||
expect(find.byType(PictureDeleteDialog), findsOneWidget);
|
expect(find.byType(PictureDeleteDialog), findsOneWidget);
|
||||||
|
|
||||||
// Click the yes button to confirm delete
|
// Click the yes button to confirm delete
|
||||||
await tester.tap(find.byKey(Key("picture_delete_no")));
|
await tester.tap(find.byKey(Key("picture_delete_no")));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify that the delete method was called on the picture controller
|
// Verify that the delete method was called on the picture controller
|
||||||
verifyNever(pictureController.delete(argThat(isA<PictureDto>())));
|
verifyNever(pictureController.delete(argThat(isA<PictureDto>())));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomerDto _dto = CustomerDto(id: 1, customerNumber: "CODE1", name: "Customer 1", pictures: [
|
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")];
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
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:flutter_test/flutter_test.dart';
|
||||||
import 'package:fotodocumentation/controller/customer_controller.dart';
|
import 'package:fotodocumentation/controller/customer_controller.dart';
|
||||||
import 'package:fotodocumentation/dto/customer_dto.dart' show CustomerDto, CustomerListDto;
|
import 'package:fotodocumentation/dto/customer_dto.dart' show CustomerDto, CustomerListDto;
|
||||||
@@ -78,18 +79,20 @@ void main() {
|
|||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
provideMockedNetworkImages(() async {
|
||||||
await tester.pumpAndSettle();
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify customer name is displayed
|
// Verify customer name is displayed
|
||||||
expect(find.text('Test Apotheke'), findsOneWidget);
|
expect(find.text('Test Apotheke'), findsOneWidget);
|
||||||
|
|
||||||
// Verify customer number is displayed
|
// Verify customer number is displayed
|
||||||
expect(find.text('CUST001'), findsOneWidget);
|
expect(find.text('CUST001'), findsOneWidget);
|
||||||
|
|
||||||
// Verify labels are displayed
|
// Verify labels are displayed
|
||||||
expect(find.text('KUNDENNUMMER'), findsOneWidget);
|
expect(find.text('KUNDENNUMMER'), findsOneWidget);
|
||||||
expect(find.text('KOMMENTAR'), findsOneWidget);
|
expect(find.text('KOMMENTAR'), findsOneWidget);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('displays picture comment', (WidgetTester tester) async {
|
testWidgets('displays picture comment', (WidgetTester tester) async {
|
||||||
@@ -98,11 +101,13 @@ void main() {
|
|||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
provideMockedNetworkImages(() async {
|
||||||
await tester.pumpAndSettle();
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify the comment is displayed
|
// Verify the comment is displayed
|
||||||
expect(find.text('First picture comment'), findsOneWidget);
|
expect(find.text('First picture comment'), findsOneWidget);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('displays empty string when comment is null', (WidgetTester tester) async {
|
testWidgets('displays empty string when comment is null', (WidgetTester tester) async {
|
||||||
@@ -110,12 +115,13 @@ void main() {
|
|||||||
|
|
||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
provideMockedNetworkImages(() async {
|
||||||
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
// The comment field should be empty but the label should exist
|
||||||
await tester.pumpAndSettle();
|
expect(find.text('KOMMENTAR'), findsOneWidget);
|
||||||
|
});
|
||||||
// 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 {
|
testWidgets('shows both navigation buttons at bottom', (WidgetTester tester) async {
|
||||||
@@ -124,12 +130,14 @@ void main() {
|
|||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
provideMockedNetworkImages(() async {
|
||||||
await tester.pumpAndSettle();
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Both navigation buttons should always be visible at the bottom
|
// Both navigation buttons should always be visible at the bottom
|
||||||
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
||||||
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('shows both navigation buttons when on middle picture', (WidgetTester tester) async {
|
testWidgets('shows both navigation buttons when on middle picture', (WidgetTester tester) async {
|
||||||
@@ -137,13 +145,14 @@ void main() {
|
|||||||
|
|
||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
provideMockedNetworkImages(() async {
|
||||||
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
// Both navigation buttons should be visible
|
||||||
await tester.pumpAndSettle();
|
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
||||||
|
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
||||||
// Both navigation buttons should be visible
|
});
|
||||||
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 {
|
testWidgets('shows both navigation buttons on last picture', (WidgetTester tester) async {
|
||||||
@@ -151,13 +160,14 @@ void main() {
|
|||||||
|
|
||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
provideMockedNetworkImages(() async {
|
||||||
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
// Both navigation buttons should be visible (right one is disabled)
|
||||||
await tester.pumpAndSettle();
|
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
||||||
|
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
||||||
// Both navigation buttons should be visible (right one is disabled)
|
});
|
||||||
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 {
|
testWidgets('navigates to next picture when right button is tapped', (WidgetTester tester) async {
|
||||||
@@ -165,20 +175,21 @@ void main() {
|
|||||||
|
|
||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
provideMockedNetworkImages(() async {
|
||||||
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
// Verify first picture comment is shown
|
||||||
await tester.pumpAndSettle();
|
expect(find.text('First picture comment'), findsOneWidget);
|
||||||
|
|
||||||
// Verify first picture comment is shown
|
// Tap right navigation button
|
||||||
expect(find.text('First picture comment'), findsOneWidget);
|
await tester.tap(find.byKey(Key("navigate_right")));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Tap right navigation button
|
// Verify second picture comment is now shown
|
||||||
await tester.tap(find.byKey(Key("navigate_right")));
|
expect(find.text('Second picture comment'), findsOneWidget);
|
||||||
await tester.pumpAndSettle();
|
expect(find.text('First picture comment'), findsNothing);
|
||||||
|
});
|
||||||
// Verify second picture comment is now shown
|
|
||||||
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 {
|
testWidgets('navigates to previous picture when left button is tapped', (WidgetTester tester) async {
|
||||||
@@ -187,19 +198,21 @@ void main() {
|
|||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/2");
|
provideMockedNetworkImages(() async {
|
||||||
await tester.pumpAndSettle();
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/2");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify second picture comment is shown
|
// Verify second picture comment is shown
|
||||||
expect(find.text('Second picture comment'), findsOneWidget);
|
expect(find.text('Second picture comment'), findsOneWidget);
|
||||||
|
|
||||||
// Tap left navigation button
|
// Tap left navigation button
|
||||||
await tester.tap(find.byKey(Key("navigate_left")));
|
await tester.tap(find.byKey(Key("navigate_left")));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify first picture comment is now shown
|
// Verify first picture comment is now shown
|
||||||
expect(find.text('First picture comment'), findsOneWidget);
|
expect(find.text('First picture comment'), findsOneWidget);
|
||||||
expect(find.text('Second picture comment'), findsNothing);
|
expect(find.text('Second picture comment'), findsNothing);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('shows disabled navigation buttons when only one picture', (WidgetTester tester) async {
|
testWidgets('shows disabled navigation buttons when only one picture', (WidgetTester tester) async {
|
||||||
@@ -215,12 +228,14 @@ void main() {
|
|||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => singlePictureCustomer);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => singlePictureCustomer);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
provideMockedNetworkImages(() async {
|
||||||
await tester.pumpAndSettle();
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Both navigation buttons should be shown but disabled
|
// Both navigation buttons should be shown but disabled
|
||||||
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
expect(find.byKey(Key("navigate_left")), findsOneWidget);
|
||||||
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
expect(find.byKey(Key("navigate_right")), findsOneWidget);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('opens fullscreen dialog when image is tapped', (WidgetTester tester) async {
|
testWidgets('opens fullscreen dialog when image is tapped', (WidgetTester tester) async {
|
||||||
@@ -228,25 +243,26 @@ void main() {
|
|||||||
|
|
||||||
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
|
||||||
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
when(mockCustomerController.getAll("", "")).thenAnswer((_) async => _list);
|
||||||
|
provideMockedNetworkImages(() async {
|
||||||
|
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
await pumpAppConfig(tester, "${GlobalRouter.pathHome}${GlobalRouter.pathCustomer}/1${GlobalRouter.pathPicture}/1");
|
// Find the GestureDetector with the image key
|
||||||
await tester.pumpAndSettle();
|
final imageFinder = find.byKey(const Key("image"));
|
||||||
|
expect(imageFinder, findsOneWidget);
|
||||||
|
|
||||||
// Find the GestureDetector with the image key
|
// Ensure the widget is visible first
|
||||||
final imageFinder = find.byKey(const Key("image"));
|
await tester.ensureVisible(imageFinder);
|
||||||
expect(imageFinder, findsOneWidget);
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Ensure the widget is visible first
|
// Tap the image - use warnIfMissed: false since the Image.memory may have
|
||||||
await tester.ensureVisible(imageFinder);
|
// rendering issues in test environment but the GestureDetector should still work
|
||||||
await tester.pumpAndSettle();
|
await tester.tap(imageFinder, warnIfMissed: false);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Tap the image - use warnIfMissed: false since the Image.memory may have
|
// Verify fullscreen dialog is shown
|
||||||
// rendering issues in test environment but the GestureDetector should still work
|
expect(find.byType(PictureFullscreenDialog), findsOneWidget);
|
||||||
await tester.tap(imageFinder, warnIfMissed: false);
|
});
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
// Verify fullscreen dialog is shown
|
|
||||||
expect(find.byType(PictureFullscreenDialog), findsOneWidget);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user