Verifies issue 40019 : Added Automated Test "I40019_VerifyCountedAmountAfterCashup"
authorRanjith S R <ranjith@qualiantech.com>
Tue, 29 Jan 2019 12:17:39 +0530
changeset 8123 356d3784ba8d
parent 8122 302e22d76237
child 8124 4c81c816736a
child 8157 745da8e8eddb
Verifies issue 40019 : Added Automated Test "I40019_VerifyCountedAmountAfterCashup"
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/I40019_VerifyCountedAmountAfterCashup.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/I40019_VerifyCountedAmountAfterCashup.java	Tue Jan 29 12:17:39 2019 +0530
@@ -0,0 +1,157 @@
+/*
+ *************************************************************************
+ * 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 RAN
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.cashup;
+
+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.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.SynchronizationMonitor;
+import org.openbravo.test.mobile.retail.mobilecore.utils.ApplicationWindow;
+import org.openbravo.test.mobile.retail.multiserver.selenium.TestIdMultiserver;
+import org.openbravo.test.mobile.retail.pack.API.WebPOSAPI;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
+
+public class I40019_VerifyCountedAmountAfterCashup extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    WebPOSAPI.cleanCashup(this);
+    // Create and Pay Receipt by Cash
+    addProduct();
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    // Create and Pay Receipt by Card
+    addProduct();
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_CARD);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    // Create and Pay Receipt by USA Cash
+    addProduct();
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_CASHUSA);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    final String cashupId = (String) SeleniumHelper
+        .executeScriptWithReturn("OB.MobileApp.model.get('terminal').cashUpId");
+
+    // Do Cashup
+    // Count Cash, Card, USA Cash
+    // Keep 100 in Cash and USA Cash
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_CASHUP);
+    SynchronizationMonitor.waitUntilCurrentWindowIsRendered(ApplicationWindow.CASHUP);
+    verify(TestIdExtModules.LABEL_CASHUP_TITLE, "Cash Up");
+    final String cashupDate = (String) SeleniumHelper
+        .executeScriptWithReturn("OB.OBPOSCashUp.UI.CashUp.getTitleExtensions()");
+    verify(TestIdPack.LABEL_CASHUP_STEP2_TITLE, "Step 1 of 4: Count Cash" + cashupDate);
+    tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_50);
+    tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_50);
+    tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_50);
+    tap(TestIdPack.BUTTON_CASHUP_COUNTCASH_050);
+    tap(TestIdPack.BUTTON_CASHUP_NEXT);
+
+    verify(TestIdPack.LABEL_CASHUP_STEP3_TITLE, "Step 2 of 4: Count Cash" + cashupDate);
+    tap(TestIdMultiserver.BUTTON_CASHUP_CARD_OK);
+    tap(TestIdMultiserver.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestIdMultiserver.BUTTON_CASHUP_VOUCHER_OK);
+    tap(TestIdMultiserver.BUTTON_CASHUP_NEXT);
+
+    verify(TestIdPack.LABEL_CASHUP_STEP4_TITLE, "Step 3 of 4: Select Cash to keep" + cashupDate);
+    tap(TestIdPack.BUTTON_CASHUP_KEEPVARIABLEAMOUNT);
+    tap(TestIdPack.BUTTON_KEYPAD_1);
+    tap(TestIdPack.BUTTON_KEYPAD_0);
+    tap(TestIdPack.BUTTON_KEYPAD_0);
+    tap(TestIdPack.BUTTON_KEYPAD_ENTER);
+    tap(TestIdPack.BUTTON_CASHUP_NEXT);
+
+    verify(TestIdPack.LABEL_CASHUP_STEP4_TITLE,
+        "Step 3 of 4: Select USA Cash to keep" + cashupDate);
+    tap(TestIdPack.BUTTON_CASHUP_KEEPVARIABLEAMOUNT);
+    tap(TestIdPack.BUTTON_KEYPAD_1);
+    tap(TestIdPack.BUTTON_KEYPAD_0);
+    tap(TestIdPack.BUTTON_KEYPAD_0);
+    tap(TestIdPack.BUTTON_KEYPAD_ENTER);
+    tap(TestIdPack.BUTTON_CASHUP_NEXT);
+
+    verify(TestIdPack.LABEL_CASHUP_STEP4_TITLE, "Step 3 of 4: Select Voucher to keep" + cashupDate);
+    tap(TestIdPack.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestIdPack.BUTTON_CASHUP_NEXT);
+
+    verify(TestIdPack.LABEL_CASHUP_STEP5_TITLE, "Step 4 of 4: Post, print and close" + cashupDate);
+    tap(TestIdPack.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+    verify(TestIdExtModules.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestIdPack.BUTTON_POPUP_OK);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    final String sql = String.format("select ap.name, pmc.totalcounted, pmc.amounttokeep "
+        + "from obpos_paymentmethodcashup pmc join obpos_app_payment ap on ap.obpos_app_payment_id = pmc.obpos_app_payment_id "
+        + "where pmc.obpos_app_cashup_id = '%s' and pmc.totalcounted > 0 order by ap.name",
+        cashupId);
+    new DatabaseHelperSelect() {
+
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        switch (rs.getString("name")) {
+          // Cash
+          case "Card":
+            assertThat((float) 150.50, equalTo(rs.getFloat("totalcounted")));
+            assertThat((float) 0.00, equalTo(rs.getFloat("amounttokeep")));
+            break;
+          // Card
+          case "Cash":
+            assertThat((float) 150.50, equalTo(rs.getFloat("totalcounted")));
+            assertThat((float) 100.00, equalTo(rs.getFloat("amounttokeep")));
+            break;
+          case "USA Cash":
+            assertThat((float) 197.81, equalTo(rs.getFloat("totalcounted")));
+            assertThat((float) 100.00, equalTo(rs.getFloat("amounttokeep")));
+            break;
+        }
+      }
+    }.execute(sql, 3);
+  }
+
+  private void addProduct() {
+    // Create and Pay Receipt by Cash
+    tap(TestIdPack.BUTTON_BROWSE);
+    tap(TestIdPack.BUTTON_CATEGORY_BESTSELLERS);
+    tap(TestIdPack.BUTTON_PRODUCT_BESTSELLERS_AVALANCHETRANSCEIVER);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "150.50");
+  }
+}