# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1451284887 -19800
# Node ID 97b540d7fbae704e249645e7289335f9cbbd2452
# Parent  9bd63f2d466ebe65661625ea4ffda80180591f4c
Verifies issue 31703: Added automated test 'I31703_OpenReceiptIfAlreadyExists'

diff --git a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I31703_OpenReceiptIfAlreadyExists.java b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I31703_OpenReceiptIfAlreadyExists.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I31703_OpenReceiptIfAlreadyExists.java
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I31703_OpenReceiptIfAlreadyExists.java
@@ -67,7 +67,7 @@
     tap(TestId.BUTTON_PAY_EXACT);
     tap(TestId.BUTTON_PAY_DONE);
 
-    // Check Receipt is loaded in selector if it is already loaded in receipt list
+    // Check Receipt is loaded in selector if it is already opened in receipt list
     tap(TestId.BUTTON_MENU);
     tap(TestId.BUTTON_MENU_RECEIPTS);
     write(TestId.FIELD_SEARCH_RECEIPT, firstReceiptNo);
@@ -80,7 +80,8 @@
     write(TestId.FIELD_SEARCH_RECEIPT, firstReceiptNo);
     tap(TestId.BUTTON_RECEIPTS_SEARCH);
     tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", firstReceiptNo, customer));
-    verify(TestId.LABEL_TOTALTOPAY, "2.78");
+    isVisible(TestId.POPUP_GLOBAL_MESSAGEDIALOG, true);
+    tap(TestId.BUTTON_POPUP_GLOBAL_MESSAGEDIALOG);
 
     // Bring the receipt to view if it is already loaded in receipt list
     tap(TestId.BUTTON_MENU);
@@ -100,7 +101,9 @@
     write(TestId.FIELD_SEARCH_RECEIPT, firstReceiptNo);
     tap(TestId.BUTTON_RECEIPTS_SEARCH);
     tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", firstReceiptNo, customer));
-    verify(TestId.LABEL_TOTALTOPAY, "2.78");
+    isVisible(TestId.POPUP_GLOBAL_MESSAGEDIALOG, true);
+    tap(TestId.BUTTON_POPUP_GLOBAL_MESSAGEDIALOG);
+
     final String currentDocumentNo2 = ((String) SeleniumHelper
         .executeScriptWithReturn("OB.MobileApp.model.receipt.get('documentNo')"));
     assertThat("Current Document No is equal to First Receipt Document No", currentDocumentNo2,
@@ -117,7 +120,7 @@
   public void testForLayaway() {
     final String customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
 
-    // user 1: create layaway
+    // user 1 (vallblanca): create layaway
     tap(TestId.BUTTON_MENU);
     tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
     verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
@@ -140,12 +143,12 @@
     verify(TestId.LABEL_TOTALTOPAY, "2.78");
     verify(TestId.LABEL_RECEIPT_TYPE, "Layaway");
 
-    // user 1: lock terminal
+    // user 1(vallblanca): lock terminal
     tap(TestId.BUTTON_MENU);
     tap(TestId.BUTTON_MENU_ONLINE);
     tap(TestId.BUTTON_LOCKSCREEN);
 
-    // user 2: login
+    // user 2(demouser): login
     login("demouser");
 
     // Load last added layaway
@@ -168,6 +171,58 @@
     tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
   }
 
+  @Test
+  public void testForQuotation() {
+    final String customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+
+    // user 1 (vallblanca): create quotation
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CREATEQUOTATION);
+    verify(TestId.LABEL_RECEIPT_TYPE, "Quotation - Draft");
+
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_LIGHTINGANDELECTRONICS);
+    tap(TestId.BUTTON_PRODUCT_LIGHTINGANDELECTRONICS_MINILINTERN);
+    verify(TestId.LABEL_TOTALTOPAY, "2.78");
+
+    final String firstQuotationNo = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+
+    // Reactivate Quotation
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_REACTIVATEQUOTATION);
+    tap(TestId.BUTTON_POPUP_REACTIVATEQUOTATION);
+    verify(TestId.LABEL_TOTALTOPAY, "2.78");
+    verify(TestId.LABEL_RECEIPT_TYPE, "Quotation - Draft");
+
+    // user 1 (vallblanca): lock terminal
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_ONLINE);
+    tap(TestId.BUTTON_LOCKSCREEN);
+
+    // user 2 (demouser): login
+    login("demouser");
+
+    // Load last added quotation
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_QUOTATIONS);
+    write(TestId.FIELD_SEARCH_RECEIPT, firstQuotationNo);
+    tap(TestId.BUTTON_QUOTATIONS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", firstQuotationNo, customer));
+
+    isVisible(TestId.POPUP_GLOBAL_MESSAGEDIALOG, true);
+    tap(TestId.BUTTON_POPUP_GLOBAL_MESSAGEDIALOG);
+
+    logOut();
+
+    logIn();
+
+    // Delete the layaway
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT);
+    tap(TestId.BUTTON_DELETERECEIPT_CONFIRM);
+  }
+
   private void login(final String newUsername) {
     TestId.LABEL_LOGIN_OPENBRAVOMOBILE.enyoNode().waitUntilIsReady();
     OBUtils.pause(OBConstants.WAIT_AFTERWEBPOSLOGO);
