forked from eatvio/eatvio_app
feat(test): Issue-165
This commit is contained in:
@@ -51,6 +51,29 @@ class _DevToolsScreenContentState extends State<DevToolsScreenContent> {
|
||||
GetPlansComments(),
|
||||
SendPlansComment(),
|
||||
GetRecipesComments(),
|
||||
AuthServiceTest(),
|
||||
DiaryServiceTest(),
|
||||
BlockedUserServiceTest(),
|
||||
PlanServiceTest(),
|
||||
AboutRecipeServiceTest(),
|
||||
BlogPostServiceTest(),
|
||||
CalendarServiceTest(),
|
||||
CardsServiceTest(),
|
||||
ConsultantServiceTest(),
|
||||
ConsultationServiceTest(),
|
||||
CreateDietServiceTest(),
|
||||
CreatePlanServiceTest(),
|
||||
GlossaryServiceTest(),
|
||||
MyDietsServiceTest(),
|
||||
MyPlansServiceTest(),
|
||||
MyRecipesServiceTest(),
|
||||
NotificationsServiceTest(),
|
||||
PlansServiceTest(),
|
||||
ProfileServiceTest(),
|
||||
RegistrationServiceTest(),
|
||||
ResetPasswordServiceTest(),
|
||||
SettingsServiceTest(),
|
||||
WsServiceTest(),
|
||||
];
|
||||
final controller = TextEditingController();
|
||||
late final List<TestState> testsStates;
|
||||
@@ -132,17 +155,56 @@ class _DevToolsScreenContentState extends State<DevToolsScreenContent> {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.loading;
|
||||
});
|
||||
final result = await testCases[index].run(baseUrl: baseUrlForTest);
|
||||
if (result) {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.success;
|
||||
});
|
||||
showSuccessToast('${testCases[index].name} passed');
|
||||
} else {
|
||||
try {
|
||||
final result = await testCases[index].run(baseUrl: baseUrlForTest);
|
||||
if (result.success) {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.success;
|
||||
});
|
||||
showSuccessToast('${testCases[index].name} passed');
|
||||
} else {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.fail;
|
||||
});
|
||||
showErrorToast('${testCases[index].name} failed');
|
||||
// Show AlertDialog with error description
|
||||
if (mounted) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Test Failed'),
|
||||
content: SingleChildScrollView(child: Text(result.error ?? 'No error details.')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e, stack) {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.fail;
|
||||
});
|
||||
showErrorToast('${testCases[index].name} failed');
|
||||
// Show AlertDialog with error description
|
||||
if (mounted) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Test Failed'),
|
||||
content: SingleChildScrollView(child: Text(e.toString() + '\n' + stack.toString())),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
buttonStyle: const ButtonStyle(),
|
||||
|
||||
Reference in New Issue
Block a user