From 5a1a2dde9901fe9d249d610e25923cd472588dcc Mon Sep 17 00:00:00 2001 From: Lum Date: Thu, 30 Apr 2026 15:51:49 -0700 Subject: [PATCH 1/2] Selenium test for custom views query. --- .../labkey/test/tests/CustomizeViewTest.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/org/labkey/test/tests/CustomizeViewTest.java b/src/org/labkey/test/tests/CustomizeViewTest.java index fb4384de1d..1b5ed0cd61 100644 --- a/src/org/labkey/test/tests/CustomizeViewTest.java +++ b/src/org/labkey/test/tests/CustomizeViewTest.java @@ -42,6 +42,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.labkey.test.params.FieldDefinition.DOMAIN_TRICKY_CHARACTERS; @@ -319,6 +320,66 @@ public void saveFilterTest() assertTextPresentInThisOrder("Default", viewNames[0], viewNames[2], viewNames[1], viewNames[3], viewNames[4]); } + @Test + public void testCustomViewsQueryTable() + { + final String viewName = "CustomViewsQueryTableTest"; + + // Navigate to the query.CustomViews table (requires folder admin permission) + goToSchemaBrowser(); + viewQueryData("query", "CustomViews"); + DataRegionTable drt = new DataRegionTable("query", getDriver()); + + // Verify the default visible columns are present + List columnNames = drt.getColumnNames(); + assertThat("Schema column should be present", columnNames, hasItem("Schema")); + assertThat("QueryName column should be present", columnNames, hasItem("QueryName")); + assertThat("Name column should be present", columnNames, hasItem("Name")); + assertThat("Flags column should be present", columnNames, hasItem("Flags")); + + // Insert a new custom view via the table's insert URL (QueryController.InternalNewViewAction) + drt.clickInsertNewRow(); + waitForElement(Locator.name("ff_schemaName")); + setFormElement(Locator.name("ff_schemaName"), "lists"); + setFormElement(Locator.name("ff_queryName"), LIST_NAME); + setFormElement(Locator.name("ff_viewName"), viewName); + checkCheckbox(Locator.name("ff_share")); + clickButton("Create"); + + // Create redirects to InternalSourceViewAction; click Cancel to return to the CustomViews table + waitForElement(Locator.lkButton("Cancel")); + clickButton("Cancel"); + + drt = new DataRegionTable("query", getDriver()); + + // Verify the new view appears with correct metadata + int rowIndex = drt.getRowIndex("Name", viewName); + assertNotEquals("Inserted view should appear in the query.CustomViews table", -1, rowIndex); + assertEquals("View should belong to the 'lists' schema", "lists", drt.getDataAsText(rowIndex, "Schema")); + assertEquals("View query name should match list name", LIST_NAME, drt.getDataAsText(rowIndex, "QueryName")); + assertEquals("New view should have no flags set", "", drt.getDataAsText(rowIndex, "Flags")); + + // Edit the row via the edit icon (QueryController.InternalSourceViewAction) and set the inherit flag + drt.clickEditRow(rowIndex); + waitForElement(Locator.id("ff_inherit")); + checkCheckbox(Locator.id("ff_inherit")); + clickButton("Save"); + + // Verify the Flags column now reflects the inherit flag + drt = new DataRegionTable("query", getDriver()); + rowIndex = drt.getRowIndex("Name", viewName); + assertNotEquals("Edited view should still appear in the query.CustomViews table", -1, rowIndex); + assertEquals("Flags should show 'inherit' after editing", "inherit", drt.getDataAsText(rowIndex, "Flags")); + + // Delete the row by selecting its checkbox and clicking Delete + drt.checkCheckbox(rowIndex); + drt.deleteSelectedRows(); + + // Verify the row is gone + drt = new DataRegionTable("query", getDriver()); + assertEquals("Deleted view should no longer appear in the query.CustomViews table", -1, drt.getRowIndex("Name", viewName)); + } + private void createList() throws Exception { ListDefinition listDefinition = new IntListDefinition(LIST_NAME, LIST_KEY_COLUMN).setFields(LIST_COLUMNS); From 3e425b358d25af047c59a09dafadad48d6654e54 Mon Sep 17 00:00:00 2001 From: lum Date: Fri, 1 May 2026 16:10:00 -0700 Subject: [PATCH 2/2] split flags field, replace legacy forms, use QUS for CRUD --- .../labkey/test/tests/CustomizeViewTest.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/org/labkey/test/tests/CustomizeViewTest.java b/src/org/labkey/test/tests/CustomizeViewTest.java index 1b5ed0cd61..95a1d1337d 100644 --- a/src/org/labkey/test/tests/CustomizeViewTest.java +++ b/src/org/labkey/test/tests/CustomizeViewTest.java @@ -335,20 +335,17 @@ public void testCustomViewsQueryTable() assertThat("Schema column should be present", columnNames, hasItem("Schema")); assertThat("QueryName column should be present", columnNames, hasItem("QueryName")); assertThat("Name column should be present", columnNames, hasItem("Name")); - assertThat("Flags column should be present", columnNames, hasItem("Flags")); + assertThat("Hidden column should be present", columnNames, hasItem("Hidden")); + assertThat("Inheritable column should be present", columnNames, hasItem("Inheritable")); // Insert a new custom view via the table's insert URL (QueryController.InternalNewViewAction) drt.clickInsertNewRow(); - waitForElement(Locator.name("ff_schemaName")); - setFormElement(Locator.name("ff_schemaName"), "lists"); - setFormElement(Locator.name("ff_queryName"), LIST_NAME); - setFormElement(Locator.name("ff_viewName"), viewName); - checkCheckbox(Locator.name("ff_share")); - clickButton("Create"); - - // Create redirects to InternalSourceViewAction; click Cancel to return to the CustomViews table - waitForElement(Locator.lkButton("Cancel")); - clickButton("Cancel"); + waitForElement(Locator.name("quf_Schema")); + setFormElement(Locator.name("quf_Schema"), "lists"); + setFormElement(Locator.name("quf_QueryName"), LIST_NAME); + setFormElement(Locator.name("quf_Name"), viewName); + setFormElement(Locator.name("quf_Flags"), "0"); + clickButton("Submit"); drt = new DataRegionTable("query", getDriver()); @@ -357,19 +354,21 @@ public void testCustomViewsQueryTable() assertNotEquals("Inserted view should appear in the query.CustomViews table", -1, rowIndex); assertEquals("View should belong to the 'lists' schema", "lists", drt.getDataAsText(rowIndex, "Schema")); assertEquals("View query name should match list name", LIST_NAME, drt.getDataAsText(rowIndex, "QueryName")); - assertEquals("New view should have no flags set", "", drt.getDataAsText(rowIndex, "Flags")); + assertEquals("New view should not be hidden", "false", drt.getDataAsText(rowIndex, "Hidden")); + assertEquals("New view should not be inheritable", "false", drt.getDataAsText(rowIndex, "Inheritable")); // Edit the row via the edit icon (QueryController.InternalSourceViewAction) and set the inherit flag drt.clickEditRow(rowIndex); - waitForElement(Locator.id("ff_inherit")); - checkCheckbox(Locator.id("ff_inherit")); - clickButton("Save"); + waitForElement(Locator.name("quf_Flags")); + setFormElement(Locator.name("quf_Flags"), "3"); + clickButton("Submit"); // Verify the Flags column now reflects the inherit flag drt = new DataRegionTable("query", getDriver()); rowIndex = drt.getRowIndex("Name", viewName); assertNotEquals("Edited view should still appear in the query.CustomViews table", -1, rowIndex); - assertEquals("Flags should show 'inherit' after editing", "inherit", drt.getDataAsText(rowIndex, "Flags")); + assertEquals("New view should be hidden", "true", drt.getDataAsText(rowIndex, "Hidden")); + assertEquals("New view should be inheritable", "true", drt.getDataAsText(rowIndex, "Inheritable")); // Delete the row by selecting its checkbox and clicking Delete drt.checkCheckbox(rowIndex);