Related to issue 28933. Verifies issue 29055. Added two automated tests
authorAntonio Moreno <antonio.moreno@openbravo.com>
Thu, 05 Mar 2015 20:00:25 +0100
changeset 4066 7c7f24150f18
parent 4065 0324c60bb932
child 4067 e2e1e5a8c1a6
Related to issue 28933. Verifies issue 29055. Added two automated tests
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/loginout/TerminalUpdateTestBasicChange.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/loginout/TerminalUpdateTestMasterdataChange.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/loginout/TerminalUpdateTestBasicChange.java	Thu Mar 05 20:00:25 2015 +0100
@@ -0,0 +1,53 @@
+package org.openbravo.test.mobile.retail.pack.selenium.tests.loginout;
+
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.common.selenium.javascript.TestId;
+import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+import org.openbravo.test.mobile.common.selenium.utils.Wait;
+
+public class TerminalUpdateTestBasicChange extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    final String varName = String.format("OB.%s", getTestName());
+    logOut();
+    SeleniumHelper.executeScript("OB.Model.Order.prototype.properties.push('test');");
+    SeleniumHelper.executeScript("OB.Model.Order.prototype.propertyMap.test='test';");
+    SeleniumHelper
+        .executeScript("OB.Model.Order.prototype.createStatement='CREATE TABLE IF NOT EXISTS c_order (c_order_id TEXT PRIMARY KEY, json CLOB, ad_session_id TEXT, hasbeenpaid TEXT, isbeingprocessed TEXT, test TEXT)';");
+    SeleniumHelper
+        .executeScript("OB.Model.Order.prototype.insertStatement='INSERT INTO c_order(c_order_id, json, ad_session_id, hasbeenpaid, isbeingprocessed, test) VALUES (?,?,?,?,?,?);'");
+
+    logIn();
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_SKI);
+    tap(TestId.BUTTON_PRODUCT_SKI_GLIDEWAX);
+    verify(TestId.LABEL_TOTALTOPAY, new OBNumber("12.5"));
+    SeleniumHelper
+        .executeScript("OB.Dal.find(OB.Model.Order, {}, function(data){if(data.models[0].attributes.hasOwnProperty('test')){"
+            + varName + "=true;}});");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, new OBNumber("0"));
+
+    new Wait() {
+      @Override
+      protected boolean until(final int currentIteration) {
+        final boolean isTestFinished = (Boolean) SeleniumHelper.executeScriptWithReturn(String
+            .format("%s===true", varName));
+        return isTestFinished;
+      }
+
+      @Override
+      protected void timeout() {
+        fail("The Session table was not updated");
+      }
+    };
+
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/loginout/TerminalUpdateTestMasterdataChange.java	Thu Mar 05 20:00:25 2015 +0100
@@ -0,0 +1,38 @@
+package org.openbravo.test.mobile.retail.pack.selenium.tests.loginout;
+
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper;
+import org.openbravo.test.mobile.common.selenium.utils.Wait;
+
+public class TerminalUpdateTestMasterdataChange extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    final String varName = String.format("OB.%s", getTestName());
+    logOut();
+    SeleniumHelper
+        .executeScript("OB.Model.Product.propertyList.push({column:'test', name:'test', type:'TEXT'});");
+    logIn();
+    SeleniumHelper
+        .executeScript("OB.Dal.find(OB.Model.Product, {}, function(data){if(data.models[0].attributes.hasOwnProperty('test')){"
+            + varName + "=true;}});");
+
+    new Wait() {
+      @Override
+      protected boolean until(final int currentIteration) {
+        final boolean isTestFinished = (Boolean) SeleniumHelper.executeScriptWithReturn(String
+            .format("%s===true", varName));
+        return isTestFinished;
+      }
+
+      @Override
+      protected void timeout() {
+        fail("The Session table was not updated");
+      }
+    };
+
+  }
+}