Skip to content

Commit 6b7690d

Browse files
authored
Attempt to fix JBrowseTest (#303)
* Attempt to fix JBrowseTest
1 parent 3252d13 commit 6b7690d

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

jbrowse/test/src/org/labkey/test/tests/external/labModules/JBrowseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private void testFilterWidget()
286286
sleep(1000);
287287

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

291291
// bottom filter UI
292292
waitForElement(Locator.tagContainingText("button", "mGAP: Showing sites where").containing("AF < 0.02"));

jbrowse/test/src/org/labkey/test/tests/external/labModules/JBrowseTestHelper.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.labkey.test.Locator;
77
import org.labkey.test.TestFileUtils;
88
import org.labkey.test.WebDriverWrapper;
9+
import org.labkey.test.categories.Base;
910
import org.labkey.test.components.ext4.Window;
1011
import org.labkey.test.util.DataRegionTable;
1112
import org.labkey.test.util.Ext4Helper;
@@ -166,19 +167,29 @@ public static void waitForJBrowseToLoad(BaseWebDriverTest test)
166167

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

181-
return Locator.findElements(test.getDriver(), l).stream().filter(WebElement::isDisplayed).map(WebElement::getLocation).distinct().count();
184+
return doVariantCount(test, l, winWidth, winHeight);
182185
}
183186
}
187+
188+
private static long doVariantCount(BaseWebDriverTest test, Locator l, long winWidth, long winHeight)
189+
{
190+
return Locator.findElements(test.getDriver(), l).stream().filter(WebElement::isDisplayed).map(WebElement::getRect).distinct().filter(
191+
// This is designed to limit to just elements within the viewport:
192+
rec -> rec.x > 0 & rec.x <= winWidth & rec.y > 0 & rec.y <= winHeight
193+
).count();
194+
}
184195
}

0 commit comments

Comments
 (0)