Skip to content

Commit

Permalink
Merge 24.11 to 25.2
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-teamcity committed Feb 11, 2025
2 parents c8db5b2 + f56e420 commit af91cbd
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 15 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
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
14 changes: 12 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,7 @@
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
import org.labkey.test.categories.Wiki;
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 +122,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 @@ -222,13 +227,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

0 comments on commit af91cbd

Please sign in to comment.