Skip to content

Commit

Permalink
Merge pull request #14 from mindnervestech/archive-product-test
Browse files Browse the repository at this point in the history
Product Archive Test
  • Loading branch information
hillelcoren committed Jul 4, 2018
2 parents 4e28d8b + 1a98f12 commit 07874e6
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/ui/app/app_bottom_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class _AppBottomBarState extends State<AppBottomBar> {
Column(
children: EntityState.values.map<Widget>((state) {
return CheckboxListTile(
key: Key(state.toString()),
title: Text(AppLocalization.of(context).lookup(state.toString())),
controlAffinity: ListTileControlAffinity.leading,
value: stateFilters.contains(state),
Expand Down
89 changes: 77 additions & 12 deletions test_driver/products_it_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,30 @@ class Constants {
static String newProductKey = 'Example Test Driver Product';
static String newProductNotes = 'Example Test Driver Notes';
static String newProductCost = '100.5';

static String updatedProductKey = 'Updated Example Test Driver Product';
static String updatedProductNotes = 'Updated Example Test Driver Notes';
static String updatedProductCost = '200.5';

static String deleteText = 'Delete';
static String restoreText = 'Restore';
static String archiveText = 'Archive';

static String saveToolTip = 'Save';
static String backToolTip = 'Back';
static String deleteToolTip = 'Delete';
static String menuToolTip = 'Show menu';
static String filterToolTip = 'Filter';

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 snackbarArchiveProduct = 'Successfully archived product';

static String openAppDrawer = 'Open navigation menu';
static String appDrawerProducts = 'Products';
}
Expand All @@ -47,21 +58,20 @@ void main() {
}
});

// Login into the app with details from .env.dart
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.enterText(loginEmail);

await driver.tap(find.byValueKey(LoginKeys.passwordKeyString));
await driver.enterText(loginPassword);

await driver.tap(find.byValueKey(LoginKeys.urlKeyString));
await driver.enterText(loginUrl);

await driver.tap(find.byValueKey(LoginKeys.secretKeyString));
await driver.enterText(loginSecret);

await driver.tap(find.text(Constants.loginButton));
await driver.waitUntilNoTransientCallbacks();

await driver.waitFor(find.byType(Constants.dashboardScreen));

Expand All @@ -77,15 +87,14 @@ void main() {
await driver.waitFor(find.byType(Constants.productScreen));
});

// Create a new product
test('Add a new product', () async {
await driver.tap(find.byValueKey(ProductKeys.productScreenFABKeyString));

await driver.tap(find.byValueKey(ProductKeys.productEditProductFieldKeyString));
await driver.enterText(Constants.newProductKey);

await driver.tap(find.byValueKey(ProductKeys.productEditNotesFieldKeyString));
await driver.enterText(Constants.newProductNotes);

await driver.tap(find.byValueKey(ProductKeys.productEditCostFieldKeyString));
await driver.enterText(Constants.newProductCost);

Expand All @@ -104,16 +113,15 @@ void main() {

await driver.tap(find.byTooltip(Constants.backToolTip));
});

test('Edit a existing product', () async {

// Edit the newly created product
test('Edit an existing product', () async {
await driver.tap(find.text(Constants.newProductKey));

await driver.tap(find.byValueKey(ProductKeys.productEditProductFieldKeyString));
await driver.enterText(Constants.updatedProductKey);

await driver.tap(find.byValueKey(ProductKeys.productEditNotesFieldKeyString));
await driver.enterText(Constants.updatedProductNotes);

await driver.tap(find.byValueKey(ProductKeys.productEditCostFieldKeyString));
await driver.enterText(Constants.updatedProductCost);

Expand All @@ -133,12 +141,69 @@ void main() {
await driver.tap(find.byTooltip(Constants.backToolTip));
});

test('Deleteing an item test', () async {
// Archive the edited product
test('Archieve a product test', () async {
// delete the test product created
await driver.tap(find.text(Constants.updatedProductKey));

await driver.tap(find.byTooltip(Constants.menuToolTip));
await driver.tap(find.text(Constants.deleteToolTip));
await driver.tap(find.text(Constants.archiveText));

// verify snackbar
await driver.waitFor(find.text(Constants.snackbarArchiveProduct));

await driver.tap(find.byTooltip(Constants.backToolTip));

// veify the product goes away from active product list when archived is not selected
await driver.waitForAbsent(find.text(Constants.updatedProductKey));

// Verify product in archived list
// Show archived products
await driver.tap(find.byTooltip(Constants.filterToolTip));
// tick the checkbox archived to show archived products
// ** Here we assume that only active box is ticked, rest are not
// ** Currently there is no way to determite if a checkbox is ticked or not
// ** We also use the state value as the key because
// ** Currently there is no way to check a checkbox without using a key
await driver.tap(find.byValueKey('archived'));

// verify product in archived product list
await driver.waitFor(find.text(Constants.updatedProductKey));

//open and check product details
await driver.tap(find.text(Constants.updatedProductKey));
await driver.waitFor(find.text(Constants.updatedProductKey));
await driver.waitFor(find.text(Constants.updatedProductNotes));
await driver.waitFor(find.text(Constants.updatedProductCost));

// restore the product
await driver.tap(find.byTooltip(Constants.menuToolTip));
await driver.tap(find.text(Constants.restoreText));

// go back
await driver.tap(find.byTooltip(Constants.backToolTip));

// uncheck archive and close filters
await driver.tap(find.byValueKey('archived'));
await driver.tap(find.byTooltip(Constants.filterToolTip));

// veify product is in active products
await driver.tap(find.text(Constants.updatedProductKey));
await driver.waitFor(find.text(Constants.updatedProductKey));
await driver.waitFor(find.text(Constants.updatedProductNotes));
await driver.waitFor(find.text(Constants.updatedProductCost));

// go back
await driver.tap(find.byTooltip(Constants.backToolTip));
});

// Delete the edited product
test('Deleteing a product test', () async {

await driver.tap(find.text(Constants.updatedProductKey));

await driver.tap(find.byTooltip(Constants.menuToolTip));
await driver.tap(find.text(Constants.deleteText));

// verify snackbar
await driver.waitFor(find.text(Constants.snackbarProductDeleted));
Expand Down

0 comments on commit 07874e6

Please sign in to comment.