Skip to content

Commit d1daced

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_keyboardInteraction
2 parents e06a151 + 24376ac commit d1daced

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

src/org/labkey/test/tests/CustomizeViewTest.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import static org.hamcrest.MatcherAssert.assertThat;
4343
import static org.junit.Assert.assertEquals;
4444
import static org.junit.Assert.assertFalse;
45+
import static org.junit.Assert.assertNotEquals;
4546
import static org.junit.Assert.assertTrue;
4647
import static org.labkey.test.params.FieldDefinition.DOMAIN_TRICKY_CHARACTERS;
4748

@@ -323,6 +324,65 @@ public void saveFilterTest()
323324
assertTextPresentInThisOrder("Default", viewNames[0], viewNames[2], viewNames[1], viewNames[3], viewNames[4]);
324325
}
325326

327+
@Test
328+
public void testCustomViewsQueryTable()
329+
{
330+
final String viewName = "CustomViewsQueryTableTest";
331+
332+
// Navigate to the query.CustomViews table (requires folder admin permission)
333+
goToSchemaBrowser();
334+
viewQueryData("query", "CustomViews");
335+
DataRegionTable drt = new DataRegionTable("query", getDriver());
336+
337+
// Verify the default visible columns are present
338+
List<String> columnNames = drt.getColumnNames();
339+
assertThat("Schema column should be present", columnNames, hasItem("Schema"));
340+
assertThat("QueryName column should be present", columnNames, hasItem("QueryName"));
341+
assertThat("Name column should be present", columnNames, hasItem("Name"));
342+
assertThat("Hidden column should be present", columnNames, hasItem("Hidden"));
343+
assertThat("Inheritable column should be present", columnNames, hasItem("Inheritable"));
344+
345+
// Insert a new custom view via the table's insert URL (QueryController.InternalNewViewAction)
346+
drt.clickInsertNewRow();
347+
waitForElement(Locator.name("quf_Schema"));
348+
setFormElement(Locator.name("quf_Schema"), "lists");
349+
setFormElement(Locator.name("quf_QueryName"), LIST_NAME);
350+
setFormElement(Locator.name("quf_Name"), viewName);
351+
setFormElement(Locator.name("quf_Flags"), "0");
352+
clickButton("Submit");
353+
354+
drt = new DataRegionTable("query", getDriver());
355+
356+
// Verify the new view appears with correct metadata
357+
int rowIndex = drt.getRowIndex("Name", viewName);
358+
assertNotEquals("Inserted view should appear in the query.CustomViews table", -1, rowIndex);
359+
assertEquals("View should belong to the 'lists' schema", "lists", drt.getDataAsText(rowIndex, "Schema"));
360+
assertEquals("View query name should match list name", LIST_NAME, drt.getDataAsText(rowIndex, "QueryName"));
361+
assertEquals("New view should not be hidden", "false", drt.getDataAsText(rowIndex, "Hidden"));
362+
assertEquals("New view should not be inheritable", "false", drt.getDataAsText(rowIndex, "Inheritable"));
363+
364+
// Edit the row via the edit icon (QueryController.InternalSourceViewAction) and set the inherit flag
365+
drt.clickEditRow(rowIndex);
366+
waitForElement(Locator.name("quf_Flags"));
367+
setFormElement(Locator.name("quf_Flags"), "3");
368+
clickButton("Submit");
369+
370+
// Verify the Flags column now reflects the inherit flag
371+
drt = new DataRegionTable("query", getDriver());
372+
rowIndex = drt.getRowIndex("Name", viewName);
373+
assertNotEquals("Edited view should still appear in the query.CustomViews table", -1, rowIndex);
374+
assertEquals("New view should be hidden", "true", drt.getDataAsText(rowIndex, "Hidden"));
375+
assertEquals("New view should be inheritable", "true", drt.getDataAsText(rowIndex, "Inheritable"));
376+
377+
// Delete the row by selecting its checkbox and clicking Delete
378+
drt.checkCheckbox(rowIndex);
379+
drt.deleteSelectedRows();
380+
381+
// Verify the row is gone
382+
drt = new DataRegionTable("query", getDriver());
383+
assertEquals("Deleted view should no longer appear in the query.CustomViews table", -1, drt.getRowIndex("Name", viewName));
384+
}
385+
326386
private void createList() throws Exception
327387
{
328388
ListDefinition listDefinition = new IntListDefinition(LIST_NAME, LIST_KEY_COLUMN).setFields(LIST_COLUMNS);

0 commit comments

Comments
 (0)