Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/org/labkey/test/BaseWebDriverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ protected void checkLeaks()
}
}
msSinceTestStart = System.currentTimeMillis() - previousLeakCheck;
beginAt("/admin/memTracker.view?gc=1&clearCaches=1", 120000);
beginAt(WebTestHelper.buildURL("admin", "memTracker", Map.of("gc", 1, "clearCaches", 1)), 120000);
if (!isTextPresent("In-Use Objects"))
throw new IllegalStateException("Asserts must be enabled to track memory leaks; add -ea to your server VM params and restart or add -DmemCheck=false to your test VM params.");
leakCount = getImageWithAltTextCount("expand/collapse");
Expand Down Expand Up @@ -1612,7 +1612,7 @@ protected void checkActionCoverage()
int rowCount, coveredActions, totalActions;
double actionCoveragePercent;
String actionCoveragePercentString;
beginAt("/admin/actions.view");
beginAt(WebTestHelper.buildURL("admin", "actions"));

rowCount = getTableRowCount(ACTION_SUMMARY_TABLE_NAME);
if (getTableCellText(Locator.id(ACTION_SUMMARY_TABLE_NAME), rowCount - 1, 0).equals("Total"))
Expand Down Expand Up @@ -1689,7 +1689,7 @@ public String getBaseURL()
protected void setSelectedFields(String containerPath, String schema, String query, String viewName, String[] fields)
{
pushLocation();
beginAt("/query" + containerPath + "/internalNewView.view");
beginAt(WebTestHelper.buildURL("query", containerPath, "internalNewView"));
setFormElement(Locator.name("ff_schemaName"), schema);
setFormElement(Locator.name("ff_queryName"), query);
if (viewName != null)
Expand Down
16 changes: 7 additions & 9 deletions src/org/labkey/test/LabKeySiteWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
import static org.junit.Assert.fail;
import static org.labkey.test.TestProperties.isDevModeEnabled;
import static org.labkey.test.WebTestHelper.buildURL;
import static org.labkey.test.WebTestHelper.getBaseURL;
import static org.labkey.test.WebTestHelper.getHttpClientBuilder;
import static org.labkey.test.WebTestHelper.getHttpResponse;
import static org.labkey.test.WebTestHelper.getRemoteApiConnection;
Expand Down Expand Up @@ -435,7 +434,6 @@ public void signInShouldFail(String email, String password, String... expectedMe
assertTrue(String.format("Wrong errors.\nExpected: ['%s']\nActual: '%s'", String.join("',\n'", expectedMessages), errorText), missingErrors.isEmpty());
}

@Deprecated // TODO: Call the variant that takes a userId instead
protected String setInitialPassword(String email)
{
return setInitialPassword(_userHelper.getUserId(email));
Expand Down Expand Up @@ -853,9 +851,9 @@ private void verifyInitialUserRedirects()
String initialText = "Welcome! We see that this is your first time logging in.";

// These requests should redirect to the initial user page
beginAt("/login/resetPassword.view");
beginAt(WebTestHelper.buildURL("login", "resetPassword"));
assertTextPresent(initialText);
beginAt("/admin/maintenance.view");
beginAt(WebTestHelper.buildURL("admin", "maintenance"));
assertTextPresent(initialText);
}

Expand All @@ -872,14 +870,14 @@ private void verifyRedirectBehavior(String upgradeText) throws IOException
{
// These requests should NOT redirect to the upgrade page

method = new HttpGet(getBaseURL() + "/login/resetPassword.view");
method = new HttpGet(WebTestHelper.buildURL("login", "resetPassword"));
response = client.execute(method, WebTestHelper.getBasicHttpContext());
status = response.getCode();
assertEquals("Unexpected response", HttpStatus.SC_OK, status);
assertFalse("Upgrade text found", WebTestHelper.getHttpResponseBody(response).contains(upgradeText));
EntityUtils.consume(response.getEntity());

method = new HttpGet(getBaseURL() + "/admin/maintenance.view");
method = new HttpGet(WebTestHelper.buildURL("admin", "maintenance"));
response = client.execute(method, WebTestHelper.getBasicHttpContext());
status = response.getCode();
assertEquals("Unexpected response", HttpStatus.SC_OK, status);
Expand Down Expand Up @@ -941,7 +939,7 @@ public boolean isRedirected(HttpRequest httpRequest, HttpResponse httpResponse,
loginParams.add(new BasicNameValuePair("password", PasswordUtil.getPassword()));

// Login to get CSRF token
HttpPost loginMethod = new HttpPost(getBaseURL() + "/login/loginApi.api");
HttpPost loginMethod = new HttpPost(WebTestHelper.buildURL("login", "loginApi.api"));
loginMethod.setEntity(new UrlEncodedFormEntity(loginParams));
HttpClientContext httpContext = WebTestHelper.getBasicHttpContext();
response = redirectClient.execute(loginMethod, httpContext);
Expand All @@ -953,7 +951,7 @@ public boolean isRedirected(HttpRequest httpRequest, HttpResponse httpResponse,
Optional<Cookie> csrfToken = httpContext.getCookieStore().getCookies().stream().filter(c -> c.getName().equals(Connection.X_LABKEY_CSRF)).findAny();
csrfToken.ifPresent(cookie -> logoutParams.add(new BasicNameValuePair(Connection.X_LABKEY_CSRF, cookie.getValue())));
// Logout to verify redirect
HttpPost logoutMethod = new HttpPost(getBaseURL() + "/login/logout.view");
HttpPost logoutMethod = new HttpPost(WebTestHelper.buildURL("login", "logout"));
logoutMethod.setEntity(new UrlEncodedFormEntity(logoutParams));
response = redirectClient.execute(logoutMethod, httpContext);
status = response.getCode();
Expand Down Expand Up @@ -1096,7 +1094,7 @@ public void disableMaintenance()
{
if ( isGuestModeTest() )
return;
beginAt("/admin/customizeSite.view");
beginAt(WebTestHelper.buildURL("admin", "customizeSite"));
click(Locator.radioButtonByNameAndValue("systemMaintenanceInterval", "never"));
clickButton("Save");
}
Expand Down
8 changes: 6 additions & 2 deletions src/org/labkey/test/WebDriverWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -188,6 +189,8 @@ public abstract class WebDriverWrapper implements WrapsDriver
private final Stack<String> _locationStack = new Stack<>();
private String _savedLocation = null;

private static final Set<String> _controllerFirstUrls = new HashSet<>();

static
{
// Eliminate noise from org.openqa.selenium.remote.ProtocolHandshake and org.openqa.selenium.interactions.Actions
Expand Down Expand Up @@ -1210,9 +1213,10 @@ public long beginAt(String url, int millis, boolean acceptAlerts)
{
try
{
if (new Crawler.ControllerActionId(relativeURL).isControllerFirstUrl())
if (new Crawler.ControllerActionId(relativeURL).isControllerFirstUrl() && !_controllerFirstUrls.contains(url))
{
RuntimeException ex = new RuntimeException("Controller first url found in URL: " + relativeURL);
_controllerFirstUrls.add(url);
RuntimeException ex = new RuntimeException("Controller-first url used: " + relativeURL);
if (TestProperties.isControllerFirstUrlFatal())
throw ex;
else
Expand Down
8 changes: 7 additions & 1 deletion src/org/labkey/test/pages/OlapTestJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import org.apache.commons.lang3.StringUtils;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.WebTestHelper;

import java.util.Map;

import static org.junit.Assert.assertEquals;

Expand All @@ -35,7 +38,10 @@ public OlapTestJson(BaseWebDriverTest test)

public void goToPage(String path, String configId, String schemaName, String cubeName)
{
_test.beginAt("/olap/" + path + "/testJson.view?configId=" + configId + "&schemaName=" + schemaName + "&cubeName=" + cubeName);
_test.beginAt(WebTestHelper.buildURL("olap", path, "testJson", Map.of(
"configId", configId,
"schemaName", schemaName,
"cubeName", cubeName)));
}

public void submitQueryAsJson(String query)
Expand Down
4 changes: 2 additions & 2 deletions src/org/labkey/test/pages/query/ExecuteQueryPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static PageFactory<ExecuteQueryPage> getPageFactory(String schemaName, St
{
return new RelativeUrl("query", "executeQuery")
.addParameters(Maps.of("schemaName", schemaName, "query.queryName", queryName))
.getPageFactory(wd -> new ExecuteQueryPage(wd));
.getPageFactory(ExecuteQueryPage::new);
}

public DataRegionTable getDataRegion()
Expand All @@ -58,7 +58,7 @@ protected ElementCache newElementCache()
return new ElementCache();
}

protected class ElementCache extends LabKeyPage.ElementCache
protected class ElementCache extends LabKeyPage<?>.ElementCache
{
DataRegionTable _dataRegionTable = new DataRegionTable.DataRegionFinder(getDriver()).withName("query").findWhenNeeded(this);
}
Expand Down
7 changes: 7 additions & 0 deletions src/org/labkey/test/pages/query/UpdateQueryRowPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ public static UpdateQueryRowPage beginAt(WebDriverWrapper webDriverWrapper, Stri
return new UpdateQueryRowPage(webDriverWrapper.getDriver());
}

public static UpdateQueryRowPage beginAtInsertRowPage(WebDriverWrapper webDriverWrapper, String containerPath, String schemaName, String queryName)
{
webDriverWrapper.beginAt(WebTestHelper.buildURL("query", containerPath, "insertQueryRow",
Map.of("schemaName", schemaName, "query.queryName", queryName)));
return new UpdateQueryRowPage(webDriverWrapper.getDriver());
}

public void update(Map<String, ?> fields)
{
setFields(fields);
Expand Down
5 changes: 3 additions & 2 deletions src/org/labkey/test/tests/AbstractQWPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.Locators;
import org.labkey.test.WebTestHelper;
import org.openqa.selenium.Alert;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
Expand All @@ -39,7 +40,7 @@ public abstract class AbstractQWPTest extends BaseWebDriverTest
protected void testQWPDemoPage()
{
log("Begin testing QWPDemo page");
beginAt("/simpletest/" + getProjectName() + "/QWPDemo.view");
beginAt(WebTestHelper.buildURL("simpletest", getProjectName(), "QWPDemo"));

log("Drop and reload QWPDemo test data");
clickButton("Drop schema and clear test data");
Expand All @@ -60,7 +61,7 @@ protected void testQWPDemoPage()
getTabSignalsPairs().stream().forEach(this::testQWPTab);

log("Drop QWPDemo test data");
beginAt("/simpletest/" + getProjectName() + "/QWPDemo.view");
beginAt(WebTestHelper.buildURL("simpletest", getProjectName(), "QWPDemo"));
clickButton("Drop schema and clear test data"); // drop domain, needed for clean up project
}

Expand Down
9 changes: 6 additions & 3 deletions src/org/labkey/test/tests/AuditLogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.pages.core.admin.logger.ManagerPage.LoggingLevel;
import org.labkey.test.pages.list.EditListDefinitionPage;
import org.labkey.test.pages.query.ExecuteQueryPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.FieldDefinition.ColumnType;
import org.labkey.test.util.ApiPermissionsHelper;
Expand Down Expand Up @@ -526,20 +527,22 @@ private void createList(String containerPath, String listName, @Nullable String

protected void verifyListAuditLogQueries(Visibility v)
{
beginAt("/query/" + getProjectName() + "/executeQuery.view?schemaName=auditLog&query.queryName=ListAuditEvent&query.containerFilterName=CurrentAndSubfolders");
ExecuteQueryPage.getPageFactory("auditLog", "ListAuditEvent")
.addParameter("query.containerFilterName", "CurrentAndSubfolders")
.navigate(this, getProjectName());
verifyAuditQueryEvent(this, "List", "Parent List", 1, canSeeParent(v));
verifyAuditQueryEvent(this, "List", "Child List", 1, canSeeChild(v));
}

protected void verifyAuditQueries(boolean canSeeAuditLog)
{
beginAt("/query/" + getProjectName() + "/executeQuery.view?schemaName=auditLog&query.queryName=ContainerAuditEvent");
ExecuteQueryPage.beginAt(this, getProjectName(), "auditLog", "ContainerAuditEvent");
if (canSeeAuditLog)
verifyAuditQueryEvent(this, COMMENT_COLUMN, AUDIT_TEST_PROJECT + " was created", 1);
else
assertTextPresent("No data to show.");

beginAt("/query/" + getProjectName() + "/executeQuery.view?schemaName=auditLog&query.queryName=GroupAuditEvent");
ExecuteQueryPage.beginAt(this, getProjectName(), "auditLog", "GroupAuditEvent");
if (canSeeAuditLog)
verifyAuditQueryEvent(this, COMMENT_COLUMN, "The user " + AUDIT_TEST_USER + " was assigned to the security role Editor.", 1);
else
Expand Down
4 changes: 3 additions & 1 deletion src/org/labkey/test/tests/BaseTermsOfUseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestTimeoutException;
import org.labkey.test.WebTestHelper;
import org.labkey.test.util.ApiPermissionsHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.WikiHelper;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public class BaseTermsOfUseTest extends BaseWebDriverTest
{
Expand Down Expand Up @@ -119,7 +121,7 @@ protected void createTermsOfUsePage(String projectName, String body)
else // site-wide terms of use page
{
message = "Create site-wide terms of use page";
beginAt("/wiki/page.view?name=_termsOfUse");
beginAt(WebTestHelper.buildURL("wiki", "page", Map.of("name", TERMS_OF_USE_NAME)));
}
if (isElementPresent(Locator.linkContainingText("add a new page")))
{
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/tests/BasicAdminTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestProperties;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Base;
import org.labkey.test.categories.DRT;
import org.labkey.test.categories.Daily;
Expand Down Expand Up @@ -108,7 +109,7 @@ public void testRedirects()
goToHome();
final String expectedTitle = getDriver().getTitle();

beginAt("/login/initialUser.view");
beginAt(WebTestHelper.buildURL("login", "initialUser"));
Assert.assertEquals("Initial user action did not redirect properly when logged in", expectedTitle, getDriver().getTitle());
}

Expand Down
9 changes: 5 additions & 4 deletions src/org/labkey/test/tests/ButtonCustomizationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
import org.labkey.test.TestTimeoutException;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.FieldDefinition.ColumnType;
Expand Down Expand Up @@ -107,9 +108,9 @@ public void testSteps()
.update(Map.of("name", "Seattle"));
new DataRegionFinder(getDriver()).find().clickInsertNewRow()
.update(Map.of("name", "Portland"));

// assert custom buttons can be added to the standard set:
beginAt("/query/" + PROJECT_NAME + "/schema.view?schemaName=lists");
beginAt(WebTestHelper.buildURL("query", PROJECT_NAME, "schema", Map.of("schemaName", "lists")));
selectQuery("lists", "Cities");
waitForText(10000, "edit metadata");
clickAndWait(Locator.linkWithText("edit metadata"));
Expand All @@ -131,7 +132,7 @@ public void testSteps()
assertElementPresent(Locator.tagWithAttribute("a", "data-original-title","Insert data"));

// assert custom buttons can REPLACE the standard set:
beginAt("/query/" + PROJECT_NAME + "/schema.view?schemaName=lists");
beginAt(WebTestHelper.buildURL("query", PROJECT_NAME, "schema", Map.of("schemaName", "lists")));
selectQuery("lists", "Cities");
waitForText(10000, "edit metadata");
clickAndWait(Locator.linkWithText("edit metadata"));
Expand Down Expand Up @@ -198,7 +199,7 @@ public void testSteps()

// wait for the button to enable:
waitForElement(Locator.lkButton(METADATA_GET_BUTTON), 10000);

// Verify that GET buttons to send form values as GET parameters:
clickButton(METADATA_GET_BUTTON);
assertElementPresent(Locator.id("params").containing(".select: 2"));
Expand Down
15 changes: 10 additions & 5 deletions src/org/labkey/test/tests/ContainerContextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
import org.labkey.test.categories.Data;
import org.labkey.test.pages.query.ExecuteQueryPage;
import org.labkey.test.pages.reports.ScriptReportPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.FieldKey;
Expand Down Expand Up @@ -212,7 +213,7 @@ public void testIssue15751() throws Exception
insertJobIntoSubFolder(SUB_FOLDER_B);

log("** Viewing pipeline status from project container. Sort by Description (report name) and include sub-folders");
beginAt("/" + getProjectName() + "/pipeline-status-showList.view?StatusFiles.sort=Description&StatusFiles.containerFilterName=CurrentAndSubfolders");
beginAt(WebTestHelper.buildURL("pipeline-status", getProjectName(), "showList", Map.of("StatusFiles.sort", "Description", "StatusFiles.containerFilterName", "CurrentAndSubfolders")));

log("** Checking URLs go to correct container...");
String href = getAttribute(Locator.tagWithText("a", "COMPLETE").index(0), "href");
Expand Down Expand Up @@ -336,7 +337,9 @@ public void testSimpleModuleTables() throws Exception

// Verify Issue 16243: Details URL creating URLs with null container unless the container column is actually added to current view
log("** Removing container column and rechecking lookup URLs...");
beginAt("/query/" + getProjectName() + "/executeQuery.view?schemaName=vehicle&query.queryName=EmissionTest&query.sort=RowId");
ExecuteQueryPage.getPageFactory("vehicle", "EmissionTest")
.addParameter("query.sort", "RowId")
.navigate(this, getProjectName());
_customizeViewsHelper.openCustomizeViewPanel();
_customizeViewsHelper.showHiddenItems();
_customizeViewsHelper.removeColumn("Container");
Expand Down Expand Up @@ -365,7 +368,7 @@ public void testSimpleModuleTables() throws Exception
overrideMetadata(getProjectName(), "vehicle", emissionTestQuery, customMetadata.apply(emissionTestQuery));
verifySimpleModuleTables(emissionTestQuery, "XXX.view", "XXX.view", max, workbookIds, emissionIds, parentRowIds, rowIdToWorkbookId, false, true, vehicleId);
removeMetadata(getProjectName(), "vehicle", emissionTestQuery);

log("** Create custom query with custom metadata over vehicle.emissiontest table WITH container");
String customQueryWithContainer =
"SELECT emissiontest.rowid,\n" +
Expand Down Expand Up @@ -504,9 +507,11 @@ private void verifySimpleModuleTables(
int vehicleId)
{
log("** Checking containers on lookup URLs for '" + queryName + "'");
beginAt("/query/" + getProjectName() + "/executeQuery.view?schemaName=vehicle&query.queryName=" + queryName + "&query.sort=RowId");
ExecuteQueryPage queryPage = ExecuteQueryPage.getPageFactory("vehicle", queryName)
.addParameter("query.sort", "RowId")
.navigate(this, getProjectName());

DataRegionTable dr = new DataRegionTable("query", this);
DataRegionTable dr = queryPage.getDataRegion();

for (int i = 0; i < max; i++)
{
Expand Down
Loading