Tests
This commit is contained in:
parent
435a532960
commit
34e56f95b1
|
|
@ -14,7 +14,6 @@ import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
|||
import 'package:invoiceninja_flutter/ui/app/app_drawer_vm.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/selected_indicator.dart';
|
||||
import 'package:invoiceninja_flutter/utils/icons.dart';
|
||||
import 'package:invoiceninja_flutter/utils/keys.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
||||
|
|
@ -170,7 +169,6 @@ class AppDrawer extends StatelessWidget {
|
|||
store.dispatch(ViewDashboard(context: context)),
|
||||
),
|
||||
DrawerTile(
|
||||
key: Key(ClientKeys.drawer),
|
||||
company: company,
|
||||
entityType: EntityType.client,
|
||||
icon: getEntityIcon(EntityType.client),
|
||||
|
|
@ -186,7 +184,6 @@ class AppDrawer extends StatelessWidget {
|
|||
},
|
||||
),
|
||||
DrawerTile(
|
||||
key: Key(ProductKeys.drawer),
|
||||
company: company,
|
||||
entityType: EntityType.product,
|
||||
icon: getEntityIcon(EntityType.product),
|
||||
|
|
@ -316,7 +313,6 @@ class AppDrawer extends StatelessWidget {
|
|||
),
|
||||
// STARTER: menu - do not remove comment
|
||||
DrawerTile(
|
||||
key: Key(SettingsKeys.drawer),
|
||||
company: company,
|
||||
icon: FontAwesomeIcons.cog,
|
||||
title: localization.settings,
|
||||
|
|
@ -344,14 +340,13 @@ class AppDrawer extends StatelessWidget {
|
|||
|
||||
class DrawerTile extends StatelessWidget {
|
||||
const DrawerTile({
|
||||
Key key,
|
||||
@required this.company,
|
||||
@required this.icon,
|
||||
@required this.title,
|
||||
@required this.onTap,
|
||||
this.onCreateTap,
|
||||
this.entityType,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
final CompanyEntity company;
|
||||
final EntityType entityType;
|
||||
|
|
@ -381,7 +376,7 @@ class DrawerTile extends StatelessWidget {
|
|||
isSelected: uiState.containsRoute(route),
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
leading: Icon(icon, size: 22.0, key: ValueKey(title)),
|
||||
leading: Icon(icon, size: 22.0),
|
||||
title: Tooltip(message: title, child: Text(title)),
|
||||
onTap: onTap,
|
||||
trailing: onCreateTap == null || !user.canCreate(entityType)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import 'package:invoiceninja_flutter/ui/auth/login_vm.dart';
|
|||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||
import 'package:invoiceninja_flutter/utils/keys.dart';
|
||||
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
||||
|
||||
class LoginView extends StatefulWidget {
|
||||
|
|
@ -32,12 +31,6 @@ class _LoginState extends State<LoginView> {
|
|||
|
||||
static const String OTP_ERROR = 'OTP_REQUIRED';
|
||||
|
||||
static final ValueKey _emailKey = Key(LoginKeys.email);
|
||||
static final ValueKey _passwordKey = Key(LoginKeys.password);
|
||||
static final ValueKey _urlKey = Key(LoginKeys.url);
|
||||
static final ValueKey _secretKey = Key(LoginKeys.secret);
|
||||
static final ValueKey _oneTimePasswordKey = Key(LoginKeys.oneTimePassword);
|
||||
|
||||
final FocusNode _focusNode1 = new FocusNode();
|
||||
|
||||
bool _isSelfHosted = false;
|
||||
|
|
@ -134,7 +127,7 @@ class _LoginState extends State<LoginView> {
|
|||
isOneTimePassword
|
||||
? TextFormField(
|
||||
controller: _oneTimePasswordController,
|
||||
key: _oneTimePasswordKey,
|
||||
key: ValueKey(localization.oneTimePassword),
|
||||
autocorrect: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.oneTimePassword),
|
||||
|
|
@ -143,7 +136,7 @@ class _LoginState extends State<LoginView> {
|
|||
children: <Widget>[
|
||||
TextFormField(
|
||||
controller: _emailController,
|
||||
key: _emailKey,
|
||||
key: ValueKey(localization.email),
|
||||
autocorrect: false,
|
||||
textInputAction: TextInputAction.next,
|
||||
decoration: InputDecoration(
|
||||
|
|
@ -160,7 +153,7 @@ class _LoginState extends State<LoginView> {
|
|||
),
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
key: _passwordKey,
|
||||
key: ValueKey(localization.password),
|
||||
autocorrect: false,
|
||||
autovalidate: _autoValidate,
|
||||
decoration: InputDecoration(
|
||||
|
|
@ -176,7 +169,7 @@ class _LoginState extends State<LoginView> {
|
|||
_isSelfHosted
|
||||
? TextFormField(
|
||||
controller: _urlController,
|
||||
key: _urlKey,
|
||||
key: ValueKey(localization.url),
|
||||
autocorrect: false,
|
||||
autovalidate: _autoValidate,
|
||||
decoration: InputDecoration(
|
||||
|
|
@ -191,7 +184,7 @@ class _LoginState extends State<LoginView> {
|
|||
_isSelfHosted
|
||||
? TextFormField(
|
||||
controller: _secretController,
|
||||
key: _secretKey,
|
||||
key: ValueKey(localization.secret),
|
||||
autocorrect: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: localization.secret),
|
||||
|
|
@ -232,7 +225,7 @@ class _LoginState extends State<LoginView> {
|
|||
setState(() => _isSelfHosted = false),
|
||||
child: Text(localization.hostedLogin))
|
||||
: FlatButton(
|
||||
key: Key(LoginKeys.loginSelfHost),
|
||||
key: ValueKey(localization.selfhostLogin),
|
||||
onPressed: () =>
|
||||
setState(() => _isSelfHosted = true),
|
||||
child: Text(localization.selfhostLogin)),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
class AppKeys {
|
||||
static const String openAppDrawer = 'Open navigation menu';
|
||||
static const String dashboardScreen = 'DashboardScreen';
|
||||
}
|
||||
|
||||
class AppTooltips {
|
||||
|
|
@ -8,16 +7,6 @@ class AppTooltips {
|
|||
static const String back = 'Back';
|
||||
}
|
||||
|
||||
class LoginKeys {
|
||||
static const String email = 'loginEmail';
|
||||
static const String password = 'loginPassword';
|
||||
static const String url = 'loginUrl';
|
||||
static const String loginSelfHost = 'loginSelfHost';
|
||||
static const String secret = 'loginSecret';
|
||||
static const String oneTimePassword = 'loginOneTimePassword';
|
||||
static const String loginButton = 'login';
|
||||
}
|
||||
|
||||
class ProductKeys {
|
||||
static const String screen = 'ProductScreen';
|
||||
static const String drawer = 'productDrawer';
|
||||
|
|
@ -33,7 +22,3 @@ class ClientKeys {
|
|||
static const String fab = 'clientFab';
|
||||
static const String drawer = 'clientDrawer';
|
||||
}
|
||||
|
||||
class SettingsKeys {
|
||||
static const String drawer = 'settingsDrawer';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ import 'package:invoiceninja_flutter/main.dart' as app;
|
|||
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
app.main();
|
||||
app.main(isTesting: true);
|
||||
}
|
||||
|
|
@ -4,5 +4,5 @@ import 'package:invoiceninja_flutter/main.dart' as app;
|
|||
void main() {
|
||||
// This line enables the extension
|
||||
enableFlutterDriverExtension();
|
||||
app.main();
|
||||
app.main(isTesting: true);
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ import 'utils/localizations.dart';
|
|||
|
||||
void main() {
|
||||
group('LOGIN TEST', () {
|
||||
|
||||
TestLocalization localization;
|
||||
FlutterDriver driver;
|
||||
|
||||
|
|
@ -26,10 +25,8 @@ void main() {
|
|||
|
||||
group('SELF-HOSTED', () {
|
||||
test('No input provided by user', () async {
|
||||
await login(driver, loginEmail: '',
|
||||
loginPassword: '',
|
||||
loginUrl: '',
|
||||
loginSecret: '');
|
||||
await login(driver,
|
||||
loginEmail: '', loginPassword: '', loginUrl: '', loginSecret: '');
|
||||
|
||||
await driver.waitFor(find.text(localization.pleaseEnterYourEmail));
|
||||
await driver.waitFor(find.text(localization.pleaseEnterYourPassword));
|
||||
|
|
@ -40,7 +37,7 @@ void main() {
|
|||
await login(driver, retype: true);
|
||||
|
||||
await driver.waitFor(
|
||||
find.byType(AppKeys.dashboardScreen),
|
||||
find.byTooltip(AppKeys.openAppDrawer),
|
||||
timeout: new Duration(seconds: 60),
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ import 'package:invoiceninja_flutter/main.dart' as app;
|
|||
void main() {
|
||||
// This line enables the extension
|
||||
enableFlutterDriverExtension();
|
||||
app.main();
|
||||
app.main(isTesting: true);
|
||||
}
|
||||
|
|
@ -5,34 +5,36 @@ import 'package:invoiceninja_flutter/utils/keys.dart';
|
|||
import 'localizations.dart';
|
||||
|
||||
Future<void> login(FlutterDriver driver,
|
||||
{
|
||||
bool selfHosted = true,
|
||||
{bool selfHosted = true,
|
||||
bool retype = false,
|
||||
String loginEmail = Config.TEST_EMAIL,
|
||||
String loginPassword = Config.TEST_PASSWORD,
|
||||
String loginUrl = Config.TEST_URL,
|
||||
String loginSecret = Config.TEST_SECRET
|
||||
}) async {
|
||||
String loginSecret = Config.TEST_SECRET}) async {
|
||||
|
||||
final localization = TestLocalization('en');
|
||||
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
LoginKeys.email: loginEmail,
|
||||
LoginKeys.password: loginPassword,
|
||||
localization.email: loginEmail,
|
||||
localization.password: loginPassword,
|
||||
});
|
||||
|
||||
if (selfHosted) {
|
||||
await fillTextFields(driver, <String, dynamic>{
|
||||
LoginKeys.url: loginUrl,
|
||||
LoginKeys.secret: loginSecret,
|
||||
localization.url: loginUrl,
|
||||
localization.secret: loginSecret,
|
||||
});
|
||||
}
|
||||
|
||||
await driver.tap(find.text(LoginKeys.loginButton.toUpperCase()));
|
||||
await driver.tap(find.text(localization.login.toUpperCase()));
|
||||
}
|
||||
|
||||
Future<void> logout(FlutterDriver driver, TestLocalization localization) async {
|
||||
// Go to Settings Screen
|
||||
await driver.tap(find.byTooltip(AppKeys.openAppDrawer));
|
||||
//await driver.scrollUntilVisible(find.byType('Drawer'), find.byValueKey(SettingsKeys.drawer));
|
||||
await driver.tap(find.byValueKey(SettingsKeys.drawer));
|
||||
//await driver.tap(find.byValueKey(SettingsKeys.drawer));
|
||||
await driver.tap(find.byTooltip(localization.settings));
|
||||
|
||||
// Tap on Log Out
|
||||
await driver.tap(find.text(localization.logout));
|
||||
|
|
@ -47,7 +49,7 @@ Future<void> logout(FlutterDriver driver, TestLocalization localization) async {
|
|||
|
||||
Future<void> loginAndOpenProducts(FlutterDriver driver) async {
|
||||
login(driver);
|
||||
await driver.waitFor(find.byType(AppKeys.dashboardScreen));
|
||||
await driver.waitFor(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byValueKey(ProductKeys.drawer));
|
||||
await driver.waitFor(find.byType(ProductKeys.screen));
|
||||
|
|
@ -55,13 +57,14 @@ Future<void> loginAndOpenProducts(FlutterDriver driver) async {
|
|||
|
||||
Future<void> loginAndOpenClients(FlutterDriver driver) async {
|
||||
login(driver);
|
||||
await driver.waitFor(find.byType(AppKeys.dashboardScreen));
|
||||
await driver.waitFor(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byTooltip(AppKeys.openAppDrawer));
|
||||
await driver.tap(find.byValueKey(ClientKeys.drawer));
|
||||
await driver.waitFor(find.byType(ClientKeys.screen));
|
||||
}
|
||||
|
||||
Future<void> fillTextFields(FlutterDriver driver, Map<String, dynamic> values) async {
|
||||
Future<void> fillTextFields(
|
||||
FlutterDriver driver, Map<String, dynamic> values) async {
|
||||
for (var entry in values.entries) {
|
||||
await driver.tap(find.byValueKey(entry.key));
|
||||
await driver.enterText(entry.value);
|
||||
|
|
|
|||
Loading…
Reference in New Issue