fix(flow): guard stepper and reset state on image-less project load
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user