forked from eatvio/eatvio_app
79 lines
2.3 KiB
Dart
79 lines
2.3 KiB
Dart
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/features/glossary/presentation/pages/glossary_screen.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
import 'package:go_router/go_router.dart';
|
||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||
import '../../../../helpers/webview_test_helper.dart';
|
||
|
||
void main() {
|
||
group('GlossaryScreen', () {
|
||
setUp(() async {
|
||
WebViewTestHelper.setUpWebViewPlatform();
|
||
await sl.reset();
|
||
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
|
||
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
|
||
});
|
||
|
||
tearDown(() {
|
||
WebViewTestHelper.tearDownWebViewPlatform();
|
||
});
|
||
|
||
testWidgets('отображает GlossaryScreen с WebView и AppBar', (WidgetTester tester) async {
|
||
const passKey = 'test-pass-key';
|
||
|
||
final router = GoRouter(
|
||
initialLocation: '/',
|
||
routes: [
|
||
GoRoute(
|
||
path: '/',
|
||
builder: (context, state) => const GlossaryScreen(passKey: passKey),
|
||
),
|
||
],
|
||
);
|
||
|
||
await tester.pumpWidget(
|
||
MaterialApp.router(
|
||
routerConfig: router,
|
||
),
|
||
);
|
||
|
||
await tester.pump();
|
||
|
||
// Проверяем, что экран отображается
|
||
expect(find.byType(GlossaryScreen), findsOneWidget);
|
||
expect(find.byType(Scaffold), findsOneWidget);
|
||
expect(find.text('Глоссарий'), findsOneWidget);
|
||
});
|
||
|
||
testWidgets('GlossaryScreen создается с правильным passKey', (WidgetTester tester) async {
|
||
const passKey = 'test-pass-key-456';
|
||
|
||
final router = GoRouter(
|
||
initialLocation: '/',
|
||
routes: [
|
||
GoRoute(
|
||
path: '/',
|
||
builder: (context, state) => const GlossaryScreen(passKey: passKey),
|
||
),
|
||
],
|
||
);
|
||
|
||
await tester.pumpWidget(
|
||
MaterialApp.router(
|
||
routerConfig: router,
|
||
),
|
||
);
|
||
|
||
await tester.pump();
|
||
|
||
expect(find.byType(GlossaryScreen), findsOneWidget);
|
||
});
|
||
});
|
||
}
|
||
|
||
|
||
|