diff --git a/integration_test/e2e_test.dart b/integration_test/e2e_test.dart index 70560b4..febfbd2 100644 --- a/integration_test/e2e_test.dart +++ b/integration_test/e2e_test.dart @@ -58,24 +58,24 @@ void testE2E(String description) { await tester.tapDescendantTextOf(S.current.equipmentProfiles); await tester.tap(find.byIcon(Icons.add_outlined).first); await tester.pumpAndSettle(); - await tester.selectProfileName(mockEquipmentProfiles[0].name); - await tester.expandEquipmentProfileContainer(mockEquipmentProfiles[0].name); - await tester.setIsoValues(0, mockEquipmentProfiles[0].isoValues); - await tester.setNdValues(0, mockEquipmentProfiles[0].ndValues); - await tester.setApertureValues(0, mockEquipmentProfiles[0].apertureValues); - await tester.setShutterSpeedValues(0, mockEquipmentProfiles[0].shutterSpeedValues); - await tester.setZoomValue(0, mockEquipmentProfiles[0].lensZoom); + await tester.enterProfileName(mockEquipmentProfiles[0].name); + await tester.setIsoValues(mockEquipmentProfiles[0].isoValues); + await tester.setNdValues(mockEquipmentProfiles[0].ndValues); + await tester.setApertureValues(mockEquipmentProfiles[0].apertureValues); + await tester.setShutterSpeedValues(mockEquipmentProfiles[0].shutterSpeedValues); + await tester.setZoomValue(mockEquipmentProfiles[0].lensZoom); expect(find.text('x1.91'), findsOneWidget); expect(find.text('f/1.7 - f/16'), findsOneWidget); expect(find.text('1/1000 - B'), findsOneWidget); + await tester.tap(find.byIcon(Icons.save_outlined)); + await tester.pump(); /// Create Praktica + Jupiter profile from Zenitar profile await tester.tap(find.byIcon(Icons.copy_outlined).first); await tester.pumpAndSettle(); - await tester.selectProfileName(mockEquipmentProfiles[1].name); - await tester.expandEquipmentProfileContainer(mockEquipmentProfiles[1].name); - await tester.setApertureValues(1, mockEquipmentProfiles[1].apertureValues); - await tester.setZoomValue(1, mockEquipmentProfiles[1].lensZoom); + await tester.enterProfileName(mockEquipmentProfiles[1].name); + await tester.setApertureValues(mockEquipmentProfiles[1].apertureValues); + await tester.setZoomValue(mockEquipmentProfiles[1].lensZoom); expect(find.text('x5.02'), findsOneWidget); expect(find.text('f/3.5 - f/22'), findsOneWidget); expect(find.text('1/1000 - B'), findsNWidgets(2)); @@ -147,40 +147,31 @@ void testE2E(String description) { } extension EquipmentProfileActions on WidgetTester { - Future expandEquipmentProfileContainer(String name) async { - await tap(find.text(name)); - await pump(Dimens.durationM); - } - - Future selectProfileName(String name) async { + Future enterProfileName(String name) async { await enterText(find.byType(TextField), name); await pump(); - await tapSaveButton(); } - Future setIsoValues(int profileIndex, List values) => - _openAndSetDialogFilterValues(profileIndex, S.current.isoValues, values); - Future setNdValues(int profileIndex, List values) => - _openAndSetDialogFilterValues(profileIndex, S.current.ndFilters, values); + Future setIsoValues(List values) => + _openAndSetDialogFilterValues(S.current.isoValues, values); + Future setNdValues(List values) => _openAndSetDialogFilterValues(S.current.ndFilters, values); Future _openAndSetDialogFilterValues( - int profileIndex, String listTileTitle, List valuesToSelect, { bool deselectAll = true, }) async { - await tap(find.text(listTileTitle).at(profileIndex)); + await tap(find.text(listTileTitle)); await pumpAndSettle(); await setDialogFilterValues(valuesToSelect, deselectAll: deselectAll); } - Future setApertureValues(int profileIndex, List values) => - _setDialogRangePickerValues(profileIndex, S.current.apertureValues, values); + Future setApertureValues(List values) => + _setDialogRangePickerValues(S.current.apertureValues, values); - Future setShutterSpeedValues(int profileIndex, List values) => - _setDialogRangePickerValues(profileIndex, S.current.shutterSpeedValues, values); + Future setShutterSpeedValues(List values) => + _setDialogRangePickerValues(S.current.shutterSpeedValues, values); - Future setZoomValue(int profileIndex, double value) => - _setDialogSliderPickerValue(profileIndex, S.current.lensZoom, value); + Future setZoomValue(double value) => _setDialogSliderPickerValue(S.current.lensZoom, value); } extension on WidgetTester { @@ -212,11 +203,10 @@ extension on WidgetTester { } Future _setDialogRangePickerValues( - int profileIndex, String listTileTitle, List valuesToSelect, ) async { - await tap(find.text(listTileTitle).at(profileIndex)); + await tap(find.text(listTileTitle)); await pumpAndSettle(); final dialog = widget>(find.byType(DialogRangePicker)); @@ -247,11 +237,10 @@ extension on WidgetTester { } Future _setDialogSliderPickerValue( - int profileIndex, String listTileTitle, double value, ) async { - await tap(find.text(listTileTitle).at(profileIndex)); + await tap(find.text(listTileTitle)); await pumpAndSettle(); final sliderFinder = find.byType(Slider); diff --git a/integration_test/mocks/paid_features_mock.dart b/integration_test/mocks/paid_features_mock.dart index 04d3ba4..56c2622 100644 --- a/integration_test/mocks/paid_features_mock.dart +++ b/integration_test/mocks/paid_features_mock.dart @@ -41,12 +41,21 @@ class _MockIAPProvidersState extends State { @override void initState() { super.initState(); + registerFallbackValue(defaultEquipmentProfile); mockEquipmentProfilesStorageService = _MockEquipmentProfilesStorageService(); when(() => mockEquipmentProfilesStorageService.init()).thenAnswer((_) async {}); when(() => mockEquipmentProfilesStorageService.getProfiles()) .thenAnswer((_) => Future.value(widget.equipmentProfiles)); when(() => mockEquipmentProfilesStorageService.selectedEquipmentProfileId) .thenReturn(widget.selectedEquipmentProfileId); + when(() => mockEquipmentProfilesStorageService.addProfile(any())).thenAnswer((_) async {}); + when( + () => mockEquipmentProfilesStorageService.updateProfile( + id: any(named: 'id'), + name: any(named: 'name'), + ), + ).thenAnswer((_) async {}); + when(() => mockEquipmentProfilesStorageService.deleteProfile(any())).thenAnswer((_) async {}); mockFilmsStorageService = _MockFilmsStorageService(); when(() => mockFilmsStorageService.init()).thenAnswer((_) async {});