mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 05:10:45 +00:00
Test improvements
This commit is contained in:
@ -19,7 +19,7 @@ public class QBaseSeleniumTest
|
|||||||
{
|
{
|
||||||
private static ChromeOptions chromeOptions;
|
private static ChromeOptions chromeOptions;
|
||||||
|
|
||||||
private WebDriver driver;
|
protected WebDriver driver;
|
||||||
protected QSeleniumJavalin qSeleniumJavalin;
|
protected QSeleniumJavalin qSeleniumJavalin;
|
||||||
protected QSeleniumLib qSeleniumLib;
|
protected QSeleniumLib qSeleniumLib;
|
||||||
|
|
||||||
@ -83,6 +83,8 @@ public class QBaseSeleniumTest
|
|||||||
@AfterEach
|
@AfterEach
|
||||||
void afterEach()
|
void afterEach()
|
||||||
{
|
{
|
||||||
|
qSeleniumLib.takeScreenshotToFile();
|
||||||
|
|
||||||
if(driver != null)
|
if(driver != null)
|
||||||
{
|
{
|
||||||
driver.quit();
|
driver.quit();
|
||||||
|
@ -208,6 +208,38 @@ public class QSeleniumLib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public void waitForSelectorContainingToNotExist(String cssSelector, String textContains)
|
||||||
|
{
|
||||||
|
LOG.debug("Waiting for non-existence of element matching selector [" + cssSelector + "] containing text [" + textContains + "]");
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
List<WebElement> elements = driver.findElements(By.cssSelector(cssSelector));
|
||||||
|
if(elements.size() == 0)
|
||||||
|
{
|
||||||
|
LOG.debug("Found non-existence of element(s) matching selector [" + cssSelector + "]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(elements.stream().noneMatch(e -> e.getText().toLowerCase().contains(textContains)))
|
||||||
|
{
|
||||||
|
LOG.debug("Found non-existence of element(s) matching selector [" + cssSelector + "] containing text [" + textContains + "]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sleepABit();
|
||||||
|
}
|
||||||
|
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
||||||
|
|
||||||
|
fail("Failed for non-existence of element matching selector [" + cssSelector + "] after [" + WAIT_SECONDS + "] seconds.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -258,31 +290,6 @@ public class QSeleniumLib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
**
|
|
||||||
*******************************************************************************/
|
|
||||||
public <T> T waitLoop(String message, Code<T> c)
|
|
||||||
{
|
|
||||||
LOG.debug("Waiting for: " + message);
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
do
|
|
||||||
{
|
|
||||||
T t = c.run();
|
|
||||||
if(t != null)
|
|
||||||
{
|
|
||||||
LOG.debug("Found: " + message);
|
|
||||||
return (t);
|
|
||||||
}
|
|
||||||
|
|
||||||
sleepABit();
|
|
||||||
}
|
|
||||||
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
|
||||||
LOG.warn("Failed to match while waiting for: " + message);
|
|
||||||
return (null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -313,7 +320,6 @@ public class QSeleniumLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
sleepABit();
|
sleepABit();
|
||||||
|
|
||||||
}
|
}
|
||||||
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
||||||
|
|
||||||
@ -323,34 +329,6 @@ public class QSeleniumLib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
**
|
|
||||||
*******************************************************************************/
|
|
||||||
public WebElement waitForSelectorContainingV2(String cssSelector, String textContains)
|
|
||||||
{
|
|
||||||
return (waitLoop("element matching selector [" + cssSelector + "] containing text [" + textContains + "].", () ->
|
|
||||||
{
|
|
||||||
List<WebElement> elements = driver.findElements(By.cssSelector(cssSelector));
|
|
||||||
for(WebElement element : elements)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if(element.getText() != null && element.getText().toLowerCase().contains(textContains.toLowerCase()))
|
|
||||||
{
|
|
||||||
return (element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(StaleElementReferenceException sere)
|
|
||||||
{
|
|
||||||
LOG.debug("Caught a StaleElementReferenceException - will retry.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (null);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Take a screenshot, putting it in the SCREENSHOTS_PATH, with a subdirectory
|
** Take a screenshot, putting it in the SCREENSHOTS_PATH, with a subdirectory
|
||||||
** for the test class simple name, filename = methodName.png.
|
** for the test class simple name, filename = methodName.png.
|
||||||
@ -396,20 +374,22 @@ public class QSeleniumLib
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public void assertElementHasFocus(WebElement element)
|
public void waitForElementToHaveFocus(WebElement element)
|
||||||
{
|
{
|
||||||
|
LOG.debug("Waiting for element [" + element + "] to have focus.");
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(Objects.equals(driver.switchTo().activeElement(), element))
|
if(Objects.equals(driver.switchTo().activeElement(), element))
|
||||||
{
|
{
|
||||||
|
LOG.debug("Element [" + element + "] has focus.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sleepABit();
|
sleepABit();
|
||||||
}
|
}
|
||||||
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
||||||
|
|
||||||
fail("Failed to see that element [" + element + "] has focus.");
|
fail("Failed to see that element [" + element + "] has focus after [" + WAIT_SECONDS + "] seconds.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ public class QSeleniumJavalin
|
|||||||
|
|
||||||
private long WAIT_SECONDS = 10;
|
private long WAIT_SECONDS = 10;
|
||||||
|
|
||||||
private List<Pair<String, String>> routesToFiles;
|
private List<Pair<String, String>> routesToFiles = new ArrayList<>();
|
||||||
private List<Pair<String, String>> routesToStrings;
|
private List<Pair<String, String>> routesToStrings = new ArrayList<>();
|
||||||
|
|
||||||
private Javalin javalin;
|
private Javalin javalin;
|
||||||
|
|
||||||
@ -52,6 +52,17 @@ public class QSeleniumJavalin
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public void clearRoutes()
|
||||||
|
{
|
||||||
|
this.routesToFiles.clear();
|
||||||
|
this.routesToStrings.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Fluent setter for routeToFile
|
** Fluent setter for routeToFile
|
||||||
**
|
**
|
||||||
@ -271,4 +282,5 @@ public class QSeleniumJavalin
|
|||||||
fail("Failed to capture a request for path [" + path + "] with body containing [" + bodyContaining + "] after [" + WAIT_SECONDS + "] seconds.");
|
fail("Failed to capture a request for path [" + path + "] with body containing [" + bodyContaining + "] after [" + WAIT_SECONDS + "] seconds.");
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,6 @@ public class AppPageNavTest extends QBaseSeleniumTest
|
|||||||
qSeleniumLib.gotoAndWaitForBreadcrumbHeader("/", "Greetings App");
|
qSeleniumLib.gotoAndWaitForBreadcrumbHeader("/", "Greetings App");
|
||||||
qSeleniumLib.waitForSelectorContaining(QQQMaterialDashboardSelectors.SIDEBAR_ITEM, "People App").click();
|
qSeleniumLib.waitForSelectorContaining(QQQMaterialDashboardSelectors.SIDEBAR_ITEM, "People App").click();
|
||||||
qSeleniumLib.waitForSelectorContaining(QQQMaterialDashboardSelectors.SIDEBAR_ITEM, "Greetings App").click();
|
qSeleniumLib.waitForSelectorContaining(QQQMaterialDashboardSelectors.SIDEBAR_ITEM, "Greetings App").click();
|
||||||
qSeleniumLib.takeScreenshotToFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +73,6 @@ public class AppPageNavTest extends QBaseSeleniumTest
|
|||||||
qSeleniumLib.gotoAndWaitForBreadcrumbHeader("/peopleApp/greetingsApp", "Greetings App");
|
qSeleniumLib.gotoAndWaitForBreadcrumbHeader("/peopleApp/greetingsApp", "Greetings App");
|
||||||
qSeleniumLib.tryMultiple(3, () -> qSeleniumLib.waitForSelectorContaining("a", "Person").click());
|
qSeleniumLib.tryMultiple(3, () -> qSeleniumLib.waitForSelectorContaining("a", "Person").click());
|
||||||
qSeleniumLib.waitForSelectorContaining(QQQMaterialDashboardSelectors.BREADCRUMB_HEADER, "Person");
|
qSeleniumLib.waitForSelectorContaining(QQQMaterialDashboardSelectors.BREADCRUMB_HEADER, "Person");
|
||||||
qSeleniumLib.takeScreenshotToFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,6 @@ public class AuditTest extends QBaseSeleniumTest
|
|||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
qSeleniumLib.waitForSelectorContaining("BUTTON", "Close").click();
|
qSeleniumLib.waitForSelectorContaining("BUTTON", "Close").click();
|
||||||
qSeleniumLib.waitForSelectorToNotExist(".audit");
|
qSeleniumLib.waitForSelectorToNotExist(".audit");
|
||||||
|
|
||||||
qSeleniumLib.takeScreenshotToFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -112,6 +110,7 @@ public class AuditTest extends QBaseSeleniumTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -153,8 +152,6 @@ public class AuditTest extends QBaseSeleniumTest
|
|||||||
captured = captured.stream().filter(cc -> cc.getPath().equals(auditQueryPath)).toList();
|
captured = captured.stream().filter(cc -> cc.getPath().equals(auditQueryPath)).toList();
|
||||||
assertEquals(1, captured.size());
|
assertEquals(1, captured.size());
|
||||||
assertThat(captured.get(0).getBody()).contains("\"isAscending\":false");
|
assertThat(captured.get(0).getBody()).contains("\"isAscending\":false");
|
||||||
|
|
||||||
qSeleniumLib.takeScreenshotToFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ package com.kingsrook.qqq.materialdashboard.tests;
|
|||||||
|
|
||||||
import com.kingsrook.qqq.materialdashboard.lib.QBaseSeleniumTest;
|
import com.kingsrook.qqq.materialdashboard.lib.QBaseSeleniumTest;
|
||||||
import com.kingsrook.qqq.materialdashboard.lib.QQQMaterialDashboardSelectors;
|
import com.kingsrook.qqq.materialdashboard.lib.QQQMaterialDashboardSelectors;
|
||||||
|
import com.kingsrook.qqq.materialdashboard.lib.QSeleniumLib;
|
||||||
import com.kingsrook.qqq.materialdashboard.lib.javalin.CapturedContext;
|
import com.kingsrook.qqq.materialdashboard.lib.javalin.CapturedContext;
|
||||||
import com.kingsrook.qqq.materialdashboard.lib.javalin.QSeleniumJavalin;
|
import com.kingsrook.qqq.materialdashboard.lib.javalin.QSeleniumJavalin;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -56,7 +57,6 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
// @RepeatedTest(10)
|
|
||||||
@Test
|
@Test
|
||||||
void testBasicQueryAndClearFilters()
|
void testBasicQueryAndClearFilters()
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
// open the filter window, enter a value, wait for query to re-run //
|
// open the filter window, enter a value, wait for query to re-run //
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
WebElement filterInput = qSeleniumLib.waitForSelector(QQQMaterialDashboardSelectors.QUERY_FILTER_INPUT);
|
WebElement filterInput = qSeleniumLib.waitForSelector(QQQMaterialDashboardSelectors.QUERY_FILTER_INPUT);
|
||||||
qSeleniumLib.assertElementHasFocus(filterInput);
|
qSeleniumLib.waitForElementToHaveFocus(filterInput);
|
||||||
qSeleniumJavalin.beginCapture();
|
qSeleniumJavalin.beginCapture();
|
||||||
filterInput.sendKeys("1");
|
filterInput.sendKeys("1");
|
||||||
|
|
||||||
@ -105,9 +105,6 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
assertThat(capturedCount).extracting("body").asString().doesNotContain(idEquals1FilterSubstring);
|
assertThat(capturedCount).extracting("body").asString().doesNotContain(idEquals1FilterSubstring);
|
||||||
assertThat(capturedQuery).extracting("body").asString().doesNotContain(idEquals1FilterSubstring);
|
assertThat(capturedQuery).extracting("body").asString().doesNotContain(idEquals1FilterSubstring);
|
||||||
qSeleniumJavalin.endCapture();
|
qSeleniumJavalin.endCapture();
|
||||||
|
|
||||||
qSeleniumLib.takeScreenshotToFile();
|
|
||||||
// qSeleniumLib.waitForever(); // todo not commit - in fact, build in linting that makes sure we never do?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +112,6 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
// @RepeatedTest(10)
|
|
||||||
@Test
|
@Test
|
||||||
void testMultiCriteriaQueryWithOr()
|
void testMultiCriteriaQueryWithOr()
|
||||||
{
|
{
|
||||||
@ -123,9 +119,9 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
qSeleniumLib.waitForSelector(QQQMaterialDashboardSelectors.QUERY_GRID_CELL);
|
qSeleniumLib.waitForSelector(QQQMaterialDashboardSelectors.QUERY_GRID_CELL);
|
||||||
qSeleniumLib.waitForSelectorContaining("BUTTON", "Filters").click();
|
qSeleniumLib.waitForSelectorContaining("BUTTON", "Filters").click();
|
||||||
|
|
||||||
addQueryFilterInput(0, "First Name", "contains", "Dar", "Or");
|
addQueryFilterInput(qSeleniumLib, 0, "First Name", "contains", "Dar", "Or");
|
||||||
qSeleniumJavalin.beginCapture();
|
qSeleniumJavalin.beginCapture();
|
||||||
addQueryFilterInput(1, "First Name", "contains", "Jam", "Or");
|
addQueryFilterInput(qSeleniumLib, 1, "First Name", "contains", "Jam", "Or");
|
||||||
|
|
||||||
String expectedFilterContents0 = """
|
String expectedFilterContents0 = """
|
||||||
{"fieldName":"firstName","operator":"CONTAINS","values":["Dar"]}""";
|
{"fieldName":"firstName","operator":"CONTAINS","values":["Dar"]}""";
|
||||||
@ -138,9 +134,6 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
qSeleniumJavalin.waitForCapturedPathWithBodyContaining("/data/person/query", expectedFilterContents1);
|
qSeleniumJavalin.waitForCapturedPathWithBodyContaining("/data/person/query", expectedFilterContents1);
|
||||||
qSeleniumJavalin.waitForCapturedPathWithBodyContaining("/data/person/query", expectedFilterContents2);
|
qSeleniumJavalin.waitForCapturedPathWithBodyContaining("/data/person/query", expectedFilterContents2);
|
||||||
qSeleniumJavalin.endCapture();
|
qSeleniumJavalin.endCapture();
|
||||||
|
|
||||||
qSeleniumLib.takeScreenshotToFile();
|
|
||||||
// qSeleniumLib.waitForever(); // todo not commit - in fact, build in linting that makes sure we never do?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,7 +141,7 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
private void addQueryFilterInput(int index, String fieldlabel, String operator, String value, String booleanOperator)
|
static void addQueryFilterInput(QSeleniumLib qSeleniumLib, int index, String fieldLabel, String operator, String value, String booleanOperator)
|
||||||
{
|
{
|
||||||
if(index > 0)
|
if(index > 0)
|
||||||
{
|
{
|
||||||
@ -164,7 +157,7 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
Select fieldSelect = new Select(subFormForField.findElement(By.cssSelector(".MuiDataGrid-filterFormColumnInput SELECT")));
|
Select fieldSelect = new Select(subFormForField.findElement(By.cssSelector(".MuiDataGrid-filterFormColumnInput SELECT")));
|
||||||
fieldSelect.selectByVisibleText(fieldlabel);
|
fieldSelect.selectByVisibleText(fieldLabel);
|
||||||
|
|
||||||
Select operatorSelect = new Select(subFormForField.findElement(By.cssSelector(".MuiDataGrid-filterFormOperatorInput SELECT")));
|
Select operatorSelect = new Select(subFormForField.findElement(By.cssSelector(".MuiDataGrid-filterFormOperatorInput SELECT")));
|
||||||
operatorSelect.selectByVisibleText(operator);
|
operatorSelect.selectByVisibleText(operator);
|
||||||
@ -172,6 +165,7 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
WebElement valueInput = subFormForField.findElement(By.cssSelector(".MuiDataGrid-filterFormValueInput INPUT"));
|
WebElement valueInput = subFormForField.findElement(By.cssSelector(".MuiDataGrid-filterFormValueInput INPUT"));
|
||||||
valueInput.click();
|
valueInput.click();
|
||||||
valueInput.sendKeys(value);
|
valueInput.sendKeys(value);
|
||||||
|
qSeleniumLib.waitForSeconds(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
178
src/test/java/com/kingsrook/qqq/materialdashboard/tests/SavedFiltersTest.java
Executable file
178
src/test/java/com/kingsrook/qqq/materialdashboard/tests/SavedFiltersTest.java
Executable file
@ -0,0 +1,178 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2022. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.materialdashboard.tests;
|
||||||
|
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import com.kingsrook.qqq.materialdashboard.lib.QBaseSeleniumTest;
|
||||||
|
import com.kingsrook.qqq.materialdashboard.lib.javalin.CapturedContext;
|
||||||
|
import com.kingsrook.qqq.materialdashboard.lib.javalin.QSeleniumJavalin;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import static com.kingsrook.qqq.materialdashboard.tests.QueryScreenTest.addQueryFilterInput;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Test for Saved Filters functionality on the Query screen.
|
||||||
|
*******************************************************************************/
|
||||||
|
public class SavedFiltersTest extends QBaseSeleniumTest
|
||||||
|
{
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
protected void addJavalinRoutes(QSeleniumJavalin qSeleniumJavalin)
|
||||||
|
{
|
||||||
|
addStandardRoutesForThisTest(qSeleniumJavalin);
|
||||||
|
qSeleniumJavalin.withRouteToFile("/processes/querySavedFilter/init", "processes/querySavedFilter/init.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
private void addStandardRoutesForThisTest(QSeleniumJavalin qSeleniumJavalin)
|
||||||
|
{
|
||||||
|
super.addJavalinRoutes(qSeleniumJavalin);
|
||||||
|
qSeleniumJavalin.withRouteToFile("/data/person/count", "data/person/count.json");
|
||||||
|
qSeleniumJavalin.withRouteToFile("/data/person/query", "data/person/index.json");
|
||||||
|
qSeleniumJavalin.withRouteToFile("/data/person/*", "data/person/1701.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testNavigatingBackAndForth()
|
||||||
|
{
|
||||||
|
qSeleniumLib.gotoAndWaitForBreadcrumbHeader("/peopleApp/greetingsApp/person", "Person");
|
||||||
|
qSeleniumLib.waitForSelectorContaining("BUTTON", "Saved Filters").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("LI", "Some People");
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// need to only return id=2 next time //
|
||||||
|
////////////////////////////////////////
|
||||||
|
qSeleniumJavalin.stop();
|
||||||
|
qSeleniumJavalin.clearRoutes();
|
||||||
|
addStandardRoutesForThisTest(qSeleniumJavalin);
|
||||||
|
qSeleniumJavalin.withRouteToFile("/processes/querySavedFilter/init", "processes/querySavedFilter/init-id=2.json");
|
||||||
|
qSeleniumJavalin.restart();
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////
|
||||||
|
// go to a specific filter - assert that it's loaded //
|
||||||
|
///////////////////////////////////////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining("LI", "Some People").click();
|
||||||
|
qSeleniumLib.waitForCondition("Current URL should have filter id", () -> driver.getCurrentUrl().endsWith("/person/savedFilter/2"));
|
||||||
|
qSeleniumLib.waitForSelectorContaining("DIV", "Current Filter: Some People");
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// click into a view screen //
|
||||||
|
//////////////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining("DIV", "Jonny").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("H5", "Viewing Person: John Doe");
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
// take breadcrumb back to table query //
|
||||||
|
// assert the previously selected filter is loaded //
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining("A", "Person").click();
|
||||||
|
qSeleniumLib.waitForCondition("Current URL should have filter id", () -> driver.getCurrentUrl().endsWith("/person/savedFilter/2"));
|
||||||
|
qSeleniumLib.waitForSelectorContaining("DIV", "Current Filter: Some People");
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiBadge-badge", "1");
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
// modify the query //
|
||||||
|
//////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiDataGrid-toolbarContainer BUTTON", "Filters").click();
|
||||||
|
addQueryFilterInput(qSeleniumLib, 1, "First Name", "contains", "Jam", "Or");
|
||||||
|
qSeleniumLib.waitForSelectorContaining("H5", "Person").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("DIV", "Current Filter: Some People")
|
||||||
|
.findElement(By.cssSelector("CIRCLE"));
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiBadge-badge", "2");
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// click into a view screen //
|
||||||
|
//////////////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining("DIV", "Jonny").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("H5", "Viewing Person: John Doe");
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// take breadcrumb back to table query //
|
||||||
|
// assert the previously selected filter, with modification, is still loaded //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
qSeleniumJavalin.beginCapture();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("A", "Person").click();
|
||||||
|
qSeleniumLib.waitForCondition("Current URL should have filter id", () -> driver.getCurrentUrl().endsWith("/person/savedFilter/2"));
|
||||||
|
qSeleniumLib.waitForSelectorContaining("DIV", "Current Filter: Some People")
|
||||||
|
.findElement(By.cssSelector("CIRCLE"));
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiBadge-badge", "2");
|
||||||
|
CapturedContext capturedContext = qSeleniumJavalin.waitForCapturedPath("/data/person/query");
|
||||||
|
assertTrue(capturedContext.getBody().contains("Jam"));
|
||||||
|
qSeleniumJavalin.endCapture();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
// navigate to the table with a filter in the URL //
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
String filter = """
|
||||||
|
{
|
||||||
|
"criteria":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"fieldName": "id",
|
||||||
|
"operator": "LESS_THAN",
|
||||||
|
"values": [10]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
""".replace('\n', ' ').replaceAll(" ", "");
|
||||||
|
qSeleniumLib.gotoAndWaitForBreadcrumbHeader("/peopleApp/greetingsApp/person?filter=" + URLEncoder.encode(filter, StandardCharsets.UTF_8), "Person");
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiBadge-badge", "1");
|
||||||
|
qSeleniumLib.waitForSelectorContainingToNotExist("DIV", "Current Filter");
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// click into a view screen //
|
||||||
|
//////////////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining("DIV", "Jonny").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("H5", "Viewing Person: John Doe");
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// take breadcrumb back to table query //
|
||||||
|
// assert the filter previously given on the URL is what is loaded & requested //
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
qSeleniumJavalin.beginCapture();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("A", "Person").click();
|
||||||
|
qSeleniumLib.waitForCondition("Current URL should not have filter id", () -> !driver.getCurrentUrl().endsWith("/person/savedFilter/2"));
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiBadge-badge", "1");
|
||||||
|
capturedContext = qSeleniumJavalin.waitForCapturedPath("/data/person/query");
|
||||||
|
assertTrue(capturedContext.getBody().matches("(?s).*id.*LESS_THAN.*10.*"));
|
||||||
|
qSeleniumJavalin.endCapture();
|
||||||
|
|
||||||
|
qSeleniumLib.waitForever();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -102,10 +102,23 @@
|
|||||||
"label": "Sleep Interactive",
|
"label": "Sleep Interactive",
|
||||||
"isHidden": false
|
"isHidden": false
|
||||||
},
|
},
|
||||||
"simpleThrow": {
|
"querySavedFilter": {
|
||||||
"name": "simpleThrow",
|
"name": "querySavedFilter",
|
||||||
"label": "Simple Throw",
|
"label": "Query Saved Filter",
|
||||||
"isHidden": false
|
"isHidden": false,
|
||||||
|
"hasPermission": true
|
||||||
|
},
|
||||||
|
"storeSavedFilter": {
|
||||||
|
"name": "storeSavedFilter",
|
||||||
|
"label": "Store Saved Filter",
|
||||||
|
"isHidden": false,
|
||||||
|
"hasPermission": true
|
||||||
|
},
|
||||||
|
"deleteSavedFilter": {
|
||||||
|
"name": "deleteSavedFilter",
|
||||||
|
"label": "Delete Saved Filter",
|
||||||
|
"isHidden": false,
|
||||||
|
"hasPermission": true
|
||||||
},
|
},
|
||||||
"carrier.bulkInsert": {
|
"carrier.bulkInsert": {
|
||||||
"name": "carrier.bulkInsert",
|
"name": "carrier.bulkInsert",
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"values": {
|
||||||
|
"_qStepTimeoutMillis": "60000",
|
||||||
|
"savedFilterList": [
|
||||||
|
{
|
||||||
|
"tableName": "savedFilter",
|
||||||
|
"values": {
|
||||||
|
"label": "Some People",
|
||||||
|
"id": 2,
|
||||||
|
"createDate": "2023-02-20T18:40:58Z",
|
||||||
|
"modifyDate": "2023-02-20T18:40:58Z",
|
||||||
|
"tableName": "person",
|
||||||
|
"filterJson": "{\"criteria\":[{\"fieldName\":\"firstName\",\"operator\":\"STARTS_WITH\",\"values\":[\"D\"]}],\"orderBys\":[{\"fieldName\":\"id\",\"isAscending\":false}],\"booleanOperator\":\"AND\"}",
|
||||||
|
"userId": "darin.kelkhoff@kingsrook.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tableName": "person"
|
||||||
|
},
|
||||||
|
"processUUID": "4eaaea82-2d09-4254-90f8-e5b6948ef0b3"
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"values": {
|
||||||
|
"_qStepTimeoutMillis": "60000",
|
||||||
|
"savedFilterList": [
|
||||||
|
{
|
||||||
|
"tableName": "savedFilter",
|
||||||
|
"values": {
|
||||||
|
"label": "All People",
|
||||||
|
"id": 1,
|
||||||
|
"createDate": "2023-02-20T18:39:11Z",
|
||||||
|
"modifyDate": "2023-02-20T18:39:11Z",
|
||||||
|
"tableName": "person",
|
||||||
|
"filterJson": "{\"orderBys\":[{\"fieldName\":\"id\",\"isAscending\":false}],\"booleanOperator\":\"AND\"}",
|
||||||
|
"userId": "darin.kelkhoff@kingsrook.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "savedFilter",
|
||||||
|
"values": {
|
||||||
|
"label": "Some People",
|
||||||
|
"id": 2,
|
||||||
|
"createDate": "2023-02-20T18:40:58Z",
|
||||||
|
"modifyDate": "2023-02-20T18:40:58Z",
|
||||||
|
"tableName": "person",
|
||||||
|
"filterJson": "{\"criteria\":[{\"fieldName\":\"firstName\",\"operator\":\"STARTS_WITH\",\"values\":[\"D\"]}],\"orderBys\":[{\"fieldName\":\"id\",\"isAscending\":false}],\"booleanOperator\":\"AND\"}",
|
||||||
|
"userId": "darin.kelkhoff@kingsrook.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tableName": "person"
|
||||||
|
},
|
||||||
|
"processUUID": "4eaaea82-2d09-4254-90f8-e5b6948ef0b3"
|
||||||
|
}
|
Reference in New Issue
Block a user