# HG changeset patch
# User Shivanand Madiwalar <shivanand.madiwalar@promantia.com>
# Date 1479809391 -19800
#      Tue Nov 22 15:39:51 2016 +0530
# Node ID 501d813c7b9c295d7a05c9ef4d84ebb52350f624
# Parent  bd58f319dc9bcab2663ad61363b0083a19575361
Verifies Issue 34531 : Automated which verifies Logic Added For the Product Filter when its COmbined with "Stock" filter and having any pattern which belongs to the same product over not only "STARTS WITH" Operator .

diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/stockcriteria/I34531_FilterWithCombinationAndPatternContain.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/stockcriteria/I34531_FilterWithCombinationAndPatternContain.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/stockcriteria/I34531_FilterWithCombinationAndPatternContain.java
@@ -0,0 +1,82 @@
+/*
+ *************************************************************************
+ * 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) 2016 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author SMA
+ *
+ */
+package org.openbravo.test.mobile.retail.extmodules.selenium.tests.stockcriteria;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+
+public class I34531_FilterWithCombinationAndPatternContain extends
+		WebPOSExtModulesTerminalHelper {
+
+	
+	@Test
+	public void test() {
+		applyStockFilter();
+		searchProductWithFullPattern();
+		reload();
+		applyStockFilter();
+		searchProductWithRandomPattern();
+	}
+
+	private void applyStockFilter() {
+		tap(TestIdExtModules.BUTTON_SEARCH);
+		tap(TestIdExtModules.BUTTON_SMALL_STOCK_CRITERIA);
+		TestIdExtModules.POPUP_STOCKFILTER_FIRST_FILTER_CONDITION.enyoNode()
+				.executeExtension(".setSelected(0)");
+		write(TestIdExtModules.POPUP_STOCKFILTER_FIRST_FILTER_VALUE, "0");
+		tap(TestIdExtModules.POPUP_STOCKFILTER_DONE_BUTTON);
+		verifyHighVolumeTime(TestIdExtModules.POPUP_STOCKFILTER_DONE_BUTTON);
+		assertThat(
+				"The stock filter button should have a yellow backgroud",
+				(Boolean) TestIdExtModules.BUTTON_SMALL_STOCK_CRITERIA
+						.enyoNode().executeExtensionWithReturn(
+								".hasClass('btnlink-yellow-bold')"),
+				equalTo(true));
+	}
+
+	private void searchProductWithRandomPattern() {
+		write(TestIdExtModules.FIELD_SEARCH_TEXT, "carrier");
+		tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+		tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_FIRSTROW);
+		verify(TestIdExtModules.LABEL_TOTALTOPAY, "110.50");
+		tap(TestIdExtModules.BUTTON_PAY);
+		tap(TestIdExtModules.BUTTON_PAY_EXACT);
+		tap(TestIdExtModules.BUTTON_PAY_DONE);
+		verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+	}
+
+	private void searchProductWithFullPattern() {
+		write(TestIdExtModules.FIELD_SEARCH_TEXT, "Baby carrier");
+		tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+		tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_FIRSTROW);
+		verify(TestIdExtModules.LABEL_TOTALTOPAY, "110.50");
+		tap(TestIdExtModules.BUTTON_PAY);
+		tap(TestIdExtModules.BUTTON_PAY_EXACT);
+		tap(TestIdExtModules.BUTTON_PAY_DONE);
+		verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+	}
+
+}
