From c692fa37b7bc1e7a50ff6ada0a94cc51dd33e97d Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Thu, 5 Nov 2026 12:02:51 -0800 Subject: [PATCH 1/5] GH Issue 1793: Wait for data sources panel to reload in LabModulesTest --- .../external/labModules/LabModulesTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java index 700304ce..e38e4228 100644 --- a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java +++ b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java @@ -868,15 +868,14 @@ private void dataSourcesTest() throws Exception waitAndClick(Ext4Helper.Locators.menuItem(DATA_SOURCE + " (\"/home\".core.Users)")); new Window.WindowFinder(getDriver()).withTitle("Success").waitFor(); click(Ext4Helper.Locators.ext4Button("OK")); + waitForRemoveBtnCount(manageDataSources, 1); addDataSourceBtn = _ext4Helper.queryOne("#" + manageDataSources + " button[text='Add Default Sources']", Ext4CmpRef.class); waitAndClick(Locator.id(addDataSourceBtn.getId())); waitAndClick(Ext4Helper.Locators.menuItem(GROUP_SOURCE + " (core.Groups)")); new Window.WindowFinder(getDriver()).withTitle("Success").waitFor(); click(Ext4Helper.Locators.ext4Button("OK")); - - waitForText("Item Type"); - assertEquals("Incorrect number of remove buttons", 2, getRemoveBtns(manageDataSources).size()); + waitForRemoveBtnCount(manageDataSources, 2); //add demographics source Ext4CmpRef addDemographicsSourceBtn = _ext4Helper.queryOne("#" + manageDemographicsSources + " button[text='Add Default Sources']", Ext4CmpRef.class); @@ -884,10 +883,8 @@ private void dataSourcesTest() throws Exception waitAndClick(Ext4Helper.Locators.menuItem(SUBJECT_LIST + " (laboratory.subjects)")); new Window.WindowFinder(getDriver()).withTitle("Success").waitFor(); click(Ext4Helper.Locators.ext4Button("OK")); - - waitForText("Table Name"); + waitForRemoveBtnCount(manageDemographicsSources, 1); waitForText("New Data Sources"); - assertEquals("Incorrect number of remove buttons", 1, getRemoveBtns(manageDemographicsSources).size()); //query to make sure columns added: Connection cn = WebTestHelper.getRemoteApiConnection(); @@ -987,6 +984,15 @@ private List getRemoveBtns(String parentItemId) return _ext4Helper.componentQuery("#" + parentItemId + " button[text='Remove']", Ext4CmpRef.class); } + // Saving a source reloads the panel asynchronously, which also rebuilds its 'Add Default Sources' menu + private void waitForRemoveBtnCount(String parentItemId, int expectedCount) + { + waitForEquals("Incorrect number of remove buttons", () -> expectedCount, () -> { + List btns = getRemoveBtns(parentItemId); + return btns == null ? 0 : btns.size(); + }, WAIT_FOR_JAVASCRIPT); + } + private String replaceNonVisibleChars(String value) { //the DB might not store unicode chars correctly, so we just eliminate them here From 3803118334e3205e42169620026b484171bb4690 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Thu, 5 Nov 2026 12:26:22 -0800 Subject: [PATCH 2/5] Ignore header product menu placeholder when waiting for Loading... in LabModulesTest --- .../external/labModules/LabModulesTest.java | 4 ++-- .../external/labModules/LabModuleHelper.java | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java index e38e4228..b63bef92 100644 --- a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java +++ b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java @@ -857,7 +857,7 @@ private void dataSourcesTest() throws Exception waitAndClickAndWait(_helper.toolIcon("Settings")); waitAndClickAndWait(Locator.linkContainingText("Manage Data and Demographics Sources")); waitForText("Below are the extra data and sample sources registered for this folder"); //proxy for data loading - waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), WAIT_FOR_JAVASCRIPT); + waitForElementToDisappear(LabModuleHelper.LOADING, WAIT_FOR_JAVASCRIPT); //precaution mainly important to resuming a test in the middle cleanupDataSources(); @@ -1796,7 +1796,7 @@ private void searchPanelTest() { _helper.goToLabHome(); _helper.clickNavPanelItem("DNA_Oligos:", "Search"); - waitForTextToDisappear("Loading..."); + waitForElementToDisappear(LabModuleHelper.LOADING); waitForElement(Locator.name("name")); sleep(50); _helper.setFormField("name", "TestPrimer"); diff --git a/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java b/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java index 5615ca1b..6d968506 100644 --- a/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java +++ b/LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java @@ -48,6 +48,8 @@ public class LabModuleHelper public static final String IMPORT_DATA_TEXT = "Import Data"; public static final String UPLOAD_RESULTS_TEXT = "Upload Results"; public static final String LAB_HOME_TEXT = "Types of Data:"; + // The header product menu's collapsed dropdown always holds a "Loading..." placeholder + public static final Locator.XPathLocator LOADING = Locator.xpath("//div[contains(text(), 'Loading...')][not(ancestor::*[@id='headerProductDropdown'])]"); public static final String POS_COLOR = "rgb(255, 192, 203)"; public static final String UNKNOWN_COLOR = "rgb(0, 0, 255)"; @@ -324,7 +326,7 @@ public void addDataSource(String type, String label, String reportCategory, Stri _test.waitAndClick(Locator.id(addBtn.getId())); _test.waitForElement(Ext4Helper.Locators.window("Add Data Source")); - _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); + _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); waitForField("Item Type"); Ext4FieldRef.getForLabel(_test, "Item Type").setValue(type); Ext4FieldRef.getForLabel(_test, "Label").setValue(label); @@ -333,13 +335,13 @@ public void addDataSource(String type, String label, String reportCategory, Stri { Ext4ComboRef combo = new Ext4ComboRef(Ext4FieldRef.getForLabel(_test, "Container (optional)"), _test); combo.setComboByDisplayValue(containerPath); - _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); + _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); } Ext4FieldRef schemaField = Ext4FieldRef.getForLabel(_test, "Schema"); schemaField.waitForEnabled(); schemaField.setValue(schema); - _test.waitForElementToDisappear(Locator.tagWithText("div", "Loading..."), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT * 3); + _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT * 3); Ext4FieldRef queryField = Ext4FieldRef.getForLabel(_test, "Query"); queryField.waitForEnabled(); @@ -361,7 +363,7 @@ public void addDemographicsSource(String label, String containerPath, String sch _test.waitAndClick(Locator.id(addBtn.getId())); _test.waitForElement(Ext4Helper.Locators.window("Add Demographics Source")); - _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); + _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); waitForField("Label"); Ext4FieldRef.getForLabel(_test, "Label").setValue(label); @@ -369,14 +371,14 @@ public void addDemographicsSource(String label, String containerPath, String sch { Ext4ComboRef combo = new Ext4ComboRef(Ext4FieldRef.getForLabel(_test, "Container (optional)"), _test); combo.setComboByDisplayValue(containerPath); - _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); + _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); } Ext4FieldRef.getForLabel(_test, "Schema").setValue(schema); - _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT * 3); + _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT * 3); Ext4FieldRef.getForLabel(_test, "Query").setValue(query); - _test.waitForElementToDisappear(Locator.xpath("//div[contains(text(), 'Loading...')]"), BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); + _test.waitForElementToDisappear(LOADING, BaseWebDriverTest.WAIT_FOR_JAVASCRIPT); if (targetColumn != null) Ext4FieldRef.getForLabel(_test, "Target Column").setValue(targetColumn); From 46b0c107f6557d5ed0b450a9cdf20b0b10ddf13d Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Thu, 5 Nov 2026 17:01:07 -0800 Subject: [PATCH 3/5] Ignore header product menu placeholder when deleting a data source in LabModulesTest --- .../labkey/test/tests/external/labModules/LabModulesTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java index b63bef92..973573bc 100644 --- a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java +++ b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java @@ -1014,7 +1014,7 @@ private void deleteSourceByLabel(String label, String parentItemId) click(Ext4Helper.Locators.ext4Button("OK")); waitForText("Loading..."); - waitForElementToDisappear(Locator.xpath("//div[" + Locator.NOT_HIDDEN + " and contains(text(), 'Loading...')]"), WAIT_FOR_JAVASCRIPT); + waitForElementToDisappear(LabModuleHelper.LOADING.notHidden(), WAIT_FOR_JAVASCRIPT); } private void settingsTest() From 234078eaf1062dc9b84e6b28b870d805b02b0749 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Mon, 9 Nov 2026 18:47:30 -0800 Subject: [PATCH 4/5] Retry opening the default sources menu in LabModulesTest --- .../external/labModules/LabModulesTest.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java index 973573bc..3960d508 100644 --- a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java +++ b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java @@ -863,24 +863,18 @@ private void dataSourcesTest() throws Exception cleanupDataSources(); //add data source - Ext4CmpRef addDataSourceBtn = _ext4Helper.queryOne("#" + manageDataSources + " button[text='Add Default Sources']", Ext4CmpRef.class); - waitAndClick(Locator.id(addDataSourceBtn.getId())); - waitAndClick(Ext4Helper.Locators.menuItem(DATA_SOURCE + " (\"/home\".core.Users)")); + selectDefaultSource(manageDataSources, DATA_SOURCE + " (\"/home\".core.Users)"); new Window.WindowFinder(getDriver()).withTitle("Success").waitFor(); click(Ext4Helper.Locators.ext4Button("OK")); waitForRemoveBtnCount(manageDataSources, 1); - addDataSourceBtn = _ext4Helper.queryOne("#" + manageDataSources + " button[text='Add Default Sources']", Ext4CmpRef.class); - waitAndClick(Locator.id(addDataSourceBtn.getId())); - waitAndClick(Ext4Helper.Locators.menuItem(GROUP_SOURCE + " (core.Groups)")); + selectDefaultSource(manageDataSources, GROUP_SOURCE + " (core.Groups)"); new Window.WindowFinder(getDriver()).withTitle("Success").waitFor(); click(Ext4Helper.Locators.ext4Button("OK")); waitForRemoveBtnCount(manageDataSources, 2); //add demographics source - Ext4CmpRef addDemographicsSourceBtn = _ext4Helper.queryOne("#" + manageDemographicsSources + " button[text='Add Default Sources']", Ext4CmpRef.class); - waitAndClick(Locator.id(addDemographicsSourceBtn.getId())); - waitAndClick(Ext4Helper.Locators.menuItem(SUBJECT_LIST + " (laboratory.subjects)")); + selectDefaultSource(manageDemographicsSources, SUBJECT_LIST + " (laboratory.subjects)"); new Window.WindowFinder(getDriver()).withTitle("Success").waitFor(); click(Ext4Helper.Locators.ext4Button("OK")); waitForRemoveBtnCount(manageDemographicsSources, 1); @@ -984,6 +978,18 @@ private List getRemoveBtns(String parentItemId) return _ext4Helper.componentQuery("#" + parentItemId + " button[text='Remove']", Ext4CmpRef.class); } + private void selectDefaultSource(String panelItemId, String sourceText) + { + Locator menuItem = Ext4Helper.Locators.menuItem(sourceText); + // A click on the menu button can be lost while the panel finishes reloading after the previous save + waitFor(() -> { + Ext4CmpRef addSourceBtn = _ext4Helper.queryOne("#" + panelItemId + " button[text='Add Default Sources']", Ext4CmpRef.class); + click(Locator.id(addSourceBtn.getId())); + return waitFor(() -> isElementVisible(menuItem), 2_000); + }, "'Add Default Sources' menu did not show " + sourceText, WAIT_FOR_JAVASCRIPT); + click(menuItem); + } + // Saving a source reloads the panel asynchronously, which also rebuilds its 'Add Default Sources' menu private void waitForRemoveBtnCount(String parentItemId, int expectedCount) { From 1c8bc6b9c2490e94b8c61dcb8e3cfdc666ec963f Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 10 Nov 2026 13:28:52 -0800 Subject: [PATCH 5/5] Keep retrying the default sources menu until the item appears in LabModulesTest --- .../labkey/test/tests/external/labModules/LabModulesTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java index 3960d508..a2d44efd 100644 --- a/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java +++ b/LDK/test/src/org/labkey/test/tests/external/labModules/LabModulesTest.java @@ -52,6 +52,7 @@ import org.labkey.test.util.ext4cmp.Ext4ComboRef; import org.labkey.test.util.ext4cmp.Ext4FieldRef; import org.labkey.test.util.external.labModules.LabModuleHelper; +import org.openqa.selenium.WebElement; import java.io.File; import java.io.UnsupportedEncodingException; @@ -985,7 +986,7 @@ private void selectDefaultSource(String panelItemId, String sourceText) waitFor(() -> { Ext4CmpRef addSourceBtn = _ext4Helper.queryOne("#" + panelItemId + " button[text='Add Default Sources']", Ext4CmpRef.class); click(Locator.id(addSourceBtn.getId())); - return waitFor(() -> isElementVisible(menuItem), 2_000); + return waitFor(() -> menuItem.findOptionalElement(getDriver()).filter(WebElement::isDisplayed).isPresent(), 2_000); }, "'Add Default Sources' menu did not show " + sourceText, WAIT_FOR_JAVASCRIPT); click(menuItem); }