diff --git a/lib/ui/app/app_bottom_bar.dart b/lib/ui/app/app_bottom_bar.dart index c26128244e1..2dedcb6ed6b 100644 --- a/lib/ui/app/app_bottom_bar.dart +++ b/lib/ui/app/app_bottom_bar.dart @@ -51,6 +51,7 @@ class _AppBottomBarState extends State { Column( children: EntityState.values.map((state) { return CheckboxListTile( + key: Key(state.toString()), title: Text(AppLocalization.of(context).lookup(state.toString())), controlAffinity: ListTileControlAffinity.leading, value: stateFilters.contains(state), diff --git a/test_driver/products_it_test.dart b/test_driver/products_it_test.dart index 315446319a8..84d2226af76 100644 --- a/test_driver/products_it_test.dart +++ b/test_driver/products_it_test.dart @@ -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'; } @@ -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)); @@ -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); @@ -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); @@ -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));