Related issue 38462: Secundary phone test
authorEduardo Becerra <ebec70@yahoo.com>
Fri, 05 Oct 2018 09:18:51 +0200
changeset 7681 94c351573bd2
parent 7680 1d0bf02a9a11
child 7722 d0109217072f
child 7732 5cc4122b177f
child 7778 d5361430ee12
child 8141 167649ef9dba
Related issue 38462: Secundary phone test
src-test/org/openbravo/test/mobile/core/utils/AllowedErrorsHelper.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customercreation/CustomerCreationHelper.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customercreation/NewCustomerWithAlternativePhone.java
--- a/src-test/org/openbravo/test/mobile/core/utils/AllowedErrorsHelper.java	Sat Oct 06 15:17:28 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/core/utils/AllowedErrorsHelper.java	Fri Oct 05 09:18:51 2018 +0200
@@ -109,6 +109,7 @@
     testsAllowedToHaveTomcatErrors.add("CustomerAddressNavigation.testReceiptProperties");
     testsAllowedToHaveTomcatErrors.add("CustomerManageAddress");
     testsAllowedToHaveTomcatErrors.add("NewCustomerWithAddress");
+    testsAllowedToHaveTomcatErrors.add("NewCustomerWithAlternativePhone");
     testsAllowedToHaveTomcatErrors.add("SelectBothAddress");
     testsAllowedToHaveTomcatErrors.add("I34927_VerifyCustomerAddressesNagivationPath");
     testsAllowedToHaveTomcatErrors.add("I35248_VerifyUpdateCustomerOnLayaway");
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java	Sat Oct 06 15:17:28 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java	Fri Oct 05 09:18:51 2018 +0200
@@ -806,6 +806,8 @@
       "customerCategory_customerCombo"); //
   public static TestIdConstructor FIELD_CUSTOMER_STATICNAME = new TestIdConstructor(
       "newAttribute_customerName"); //
+  public static TestIdConstructor FIELD_CUSTOMER_ALT_PHONE = new TestIdConstructor(
+      "newAttribute_alternativePhone"); //
   public static TestIdConstructor FIELD_CUSTOMER_ADDRESS_INV_NAME = new TestIdConstructor(
       "newAttribute_customerInvLocName"); //
   public static TestIdConstructor FIELD_CUSTOMER_ADDRESS_INV_POSTALCODE = new TestIdConstructor(
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customercreation/CustomerCreationHelper.java	Sat Oct 06 15:17:28 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customercreation/CustomerCreationHelper.java	Fri Oct 05 09:18:51 2018 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo S.L.U.
- * All portions are Copyright (C) 2016 Openbravo S.L.U.
+ * All portions are Copyright (C) 2016-2018 Openbravo S.L.U.
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -35,11 +35,18 @@
 public class CustomerCreationHelper extends WebPOSTerminalHelper {
 
   protected void createCustomer(final String customerName) {
+    createCustomer(customerName, null);
+  }
+
+  protected void createCustomer(final String customerName, final String alternativePhone) {
     tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
     tap(TestIdPack.BUTTON_CUSTOMER_NEW);
-
+    if (alternativePhone != null) {
+      write(TestIdPack.FIELD_CUSTOMER_ALT_PHONE, alternativePhone);
+    }
     write(TestIdPack.FIELD_CUSTOMER_NAME, customerName);
     write(TestIdPack.FIELD_CUSTOMER_ADDRESS_INV_NAME, customerName + " Addr");
+    verify(TestIdPack.FIELD_CUSTOMER_CUSTOMER_COUNTRY_VIEW, "106");
     write(TestIdPack.FIELD_CUSTOMER_ADDRESS_INV_POSTALCODE, "31000");
     write(TestIdPack.FIELD_CUSTOMER_ADDRESS_INV_CITY, "Pamplona");
     tap(TestIdPack.BUTTON_CUSTOMER_SAVE);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customercreation/NewCustomerWithAlternativePhone.java	Fri Oct 05 09:18:51 2018 +0200
@@ -0,0 +1,88 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2018 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.customercreation;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+/**
+ * Create a new customer with address in a receipt
+ */
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class NewCustomerWithAlternativePhone extends CustomerCreationHelper {
+  @Test
+  public void test() {
+    final String customerName = "CCIa140 " + System.currentTimeMillis();
+    final String secondaryPhone = "666666666";
+    final String editSecondaryPhone = "666666677";
+
+    reload();
+    createCustomer(customerName, secondaryPhone);
+    verifyFlagsAddress(customerName);
+    verifyBPSecondaryPhoneinBackend(customerName, secondaryPhone);
+    tap(TestIdPack.BUTTON_DELETERECEIPT);
+    tap(TestIdPack.BUTTON_DELETERECEIPT_CONFIRM);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    // edit secondary or alternate phone no.
+    reload();
+
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_CUSTOMERS);
+    write(TestIdPack.FIELD_CUSTOMER_MODAL, customerName);
+    tap(TestIdPack.BUTTON_CUSTOMER_MODAL_SEARCH);
+    tap(TestIdPack.BUTTON_POPUP_CUSTOMER_3DOTS);
+    tap(TestIdPack.BUTTON_POPUP_CUSTOMER_3DOTS_EDIT);
+    verify(TestIdPack.FIELD_VIEW_CUSTOMER_EDIT, "Edit Customer");
+    verify(TestIdPack.FIELD_CUSTOMER_ALT_PHONE, secondaryPhone);
+    write(TestIdPack.FIELD_CUSTOMER_ALT_PHONE, editSecondaryPhone);
+    tap(TestIdPack.BUTTON_CUSTOMER_SAVE);
+    verify(TestIdPack.FIELD_VIEW_CUSTOMER_DETAILS, "Customer details");
+    tap(TestIdPack.BUTTON_CUSTOMER_DETAILS_CLOSE);
+    verify(TestIdPack.LABEL_CUSTOMER_ASSIGN_TITLE, "Assign a customer");
+    tap(TestIdPack.BUTTON_CUSTOMER_SELECTOR_CLOSE);
+    verifyBPSecondaryPhoneinBackend(customerName, editSecondaryPhone);
+  }
+
+  public static void verifyBPSecondaryPhoneinBackend(final String BPname,
+      final String BPSecondaryPhone) {
+    final String clientId = BackboneHelper.getTerminalValue("client");
+    final String query = String
+        .format("SELECT phone2 from ad_user where c_bpartner_id = (select c_bpartner_id from c_bpartner where name = '"
+            + BPname + "' and ad_client_id = '" + clientId + "')");
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat("Secondary or Alternate phone of the BPartner is not the expected",
+            rs.getString("phone2"), equalTo(BPSecondaryPhone));
+      }
+    }.execute(query, 1);
+  }
+}