forked from eatvio/eatvio_app
chore(dependencies): add webview_flutter_platform_interface package to pubspec.yaml and clean up test files by removing unnecessary whitespace
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
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/features/order_info/presentation/widgets/plan_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
void main() {
|
||||
group('PlanInfo', () {
|
||||
setUpAll(() async {
|
||||
// Initialize dotenv for tests
|
||||
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
|
||||
});
|
||||
|
||||
setUp(() async {
|
||||
// Reset GetIt and register AppConfig
|
||||
await sl.reset();
|
||||
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
|
||||
});
|
||||
|
||||
testWidgets('displays title and description correctly', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: PlanInfo(
|
||||
title: 'Test Plan',
|
||||
description: 'This is a test plan description',
|
||||
imagePath: 'test/image.jpg',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Test Plan'), findsOneWidget);
|
||||
expect(find.text('This is a test plan description'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays image with correct path', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: PlanInfo(
|
||||
title: 'Plan Title',
|
||||
description: 'Plan Description',
|
||||
imagePath: 'plans/plan1.jpg',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Check that CachedNetworkImage is present
|
||||
expect(find.byType(Image), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('works with empty strings', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: PlanInfo(
|
||||
title: '',
|
||||
description: '',
|
||||
imagePath: '',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text(''), findsNWidgets(2)); // Title and description
|
||||
});
|
||||
|
||||
testWidgets('displays long text correctly', (WidgetTester tester) async {
|
||||
const longTitle = 'This is a very long title that should still be displayed correctly';
|
||||
const longDescription = 'This is a very long description that contains a lot of text and should be displayed properly in the widget';
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
home: const Scaffold(
|
||||
body: PlanInfo(
|
||||
title: longTitle,
|
||||
description: longDescription,
|
||||
imagePath: 'test.jpg',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text(longTitle), findsOneWidget);
|
||||
expect(find.text(longDescription), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/order_info/presentation/widgets/plan_status_box.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('PlanStatusBox', () {
|
||||
Widget createTestWidget(PlanStatusValues status) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('ru')],
|
||||
home: Scaffold(
|
||||
body: PlanStatusBox(status: status),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('displays paid status correctly', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createTestWidget(PlanStatusValues.paid));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Should display status text (exact text depends on localization)
|
||||
expect(find.byType(PlanStatusBox), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays pending payment status correctly', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createTestWidget(PlanStatusValues.pendingPayment));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(PlanStatusBox), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays payment failed status correctly', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createTestWidget(PlanStatusValues.paymentFailed));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(PlanStatusBox), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('has correct container styling', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createTestWidget(PlanStatusValues.paid));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final container = tester.widget<Container>(
|
||||
find.byType(Container).first,
|
||||
);
|
||||
|
||||
expect(container.decoration, isNotNull);
|
||||
});
|
||||
|
||||
testWidgets('displays text with correct style', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(createTestWidget(PlanStatusValues.paid));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(Text), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
group('PlanStatusValues', () {
|
||||
test('has all expected enum values', () {
|
||||
expect(PlanStatusValues.paid, isNotNull);
|
||||
expect(PlanStatusValues.pendingPayment, isNotNull);
|
||||
expect(PlanStatusValues.paymentFailed, isNotNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user