Related to issue 28933. Verifies issue 29152: Added 'I29152_NoCashAvailableWhenVoidingALayaway' test
authorRafa Alonso <rafael.alonso@openbravo.com>
Sat, 07 Mar 2015 23:11:14 +0100
changeset 4062 6fd24a428a31
parent 4061 311d8ee5ef7e
child 4063 f472a492da0d
Related to issue 28933. Verifies issue 29152: Added 'I29152_NoCashAvailableWhenVoidingALayaway' test
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/I29152_NoCashAvailableWhenVoidingALayaway.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/I29152_NoCashAvailableWhenVoidingALayaway.java	Sat Mar 07 23:11:14 2015 +0100
@@ -0,0 +1,124 @@
+/*
+ *************************************************************************
+ * 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) 2008-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.TestAnnotations;
+import org.openbravo.test.mobile.common.selenium.javascript.BackboneHelper;
+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.testhelpers.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway in terminal 1001, void in 1002
+ */
+@RunWith(Parameterized.class)
+public class I29152_NoCashAvailableWhenVoidingALayaway extends WebPOSTerminalHelper {
+
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+
+  private static final OBNumber GROSSTOTAL = new OBNumber("39.90");
+  private static final OBNumber PARTIALPAYMENT1 = new OBNumber("12.00");
+  private static final OBNumber GROSS1 = new OBNumber("27.90");
+
+  private static String documentNo1;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    return parameters;
+  }
+
+  public I29152_NoCashAvailableWhenVoidingALayaway(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  @TestAnnotations(waitFixOf = 29152)
+  public void test() {
+    WebPOSSnippet.cleanCashup(this);
+
+    if (getTerminal().equals(VBS1001)) {
+
+      // 1. Create a layaway in one terminal and cashup
+      createLayawayWithInitialPayment();
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      // 2. Retrieve the layaway and void it
+      retrieveLayawayAndVoid();
+
+      isVisible(TestId.LABEL_RECEIPT_PAY_NOTENOUGHCASH, true);
+      isDisabled(TestId.BUTTON_PAY_DONE, true);
+
+    } else {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+  private void createLayawayWithInitialPayment() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_CRAMPONS10POINT);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, GROSSTOTAL);
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSSTOTAL + "€");
+    WebPOSSnippet.tapKeypad(this, PARTIALPAYMENT1.intValue());
+    tap(TestId.BUTTON_CASH);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSS1 + "€");
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void retrieveLayawayAndVoid() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    isDisabled(TestId.BUTTON_PAY, false);
+    verify(TestId.LABEL_TOTALTOPAY, GROSSTOTAL);
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_VOIDLAYAWAY);
+  }
+
+}