mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-22 01:00:41 +01:00
[Tests] Add simple signUp test and try to make non named routes detectable (not working)
Took 55 minutes
This commit is contained in:
parent
7a3ef82546
commit
22f1f7a0c3
@ -94,6 +94,7 @@ class _SignUpState extends State<SignUp> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: TextField(
|
||||
key: Key("serverField"),
|
||||
autocorrect: false,
|
||||
controller: serverController,
|
||||
decoration: InputDecoration(
|
||||
@ -149,6 +150,7 @@ class _SignUpState extends State<SignUp> {
|
||||
),
|
||||
),
|
||||
title: TextField(
|
||||
key: Key("usernameField"),
|
||||
autocorrect: false,
|
||||
controller: usernameController,
|
||||
onSubmitted: (s) => signUpAction(context),
|
||||
@ -163,6 +165,7 @@ class _SignUpState extends State<SignUp> {
|
||||
height: 50,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
child: RaisedButton(
|
||||
key: Key("signUpButton"),
|
||||
elevation: 7,
|
||||
color: Theme.of(context).primaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
@ -179,6 +182,7 @@ class _SignUpState extends State<SignUp> {
|
||||
),
|
||||
Center(
|
||||
child: FlatButton(
|
||||
key: Key("alreadyHaveAnAccountButton"),
|
||||
child: Text(
|
||||
I18n.tr(context).alreadyHaveAnAccount,
|
||||
style: TextStyle(
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat_list.dart';
|
||||
import 'package:fluffychat/views/login.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@ -29,6 +31,11 @@ void main() {
|
||||
expect(
|
||||
find.byKey(Key("passwordField")), findsOneWidget); // Password Input
|
||||
expect(find.byKey(Key("loginButton")), findsOneWidget); // Login Button
|
||||
|
||||
/*await Utils.tapItem(tester, Key("loginButton"));
|
||||
// FIXME Use better way
|
||||
await tester.pump(Duration(seconds: 5));
|
||||
expect(isPushed, isTrue);*/
|
||||
});
|
||||
});
|
||||
});
|
||||
|
40
test/sign_up_test.dart
Normal file
40
test/sign_up_test.dart
Normal file
@ -0,0 +1,40 @@
|
||||
import 'package:fluffychat/views/sign_up.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
void main() {
|
||||
/// All Tests related to the Login
|
||||
group("SignUpPage", () {
|
||||
/// Check if all Elements get created
|
||||
testWidgets('should get created', (WidgetTester tester) async {
|
||||
await tester.runAsync(() async {
|
||||
final TestObserver observer = TestObserver()
|
||||
..onPushed = (Route<dynamic> route, Route<dynamic> previousRoute) {}
|
||||
..onPopped = (Route<dynamic> route, Route<dynamic> previousRoute) {};
|
||||
|
||||
await tester.pumpWidget(
|
||||
Utils.getWidgetWrapper(
|
||||
SignUp(),
|
||||
observer,
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump(Duration.zero);
|
||||
|
||||
expect(find.byKey(Key("serverField")), findsOneWidget); // Server field
|
||||
expect(
|
||||
find.byKey(Key("usernameField")), findsOneWidget); // Username Input
|
||||
expect(find.byKey(Key("signUpButton")), findsOneWidget); // Login Button
|
||||
expect(find.byKey(Key("alreadyHaveAnAccountButton")),
|
||||
findsOneWidget); // alreadyHaveAnAccount Button
|
||||
|
||||
/*await Utils.tapItem(tester, Key("loginButton"));
|
||||
// FIXME Use better way
|
||||
await tester.pump(Duration(seconds: 5));
|
||||
expect(isPushed, isTrue);*/
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
@ -11,6 +11,18 @@ class Utils {
|
||||
debugPrint(tester.allWidgets.toList().join("\n").toString());
|
||||
}
|
||||
|
||||
static bool isWidgetInWidgets(WidgetTester tester, Type widget) {
|
||||
debugPrint(tester.allWidgets
|
||||
.toList()
|
||||
.map((e) => e.runtimeType)
|
||||
.join("\n")
|
||||
.toString());
|
||||
return tester.allWidgets
|
||||
.toList()
|
||||
.map((e) => e.runtimeType)
|
||||
.contains(widget);
|
||||
}
|
||||
|
||||
static Client get defaultClient {
|
||||
Client client = Client("testclient", debug: true);
|
||||
client.httpClient = FakeMatrixApi();
|
||||
|
Loading…
x
Reference in New Issue
Block a user