From f3dab7f7e931d3be1781e674eaeb318bbdeae592 Mon Sep 17 00:00:00 2001 From: Trey Chadick Date: Wed, 11 Nov 2026 10:10:54 -0800 Subject: [PATCH 1/2] GH Issue 1793: Fix LabModulesTest for Firefox 153 and the header product menu (#328) * Wait for the data sources panel to reload before reopening its menu or counting rows * Ignore the header product menu's placeholder when waiting for "Loading..." to disappear --- .../external/labModules/LabModulesTest.java | 49 ++++++++++++------- .../external/labModules/LabModuleHelper.java | 16 +++--- 2 files changed, 40 insertions(+), 25 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..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; @@ -857,37 +858,28 @@ 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(); //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")); - - 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); - 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")); - - 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 +979,27 @@ 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(() -> menuItem.findOptionalElement(getDriver()).filter(WebElement::isDisplayed).isPresent(), 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) + { + 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 @@ -1008,7 +1021,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() @@ -1790,7 +1803,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 cc87382ad5b5de3a2b478c11febd30063736ded8 Mon Sep 17 00:00:00 2001 From: Trey Chadick Date: Tue, 17 Nov 2026 15:38:15 -0800 Subject: [PATCH 2/2] GH Issue 1920: Fire one change from the date-time field with its full value (#329) - Editing the date or time fires one change from the date-time field, with the combined value and the previous value - Setting the value in code fires one change instead of one per box - The field's starting value is the parsed date, so the first change and a reset compare against the right value --- LDK/resources/web/LDK/ux/DateTimeField.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/LDK/resources/web/LDK/ux/DateTimeField.js b/LDK/resources/web/LDK/ux/DateTimeField.js index 9f713373..f8b25cd9 100644 --- a/LDK/resources/web/LDK/ux/DateTimeField.js +++ b/LDK/resources/web/LDK/ux/DateTimeField.js @@ -79,7 +79,6 @@ Ext4.define('Ext.ux.form.field.DateTime', { me.dateField = Ext4.create('Ext.form.field.Date', Ext4.apply({ format:me.dateFormat, - bubbleEvents: ['change'], flex:1, isFormField:false, //exclude from field query's submitValue:false, @@ -114,6 +113,8 @@ Ext4.define('Ext.ux.form.field.DateTime', { this.timeField.setValue(val); } } + + this.checkChange(); } }, getErrors: function(value){ @@ -132,7 +133,6 @@ Ext4.define('Ext.ux.form.field.DateTime', { me.timeField = Ext4.create('Ext.form.field.Time', Ext4.apply({ format:me.timeFormat, - bubbleEvents: ['change'], flex:1, isFormField:false, //exclude from field query's submitValue:false, @@ -153,6 +153,8 @@ Ext4.define('Ext.ux.form.field.DateTime', { if (date && !this.dateField.getValue()){ this.dateField.setValue(date); } + + this.checkChange(); } }, getErrors: function(value){ @@ -191,6 +193,8 @@ Ext4.define('Ext.ux.form.field.DateTime', { me.callParent(); me.initField(); + // Compare later changes against the parsed Date, not a configured string + me.originalValue = me.lastValue = me.getValue(); }, getDefaultDate: function(){ @@ -258,8 +262,11 @@ Ext4.define('Ext.ux.form.field.DateTime', { } } } - this.dateField.setValue(value); - this.timeField.setValue(value); + var me = this; + me.batchChanges(function(){ + me.dateField.setValue(value); + me.timeField.setValue(value); + }); }, getFormat: function(){