From 7a70b6eccf150b9db2732475ff3e3aa954f1dbf4 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Wed, 25 Jun 2025 10:29:46 -0700 Subject: [PATCH] Issue 52485: App admins can't edit shorturls --- .../test/tests/core/admin/ShortUrlTest.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/org/labkey/test/tests/core/admin/ShortUrlTest.java b/src/org/labkey/test/tests/core/admin/ShortUrlTest.java index 8952bed624..bb85f7e2f5 100644 --- a/src/org/labkey/test/tests/core/admin/ShortUrlTest.java +++ b/src/org/labkey/test/tests/core/admin/ShortUrlTest.java @@ -7,6 +7,7 @@ import org.junit.experimental.categories.Category; import org.labkey.remoteapi.Connection; import org.labkey.test.BaseWebDriverTest; +import org.labkey.test.Locator; import org.labkey.test.WebTestHelper; import org.labkey.test.categories.Daily; import org.labkey.test.pages.admin.ShortUrlAdminPage; @@ -186,20 +187,36 @@ public void testShortUrlPermissions() adminPage.submitShortUrl(shortUrl_a, targetUrl2); // Issue #52485 "App admins can create and edit shorturls but can't view them" (but now they can!) - verifyShortUrlsInGrid(shortUrl_a, targetUrl2, shortUrl_b); + verifyShortUrlsInGrid(Map.of(shortUrl_a, targetUrl2, shortUrl_b, targetUrl2)); + + // Edit an existing row, setting it back to the original target + DataRegionTable table = new DataRegionTable("ShortURL", getDriver()); + table.setFilter("ShortURL", "Equals", shortUrl_a); + table.clickEditRow(0); + setFormElement(Locator.name("fullURL"), targetUrl1); + clickButton("Update"); + + // Issue #52485 "App admins can create and edit shorturls but can't view them" (but now they can!) + verifyShortUrlsInGrid(Map.of(shortUrl_a, targetUrl1, shortUrl_b, targetUrl2)); + + // Delete an existing row + table = new DataRegionTable("ShortURL", getDriver()); + table.setFilter("ShortURL", "Equals", shortUrl_a); + table.checkCheckbox(0); + table.deleteSelectedRows(); + assertTextNotPresent(targetUrl1); }); - verifyShortUrlsInGrid(shortUrl_a, targetUrl2, shortUrl_b); + // Double-verify the single entry to reuse the same validation method + verifyShortUrlsInGrid(Map.of(shortUrl_b, targetUrl2)); } - private void verifyShortUrlsInGrid(String shortUrl_a, String targetUrl2, String shortUrl_b) + /** Map of short URL to target URLs to expect */ + private void verifyShortUrlsInGrid(Map urlMap) { Assertions.assertThat(ShortUrlAdminPage.beginAt(this).getUrlsFromGrid()) .as("short URLs") - .containsAllEntriesOf(Map.of( - shortUrl_a, targetUrl2, - shortUrl_b, targetUrl2 - )); + .containsAllEntriesOf(urlMap); } private String nextUrlKey()