chore(version): update app version to 1.3.5+85 and improve test coverage reporting in CI

This commit is contained in:
mso7nueh
2025-12-08 11:19:08 +03:00
parent abe4985f0e
commit c2a506cdbf
148 changed files with 12395 additions and 1889 deletions

View File

@@ -0,0 +1,118 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart';
import 'package:eatvio_app/features/registration_v2/presentation/widgets/sex_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'sex_widget_test.mocks.dart';
@GenerateNiceMocks([MockSpec<RegistrationCubitV2>()])
void main() {
group('SexWidget', () {
late MockRegistrationCubitV2 mockCubit;
setUp(() {
mockCubit = MockRegistrationCubitV2();
});
Widget createTestWidget() {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [Locale('ru')],
home: BlocProvider<RegistrationCubitV2>.value(
value: mockCubit,
child: Scaffold(
body: SexWidget(),
),
),
);
}
testWidgets('displays sex widget', (tester) async {
when(mockCubit.state).thenReturn(
RegistrationStateV2(
step: 0,
gender: '',
isGenderValid: true,
),
);
when(mockCubit.stream).thenAnswer((_) => Stream.value(
RegistrationStateV2(
step: 0,
gender: '',
isGenderValid: true,
),
));
await tester.pumpWidget(createTestWidget());
await tester.pumpAndSettle();
expect(find.byType(SexWidget), findsOneWidget);
});
testWidgets('calls setGender when male is tapped', (tester) async {
when(mockCubit.state).thenReturn(
RegistrationStateV2(
step: 0,
gender: '',
isGenderValid: true,
),
);
when(mockCubit.stream).thenAnswer((_) => Stream.value(
RegistrationStateV2(
step: 0,
gender: '',
isGenderValid: true,
),
));
when(mockCubit.setGender(any)).thenAnswer((_) async {});
await tester.pumpWidget(createTestWidget());
await tester.pumpAndSettle();
// Find and tap male button - try to find by InkWell or text
final inkWells = find.byType(InkWell);
if (inkWells.evaluate().isNotEmpty) {
await tester.tap(inkWells.first);
await tester.pump();
verify(mockCubit.setGender('male')).called(1);
}
});
testWidgets('shows error when gender is invalid', (tester) async {
when(mockCubit.state).thenReturn(
RegistrationStateV2(
step: 0,
gender: '',
isGenderValid: false,
),
);
when(mockCubit.stream).thenAnswer((_) => Stream.value(
RegistrationStateV2(
step: 0,
gender: '',
isGenderValid: false,
),
));
await tester.pumpWidget(createTestWidget());
await tester.pumpAndSettle();
expect(find.byType(SexWidget), findsOneWidget);
});
});
}

View File

@@ -0,0 +1,69 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart';
import 'package:eatvio_app/features/registration_v2/presentation/widgets/step_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'step_widget_test.mocks.dart';
@GenerateMocks([RegistrationCubitV2])
void main() {
group('StepWidget', () {
late MockRegistrationCubitV2 mockCubit;
setUp(() {
mockCubit = MockRegistrationCubitV2();
});
Widget createTestWidget() {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [Locale('ru'), Locale('en')],
locale: const Locale('ru'),
home: BlocProvider<RegistrationCubitV2>.value(
value: mockCubit,
child: Scaffold(
body: StepWidget(),
),
),
);
}
testWidgets('displays step widget', (tester) async {
when(mockCubit.state).thenReturn(
RegistrationStateV2(step: 0),
);
when(mockCubit.stream).thenAnswer((_) => Stream.value(RegistrationStateV2(step: 0)));
await tester.pumpWidget(createTestWidget());
await tester.pumpAndSettle();
expect(find.byType(StepWidget), findsOneWidget);
});
testWidgets('displays correct step number', (tester) async {
when(mockCubit.state).thenReturn(
RegistrationStateV2(step: 2),
);
when(mockCubit.stream).thenAnswer((_) => Stream.value(RegistrationStateV2(step: 2)));
await tester.pumpWidget(createTestWidget());
await tester.pumpAndSettle();
expect(find.byType(StepWidget), findsOneWidget);
});
});
}