Related to issue 38686: Test has been refactored due to changes in sampledata
authorAlejandro <alekosmp86@gmail.com>
Mon, 14 Jan 2019 09:43:15 -0500
changeset 8048 f56706bc6bab
parent 8047 b8fa1964c3b4
child 8049 d245d32c66c1
Related to issue 38686: Test has been refactored due to changes in sampledata
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customer/I38686_VerifyFullCustomerAddressIsVisibleInPOS.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customer/I38686_VerifyFullCustomerAddressIsVisibleInPOS.java	Thu Jan 10 13:00:34 2019 -0500
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customer/I38686_VerifyFullCustomerAddressIsVisibleInPOS.java	Mon Jan 14 09:43:15 2019 -0500
@@ -27,13 +27,15 @@
 import org.junit.Test;
 import org.openbravo.test.mobile.core.utils.OBUtils;
 import org.openbravo.test.mobile.core.utils.OBWait;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
 import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
 import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
 
 public class I38686_VerifyFullCustomerAddressIsVisibleInPOS extends WebPOSTerminalHelper {
   final static String LOCATION_LINE1 = "123 Grand Avenue";
   final static String LOCATION_LINE2 = "BuenaVista Boulevard";
-  final static String BUSINESS_PARTNER_NAME = "John Smith";
+  final static String BUSINESS_PARTNER_NAME = "Steven Homewood";
+  final static String BUSINESS_PARTNER_ID = "567DA8DE48F94EAC94DDC377A501FAD6";
 
   @Test
   public void test() {
@@ -66,5 +68,39 @@
 
     tap(TestIdPack.BUTTON_ADDRESS_DETAIL_POPUP_CLOSE);
     tap(TestIdPack.BUTTON_CUSTOMERADDRESS_SELECTOR_CLOSE);
+
+    // select the default customer
+    tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+    write(TestIdPack.FIELD_CUSTOMER_MODAL, "VBS Customer");
+    TestIdPack.FIELD_CUSTOMER_MODAL.enyoNode().executeExtension(".waterfall('onchange')");
+    tap(TestIdPack.BUTTON_CUSTOMER_MODAL_SEARCH);
+    new OBWait() {
+      @Override
+      protected boolean until(int currentIteration) {
+        return get(TestIdPack.LABEL_CUSTOMER_SEARCH_IDENTIFIER).equals("VBS Customer");
+      }
+
+      @Override
+      protected void timeout() {
+        fail("Business Partner not found");
+      }
+    };
+    tap(TestIdPack.BUTTON_CUSTOMER_SEARCH_ROW1);
+  }
+
+  public void beforeWithReload() {
+    setActiveCustomer(BUSINESS_PARTNER_ID, true);
+  }
+
+  public void afterWithReload() {
+    setActiveCustomer(BUSINESS_PARTNER_ID, false);
+  }
+
+  private void setActiveCustomer(String customerId, boolean active) {
+    String sql = String.format("update c_bpartner set isactive = '%s' where c_bpartner_id = '%s'",
+        active ? "Y" : "N", customerId);
+
+    new DatabaseHelperInsertUpdateOrDelete() {
+    }.execute(sql, 1);
   }
 }
\ No newline at end of file