This commit is contained in:
Anmol Gupta 2018-06-27 20:40:50 +05:30
parent 806b0b5bae
commit 29a56200c1
1 changed files with 55 additions and 34 deletions

View File

@ -5,6 +5,27 @@ import 'package:invoiceninja/utils/keys.dart';
import '../.env.dart'; import '../.env.dart';
class Constants {
static String newProductKey = 'Example Test Driver Product';
static String newProductNotes = 'Example Test Driver Notes';
static String newProductCost = '100.50';
static String updatedProductKey = 'Updated Example Test Driver Product';
static String updatedProductNotes = 'Updated Example Test Driver Notes';
static String updatedProductCost = '200.50';
static String saveToolTip = 'Save';
static String backToolTip = 'Back';
static String deleteToolTip = 'Delete';
static String menuToolTip = 'Show menu';
static String loginButton = 'LOGIN';
static String dashboardScreen = 'DashboardScreen';
static String productScreen = 'ProductScreen';
static String snackbarProductCreated = 'Successfully created product';
static String snackbarProductUpdated = 'Successfully updated product';
static String snackbarProductDeleted = 'Successfully deleted product';
static String openAppDrawer = 'Open navigation menu';
static String appDrawerProducts = 'Products';
}
void main() { void main() {
group('PRODUCTS TEST', () { group('PRODUCTS TEST', () {
@ -41,92 +62,92 @@ void main() {
await driver.tap(find.byValueKey(LoginKeys.secretKeyString)); await driver.tap(find.byValueKey(LoginKeys.secretKeyString));
await driver.enterText(loginSecret); await driver.enterText(loginSecret);
await driver.tap(find.text('LOGIN')); await driver.tap(find.text(Constants.loginButton));
await driver.waitFor(find.byType('DashboardScreen')); await driver.waitFor(find.byType(Constants.dashboardScreen));
// open the app drawer and switch to products screen // open the app drawer and switch to products screen
// https://github.com/flutter/flutter/issues/9002[Issue still open] - Using this solution to implement it // https://github.com/flutter/flutter/issues/9002[Issue still open] - Using this solution to implement it
final SerializableFinder drawerOpenButton = find.byTooltip('Open navigation menu'); final SerializableFinder drawerOpenButton = find.byTooltip(Constants.openAppDrawer);
await driver.tap(drawerOpenButton); await driver.tap(drawerOpenButton);
final SerializableFinder productsDrawerButton = find.text('Products'); final SerializableFinder productsDrawerButton = find.text(Constants.appDrawerProducts);
await driver.tap(productsDrawerButton); await driver.tap(productsDrawerButton);
await driver.waitFor(find.byType('ProductScreen')); await driver.waitFor(find.byType(Constants.productScreen));
}); });
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.productScreenFABKeyString));
await driver.tap(find.byValueKey(ProductKeys.productEditProductFieldKeyString)); await driver.tap(find.byValueKey(ProductKeys.productEditProductFieldKeyString));
await driver.enterText('Example Test Driver Product'); await driver.enterText(Constants.newProductKey);
await driver.tap(find.byValueKey(ProductKeys.productEditNotesFieldKeyString)); await driver.tap(find.byValueKey(ProductKeys.productEditNotesFieldKeyString));
await driver.enterText('Example Test Driver Notes'); await driver.enterText(Constants.newProductNotes);
await driver.tap(find.byValueKey(ProductKeys.productEditCostFieldKeyString)); await driver.tap(find.byValueKey(ProductKeys.productEditCostFieldKeyString));
await driver.enterText('100.50'); await driver.enterText(Constants.newProductCost);
await driver.tap(find.byTooltip('Save')); await driver.tap(find.byTooltip(Constants.saveToolTip));
// verify snackbar // verify snackbar
await driver.waitFor(find.text('Successfully created product')); await driver.waitFor(find.text(Constants.snackbarProductCreated));
await driver.tap(find.byTooltip('Back')); await driver.tap(find.byTooltip(Constants.backToolTip));
// verify entered text while new product creation // verify entered text while new product creation
await driver.tap(find.text('Example Test Driver Product')); await driver.tap(find.text(Constants.newProductKey));
await driver.waitFor(find.text('Example Test Driver Product')); await driver.waitFor(find.text(Constants.newProductKey));
await driver.waitFor(find.text('Example Test Driver Notes')); await driver.waitFor(find.text(Constants.newProductNotes));
await driver.waitFor(find.text('100.50')); await driver.waitFor(find.text(Constants.newProductCost));
await driver.tap(find.byTooltip('Back')); await driver.tap(find.byTooltip(Constants.backToolTip));
}); });
test('Edit a existing product', () async { test('Edit a existing product', () async {
await driver.tap(find.text('Example Test Driver Product')); await driver.tap(find.text(Constants.newProductKey));
await driver.tap(find.byValueKey(ProductKeys.productEditProductFieldKeyString)); await driver.tap(find.byValueKey(ProductKeys.productEditProductFieldKeyString));
await driver.enterText('Updated Example Test Driver Product'); await driver.enterText(Constants.updatedProductKey);
await driver.tap(find.byValueKey(ProductKeys.productEditNotesFieldKeyString)); await driver.tap(find.byValueKey(ProductKeys.productEditNotesFieldKeyString));
await driver.enterText('Updated Example Test Driver Notes'); await driver.enterText(Constants.updatedProductNotes);
await driver.tap(find.byValueKey(ProductKeys.productEditCostFieldKeyString)); await driver.tap(find.byValueKey(ProductKeys.productEditCostFieldKeyString));
await driver.enterText('200.50'); await driver.enterText(Constants.updatedProductCost);
await driver.tap(find.byTooltip('Save')); await driver.tap(find.byTooltip(Constants.saveToolTip));
// verify snackbar // verify snackbar
await driver.waitFor(find.text('Successfully updated product')); await driver.waitFor(find.text(Constants.snackbarProductUpdated));
await driver.tap(find.byTooltip('Back')); await driver.tap(find.byTooltip(Constants.backToolTip));
// verify updated values while editing existing product // verify updated values while editing existing product
await driver.tap(find.text('Updated Example Test Driver Notes')); await driver.tap(find.text(Constants.updatedProductKey));
await driver.waitFor(find.text('Updated Example Test Driver Product')); await driver.waitFor(find.text(Constants.updatedProductKey));
await driver.waitFor(find.text('Updated Example Test Driver Notes')); await driver.waitFor(find.text(Constants.updatedProductNotes));
await driver.waitFor(find.text('200.50')); await driver.waitFor(find.text(Constants.updatedProductCost));
await driver.tap(find.byTooltip('Back')); await driver.tap(find.byTooltip(Constants.backToolTip));
}); });
test('Deleteing an item test', () async { test('Deleteing an item test', () async {
// delete the test product created // delete the test product created
await driver.tap(find.text('Updated Example Test Driver Product')); await driver.tap(find.text(Constants.updatedProductKey));
await driver.tap(find.byTooltip('Show menu')); await driver.tap(find.byTooltip(Constants.menuToolTip));
await driver.tap(find.text('Delete')); await driver.tap(find.text(Constants.deleteToolTip));
// verify snackbar // verify snackbar
await driver.waitFor(find.text('Successfully deleted product')); await driver.waitFor(find.text(Constants.snackbarProductDeleted));
await driver.tap(find.byTooltip('Back')); await driver.tap(find.byTooltip(Constants.backToolTip));
// verify not in list // verify not in list
await driver.waitForAbsent(find.text('Updated Example Test Driver Product')); await driver.waitForAbsent(find.text(Constants.updatedProductKey));
}); });
}); });
} }