feat(tests): test coverage is 70.5

This commit is contained in:
misha
2026-01-26 16:38:15 +03:00
parent 92205c09d6
commit 29589ef6fd
49 changed files with 2690 additions and 18 deletions

View File

@@ -123,6 +123,64 @@ void main() {
expect(find.text('Test Content'), findsNothing);
});
testWidgets('shows bottom sheet with enableDrag false', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
enableDrag: false,
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
});
testWidgets('shows bottom sheet with userRootNavigator true', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
userRootNavigator: true,
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
});
});
}

View File

@@ -1,4 +1,5 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/marketing_bottom_sheet.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
@@ -66,6 +67,42 @@ void main() {
expect(find.byType(MarketingBottomSheet), findsOneWidget);
});
testWidgets('displays marketing bottom sheet with congratulations text', (tester) async {
await tester.pumpWidget(
createTestWidget(
const MarketingBottomSheet(),
),
);
await tester.pumpAndSettle();
expect(find.byType(MarketingBottomSheet), findsOneWidget);
expect(find.textContaining('Поздравляем'), findsWidgets);
});
testWidgets('displays marketing bottom sheet with invite button', (tester) async {
await tester.pumpWidget(
createTestWidget(
const MarketingBottomSheet(),
),
);
await tester.pumpAndSettle();
expect(find.byType(MarketingBottomSheet), findsOneWidget);
expect(find.byType(CustomOutlinedButton), findsOneWidget);
});
testWidgets('displays marketing bottom sheet with logo', (tester) async {
await tester.pumpWidget(
createTestWidget(
const MarketingBottomSheet(),
),
);
await tester.pumpAndSettle();
expect(find.byType(MarketingBottomSheet), findsOneWidget);
expect(find.byType(ClipRRect), findsWidgets);
});
});
}

View File

@@ -70,6 +70,34 @@ void main() {
expect(find.text('Item 2'), findsOneWidget);
expect(find.text('Item 3'), findsOneWidget);
});
testWidgets('displays option widget with empty items list', (tester) async {
const option = PacketOptions(items: [], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
await tester.pumpAndSettle();
expect(find.byType(OptionWidget), findsOneWidget);
expect(find.text('Short'), findsOneWidget);
});
testWidgets('displays option widget with different duration', (tester) async {
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 14)));
await tester.pumpAndSettle();
expect(find.byType(OptionWidget), findsOneWidget);
});
testWidgets('displays option widget with personal diet and duration disabled', (tester) async {
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: true);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7, disableDuration: true)));
await tester.pumpAndSettle();
expect(find.byType(OptionWidget), findsOneWidget);
});
});
}

View File

@@ -152,5 +152,40 @@ void main() {
// Dialog should be closed
expect(find.text('Упс! Произошла ошибка'), findsNothing);
});
testWidgets('displays error dialog with needToOpenSettings', (tester) async {
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showErrorDialog(
context,
needToOpenSettings: true,
);
},
child: const Text('Show Error'),
),
);
},
),
),
);
await tester.pump();
await tester.tap(find.text('Show Error'));
await tester.pumpAndSettle();
expect(find.text('Упс! Произошла ошибка'), findsOneWidget);
});
});
}

View File

@@ -3,6 +3,8 @@ import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/app_initializer.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/success_published_diet_bottom_sheet.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
@@ -75,5 +77,35 @@ void main() {
expect(find.text('Test Plan'), findsOneWidget);
expect(find.textContaining('опубликован'), findsWidgets);
});
testWidgets('displays bottom sheet handler bar', (tester) async {
await tester.pumpWidget(wrap(const SuccessPublishedDietOrPlanBottomSheet(title: 'Test Diet', isPlan: false)));
await tester.pump();
expect(find.byType(BottomSheetHandlerBar), findsOneWidget);
});
testWidgets('displays ok button', (tester) async {
await tester.pumpWidget(wrap(const SuccessPublishedDietOrPlanBottomSheet(title: 'Test Diet', isPlan: false)));
await tester.pump();
expect(find.byType(CustomOutlinedButton), findsOneWidget);
});
testWidgets('displays different titles for diet', (tester) async {
await tester.pumpWidget(wrap(const SuccessPublishedDietOrPlanBottomSheet(title: 'Another Diet', isPlan: false)));
await tester.pump();
expect(find.text('Another Diet'), findsOneWidget);
expect(find.textContaining('опубликованна'), findsWidgets);
});
testWidgets('displays different titles for plan', (tester) async {
await tester.pumpWidget(wrap(const SuccessPublishedDietOrPlanBottomSheet(title: 'Another Plan', isPlan: true)));
await tester.pump();
expect(find.text('Another Plan'), findsOneWidget);
expect(find.textContaining('опубликован'), findsWidgets);
});
});
}

View File

@@ -3,6 +3,8 @@ import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/app_initializer.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/bottom_sheet_handler_bar.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/success_published_recipe_bottom_sheet.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
@@ -59,5 +61,34 @@ void main() {
expect(find.textContaining('My Recipe'), findsWidgets);
});
testWidgets('displays recipe publishing text', (tester) async {
await tester.pumpWidget(wrap(const SuccessPublishedRecipeBottomSheet(title: 'Test Recipe')));
await tester.pump();
expect(find.byType(SuccessPublishedRecipeBottomSheet), findsOneWidget);
expect(find.textContaining('Публикация рецепта'), findsWidgets);
});
testWidgets('displays bottom sheet handler bar', (tester) async {
await tester.pumpWidget(wrap(const SuccessPublishedRecipeBottomSheet(title: 'Test Recipe')));
await tester.pump();
expect(find.byType(BottomSheetHandlerBar), findsOneWidget);
});
testWidgets('displays ok button', (tester) async {
await tester.pumpWidget(wrap(const SuccessPublishedRecipeBottomSheet(title: 'Test Recipe')));
await tester.pump();
expect(find.byType(CustomOutlinedButton), findsOneWidget);
});
testWidgets('displays different recipe titles', (tester) async {
await tester.pumpWidget(wrap(const SuccessPublishedRecipeBottomSheet(title: 'Another Recipe')));
await tester.pump();
expect(find.textContaining('Another Recipe'), findsWidgets);
});
});
}