Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix JBrowseTest #303

Merged
merged 5 commits into from
Nov 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private void testFilterWidget()
sleep(1000);

// NOTE: depending on the size of the view area, this can vary. This is more a factor of the environment that actual behavior
Assert.assertEquals("Incorrect number of variants", 85.0, getTotalVariantFeatures(), 1.0);
Assert.assertEquals("Incorrect number of variants", 87.0, getTotalVariantFeatures(), 1.0);

// bottom filter UI
waitForElement(Locator.tagContainingText("button", "mGAP: Showing sites where").containing("AF < 0.02"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
import org.labkey.test.WebDriverWrapper;
import org.labkey.test.categories.Base;
import org.labkey.test.components.ext4.Window;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.Ext4Helper;
Expand Down Expand Up @@ -166,19 +167,29 @@ public static void waitForJBrowseToLoad(BaseWebDriverTest test)

public static long getTotalVariantFeatures(BaseWebDriverTest test)
{
Locator l = Locator.tagWithAttribute("svg", "data-testid", "svgfeatures").append(Locator.tag("polygon"));
final Long winWidth = test.executeScript("return window.outerWidth", Long.class);
final Long winHeight = test.executeScript("return window.outerHeight", Long.class);
final Locator l = Locator.tagWithAttribute("svg", "data-testid", "svgfeatures").append(Locator.tag("polygon"));
try
{
// NOTE: JBrowse renders features using multiple blocks per track, and these tracks can redundantly render identical features on top of one another.
// Counting unique locations is indirect, but should result in unique features
return Locator.findElements(test.getDriver(), l).stream().filter(WebElement::isDisplayed).map(WebElement::getLocation).distinct().count();
return doVariantCount(test, l, winWidth, winHeight);
}
catch (StaleElementReferenceException e)
{
test.log("Stale elements, retrying");
WebDriverWrapper.sleep(5000);

return Locator.findElements(test.getDriver(), l).stream().filter(WebElement::isDisplayed).map(WebElement::getLocation).distinct().count();
return doVariantCount(test, l, winWidth, winHeight);
}
}

private static long doVariantCount(BaseWebDriverTest test, Locator l, long winWidth, long winHeight)
{
return Locator.findElements(test.getDriver(), l).stream().filter(WebElement::isDisplayed).map(WebElement::getRect).distinct().filter(
// This is designed to limit to just elements within the viewport:
rec -> rec.x > 0 & rec.x <= winWidth & rec.y > 0 & rec.y <= winHeight
).count();
}
}