Related to issue 40659: added automated test
authorAlejandro <alekosmp86@gmail.com>
Wed, 08 May 2019 11:27:52 -0400
changeset 8543 bf120555e05d
parent 8542 6ca36b6d0d18
child 8544 2ee962a4292c
Related to issue 40659: added automated test
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/payment/I40659_VerifyChangeValueIfPayingWithForeignCurrency.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/payment/I40659_VerifyChangeValueIfPayingWithForeignCurrency.java	Wed May 08 11:27:52 2019 -0400
@@ -0,0 +1,73 @@
+/*
+ *************************************************************************
+ * 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) 2019 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ *
+ * @author alekosmp86
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.payment;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.commons.codec.binary.StringUtils;
+import org.junit.Test;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.SynchronizationMonitor;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
+
+public class I40659_VerifyChangeValueIfPayingWithForeignCurrency extends WebPOSTerminalHelper {
+  final private String PRODUCT_NAME = "Avalanche transceiver";
+
+  @Test
+  public void test() {
+    // sell a product and pay with foreign currency to generate some cash
+    addProduct(PRODUCT_NAME);
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_PAYMENT_USACASH);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    SynchronizationMonitor.waitUntilDataIsInTheServer();
+
+    addProduct(PRODUCT_NAME);
+    tap(TestIdPack.BUTTON_PAY);
+    write(TestIdPack.INPUT_POINTOFSALE, "155");
+    tap(TestIdPack.BUTTON_KEYPAD_ENTER);
+    verify(TestIdPack.LABEL_RECEIPT_ADDEDPAYMENT_ROW1_NAME, "Cash");
+    verify(TestIdPack.LABEL_RECEIPT_ADDEDPAYMENT_ROW1_AMOUNT, "155.00");
+    tap(TestIdPack.BUTTON_PAYMENT_USACASH);
+    verify(TestIdPack.LABEL_RECEIPT_PAY_CHANGE, "$5.91");
+
+    final String changeReceipt = (String) SeleniumHelper
+        .executeScriptWithReturn("OB.MobileApp.model.attributes.changeReceipt");
+    assertThat("Wrong change value in 'OB.MobileApp.model.attributes.changeReceipt' variable",
+        StringUtils.equals(changeReceipt, get(TestIdPack.LABEL_RECEIPT_PAY_CHANGE)));
+
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    SynchronizationMonitor.waitUntilDataIsInTheServer();
+  }
+
+  private void addProduct(String productName) {
+    // add a product
+    tap(TestIdPack.BUTTON_SEARCH);
+    write(TestIdPack.FIELD_SEARCH_TEXT, productName);
+    TestIdPack.FIELD_SEARCH_TEXT.enyoNode().executeExtension(".waterfall('onchange')");
+    tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+    tap(TestIdPack.BUTTON_SEARCHPRODUCT_FIRSTROW);
+  }
+}