fixed integration tests

This commit is contained in:
Vadim 2024-04-25 14:03:20 +02:00
parent c7af27e7cf
commit 8b9a3f660b
5 changed files with 22 additions and 15 deletions

View file

@ -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

View file

@ -10,18 +10,21 @@ class _MockIAPStorageService extends Mock implements IAPStorageService {}
class MockIAPProviders extends StatefulWidget {
final List<EquipmentProfile>? equipmentProfiles;
final String selectedEquipmentProfileId;
final List<Film>? films;
final List<Film> availableFilms;
final List<Film> filmsInUse;
final Film selectedFilm;
final Widget child;
const MockIAPProviders({
this.equipmentProfiles = const [],
this.selectedEquipmentProfileId = '',
this.films = mockFilms,
List<Film>? availableFilms,
List<Film>? filmsInUse,
this.selectedFilm = const Film.other(),
required this.child,
super.key,
});
}) : availableFilms = availableFilms ?? mockFilms,
filmsInUse = filmsInUse ?? mockFilms;
@override
State<MockIAPProviders> createState() => _MockIAPProvidersState();
@ -36,7 +39,7 @@ class _MockIAPProvidersState extends State<MockIAPProviders> {
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<MockIAPProviders> {
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),

View file

@ -22,7 +22,8 @@ extension WidgetTesterCommonActions on WidgetTester {
IAPProductStatus productStatus = IAPProductStatus.purchased,
List<EquipmentProfile>? equipmentProfiles,
String selectedEquipmentProfileId = '',
List<Film>? films,
List<Film>? availableFilms,
List<Film>? 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(),
),

View file

@ -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,
);

View file

@ -98,7 +98,7 @@ class _GoldenTestApplicationMockState extends State<GoldenTestApplicationMock> {
child: MockIAPProviders(
equipmentProfiles: mockEquipmentProfiles,
selectedEquipmentProfileId: mockEquipmentProfiles.first.id,
films: films,
selectedFilm: mockFilms.first,
child: Builder(
builder: (context) {
return MaterialApp(