forked from eatvio/eatvio_app
Merge pull request 'feat(tests)' (#736) from misha/eatvio_app:tests into main
Reviewed-on: eatvio/eatvio_app#736
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/app_initializer.dart';
|
||||
import 'package:eatvio_app/core/env_config.dart';
|
||||
import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart';
|
||||
import 'package:eatvio_app/main.dart' as app;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
@@ -12,7 +14,7 @@ void main() {
|
||||
await AppInitializer.initialize(buildType: AppBuildType.tests);
|
||||
});
|
||||
|
||||
testWidgets('Signs in successfully with valid credentials', (WidgetTester tester) async {
|
||||
testWidgets('Signs in successfully with valid credentials', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const app.MyApp());
|
||||
await tester.pumpAndSettle(const Duration(seconds: 3));
|
||||
await skipWelcomeScreen(tester);
|
||||
@@ -24,14 +26,14 @@ void main() {
|
||||
expect(passwordFieldFinder, findsOneWidget, reason: 'Password text field should be found.');
|
||||
expect(signInButtonFinder, findsOneWidget, reason: 'Sign In button should be found.');
|
||||
|
||||
await tester.enterText(emailFieldFinder, 'reshetnick.mike+user4@gmail.com');
|
||||
await tester.enterText(passwordFieldFinder, '1234567890');
|
||||
await tester.enterText(emailFieldFinder, EnvConfig.testEmail);
|
||||
await tester.enterText(passwordFieldFinder, EnvConfig.testPassword);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(signInButtonFinder);
|
||||
|
||||
await tester.pumpAndSettle(const Duration(seconds: 3));
|
||||
|
||||
expect(signInButtonFinder, findsNothing, reason: 'Sign-in button should not be visible after successful login and navigation.');
|
||||
expect(FeedScreen, findsOne, reason: 'Feed screen should be visible after successful login and navigation.');
|
||||
});
|
||||
}
|
||||
21
integration_test/common_cases/skip_sign_in.dart
Normal file
21
integration_test/common_cases/skip_sign_in.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/env_config.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Future<void> skipSignIn(WidgetTester tester) async {
|
||||
final emailFieldFinder = find.byKey(AppKeys.emailTextFieldAuthScreen);
|
||||
final passwordFieldFinder = find.byKey(AppKeys.passwordTextFieldAuthScreen);
|
||||
final signInButtonFinder = find.byKey(AppKeys.signInButtonAuthScreen);
|
||||
|
||||
expect(emailFieldFinder, findsOneWidget, reason: 'Email text field should be found.');
|
||||
expect(passwordFieldFinder, findsOneWidget, reason: 'Password text field should be found.');
|
||||
expect(signInButtonFinder, findsOneWidget, reason: 'Sign In button should be found.');
|
||||
|
||||
await tester.enterText(emailFieldFinder, EnvConfig.testEmail);
|
||||
await tester.enterText(passwordFieldFinder, EnvConfig.testPassword);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(signInButtonFinder);
|
||||
|
||||
await tester.pumpAndSettle(const Duration(seconds: 3));
|
||||
}
|
||||
@@ -5,4 +5,4 @@ Future<void> skipWelcomeScreen(WidgetTester tester) async {
|
||||
final welcomeScreenButtonFinder = find.byKey(AppKeys.welcomeScreenButton);
|
||||
await tester.tap(welcomeScreenButtonFinder);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/app_initializer.dart';
|
||||
import 'package:eatvio_app/main.dart' as app;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import '../common_cases/skip_sign_in.dart';
|
||||
import '../common_cases/skip_welcome_screen.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUpAll(() async {
|
||||
await AppInitializer.initialize(buildType: AppBuildType.tests);
|
||||
});
|
||||
|
||||
testWidgets('qwe', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const app.MyApp());
|
||||
await tester.pumpAndSettle(const Duration(seconds: 3));
|
||||
await skipWelcomeScreen(tester);
|
||||
await skipSignIn(tester);
|
||||
|
||||
final blogPostCreationFinder = find.byKey(AppKeys.feedScreenBlogPostCreationButton);
|
||||
|
||||
expect(blogPostCreationFinder, findsOneWidget, reason: 'Blog post creation button should be found.');
|
||||
|
||||
await tester.tap(blogPostCreationFinder);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
}
|
||||
@@ -1,13 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppKeys {
|
||||
|
||||
class AppKeys {
|
||||
// Auth Screen
|
||||
static const hiddenLogoButtonAuthScreen = ValueKey('hiddenLogoButtonAuthScreen');
|
||||
static const emailTextFieldAuthScreen = ValueKey('emailTextFieldAuthScreen');
|
||||
static const passwordTextFieldAuthScreen = ValueKey('passwordTextFieldAuthScreen');
|
||||
static const signInButtonAuthScreen = ValueKey('signInButtonAuthScreen');
|
||||
|
||||
// Welcome Screen
|
||||
// Welcome Screen
|
||||
static const welcomeScreenButton = ValueKey('welcomeScreenButton');
|
||||
|
||||
// Feed Screen
|
||||
static const feedScreenBlogPostCreationButton = ValueKey('feedScreenBlogPostCreationButton');
|
||||
|
||||
// BlogPostCreateScreen
|
||||
static const blogPostCreateScreenTitleTextField = ValueKey('blogPostCreateScreenTitleTextField');
|
||||
static const blogPostCreateScreenContentTextField = ValueKey('blogPostCreateScreenContentTextField');
|
||||
static const blogPostCreateScreenVideoLinkTextField = ValueKey('blogPostCreateScreenVideoLinkTextField');
|
||||
static const blogPostCreateScreenCreateButton = ValueKey('blogPostCreateScreenCreateButton');
|
||||
static const imageWidget = ValueKey('imageWidget');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/app_config.dart';
|
||||
import 'package:eatvio_app/core/app_router.dart';
|
||||
import 'package:eatvio_app/core/permission_handler/permission_handler.dart';
|
||||
@@ -153,6 +154,7 @@ class _BlogPostCreateScreenState extends State<BlogPostCreateScreen> {
|
||||
floatingActionButton: SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 32,
|
||||
child: FloatingActionButton.extended(
|
||||
key: AppKeys.blogPostCreateScreenCreateButton,
|
||||
heroTag: 'createBlogPost',
|
||||
highlightElevation: 0,
|
||||
elevation: 0,
|
||||
@@ -225,12 +227,14 @@ class _BlogPostCreateScreenState extends State<BlogPostCreateScreen> {
|
||||
const Text('Заголовок'),
|
||||
const SizedBox(height: 8),
|
||||
CustomTextFormField(
|
||||
key: AppKeys.blogPostCreateScreenTitleTextField,
|
||||
controller: titleController,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text('Описание'),
|
||||
const SizedBox(height: 8),
|
||||
CustomTextFormField(
|
||||
key: AppKeys.blogPostCreateScreenContentTextField,
|
||||
controller: descriptionController,
|
||||
maxLines: 6,
|
||||
minLines: 4,
|
||||
@@ -244,6 +248,7 @@ class _BlogPostCreateScreenState extends State<BlogPostCreateScreen> {
|
||||
if (image == null && widget.feedBlogPostModel?.image == null) const SizedBox(height: 8),
|
||||
if (image == null && widget.feedBlogPostModel?.image == null)
|
||||
CustomTextFormField(
|
||||
key: AppKeys.blogPostCreateScreenVideoLinkTextField,
|
||||
controller: videoUrlController,
|
||||
),
|
||||
const SizedBox(height: 80),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:easy_debounce/easy_debounce.dart';
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/const.dart';
|
||||
import 'package:eatvio_app/core/views/cubit/views_cubit.dart';
|
||||
import 'package:eatvio_app/core/widgets/add_item_button.dart';
|
||||
@@ -215,7 +216,7 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
||||
3 when !hidePlans => AddItemButton(
|
||||
onTap: state.profile?.roles.contains('consultant') ?? false ? () => GoRouter.of(context).pushNamed(CreatePlanScreen.name) : null,
|
||||
),
|
||||
_ => const AddItemButton(),
|
||||
_ => const AddItemButton(key: AppKeys.feedScreenBlogPostCreationButton),
|
||||
},
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user