Skip to content

Commit

Permalink
Merge branch 'develop' into fb_noEncodePart
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-danield committed Feb 12, 2025
2 parents 351b529 + 986ff6f commit 9762943
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 20 deletions.
38 changes: 35 additions & 3 deletions src/org/labkey/test/components/html/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import org.openqa.selenium.WebElement;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Table extends WebDriverComponent<Table.Elements>
{
Expand Down Expand Up @@ -62,7 +64,7 @@ protected Elements newElementCache()
return new Elements();
}

protected class Elements extends Component.ElementCache
protected class Elements extends Component<?>.ElementCache
{
List<WebElement> rows;

Expand All @@ -86,15 +88,15 @@ public int getRowCount()
*/
public List<String> getTableHeaderTexts()
{
List<WebElement> headerEls = Locator.xpath("//thead//th").findElements(this);
List<WebElement> headerEls = Locator.xpath("./thead/tr[1]/th").findElements(this);
List<String> columnHeaders = new ArrayList<>();
for(WebElement headerEl : headerEls){columnHeaders.add(headerEl.getText());}
return columnHeaders;
}

public int getTableHeaderIndex(String headerText)
{
List<WebElement> headerEls = Locator.xpath("//thead//th").findElements(this);
List<WebElement> headerEls = Locator.xpath("./thead/tr[1]/th").findElements(this);
int counter = 1;
for(WebElement headerEl : headerEls)
{
Expand All @@ -105,6 +107,36 @@ public int getTableHeaderIndex(String headerText)
throw new RuntimeException( headerText + " column not found");
}

/**
* Get table data as a list of maps. Each map represents a row.<br>
* Assumes a simple table with a single header row with no colspans and unique header labels
* @return table data
*/
public List<Map<String, String>> getTableData()
{
List<Map<String, String>> data = new ArrayList<>();

List<String> headerTexts = getTableHeaderTexts();
List<WebElement> rows = elementCache().getRows();

for (WebElement row : rows)
{
List<String> dataTexts = getWrapper().getTexts(Locator.tag("td").findElements(row));
if (headerTexts.size() != dataTexts.size())
{
throw new IllegalStateException("Size of row %s doesn't match table header %s".formatted(dataTexts, headerTexts));
}
Map<String, String> rowMap = new LinkedHashMap<>();
for (int i = 0; i < headerTexts.size(); i++)
{
rowMap.put(headerTexts.get(i), dataTexts.get(i));
}
data.add(rowMap);
}

return data;
}

public List<String> getTableHeaderColumnData(String headerText)
{
List<String> columnData = new ArrayList<>();
Expand Down
6 changes: 3 additions & 3 deletions src/org/labkey/test/pages/core/admin/ShowAdminPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.labkey.test.pages.LabKeyPage;
import org.labkey.test.pages.compliance.ComplianceSettingsAccountsPage;
import org.labkey.test.pages.core.login.LoginConfigurePage;
import org.labkey.test.util.OptionalFeatureHelper;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

Expand Down Expand Up @@ -133,8 +134,8 @@ public DomainDesignerPage clickChangeUserProperties()

public void clickDeprecatedFeatures()
{
goToSettingsSection();
clickAndWait(elementCache().deprecatedFeaturesLink);
throw new UnsupportedOperationException("Use %s to manage experimental/optional/deprecated features"
.formatted(OptionalFeatureHelper.class.getSimpleName()));
}

public void clickEmailCustomization()
Expand Down Expand Up @@ -267,7 +268,6 @@ protected class ElementCache extends LabKeyPage.ElementCache
protected WebElement configurePageElements = Locator.linkWithText("configure page elements").findWhenNeeded(this);
protected WebElement complianceSettings = Locator.linkWithText("Compliance Settings").findWhenNeeded(this);
protected WebElement changeUserPropertiesLink = Locator.linkWithText("change user properties").findWhenNeeded(this);
protected WebElement deprecatedFeaturesLink = Locator.linkWithText("deprecated features").findWhenNeeded(this);
protected WebElement emailCustomizationLink = Locator.linkWithText("email customization").findWhenNeeded(this);
protected WebElement notificationServiceAdminLink = Locator.linkWithText("notification service admin").findWhenNeeded(this);
protected WebElement filesLink = Locator.linkWithText("files").findWhenNeeded(this);
Expand Down
30 changes: 20 additions & 10 deletions src/org/labkey/test/tests/MessagesLongTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ public class MessagesLongTest extends BaseWebDriverTest
private static final String USER3 = "messageslong_user3@messages.test";
private static final String NOT_A_USER = "Squirrel";
private static final String RESPONDER = "responder@messages.test";
private static final String MACRO_WEBPART = "${labkey.webPart(partName='Lists')}";
private static final String HTML_BODY = "1 <b>x</b>\n" +
"<b>${labkey.webPart(partName='Lists')}</b>\n";
"<b>" +
MACRO_WEBPART +
"</b>\n";
private static final String HTML_BODY_WEBPART_TEST = "manage lists";
private static final String MEMBER_LIST = "memberListInput";
private static final String TEMPLATE_TEXT = "***Please do not reply to this email notification. Replies to this email are routed to an unmonitored mailbox. Instead, please use the link below.***";
Expand Down Expand Up @@ -224,22 +227,29 @@ public void testSteps()
InsertPage markdownPage = new InsertPage(getDriver());
assertEquals("default selection should be 'Markdown'",markdownPage.getRenderAs(), WikiHelper.WikiRendererType.MARKDOWN);
markdownPage.setTitle("Markdown is a thing now")
.setBody("# Holy Header, Batman!\n" +
"**bold as bold can possibly be**\n" +
"\n" +
"```var foo = bar.fooValue;```\n" +
"\n" +
"## List of things I don't like \n" +
"+ hair clogs\n" +
"+ stinky feet\n" +
"+ internet trolls");
.setBody("""
# Holy Header, Batman!
**bold as bold can possibly be**
```var foo = bar.fooValue;```
## List of things I don't like\s
+ hair clogs
+ stinky feet
+ internet trolls
<b>escaped</b>""" +
"\n" + MACRO_WEBPART);

// now look at the preview pane
markdownPage.selectPreviewTab();
waitForElement(Locator.tagWithText("h2", "List of things I don't like"), 2000);
assertElementPresent(Locator.tagWithText("li", "hair clogs"));
assertElementPresent(Locator.tagWithText("li", "stinky feet"));
assertElementPresent(Locator.tagWithText("li", "internet trolls"));
assertElementPresent(Locator.tagWithText("p", "<b>escaped</b>"));
assertElementPresent(PortalHelper.Locators.webPart("Lists"));
assertElementPresent(Locator.linkWithText("manage lists"));
clickButton("Submit");
assertElementPresent(Locator.tagWithText("h1", "Holy Header, Batman!"));
assertElementPresent(Locator.tagWithText("strong", "bold as bold can possibly be"));
Expand Down
5 changes: 5 additions & 0 deletions src/org/labkey/test/tests/NonStudyReportsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.labkey.test.categories.Reports;
import org.labkey.test.components.html.BootstrapMenu;
import org.labkey.test.util.LogMethod;
import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.RReportHelper;
import org.labkey.test.util.ext4cmp.Ext4FileFieldRef;
Expand Down Expand Up @@ -65,6 +66,7 @@ public class NonStudyReportsTest extends ReportTest
protected void doCleanup(boolean afterTest) throws TestTimeoutException
{
_userHelper.deleteUsers(false, ATTACHMENT_USER);
OptionalFeatureHelper.disableOptionalFeature(createDefaultConnection(), "deprecatedObjectLevelDiscussions");
super.doCleanup(afterTest);
}

Expand Down Expand Up @@ -258,6 +260,9 @@ private void doThumbnailChangeTest()
@LogMethod
private void doReportDiscussionTest()
{
// Issue 51620: Remove the UI for Object-level discussions
OptionalFeatureHelper.enableOptionalFeature(createDefaultConnection(), "deprecatedObjectLevelDiscussions");

clickProject(getProjectName());

goToManageViews();
Expand Down
12 changes: 10 additions & 2 deletions src/org/labkey/test/tests/announcements/DiscussionLinkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import org.junit.experimental.categories.Category;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestTimeoutException;
import org.labkey.test.categories.Daily;
import org.labkey.test.pages.core.admin.ProjectSettingsPage;
import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.WikiHelper;

Expand Down Expand Up @@ -50,8 +52,14 @@ private void doSetup()
_containerHelper.createProject(getProjectName());

// Issue 51620: Remove the UI for Object-level discussions
goToAdminConsole().clickDeprecatedFeatures();
click(Locator.inputById("deprecatedObjectLevelDiscussions"));
OptionalFeatureHelper.enableOptionalFeature(createDefaultConnection(), "deprecatedObjectLevelDiscussions");
}

@Override
protected void doCleanup(boolean afterTest) throws TestTimeoutException
{
OptionalFeatureHelper.disableOptionalFeature(createDefaultConnection(), "deprecatedObjectLevelDiscussions");
super.doCleanup(afterTest);
}

@Before
Expand Down
19 changes: 17 additions & 2 deletions src/org/labkey/test/tests/wiki/WikiLongTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
import org.labkey.test.categories.Wiki;
import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.WikiHelper;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -121,6 +123,10 @@ public class WikiLongTest extends BaseWebDriverTest
# Title MD
## Subtitle MD
*italic text MD*
<b>escaped</b>
${labkey.webPart(partName='Query', title='WebPart Macro', schemaName='core', queryName='containers', allowChooseQuery='true', allowChooseView='true')}
""";

private static final String SAFE_LINK_HTML = "<a href=\"http://labkey.com\">Safe link</a>";
Expand Down Expand Up @@ -157,6 +163,9 @@ protected String getProjectName()
@Test
public void testSteps()
{
// Issue 51620: Remove the UI for Object-level discussions
OptionalFeatureHelper.enableOptionalFeature(createDefaultConnection(), "deprecatedObjectLevelDiscussions");

enableEmailRecorder();
_containerHelper.createProject(PROJECT2_NAME, null);
_containerHelper.enableModule(PROJECT2_NAME, "MS2");
Expand Down Expand Up @@ -222,13 +231,18 @@ public void testSteps()
_wikiHelper.setWikiBody(WIKI_PAGE7_CONTENT);
_wikiHelper.saveWikiPage();
// verify that after saving the markdown that it is rendered as html that does not include the markdown symbols
assertTextPresent("Title MD");
assertElementPresent(Locator.tagWithText("h1", "Title MD"));
assertElementPresent(Locator.tagWithText("p", "<b>escaped</b>"));
assertElementPresent(PortalHelper.Locators.webPart("WebPart Macro"));
assertElementPresent(DataRegionTable.Locators.dataRegionTable().descendant(Locator.linkWithText(getProjectName())));
assertTextNotPresent("# Title MD");
clickAndWait(Locator.linkWithText("Edit"));
_wikiHelper.convertWikiFormat("HTML");
// verify that after converting the markdown to html that it is rendered as html that does not include the markdown symbols
_wikiHelper.saveWikiPage();
assertTextPresent("Title MD");
assertElementPresent(Locator.tagWithText("h1", "Title MD"));
assertElementPresent(Locator.tagWithText("p", "<b>escaped</b>"));
// Webpart macro
assertTextNotPresent("# Title MD");
searchFor(PROJECT_NAME, "italic text MD", 1, WIKI_PAGE7_TITLE);

Expand Down Expand Up @@ -777,6 +791,7 @@ protected void selectRenderType(String renderType)
@Override
protected void doCleanup(boolean afterTest) throws TestTimeoutException
{
OptionalFeatureHelper.disableOptionalFeature(createDefaultConnection(), "deprecatedObjectLevelDiscussions");
deleteUsersIfPresent(USER1);
_containerHelper.deleteProject(PROJECT2_NAME, afterTest);
_containerHelper.deleteProject(PROJECT_NAME, afterTest);
Expand Down

0 comments on commit 9762943

Please sign in to comment.