Skip to content

Commit

Permalink
testes
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrcode committed Oct 19, 2022
1 parent 5d67b7e commit 5894197
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 32 deletions.
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// Use o IntelliSense para saber mais sobre os atributos possíveis.
// Focalizar para exibir as descrições dos atributos existentes.
// Para obter mais informações, acesse: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "organizei-mobile",
"request": "launch",
"type": "dart"
},
{
"name": "organizei-mobile (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "organizei-mobile (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}
1 change: 1 addition & 0 deletions lib/Controller/UsuarioController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class UsuarioController extends Base {

try {
if (model.id == null) {
print('a');
return await repository.addUsuario(model).then((value) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
elevation: 6.0,
Expand Down
4 changes: 2 additions & 2 deletions lib/Model/API/APIModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class ApiModel {
Future<Map<String, String>> getHeaders() async {
SharedPreferences prefs = await SharedPreferences.getInstance();

String? token = prefs.getString('UsuarioToken');
String token = prefs.getString('UsuarioToken') ?? '';

Map<String, String> headers = {
"Content-Type": "application/json",
"Authorization": "Bearer " + token!
"Authorization": "Bearer " + token
};
return headers;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/components/dialogs/login/entrarDialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Future<dynamic> entrar(BuildContext context) {

loginController = LoginController(LoginRepository(), context);

print('chmei');

return showDialog(
barrierDismissible: false,
barrierColor: Colors.white.withOpacity(0),
Expand Down Expand Up @@ -58,9 +60,11 @@ Future<dynamic> entrar(BuildContext context) {
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 16.0),
child: Botao(
key: Key("BB"),
texto: 'Entrar',
cor: const Color(0xFF6BC8E4),
clicar: () async {
print('over');
bool succes =
await loginController.autentica();

Expand Down
89 changes: 89 additions & 0 deletions test/empresa_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:organizei/components/botao.dart';
import 'package:organizei/components/dialogs/login/entrarDialog.dart';

void main() {
group('LOGIN', () {
testWidgets('Email e CPF/CNPJ vazio', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return Botao(
key: Key("keyEntrarButton"),
texto: 'Entrar',
cor: const Color(0xFF74C198),
clicar: () {
print('aaaa');
entrar(context);
});
},
),
),
),
);
//Entra no widget

//Pressiona o botão de "Entrar"
await tester.tap(find.byKey(ValueKey("keyEntrarButton")));

//Atualiza o estado da tela
await tester.pump();

expect(find.text('e-mail'), findsOneWidget);
expect(find.text('senha'), findsOneWidget);

//Verifica se ambas validações aparecem em tela
// expect(find.text('Informe o CPF/CNPJ'), findsOneWidget);
// expect(find.text('Informe o Email'), findsOneWidget);
});
testWidgets('Senha vazia', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return Botao(
key: Key("keyEntrarButton"),
texto: 'clicar',
cor: const Color(0xFF74C198),
clicar: () {
print('aaaa');
entrar(context);
});
},
),
),
));

await tester.tap(find.byKey(ValueKey("keyEntrarButton")));
await tester.pump();

await tester.enterText(find.text('nome'), "[email protected]");

// await tester.tap(find.byKey(ValueKey("BB")));

//await tester.enterText(find.byKey(ValueKey("BB")), "[email protected]");
// await tester.tap(find.text('Entrar'));
//await tester.tap(find.byKey(ValueKey("BB")));
//await tester.tap(find.text('Entrar'));

// await tester.enterText(
// find.byKey(ValueKey("keyTextFieldEmail")), "[email protected]");

//await tester.enterText(find.text('e-mail'), "[email protected]");

// await tester.enterText(
// find.byKey(ValueKey("keyTextFieldEmail")), "[email protected]");
// await tester.tap(find.byKey(ValueKey("keyEntrarButton")));
// await tester.pump();
// expect(find.text('Informe o CPF/CNPJ'), findsOneWidget);
// expect(find.text('Informe o Email'), findsNothing);
});

//Verifica se ambas validações aparecem em tela
// expect(find.text('Informe o CPF/CNPJ'), findsOneWidget);
// expect(find.text('Informe o Email'), findsOneWidget);
});
}
30 changes: 0 additions & 30 deletions test/widget_test.dart

This file was deleted.

0 comments on commit 5894197

Please sign in to comment.