Working on tests
This commit is contained in:
parent
bf247ae3f7
commit
5909300543
|
|
@ -59,6 +59,7 @@ The architecture is based off these two projects:
|
||||||
- Press "Register App" button.
|
- Press "Register App" button.
|
||||||
- Download "google-services.json" and put it in `android/app` directory.
|
- Download "google-services.json" and put it in `android/app` directory.
|
||||||
- Run `flutter run` while you have a device connected to the computer or an emulator running and now you can run it.
|
- Run `flutter run` while you have a device connected to the computer or an emulator running and now you can run it.
|
||||||
|
- Run `flutter drive --target=test_driver/products_it.dart` to run the tests
|
||||||
|
|
||||||
## Contributions
|
## Contributions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ void _saveAuthLocal(dynamic action) async {
|
||||||
|
|
||||||
void _loadAuthLocal(Store<AppState> store, dynamic action) async {
|
void _loadAuthLocal(Store<AppState> store, dynamic action) async {
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
final String email = prefs.getString(kSharedPrefEmail) ?? Config.LOGIN_EMAIL;
|
final String email = prefs.getString(kSharedPrefEmail) ?? '';
|
||||||
final String url =
|
final String url =
|
||||||
formatApiUrlMachine(prefs.getString(kSharedPrefUrl) ?? Config.LOGIN_URL);
|
formatApiUrlMachine(prefs.getString(kSharedPrefUrl) ?? '');
|
||||||
final String secret =
|
final String secret =
|
||||||
prefs.getString(kSharedPrefSecret) ?? Config.LOGIN_SECRET;
|
prefs.getString(kSharedPrefSecret) ?? '';
|
||||||
store.dispatch(UserLoginLoaded(email, url, secret));
|
store.dispatch(UserLoginLoaded(email, url, secret));
|
||||||
|
|
||||||
final bool enableDarkMode = prefs.getBool(kSharedPrefEnableDarkMode) ?? false;
|
final bool enableDarkMode = prefs.getBool(kSharedPrefEnableDarkMode) ?? false;
|
||||||
|
|
@ -136,7 +136,7 @@ Middleware<AppState> _createRefreshRequest(AuthRepository repository) {
|
||||||
|
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
final String url = formatApiUrlMachine(
|
final String url = formatApiUrlMachine(
|
||||||
prefs.getString(kSharedPrefUrl) ?? Config.LOGIN_URL);
|
prefs.getString(kSharedPrefUrl) ?? Config.TEST_URL);
|
||||||
final String token = prefs.getString(getKeychainTokenKey());
|
final String token = prefs.getString(getKeychainTokenKey());
|
||||||
|
|
||||||
repository
|
repository
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@ class _LoginState extends State<LoginView> {
|
||||||
|
|
||||||
static const String OTP_ERROR = 'OTP_REQUIRED';
|
static const String OTP_ERROR = 'OTP_REQUIRED';
|
||||||
|
|
||||||
static final ValueKey _emailKey = Key(LoginKeys.emailKeyString);
|
static final ValueKey _emailKey = Key(LoginKeys.email);
|
||||||
static final ValueKey _passwordKey = Key(LoginKeys.passwordKeyString);
|
static final ValueKey _passwordKey = Key(LoginKeys.password);
|
||||||
static final ValueKey _urlKey = Key(LoginKeys.urlKeyString);
|
static final ValueKey _urlKey = Key(LoginKeys.url);
|
||||||
static final ValueKey _secretKey = Key(LoginKeys.secretKeyString);
|
static final ValueKey _secretKey = Key(LoginKeys.secret);
|
||||||
static final ValueKey _oneTimePasswordKey =
|
static final ValueKey _oneTimePasswordKey =
|
||||||
Key(LoginKeys.oneTimePasswordKeyString);
|
Key(LoginKeys.oneTimePassword);
|
||||||
|
|
||||||
final FocusNode _focusNode1 = new FocusNode();
|
final FocusNode _focusNode1 = new FocusNode();
|
||||||
|
|
||||||
|
|
@ -227,6 +227,7 @@ class _LoginState extends State<LoginView> {
|
||||||
setState(() => _isSelfHosted = false),
|
setState(() => _isSelfHosted = false),
|
||||||
child: Text(localization.hostedLogin))
|
child: Text(localization.hostedLogin))
|
||||||
: FlatButton(
|
: FlatButton(
|
||||||
|
key: Key(LoginKeys.loginSelfHost),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
setState(() => _isSelfHosted = true),
|
setState(() => _isSelfHosted = true),
|
||||||
child: Text(localization.selfhostLogin)),
|
child: Text(localization.selfhostLogin)),
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
FormCard(
|
FormCard(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextFormField(
|
TextFormField(
|
||||||
key: Key(ProductKeys.productEditProductFieldKeyString),
|
key: Key(ProductKeys.productKey),
|
||||||
controller: _productKeyController,
|
controller: _productKeyController,
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|
@ -160,7 +160,7 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
autovalidate: autoValidate,
|
autovalidate: autoValidate,
|
||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
key: Key(ProductKeys.productEditNotesFieldKeyString),
|
key: Key(ProductKeys.notes),
|
||||||
controller: _notesController,
|
controller: _notesController,
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|
@ -182,7 +182,7 @@ class _ProductEditState extends State<ProductEdit> {
|
||||||
company.getCustomFieldValues(CustomFieldType.product2),
|
company.getCustomFieldValues(CustomFieldType.product2),
|
||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
key: Key(ProductKeys.productEditCostFieldKeyString),
|
key: Key(ProductKeys.cost),
|
||||||
controller: _costController,
|
controller: _costController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class ProductScreen extends StatelessWidget {
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
|
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
|
||||||
floatingActionButton: user.canCreate(EntityType.product)
|
floatingActionButton: user.canCreate(EntityType.product)
|
||||||
? FloatingActionButton(
|
? FloatingActionButton(
|
||||||
key: Key(ProductKeys.productScreenFABKeyString),
|
key: Key(ProductKeys.fab),
|
||||||
backgroundColor: Theme.of(context).primaryColorDark,
|
backgroundColor: Theme.of(context).primaryColorDark,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
// Keys for Login Screen
|
|
||||||
class LoginKeys {
|
class LoginKeys {
|
||||||
static const String emailKeyString = 'loginEmail';
|
static const String email = 'loginEmail';
|
||||||
static const String passwordKeyString = 'loginPassword';
|
static const String password = 'loginPassword';
|
||||||
static const String urlKeyString = 'loginUrl';
|
static const String url = 'loginUrl';
|
||||||
static const String secretKeyString = 'loginSecret';
|
static const String loginSelfHost = 'loginSelfHost';
|
||||||
static const String oneTimePasswordKeyString = 'loginOneTimePassword';
|
static const String secret = 'loginSecret';
|
||||||
|
static const String oneTimePassword = 'loginOneTimePassword';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keys for Product Screen
|
|
||||||
class ProductKeys {
|
class ProductKeys {
|
||||||
static const String productScreenFABKeyString = 'productScreenFAB';
|
static const String fab = 'productFab';
|
||||||
static const String productEditProductFieldKeyString = 'productEditProductField';
|
static const String productKey = 'productKey';
|
||||||
static const String productEditNotesFieldKeyString = 'productEditNotesField';
|
static const String notes = 'productNotes';
|
||||||
static const String productEditCostFieldKeyString = 'productEditCostField';
|
static const String cost = 'productCost';
|
||||||
}
|
}
|
||||||
|
|
@ -14,10 +14,10 @@ void main() {
|
||||||
driver = await FlutterDriver.connect();
|
driver = await FlutterDriver.connect();
|
||||||
|
|
||||||
// read config file
|
// read config file
|
||||||
loginEmail = Config.LOGIN_EMAIL;
|
loginEmail = Config.TEST_EMAIL;
|
||||||
loginPassword = Config.LOGIN_PASSWORD;
|
loginPassword = Config.TEST_PASSWORD;
|
||||||
loginUrl = Config.LOGIN_URL;
|
loginUrl = Config.TEST_URL;
|
||||||
loginSecret = Config.LOGIN_SECRET;
|
loginSecret = Config.TEST_SECRET;
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() async {
|
tearDown(() async {
|
||||||
|
|
@ -28,16 +28,16 @@ void main() {
|
||||||
|
|
||||||
test('No input provided by user test', () async {
|
test('No input provided by user test', () async {
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.emailKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.email));
|
||||||
await driver.enterText('');
|
await driver.enterText('');
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.passwordKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.password));
|
||||||
await driver.enterText('');
|
await driver.enterText('');
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.urlKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.url));
|
||||||
await driver.enterText('');
|
await driver.enterText('');
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.secretKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.secret));
|
||||||
await driver.enterText('');
|
await driver.enterText('');
|
||||||
|
|
||||||
await driver.tap(find.text('LOGIN'));
|
await driver.tap(find.text('LOGIN'));
|
||||||
|
|
@ -47,16 +47,16 @@ void main() {
|
||||||
|
|
||||||
test('Details filled by user and login', () async {
|
test('Details filled by user and login', () async {
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.emailKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.email));
|
||||||
await driver.enterText(loginEmail);
|
await driver.enterText(loginEmail);
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.passwordKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.password));
|
||||||
await driver.enterText(loginPassword);
|
await driver.enterText(loginPassword);
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.urlKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.url));
|
||||||
await driver.enterText(loginUrl);
|
await driver.enterText(loginUrl);
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.secretKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.secret));
|
||||||
await driver.enterText(loginSecret);
|
await driver.enterText(loginSecret);
|
||||||
|
|
||||||
await driver.tap(find.text('LOGIN'));
|
await driver.tap(find.text('LOGIN'));
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,10 @@ void main() {
|
||||||
driver = await FlutterDriver.connect();
|
driver = await FlutterDriver.connect();
|
||||||
|
|
||||||
// read config file
|
// read config file
|
||||||
loginEmail = Config.LOGIN_EMAIL;
|
loginEmail = Config.TEST_EMAIL;
|
||||||
loginPassword = Config.LOGIN_PASSWORD;
|
loginPassword = Config.TEST_PASSWORD;
|
||||||
loginUrl = Config.LOGIN_URL;
|
loginUrl = Config.TEST_URL;
|
||||||
loginSecret = Config.LOGIN_SECRET;
|
loginSecret = Config.TEST_SECRET;
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() async {
|
tearDown(() async {
|
||||||
|
|
@ -61,17 +61,18 @@ void main() {
|
||||||
// Login into the app with details from .env.dart
|
// Login into the app with details from .env.dart
|
||||||
test('Login into the app and switch to products screen', () async {
|
test('Login into the app and switch to products screen', () async {
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(LoginKeys.emailKeyString), timeout: new Duration(seconds: 60));
|
await driver.tap(find.byValueKey(LoginKeys.loginSelfHost));
|
||||||
|
await driver.tap(find.byValueKey(LoginKeys.email), timeout: new Duration(seconds: 60));
|
||||||
await driver.enterText(loginEmail);
|
await driver.enterText(loginEmail);
|
||||||
await driver.tap(find.byValueKey(LoginKeys.passwordKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.password));
|
||||||
await driver.enterText(loginPassword);
|
await driver.enterText(loginPassword);
|
||||||
await driver.tap(find.byValueKey(LoginKeys.urlKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.url));
|
||||||
await driver.enterText(loginUrl);
|
await driver.enterText(loginUrl);
|
||||||
await driver.tap(find.byValueKey(LoginKeys.secretKeyString));
|
await driver.tap(find.byValueKey(LoginKeys.secret));
|
||||||
await driver.enterText(loginSecret);
|
await driver.enterText(loginSecret);
|
||||||
|
|
||||||
await driver.tap(find.text(Constants.loginButton));
|
await driver.tap(find.text(Constants.loginButton));
|
||||||
await driver.waitUntilNoTransientCallbacks();
|
await driver.waitUntilNoTransientCallbacks(timeout: Duration(minutes: 1));
|
||||||
|
|
||||||
await driver.waitFor(find.byType(Constants.dashboardScreen));
|
await driver.waitFor(find.byType(Constants.dashboardScreen));
|
||||||
|
|
||||||
|
|
@ -89,13 +90,13 @@ void main() {
|
||||||
|
|
||||||
// Create a new product
|
// Create a new product
|
||||||
test('Add a new product', () async {
|
test('Add a new product', () async {
|
||||||
await driver.tap(find.byValueKey(ProductKeys.productScreenFABKeyString));
|
await driver.tap(find.byValueKey(ProductKeys.fab));
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(ProductKeys.productEditProductFieldKeyString));
|
await driver.tap(find.byValueKey(ProductKeys.productKey));
|
||||||
await driver.enterText(Constants.newProductKey);
|
await driver.enterText(Constants.newProductKey);
|
||||||
await driver.tap(find.byValueKey(ProductKeys.productEditNotesFieldKeyString));
|
await driver.tap(find.byValueKey(ProductKeys.notes));
|
||||||
await driver.enterText(Constants.newProductNotes);
|
await driver.enterText(Constants.newProductNotes);
|
||||||
await driver.tap(find.byValueKey(ProductKeys.productEditCostFieldKeyString));
|
await driver.tap(find.byValueKey(ProductKeys.cost));
|
||||||
await driver.enterText(Constants.newProductCost);
|
await driver.enterText(Constants.newProductCost);
|
||||||
|
|
||||||
await driver.tap(find.byTooltip(Constants.saveToolTip));
|
await driver.tap(find.byTooltip(Constants.saveToolTip));
|
||||||
|
|
@ -118,11 +119,11 @@ void main() {
|
||||||
test('Edit an existing product', () async {
|
test('Edit an existing product', () async {
|
||||||
await driver.tap(find.text(Constants.newProductKey));
|
await driver.tap(find.text(Constants.newProductKey));
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(ProductKeys.productEditProductFieldKeyString));
|
await driver.tap(find.byValueKey(ProductKeys.productKey));
|
||||||
await driver.enterText(Constants.updatedProductKey);
|
await driver.enterText(Constants.updatedProductKey);
|
||||||
await driver.tap(find.byValueKey(ProductKeys.productEditNotesFieldKeyString));
|
await driver.tap(find.byValueKey(ProductKeys.notes));
|
||||||
await driver.enterText(Constants.updatedProductNotes);
|
await driver.enterText(Constants.updatedProductNotes);
|
||||||
await driver.tap(find.byValueKey(ProductKeys.productEditCostFieldKeyString));
|
await driver.tap(find.byValueKey(ProductKeys.cost));
|
||||||
await driver.enterText(Constants.updatedProductCost);
|
await driver.enterText(Constants.updatedProductCost);
|
||||||
|
|
||||||
await driver.tap(find.byTooltip(Constants.saveToolTip));
|
await driver.tap(find.byTooltip(Constants.saveToolTip));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue