Automated test for issue 32474
authorCarlos Aristu <carlos.aristu@openbravo.com>
Tue, 15 Mar 2016 18:59:27 +0100
changeset 3898 9df79d65a16f
parent 3897 631a6b952646
child 4144 c2ba77d703bb
Automated test for issue 32474
src-test/com/openbravo/test/integration/erp/gui/financial/receivablespayables/transactions/financialaccount/TransactionTab.java
src-test/com/openbravo/test/integration/erp/modules/client/application/gui/selectors/OBSelectorPopUpWindow.java
src-test/com/openbravo/test/integration/erp/modules/client/application/testsuites/standardview/grid/GFI002_DateFilterRemovedAfterClickingOnFunnel.java
src-test/com/openbravo/test/integration/erp/modules/client/application/testsuites/standardview/grid/GridSuite.java
src-test/com/openbravo/test/integration/erp/modules/userinterface/smartclient/gui/SelectorField.java
src-test/com/openbravo/test/integration/erp/testscripts/financial/receivablespayables/transactions/FinancialAccount.java
--- a/src-test/com/openbravo/test/integration/erp/gui/financial/receivablespayables/transactions/financialaccount/TransactionTab.java	Tue Mar 15 18:56:03 2016 +0100
+++ b/src-test/com/openbravo/test/integration/erp/gui/financial/receivablespayables/transactions/financialaccount/TransactionTab.java	Tue Mar 15 18:59:27 2016 +0100
@@ -115,4 +115,15 @@
     AddPaymentProcess addPaymentProcess = new AddPaymentProcess(this);
     return addPaymentProcess;
   }
+
+  /**
+   * Get the value present on the filter of a selector field.
+   * 
+   * @param fieldName
+   *          The name of the field whose filter value will be returned.
+   */
+  public Object getSelectorFieldFilterClearedValue(String fieldName) {
+    return ((AddPaymentSelectorField) this.getForm().getField("finPayment"))
+        .getClearedFilterValue(fieldName);
+  }
 }
--- a/src-test/com/openbravo/test/integration/erp/modules/client/application/gui/selectors/OBSelectorPopUpWindow.java	Tue Mar 15 18:56:03 2016 +0100
+++ b/src-test/com/openbravo/test/integration/erp/modules/client/application/gui/selectors/OBSelectorPopUpWindow.java	Tue Mar 15 18:59:27 2016 +0100
@@ -25,10 +25,13 @@
 import org.openqa.selenium.NoSuchElementException;
 
 import com.openbravo.test.integration.erp.data.selectors.SelectorDataObject;
+import com.openbravo.test.integration.erp.modules.client.application.gui.GridInputFieldFactory;
 import com.openbravo.test.integration.erp.modules.userinterface.smartclient.gui.Button;
 import com.openbravo.test.integration.erp.modules.userinterface.smartclient.gui.Grid;
+import com.openbravo.test.integration.erp.modules.userinterface.smartclient.gui.InputField;
 import com.openbravo.test.integration.erp.modules.userinterface.smartclient.gui.PopUpWindow;
 import com.openbravo.test.integration.selenium.Sleep;
+import com.openbravo.test.integration.util.TestUtils;
 
 /**
  * Executes actions on OpenbravoERP selector pop up window.
@@ -131,4 +134,23 @@
     okButton.smartClientClick();
   }
 
+  public void clearFilters() {
+    grid.clearFilters();
+  }
+
+  /**
+   * Get the value present on the filter of a selector field.
+   * 
+   * @param fieldName
+   *          The name of the field whose filter value will be returned.
+   */
+  public Object getFilterValue(String key) {
+    String fieldSmartClientLocator = String.format("%s/editRowForm/item[name=%s]",
+        grid.getFilterLocator(), TestUtils.convertFieldSeparator(key, false));
+    InputField filterInputField = GridInputFieldFactory.getFilterInputFieldObject(
+        grid.getObjectString(), key, fieldSmartClientLocator);
+    filterInputField.focus();
+    return filterInputField.getValue();
+  }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/com/openbravo/test/integration/erp/modules/client/application/testsuites/standardview/grid/GFI002_DateFilterRemovedAfterClickingOnFunnel.java	Tue Mar 15 18:59:27 2016 +0100
@@ -0,0 +1,86 @@
+/*
+ *************************************************************************
+ * 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) 2011-2015 Openbravo S.L.U. 
+ * All Rights Reserved. 
+ ************************************************************************
+ */
+
+package com.openbravo.test.integration.erp.modules.client.application.testsuites.standardview.grid;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+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 com.openbravo.test.integration.erp.data.LogInData;
+import com.openbravo.test.integration.erp.data.financial.receivablespayables.transactions.financialaccount.AccountData;
+import com.openbravo.test.integration.erp.data.financial.receivablespayables.transactions.financialaccount.TransactionsData;
+import com.openbravo.test.integration.erp.testscripts.OpenbravoERPTest;
+import com.openbravo.test.integration.erp.testscripts.financial.receivablespayables.transactions.FinancialAccount;
+import com.openbravo.test.integration.util.ConfigurationProperties;
+
+@RunWith(Parameterized.class)
+public class GFI002_DateFilterRemovedAfterClickingOnFunnel extends OpenbravoERPTest {
+
+  private final AccountData accountHeaderData;
+  private final TransactionsData transactionLinesData;
+
+  /**
+   * Class constructor.
+   * 
+   * @param dataObjectForFiltering
+   *          The data object to be used in the filtering
+   */
+  public GFI002_DateFilterRemovedAfterClickingOnFunnel(AccountData accountHeaderData,
+      TransactionsData transactionLinesData) {
+    this.accountHeaderData = accountHeaderData;
+    this.transactionLinesData = transactionLinesData;
+    logInData = new LogInData.Builder()
+        .userName(ConfigurationProperties.INSTANCE.getSystemAdministratorUser())
+        .password(ConfigurationProperties.INSTANCE.getSystemAdministratorPassword()).build();
+  }
+
+  /**
+   * Test parameters.
+   * 
+   * @return collection of object arrays with data for the test
+   * 
+   */
+  @Parameters
+  public static Collection<Object[]> editRecordValues() {
+    Object[][] data = new Object[][] { { new AccountData.Builder().name("Spain Bank").build(),
+        new TransactionsData.Builder().transactionType("BP Deposit").build() } };
+    return Arrays.asList(data);
+  }
+
+  /**
+   * Test to check that a date filter is not cleared after pressing enter/tab keys.
+   */
+  @Test
+  public void dateFilterIsCleared() {
+    FinancialAccount financialAccount = new FinancialAccount(mainPage).open();
+    financialAccount.select(accountHeaderData);
+    FinancialAccount.Transaction transactions = financialAccount.new Transaction(mainPage);
+    transactions.createWithoutSaving(transactionLinesData);
+    String value = (String) transactions.getSelectorFieldFilterClearedValue("paymentDate");
+    assertThat(value, is(equalTo(""))); // The filter value must has been cleared
+  }
+}
--- a/src-test/com/openbravo/test/integration/erp/modules/client/application/testsuites/standardview/grid/GridSuite.java	Tue Mar 15 18:56:03 2016 +0100
+++ b/src-test/com/openbravo/test/integration/erp/modules/client/application/testsuites/standardview/grid/GridSuite.java	Tue Mar 15 18:59:27 2016 +0100
@@ -46,12 +46,13 @@
     GRD0126_DeleteRecordWithShortcut.class, //
     GRD0130_DeleteMultipleRecordsOneCheckbox.class, //
     GRD0135_DeleteMultipleRecordsMultipleCheckboxes.class, //
-    GFI001_DateFilterPersistsAfterPressingKey.class /*
-                                                     * , GRD0200_NullifyField.class, commented out
-                                                     * because of jenkins error
-                                                     * 
-                                                     * GRD0210_ReopenFilterDropDown.class
-                                                     */})
+    GFI001_DateFilterPersistsAfterPressingKey.class, //
+    GFI002_DateFilterRemovedAfterClickingOnFunnel.class /*
+                                                         * , GRD0200_NullifyField.class, commented
+                                                         * out because of jenkins error
+                                                         * 
+                                                         * GRD0210_ReopenFilterDropDown.class
+                                                         */})
 public class GridSuite {
   // No content is required, this is just the definition of a test suite.
 }
--- a/src-test/com/openbravo/test/integration/erp/modules/userinterface/smartclient/gui/SelectorField.java	Tue Mar 15 18:56:03 2016 +0100
+++ b/src-test/com/openbravo/test/integration/erp/modules/userinterface/smartclient/gui/SelectorField.java	Tue Mar 15 18:59:27 2016 +0100
@@ -90,6 +90,41 @@
   }
 
   /**
+   * Open and clears the filters on the selector using the pop up.
+   */
+  public void openPopUpAndClearFilters() {
+    // The field might have the list box with the options opened. If this is the case, the following
+    // click will just close the box. Click it in order to make sure
+    // it's closed and that the next click will work.
+    Sleep.trySleep(800);
+    selectorItem.click();
+    Sleep.trySleep(400);
+    selectorItem.openSelectorPopUp();
+    popUp = new OBSelectorPopUpWindow<T>(selectorItem.getSelectorWindowObjectString());
+    popUp.waitUntilVisible();
+    popUp.waitForDataToLoad();
+
+    // Added to solve a false positive
+    // Sleep.trySleep();
+    Sleep.trySleep(150);
+    popUp.waitForDataToLoad();
+
+    popUp.clearFilters();
+  }
+
+  /**
+   * Get the value present on the filter of a selector field.
+   * 
+   * @param fieldName
+   *          The name of the field whose filter value will be returned.
+   */
+  public Object getClearedFilterValue(String fieldName) {
+    openPopUpAndClearFilters();
+    Sleep.trySleep(250);
+    return popUp.getFilterValue(fieldName);
+  }
+
+  /**
    * Set a value on the selector using the combo box.
    * 
    * @param data
--- a/src-test/com/openbravo/test/integration/erp/testscripts/financial/receivablespayables/transactions/FinancialAccount.java	Tue Mar 15 18:56:03 2016 +0100
+++ b/src-test/com/openbravo/test/integration/erp/testscripts/financial/receivablespayables/transactions/FinancialAccount.java	Tue Mar 15 18:59:27 2016 +0100
@@ -341,6 +341,17 @@
     }
 
     /**
+     * Get the value present on the filter of a selector field.
+     * 
+     * @param fieldName
+     *          The name of the field whose filter value will be returned.
+     */
+    public Object getSelectorFieldFilterClearedValue(String fieldName) {
+      TransactionTab tab = selectTab();
+      return tab.getSelectorFieldFilterClearedValue(fieldName);
+    }
+
+    /**
      * Assert that deposit and payment amounts are zero.
      */
     public void assertAmountsAreZero() {