From 8b9a3f660b535b57d2e48f374d4ac94408549f32 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:03:20 +0200 Subject: [PATCH] fixed integration tests --- integration_test/e2e_test.dart | 6 +++--- integration_test/mocks/paid_features_mock.dart | 17 ++++++++++------- .../utils/widget_tester_actions.dart | 6 ++++-- screenshots/generate_screenshots.dart | 6 ++++-- test/application_mock.dart | 2 +- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/integration_test/e2e_test.dart b/integration_test/e2e_test.dart index e84f73b..ed9de80 100644 --- a/integration_test/e2e_test.dart +++ b/integration_test/e2e_test.dart @@ -44,7 +44,7 @@ void testE2E(String description) { testWidgets( description, (tester) async { - await tester.pumpApplication(equipmentProfiles: [], films: []); + await tester.pumpApplication(equipmentProfiles: [], filmsInUse: []); /// Create Praktica + Zenitar profile from scratch await tester.openSettings(); @@ -60,7 +60,7 @@ void testE2E(String description) { await tester.setZoomValue(0, mockEquipmentProfiles[0].lensZoom); expect(find.text('x1.91'), findsOneWidget); expect(find.text('f/1.7 - f/16'), findsOneWidget); - expect(find.text('1/1000 - 16"'), findsOneWidget); + expect(find.text('1/1000 - B'), findsOneWidget); /// Create Praktica + Jupiter profile from Zenitar profile await tester.tap(find.byIcon(Icons.copy).first); @@ -71,7 +71,7 @@ void testE2E(String description) { await tester.setZoomValue(1, mockEquipmentProfiles[1].lensZoom); expect(find.text('x5.02'), findsOneWidget); expect(find.text('f/3.5 - f/22'), findsOneWidget); - expect(find.text('1/1000 - 16"'), findsNWidgets(2)); + expect(find.text('1/1000 - B'), findsNWidgets(2)); await tester.navigatorPop(); /// Select some films diff --git a/integration_test/mocks/paid_features_mock.dart b/integration_test/mocks/paid_features_mock.dart index 84c5090..34e8fb0 100644 --- a/integration_test/mocks/paid_features_mock.dart +++ b/integration_test/mocks/paid_features_mock.dart @@ -10,18 +10,21 @@ class _MockIAPStorageService extends Mock implements IAPStorageService {} class MockIAPProviders extends StatefulWidget { final List? equipmentProfiles; final String selectedEquipmentProfileId; - final List? films; + final List availableFilms; + final List filmsInUse; final Film selectedFilm; final Widget child; const MockIAPProviders({ this.equipmentProfiles = const [], this.selectedEquipmentProfileId = '', - this.films = mockFilms, + List? availableFilms, + List? filmsInUse, this.selectedFilm = const Film.other(), required this.child, super.key, - }); + }) : availableFilms = availableFilms ?? mockFilms, + filmsInUse = filmsInUse ?? mockFilms; @override State createState() => _MockIAPProvidersState(); @@ -36,7 +39,7 @@ class _MockIAPProvidersState extends State { mockIAPStorageService = _MockIAPStorageService(); when(() => mockIAPStorageService.equipmentProfiles).thenReturn(widget.equipmentProfiles ?? mockEquipmentProfiles); when(() => mockIAPStorageService.selectedEquipmentProfileId).thenReturn(widget.selectedEquipmentProfileId); - when(() => mockIAPStorageService.filmsInUse).thenReturn(widget.films ?? mockFilms); + when(() => mockIAPStorageService.filmsInUse).thenReturn(widget.filmsInUse); when(() => mockIAPStorageService.selectedFilm).thenReturn(widget.selectedFilm); } @@ -46,7 +49,7 @@ class _MockIAPProvidersState extends State { storageService: mockIAPStorageService, child: FilmsProvider( storageService: mockIAPStorageService, - availableFilms: widget.films ?? mockFilms, + availableFilms: widget.availableFilms, child: widget.child, ), ); @@ -78,7 +81,7 @@ final mockEquipmentProfiles = [ ], shutterSpeedValues: ShutterSpeedValue.values.sublist( ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)), - ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(16, false, StopType.full)) + 1, + ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1, false, StopType.full)) + 1, ), isoValues: const [ IsoValue(50, StopType.full), @@ -108,7 +111,7 @@ final mockEquipmentProfiles = [ ], shutterSpeedValues: ShutterSpeedValue.values.sublist( ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1000, true, StopType.full)), - ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(16, false, StopType.full)) + 1, + ShutterSpeedValue.values.indexOf(const ShutterSpeedValue(1, false, StopType.full)) + 1, ), isoValues: const [ IsoValue(50, StopType.full), diff --git a/integration_test/utils/widget_tester_actions.dart b/integration_test/utils/widget_tester_actions.dart index 6ae0194..7732d1a 100644 --- a/integration_test/utils/widget_tester_actions.dart +++ b/integration_test/utils/widget_tester_actions.dart @@ -22,7 +22,8 @@ extension WidgetTesterCommonActions on WidgetTester { IAPProductStatus productStatus = IAPProductStatus.purchased, List? equipmentProfiles, String selectedEquipmentProfileId = '', - List? films, + List? availableFilms, + List? filmsInUse, Film selectedFilm = const Film.other(), }) async { await pumpWidget( @@ -33,7 +34,8 @@ extension WidgetTesterCommonActions on WidgetTester { child: MockIAPProviders( equipmentProfiles: equipmentProfiles, selectedEquipmentProfileId: selectedEquipmentProfileId, - films: films, + availableFilms: availableFilms, + filmsInUse: filmsInUse, selectedFilm: selectedFilm, child: const Application(), ), diff --git a/screenshots/generate_screenshots.dart b/screenshots/generate_screenshots.dart index e48ec60..fae038a 100644 --- a/screenshots/generate_screenshots.dart +++ b/screenshots/generate_screenshots.dart @@ -72,7 +72,8 @@ void main() { testWidgets('Generate light theme screenshots', (tester) async { mockSharedPrefs(ThemeType.light, lightThemeColor); await tester.pumpApplication( - films: [_mockFilm], + availableFilms: [_mockFilm], + filmsInUse: [_mockFilm], selectedFilm: _mockFilm, ); @@ -115,7 +116,8 @@ void main() { (tester) async { mockSharedPrefs(ThemeType.dark, darkThemeColor); await tester.pumpApplication( - films: [_mockFilm], + availableFilms: [_mockFilm], + filmsInUse: [_mockFilm], selectedFilm: _mockFilm, ); diff --git a/test/application_mock.dart b/test/application_mock.dart index b030428..a1bffef 100644 --- a/test/application_mock.dart +++ b/test/application_mock.dart @@ -98,7 +98,7 @@ class _GoldenTestApplicationMockState extends State { child: MockIAPProviders( equipmentProfiles: mockEquipmentProfiles, selectedEquipmentProfileId: mockEquipmentProfiles.first.id, - films: films, + selectedFilm: mockFilms.first, child: Builder( builder: (context) { return MaterialApp(