Added CustomerFieldSortOrder Test
authorGerard van den Berg <gerard.vandenberg@openbravo.com>
Mon, 04 Feb 2019 09:58:11 +0100
changeset 8179 2c2140ad7f4f
parent 8178 0433be1c40f8
child 8180 f6432ccaa024
Added CustomerFieldSortOrder Test
src-test/org/openbravo/test/mobile/retail/pack/selenium/suites/concurrent/job013/CustomerFieldSortOrder.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/suites/concurrent/job013/CustomerFieldSortOrderHV.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customerFieldSortOrder/AllCustomerFieldSortOrderTest.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customerFieldSortOrder/AllCustomerFieldSortOrderTestHV.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customerFieldSortOrder/SCF020_CheckTheCustomerFieldsOrder.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/suites/concurrent/job013/CustomerFieldSortOrder.java	Mon Feb 04 09:58:11 2019 +0100
@@ -0,0 +1,49 @@
+/*
+ *************************************************************************
+ * 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) 2017 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author GVB
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.suites.concurrent.job013;
+
+import org.junit.AfterClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+import org.openbravo.test.mobile.core.utils.SuiteHelper;
+import org.openbravo.test.mobile.retail.extmodules.selenium.tests.loginlogout.ExtModLogoutAndCloseBrowser;
+import org.openbravo.test.mobile.retail.pack.selenium.tests.customerFieldSortOrder.AllCustomerFieldSortOrderTest;
+import org.openbravo.test.mobile.retail.pack.selenium.tests.loginout.LogoutAndCloseBrowser;
+
+@RunWith(Suite.class)
+@SuiteClasses({
+//
+    AllCustomerFieldSortOrderTest.class, //
+
+    LogoutAndCloseBrowser.class //
+})
+public class CustomerFieldSortOrder extends SuiteHelper {
+
+  @AfterClass
+  public static void afterclass() {
+    nameChild(CustomerFieldSortOrder.class.getSimpleName());
+    SuiteHelper.afterclass();
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/suites/concurrent/job013/CustomerFieldSortOrderHV.java	Mon Feb 04 09:58:11 2019 +0100
@@ -0,0 +1,49 @@
+/*
+ *************************************************************************
+ * 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) 2017 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author GVB
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.suites.concurrent.job013;
+
+import org.junit.AfterClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+import org.openbravo.test.mobile.core.utils.SuiteHelper;
+import org.openbravo.test.mobile.retail.extmodules.selenium.tests.loginlogout.ExtModLogoutAndCloseBrowser;
+import org.openbravo.test.mobile.retail.pack.selenium.tests.customerFieldSortOrder.AllCustomerFieldSortOrderTestHV;
+import org.openbravo.test.mobile.retail.pack.selenium.tests.loginout.LogoutAndCloseBrowser;
+
+@RunWith(Suite.class)
+@SuiteClasses({
+//
+    AllCustomerFieldSortOrderTestHV.class, //
+
+    LogoutAndCloseBrowser.class //
+})
+public class CustomerFieldSortOrderHV extends SuiteHelper {
+
+  @AfterClass
+  public static void afterclass() {
+    nameChild(CustomerFieldSortOrderHV.class.getSimpleName());
+    SuiteHelper.afterclass();
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customerFieldSortOrder/AllCustomerFieldSortOrderTest.java	Mon Feb 04 09:58:11 2019 +0100
@@ -0,0 +1,11 @@
+package org.openbravo.test.mobile.retail.pack.selenium.tests.customerFieldSortOrder;
+
+import org.junit.runner.RunWith;
+import org.openbravo.test.mobile.core.junit.toolbox.SuiteClassesToolbox;
+import org.openbravo.test.mobile.retail.mobilecore.junit.OBWildcardPatternSuite;
+
+@RunWith(OBWildcardPatternSuite.class)
+@SuiteClassesToolbox()
+public class AllCustomerFieldSortOrderTest {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customerFieldSortOrder/AllCustomerFieldSortOrderTestHV.java	Mon Feb 04 09:58:11 2019 +0100
@@ -0,0 +1,11 @@
+package org.openbravo.test.mobile.retail.pack.selenium.tests.customerFieldSortOrder;
+
+import org.junit.runner.RunWith;
+import org.openbravo.test.mobile.core.junit.toolbox.SuiteClassesToolbox;
+import org.openbravo.test.mobile.retail.mobilecore.junit.OBWildcardPatternSuite;
+
+@RunWith(OBWildcardPatternSuite.class)
+@SuiteClassesToolbox()
+public class AllCustomerFieldSortOrderTestHV {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/customerFieldSortOrder/SCF020_CheckTheCustomerFieldsOrder.java	Mon Feb 04 09:58:11 2019 +0100
@@ -0,0 +1,94 @@
+package org.openbravo.test.mobile.retail.pack.selenium.tests.customerFieldSortOrder;
+/*
+ *************************************************************************
+ * 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) 2016 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.core.utils.OBUtils;
+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;
+import org.openqa.selenium.Keys;
+
+
+import org.apache.log4j.Logger;
+import org.junit.Test;
+import org.openbravo.test.mobile.core.utils.TestLogger;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
+
+public class SCF020_CheckTheCustomerFieldsOrder extends WebPOSTerminalHelper {
+  public SCF020_CheckTheCustomerFieldsOrder() {
+    super("VBS-1","vallblanca","openbravo");
+  }
+  private String getFieldIdFromPosition(int position)
+  {
+    return (String) SeleniumHelper.executeScriptWithReturn(String.format("TestRegistry.registry(\"impl_customerOnlyFields\").enyoObject.children[%d].name", position));
+  }
+  
+  final String preference_id = RetailUtils.getRandomUUID();
+  final String property = "OBPOS_CustomerCompSortOrder";
+  final String value = "[''lastName'', ''email'']";
+  final String lastNameId = "line_customerLastName";
+  final String emailId = "line_customerEmail";
+  private void addPreference(String preferenceId, String property, String value) {
+    String sql;
+   
+      sql = String
+          .format(
+              "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, property,value, ispropertylist, selected) "
+                  + "VALUES ('%s', '0', '0', to_char('Y'),'100', '100', '%s', '%s', to_char('Y'), to_char('Y'))",
+              preferenceId, property,value);
+
+    new DatabaseHelperInsertUpdateOrDelete().execute(sql, 1);
+  }
+  private void delPreference(String preferenceId)
+  {
+    String sql = String.format("DELETE FROM ad_preference where ad_preference_id = '%s'", preferenceId);
+    new DatabaseHelperInsertUpdateOrDelete().execute(sql, 1);
+
+  }
+  @Override
+  public void beforeWithReload() {
+   addPreference(preference_id, property, value);
+  }
+  @Override
+  public void afterWithReload() {
+   delPreference(preference_id);
+  }
+  @Test
+  public void test()
+  {
+    tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+    write(TestIdPack.FIELD_CUSTOMER_MODAL, "arturo montoro");
+    tap(TestIdPack.BUTTON_CUSTOMER_MODAL_SEARCH);
+    tap(TestIdPack.BUTTON_CUSTOMER_ARTUROMONTORO);
+    tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+    tap(TestIdPack.BUTTON_POPUP_CUSTOMER_3DOTS);
+    tap(TestIdPack.BUTTON_POPUP_CUSTOMER_3DOTS_DETAILS);
+    assertThat(getFieldIdFromPosition(0),equalTo(lastNameId));
+    assertThat(getFieldIdFromPosition(1),equalTo(emailId));
+    
+  }
+}