Verifies issue 40460 : Added automated test 'I40460_VerifyTotalDiscountWithPriority'
authorRanjith S R <ranjith@qualiantech.com>
Fri, 12 Apr 2019 11:10:22 +0530
changeset 8458 799596a77295
parent 8457 80d269396c1c
child 8459 71f8d16e049a
Verifies issue 40460 : Added automated test 'I40460_VerifyTotalDiscountWithPriority'
src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/discounts_bytotal/I40460_VerifyTotalDiscountWithPriority.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/discounts_bytotal/I40460_VerifyTotalDiscountWithPriority.java	Fri Apr 12 11:10:22 2019 +0530
@@ -0,0 +1,96 @@
+/*
+ *************************************************************************
+ * 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.extmodules.selenium.tests.discounts_bytotal;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+public class I40460_VerifyTotalDiscountWithPriority extends WebPOSExtModulesTerminalHelper {
+  final String PRODUCT_1 = "WVG/L0001";
+  final String PRODUCT_2 = "WVG/B0016";
+
+  final String DISCOUNT_ID_1 = "E73C248F47454103B3E5B41F6AD29C7E";
+  final String DISCOUNT_ID_2 = "DA41DD57025B41998149F017670A84D3";
+  final String DISCOUNT_NAME_1 = "Discount per Total Amount 5 per 20";
+  final String DISCOUNT_NAME_2 = "Discount per Total Amount 10 per 40";
+
+  @Test
+  public void test() {
+    tap(TestIdExtModules.BUTTON_SEARCH);
+    write(TestIdExtModules.FIELD_SEARCH_TEXT, PRODUCT_1);
+    tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+    TestIdExtModules.BUTTON_SEARCHPRODUCT_FIRSTROW.enyoNode().waitUntilIsReady();
+    tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_FIRSTROW);
+    verify(TestIdExtModules.LABEL_TOTALTOPAY, "18.90");
+
+    tap(TestIdExtModules.BUTTON_SEARCH);
+    write(TestIdExtModules.FIELD_SEARCH_TEXT, PRODUCT_2);
+    tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+    TestIdExtModules.BUTTON_SEARCHPRODUCT_FIRSTROW.enyoNode().waitUntilIsReady();
+    tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_FIRSTROW);
+    verify(TestIdExtModules.LABEL_TOTALTOPAY, "28.40");
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW1_DISCOUNTNAME, "-- " + DISCOUNT_NAME_1);
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- " + DISCOUNT_NAME_1);
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT, "-2.83");
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-2.17");
+
+    tap(TestIdPack.BUTTON_RECEIPT_ROW1);
+    tap(TestIdPack.BUTTON_KEYPAD_PLUS);
+    verify(TestIdExtModules.LABEL_TOTALTOPAY, "42.30");
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW1_DISCOUNTNAME, "-- " + DISCOUNT_NAME_2);
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- " + DISCOUNT_NAME_2);
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT, "-7.23");
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-2.77");
+
+    tap(TestIdPack.BUTTON_RECEIPT_ROW2);
+    tap(TestIdPack.BUTTON_KEYPAD_MINUS);
+    verify(TestIdExtModules.LABEL_TOTALTOPAY, "32.80");
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW1_DISCOUNTNAME, "-- " + DISCOUNT_NAME_1);
+    verify(TestIdExtModules.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT, "-5.00");
+
+    // Delete Ticket
+    tap(TestIdExtModules.BUTTON_DELETERECEIPT);
+    tap(TestIdExtModules.BUTTON_DELETERECEIPT_CONFIRM);
+    verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  @Override
+  public void beforeWithReload() {
+    setActiveDiscount(true);
+  }
+
+  @Override
+  public void afterWithReload() {
+    setActiveDiscount(false);
+  }
+
+  private void setActiveDiscount(final boolean isForTest) {
+    String sql = String.format(
+        "update m_offer set isactive = '%s' where m_offer_id in ('%s', '%s')",
+        isForTest ? "Y" : "N", DISCOUNT_ID_1, DISCOUNT_ID_2);
+    new DatabaseHelperInsertUpdateOrDelete().execute(sql, 2);
+  }
+}