rework ui

This commit is contained in:
verboomp
2026-01-29 12:37:44 +01:00
parent 38979c99e5
commit e062b4c688
18 changed files with 462 additions and 246 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,13 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/customer_controller.dart';
import 'package:fotodocumentation/dto/customer_dto.dart' show CustomerDto;
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/pages/customer/picture_widget.dart';
import 'package:fotodocumentation/pages/customer/picture_fullscreen_dialog.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:mockito/mockito.dart';
import '../testing/test_utils.dart';
import '../testing/test_utils.mocks.dart';
// Minimal valid base64 encoded 1x1 pixel PNG image
const String _testImage =
@@ -22,6 +25,7 @@ void main() {
late PictureDto pictureDto1;
late PictureDto pictureDto2;
late PictureDto pictureDto3;
late MockCustomerController mockCustomerController;
setUp(() {
pictureDto1 = PictureDto(
@@ -60,20 +64,19 @@ void main() {
customerNumber: 'CUST001',
pictures: [pictureDto1, pictureDto2, pictureDto3],
);
mockCustomerController = MockCustomerController();
DiContainer.instance.put(CustomerController, mockCustomerController);
});
group('PictureWidget', () {
testWidgets('displays customer information correctly', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
// Verify that the header is displayed
expect(find.text('INFORMATIONEN'), findsOneWidget);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/1");
await tester.pumpAndSettle();
// Verify customer name is displayed
expect(find.text('Test Apotheke'), findsOneWidget);
@@ -82,19 +85,16 @@ void main() {
expect(find.text('CUST001'), findsOneWidget);
// Verify labels are displayed
expect(find.text('APOTHEKE'), findsOneWidget);
expect(find.text('KUNDENNUMMER'), findsOneWidget);
expect(find.text('DATUM'), findsOneWidget);
expect(find.text('KOMMENTAR'), findsOneWidget);
});
testWidgets('displays picture comment', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/1");
await tester.pumpAndSettle();
// Verify the comment is displayed
@@ -104,10 +104,9 @@ void main() {
testWidgets('displays empty string when comment is null', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto3),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/3");
await tester.pumpAndSettle();
// The comment field should be empty but the label should exist
@@ -117,10 +116,9 @@ void main() {
testWidgets('shows both navigation buttons at bottom', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/1");
await tester.pumpAndSettle();
// Both navigation buttons should always be visible at the bottom
@@ -131,10 +129,9 @@ void main() {
testWidgets('shows both navigation buttons when on middle picture', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto2),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/2");
await tester.pumpAndSettle();
// Both navigation buttons should be visible
@@ -145,10 +142,9 @@ void main() {
testWidgets('shows both navigation buttons on last picture', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto3),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/3");
await tester.pumpAndSettle();
// Both navigation buttons should be visible (right one is disabled)
@@ -159,10 +155,9 @@ void main() {
testWidgets('navigates to next picture when right button is tapped', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/1");
await tester.pumpAndSettle();
// Verify first picture comment is shown
@@ -180,10 +175,9 @@ void main() {
testWidgets('navigates to previous picture when left button is tapped', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto2),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/2");
await tester.pumpAndSettle();
// Verify second picture comment is shown
@@ -208,10 +202,9 @@ void main() {
pictures: [pictureDto1],
);
await pumpApp(
tester,
PictureWidget(customerDto: singlePictureCustomer, pictureDto: pictureDto1),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => singlePictureCustomer);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/1");
await tester.pumpAndSettle();
// Both navigation buttons should be shown but disabled
@@ -222,10 +215,9 @@ void main() {
testWidgets('opens fullscreen dialog when image is tapped', (WidgetTester tester) async {
setScreenSize(tester, 2048, 2048);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
when(mockCustomerController.get(id: 1)).thenAnswer((_) async => customerDto);
await pumpAppConfig(tester, "${GlobalRouter.pathPicture}/1/1");
await tester.pumpAndSettle();
// Find the GestureDetector with the image key