forked from eatvio/eatvio_app
feat: test case for A.P. #1208
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class DevToolsScreen extends StatelessWidget {
|
||||
const DevToolsScreen({super.key});
|
||||
|
||||
static const name = 'devToolsScreen';
|
||||
static const path = '/dev-tools-screen';
|
||||
|
||||
@@ -64,22 +65,10 @@ class _DevToolsScreenContentState extends State<DevToolsScreenContent> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Text('BaseUrl: ${baseUrlForTest}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(padding: const EdgeInsets.all(8.0), child: Row(children: [Text('BaseUrl: ${baseUrlForTest}')])),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CustomTextFormField(
|
||||
controller: controller,
|
||||
hintText: 'type new base url',
|
||||
),
|
||||
),
|
||||
Expanded(child: CustomTextFormField(controller: controller, hintText: 'type new base url')),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -91,9 +80,7 @@ class _DevToolsScreenContentState extends State<DevToolsScreenContent> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (baseUrlForTest != baseUrl)
|
||||
CustomOutlinedButton(
|
||||
text: 'Set dev2 base url',
|
||||
@@ -104,78 +91,62 @@ class _DevToolsScreenContentState extends State<DevToolsScreenContent> {
|
||||
},
|
||||
buttonStyle: ButtonStyle(),
|
||||
),
|
||||
SizedBox(
|
||||
height: baseUrlForTest != baseUrl ? 40 : 10,
|
||||
),
|
||||
if (baseUrlForTest != 'https://eatvio.ru')
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: testCases.length,
|
||||
itemBuilder: (context, index) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text('${index + 1}. ${testCases[index].name}'),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomOutlinedButton(
|
||||
text: 'run',
|
||||
height: 20,
|
||||
width: 60,
|
||||
onPressed: () async {
|
||||
if (testsStates[index] == TestState.loading) return;
|
||||
SizedBox(height: baseUrlForTest != baseUrl ? 40 : 10),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: testCases.length,
|
||||
itemBuilder:
|
||||
(context, index) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: Text('${index + 1}. ${testCases[index].name}')),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomOutlinedButton(
|
||||
text: 'run',
|
||||
height: 20,
|
||||
width: 60,
|
||||
onPressed: () async {
|
||||
if (testsStates[index] == TestState.loading) return;
|
||||
|
||||
setState(() {
|
||||
testsStates[index] = TestState.loading;
|
||||
});
|
||||
final result = await testCases[index].run(baseUrl: baseUrlForTest);
|
||||
if (result) {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.success;
|
||||
testsStates[index] = TestState.loading;
|
||||
});
|
||||
showSuccessToast('${testCases[index].name} passed');
|
||||
} else {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.fail;
|
||||
});
|
||||
showErrorToast('${testCases[index].name} failed');
|
||||
}
|
||||
},
|
||||
buttonStyle: ButtonStyle(),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
switch (testsStates[index]) {
|
||||
TestState.success => Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
color: Colors.green,
|
||||
),
|
||||
TestState.fail => Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
color: Colors.red,
|
||||
),
|
||||
TestState.notRun => Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
color: Colors.grey,
|
||||
),
|
||||
TestState.loading => Container(
|
||||
final result = await testCases[index].run(baseUrl: baseUrlForTest);
|
||||
if (result) {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.success;
|
||||
});
|
||||
showSuccessToast('${testCases[index].name} passed');
|
||||
} else {
|
||||
setState(() {
|
||||
testsStates[index] = TestState.fail;
|
||||
});
|
||||
showErrorToast('${testCases[index].name} failed');
|
||||
}
|
||||
},
|
||||
buttonStyle: ButtonStyle(),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
switch (testsStates[index]) {
|
||||
TestState.success => Container(width: 20, height: 20, color: Colors.green),
|
||||
TestState.fail => Container(width: 20, height: 20, color: Colors.red),
|
||||
TestState.notRun => Container(width: 20, height: 20, color: Colors.grey),
|
||||
TestState.loading => Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: SizedBox(height: 20, width: 20, child: Center(child: CircularProgressIndicator())),
|
||||
),
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user