forked from eatvio/eatvio_app
78 lines
2.2 KiB
Dart
78 lines
2.2 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/registration/presentation/pages/verify_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('VerifyScreen', () {
|
||
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('отображает VerifyScreen с WebView', (WidgetTester tester) async {
|
||
const passKey = 'test-pass-key';
|
||
|
||
final router = GoRouter(
|
||
initialLocation: '/',
|
||
routes: [
|
||
GoRoute(
|
||
path: '/',
|
||
builder: (context, state) => const VerifyScreen(passKey: passKey),
|
||
),
|
||
],
|
||
);
|
||
|
||
await tester.pumpWidget(
|
||
MaterialApp.router(
|
||
routerConfig: router,
|
||
),
|
||
);
|
||
|
||
await tester.pump();
|
||
|
||
// Проверяем, что экран отображается
|
||
expect(find.byType(VerifyScreen), findsOneWidget);
|
||
expect(find.byType(Scaffold), findsOneWidget);
|
||
});
|
||
|
||
testWidgets('VerifyScreen создается с правильным passKey', (WidgetTester tester) async {
|
||
const passKey = 'test-pass-key-123';
|
||
|
||
final router = GoRouter(
|
||
initialLocation: '/',
|
||
routes: [
|
||
GoRoute(
|
||
path: '/',
|
||
builder: (context, state) => const VerifyScreen(passKey: passKey),
|
||
),
|
||
],
|
||
);
|
||
|
||
await tester.pumpWidget(
|
||
MaterialApp.router(
|
||
routerConfig: router,
|
||
),
|
||
);
|
||
|
||
await tester.pump();
|
||
|
||
expect(find.byType(VerifyScreen), findsOneWidget);
|
||
});
|
||
});
|
||
}
|
||
|
||
|
||
|