fix(flow): guard stepper and reset state on image-less project load

This commit is contained in:
gary
2026-02-24 21:43:28 +01:00
parent fd72d53d2a
commit 1a21bc18bb
2 changed files with 87 additions and 23 deletions

View File

@@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:korken_mosaic/main.dart';
void main() {
testWidgets('shows 4-step workflow and can navigate to result step',
testWidgets('stepper blocks forward navigation without image and shows hint',
(WidgetTester tester) async {
await tester.pumpWidget(const KorkenMosaicApp());
@@ -12,13 +13,23 @@ void main() {
expect(find.text('4) Ergebnis'), findsOneWidget);
await tester.tap(find.text('Weiter'));
await tester.pumpAndSettle();
await tester.tap(find.text('Weiter'));
await tester.pumpAndSettle();
await tester.tap(find.text('Weiter'));
await tester.pumpAndSettle();
await tester.pump();
expect(find.byKey(const Key('generate-btn')), findsOneWidget);
expect(find.text('Export JSON'), findsOneWidget);
// Stays on step 1 because no source image is available yet.
expect(find.text('Import target image'), findsOneWidget);
expect(find.text('Bitte zuerst ein Bild auswählen.'), findsOneWidget);
});
testWidgets('generate actions are disabled without image',
(WidgetTester tester) async {
await tester.pumpWidget(const KorkenMosaicApp());
final fab = tester.widget<FloatingActionButton>(
find.byType(FloatingActionButton),
);
expect(fab.onPressed, isNull);
// Result-step action is not reachable before image selection.
expect(find.byKey(const Key('generate-btn')), findsNothing);
});
}