test(registration): All tests passed! SMOKE TESTING FINISHED

This commit is contained in:
2024-03-13 12:51:50 +03:00
parent 37a5fdf51c
commit 4b4e0dd814
6 changed files with 216 additions and 58 deletions

View File

@@ -34,7 +34,7 @@ class NameScreen extends StatelessWidget {
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
child: Column(children: [
child: ListView(children: [
SizedBox(height: 7.v),
Container(
height: 16.v,
@@ -75,7 +75,6 @@ class NameScreen extends StatelessWidget {
);
}),
SizedBox(height: 21.v),
Spacer(),
BlocBuilder<NameBloc, NameState>(builder: (context, state) {
return NextStepButton(
text: "continue".tr.toUpperCase(),
@@ -104,65 +103,66 @@ class NameScreen extends StatelessWidget {
NavigatorService.goBack();
}
_onTapNext(BuildContext context, state) {
List<String> errors = validateFields(
state.firstNameController!.text, state.lastNameController!.text);
if (errors.isEmpty) {
UserRegistrationSheet sheet = state.nameModelObj!.userRegistrationSheet;
sheet.firstName = state.firstNameController!.text;
sheet.lastName = state.lastNameController!.text;
Navigator.pushNamed(
context,
AppRoutes.genderScreen,
arguments: sheet,
);
} else {
String errorMessage = '';
_onTapNext(BuildContext context, NameState state) {
if (state.firstNameController != null && state.lastNameController != null) {
List<String> errors = validateFields(
state.firstNameController!.text, state.lastNameController!.text);
for (var error in errors) {
errorMessage += error + '\n\n';
if (errors.isEmpty) {
UserRegistrationSheet sheet = state.nameModelObj!.userRegistrationSheet;
sheet.firstName = state.firstNameController!.text;
sheet.lastName = state.lastNameController!.text;
Navigator.pushNamed(
context,
AppRoutes.genderScreen,
arguments: sheet,
);
} else {
String errorMessage = '';
for (var error in errors) {
errorMessage += error + '\n\n';
}
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Error'),
content: Text(errorMessage),
actions: [
TextButton(
onPressed: () => onTapOk(context),
child: Text('OK'),
),
],
),
);
}
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Ошибка'),
content: Text(errorMessage),
actions: [
TextButton(
onPressed: onTapOk(context),
child: Text('OK'),
),
],
),
);
}
}
onTapOk(BuildContext context) {
void onTapOk(BuildContext context) {
Navigator.pop(context);
}
List<String> validateFields(
String firstName,
String lastName,
) {
List<String> validateFields(String firstName, String lastName) {
List<String> errors = [];
if (firstName.isEmpty) {
errors.add('first_name_empty'.tr);
errors.add('First name cannot be empty');
}
if (firstName.length < 1) {
errors.add('first_name_short'.tr);
errors.add('First name is too short');
}
if (lastName.isEmpty) {
errors.add('last_name_empty'.tr);
errors.add('Last name cannot be empty');
}
if (lastName.length < 1) {
errors.add('last_name_short'.tr);
errors.add('Last name is too short');
}
return errors;

View File

@@ -36,7 +36,7 @@ class _WeightScreenState extends State<WeightScreen> {
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
child: Column(children: [
child: ListView(children: [
SizedBox(height: 7.v),
Container(
height: 16.v,
@@ -81,7 +81,6 @@ class _WeightScreenState extends State<WeightScreen> {
})
])
]),
Spacer(),
BlocBuilder<WeightBloc, WeightState>(
builder: (context, state) {
return NextStepButton(
@@ -111,20 +110,15 @@ class _WeightScreenState extends State<WeightScreen> {
NavigatorService.goBack();
}
onTapNext(BuildContext context, state) {
UserRegistrationSheet sheet = state.weightModelObj!.userRegistrationSheet;
Navigator.pushNamed(
context,
AppRoutes.heightScreen,
arguments: sheet,
);
}
/// Navigates to the allergiesScreen when the action is triggered.
navigateToHeight(BuildContext context) {
NavigatorService.pushNamed(
AppRoutes.heightScreen,
);
onTapNext(BuildContext context, WeightState state) {
return () {
UserRegistrationSheet sheet = state.weightModelObj!.userRegistrationSheet;
Navigator.pushNamed(
context,
AppRoutes.heightScreen,
arguments: sheet,
);
};
}
void _onDropDownChanged(value) {

View File

@@ -1,4 +1,3 @@
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';

View File

@@ -0,0 +1,55 @@
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:eatvio_app/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart';
import 'package:eatvio_app/presentation/registration/medicine_intake_screen/bloc/medicine_intake_bloc.dart';
import 'package:eatvio_app/presentation/registration/medicine_intake_screen/models/medicine_intake_model.dart';
void main() {
group('AdditionalInfoScreen', () {
testWidgets('renders screen in initial state', (WidgetTester tester) async {
final myProfileBloc = MedicineIntakeBloc(MedicineIntakeState(
medicineIntakeModelObj: MedicineIntakeModel(
userRegistrationSheet: UserRegistrationSheet(
name: "name",
firstName: "firstName",
lastName: "lastName",
email: "email",
password: "password",
passwordConfirmation: "passwordConfirmation",
termsAccepted: "termsAccepted",
birthdate: "birthdate",
gender: "gender",
country: "country",
city: "city",
lang: "lang",
weight: "weight",
height: "height",
chestCircumference: 'asdasd',
waistCircumference: "waistCircumference",
hipCircumference: "hipCircumference",
bloodPressureUp: "bloodPressureUp",
bloodPressureDown: "bloodPressureDown",
hasHypo: "hasHypo",
hasHyper: "hasHyper",
aboutAllergy: "aboutAllergy",
aboutTakingPils: "aboutTakingPils",
aboutSportHobbies: "aboutSportHobbies",
favoriteFoods: "favoriteFoods",
unfavoriteFoods: "unfavoriteFoods",
additionalInfo:
"additionalInfo")))); // Ensure that MyProfileModel is non-nullable
await tester.pumpWidget(
MaterialApp(
home: BlocProvider<MedicineIntakeBloc>.value(
value: myProfileBloc,
child: MedicineIntakeScreen(),
),
),
);
});
});
}
//sports

55
test/name_test.dart Normal file
View File

@@ -0,0 +1,55 @@
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:eatvio_app/presentation/registration/name_screen/name_screen.dart';
import 'package:eatvio_app/presentation/registration/name_screen/bloc/name_bloc.dart';
import 'package:eatvio_app/presentation/registration/name_screen/models/name_model.dart';
void main() {
group('AdditionalInfoScreen', () {
testWidgets('renders screen in initial state', (WidgetTester tester) async {
final myProfileBloc = NameBloc(NameState(
nameModelObj: NameModel(
userRegistrationSheet: UserRegistrationSheet(
name: "name",
firstName: "firstName",
lastName: "lastName",
email: "email",
password: "password",
passwordConfirmation: "passwordConfirmation",
termsAccepted: "termsAccepted",
birthdate: "birthdate",
gender: "gender",
country: "country",
city: "city",
lang: "lang",
weight: "weight",
height: "height",
chestCircumference: 'asdasd',
waistCircumference: "waistCircumference",
hipCircumference: "hipCircumference",
bloodPressureUp: "bloodPressureUp",
bloodPressureDown: "bloodPressureDown",
hasHypo: "hasHypo",
hasHyper: "hasHyper",
aboutAllergy: "aboutAllergy",
aboutTakingPils: "aboutTakingPils",
aboutSportHobbies: "aboutSportHobbies",
favoriteFoods: "favoriteFoods",
unfavoriteFoods: "unfavoriteFoods",
additionalInfo:
"additionalInfo")))); // Ensure that MyProfileModel is non-nullable
await tester.pumpWidget(
MaterialApp(
home: BlocProvider<NameBloc>.value(
value: myProfileBloc,
child: NameScreen(),
),
),
);
});
});
}
//sports

55
test/weight_test.dart Normal file
View File

@@ -0,0 +1,55 @@
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:eatvio_app/presentation/registration/weight_screen/weight_screen.dart';
import 'package:eatvio_app/presentation/registration/weight_screen/bloc/weight_bloc.dart';
import 'package:eatvio_app/presentation/registration/weight_screen/models/weight_model.dart';
void main() {
group('AdditionalInfoScreen', () {
testWidgets('renders screen in initial state', (WidgetTester tester) async {
final myProfileBloc = WeightBloc(WeightState(
weightModelObj: WeightModel(
userRegistrationSheet: UserRegistrationSheet(
name: "name",
firstName: "firstName",
lastName: "lastName",
email: "email",
password: "password",
passwordConfirmation: "passwordConfirmation",
termsAccepted: "termsAccepted",
birthdate: "birthdate",
gender: "gender",
country: "country",
city: "city",
lang: "lang",
weight: "weight",
height: "height",
chestCircumference: 'asdasd',
waistCircumference: "waistCircumference",
hipCircumference: "hipCircumference",
bloodPressureUp: "bloodPressureUp",
bloodPressureDown: "bloodPressureDown",
hasHypo: "hasHypo",
hasHyper: "hasHyper",
aboutAllergy: "aboutAllergy",
aboutTakingPils: "aboutTakingPils",
aboutSportHobbies: "aboutSportHobbies",
favoriteFoods: "favoriteFoods",
unfavoriteFoods: "unfavoriteFoods",
additionalInfo:
"additionalInfo")))); // Ensure that MyProfileModel is non-nullable
await tester.pumpWidget(
MaterialApp(
home: BlocProvider<WeightBloc>.value(
value: myProfileBloc,
child: WeightScreen(),
),
),
);
});
});
}
//sports