Skip to content

Commit cfd4cce

Browse files
Merge branch 'develop' into fb_pipelineFileLike
2 parents 7e8605f + a3751a7 commit cfd4cce

6 files changed

Lines changed: 81 additions & 24 deletions

File tree

src/org/labkey/test/pages/core/admin/CustomizeSitePage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static CustomizeSitePage beginAt(WebDriverWrapper driver)
4747

4848
public ShowAdminPage save()
4949
{
50-
clickAndWait(elementCache().saveButton);
50+
clickAndWait(scrollIntoView(elementCache().saveButton));
5151

5252
return new ShowAdminPage(getDriver());
5353
}
@@ -217,7 +217,7 @@ protected ElementCache newElementCache()
217217
return new ElementCache();
218218
}
219219

220-
protected class ElementCache extends LabKeyPage.ElementCache
220+
protected class ElementCache extends LabKeyPage<?>.ElementCache
221221
{
222222
protected final WebElement saveButton = Locator.lkButton("Save").findWhenNeeded(this);
223223

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,15 @@ public final void testAssayInlineImages() throws Exception
182182
customizeView.addColumn(FieldKey.fromParts("Run", "RowId"));
183183
customizeView.addColumn(FieldKey.fromParts("Run", "Protocol", "RowId"));
184184
customizeView.applyCustomView();
185-
String helpJpgFilePath = HELP_JPG_FILE.getName();
185+
var protocolId = list.getDataAsText(0, "Run/Protocol/RowId");
186+
var runId = list.getDataAsText(0, "Run/RowId");
187+
String helpJpgFilePath = String.format("AssayId_%s%sRunId_%s%s%s", protocolId, File.separatorChar,
188+
runId, File.separatorChar, HELP_JPG_FILE.getName());
186189

187190
log("Validate that two links to this image file are now present.");
188191
assertElementPresent("Did not find the expected number of icons for images for " + PNG01_FILE.getName() + " from the runs.", Locator.xpath("//img[contains(@title, '" + PNG01_FILE.getName() + "')]"), 3);
189192
assertElementPresent("Did not find the expected number of icons for images for " + LRG_PNG_FILE.getName() + " from the runs.", Locator.xpath("//img[contains(@title, '" + LRG_PNG_FILE.getName() + "')]"), 1);
190-
assertElementPresent("Did not find the expected number of icons for images for " + helpJpgFilePath + " from the runs.", Locator.xpath("//img[contains(@title, '" + helpJpgFilePath + "')]"), 1);
193+
assertElementPresent("Did not find the expected number of icons for images for " + HELP_JPG_FILE.getName() + " from the runs.", Locator.xpath("//img[contains(@title, '" + HELP_JPG_FILE.getName() + "')]"), 1);
191194

192195
log("Export the grid to excel.");
193196
File exportedFile;
@@ -203,7 +206,7 @@ public final void testAssayInlineImages() throws Exception
203206

204207
log("Validate that the 'File' (last) column is as expected.");
205208
assertEquals("Values in 'File' column not exported as expected [" + exportedFile.getName() + "]",
206-
Arrays.asList("Batch File Field", XLS_FILE.getName(), XLS_FILE.getName(), XLS_FILE.getName()),
209+
Arrays.asList("Batch File Field", "assaydata" + File.separator + XLS_FILE.getName(), "assaydata" + File.separator + XLS_FILE.getName(), "assaydata" + File.separator + XLS_FILE.getName()),
207210
ExcelHelper.getColumnData(workbook.getSheetAt(workbook.getActiveSheetIndex()), 7));
208211
}
209212

@@ -221,7 +224,7 @@ public final void testAssayInlineImages() throws Exception
221224
log("Verify that the other 'File' fields are not affected.");
222225
assertElementPresent("Did not find the expected number of icons for images for " + PNG01_FILE.getName() + " from the runs.", Locator.xpath("//img[contains(@title, '" + PNG01_FILE.getName() + "')]"), 3);
223226
assertElementPresent("Did not find the expected number of icons for images for " + LRG_PNG_FILE.getName() + " from the runs.", Locator.xpath("//img[contains(@title, '" + LRG_PNG_FILE.getName() + "')]"), 1);
224-
assertElementPresent("Did not find the expected number of icons for images for " + helpJpgFilePath + " from the runs.", Locator.xpath("//img[contains(@title, '" + helpJpgFilePath + "')]"), 1);
227+
assertElementPresent("Did not find the expected number of icons for images for " + HELP_JPG_FILE.getName() + " from the runs.", Locator.xpath("//img[contains(@title, '" + HELP_JPG_FILE.getName() + "')]"), 1);
225228

226229

227230
log("Export the grid to excel again and make sure that everything is as expected.");
@@ -283,7 +286,7 @@ private void validateExcelExport(File exportedFile, Workbook workbook, String he
283286

284287
exportedColumn = ExcelHelper.getColumnData(sheet, 5);
285288
assertEquals("Values in 'File' column not exported as expected [" + exportedFile.getName() + "]",
286-
Arrays.asList("Run File Field", PNG01_FILE.getName(), PNG01_FILE.getName(), PNG01_FILE.getName()),
289+
Arrays.asList("Run File Field", "assaydata" + File.separator + PNG01_FILE.getName(), "assaydata" + File.separator + PNG01_FILE.getName(), "assaydata" + File.separator + PNG01_FILE.getName()),
287290
exportedColumn);
288291

289292
}

src/org/labkey/test/tests/flow/FlowSpecimenTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Map;
3333

3434
import static org.junit.Assert.assertEquals;
35+
import static org.junit.Assert.assertFalse;
3536
import static org.junit.Assert.assertTrue;
3637

3738
/**
@@ -227,7 +228,8 @@ private void linkFlowResultsToStudy()
227228
beginAt(WebTestHelper.buildURL("flow", getContainerPath(), "query", Map.of("schemaName", "flow", "query.queryName", "FCSAnalyses")));
228229
click(Locator.checkboxByName(".toggle"));
229230
clickButton("Link to Study");
230-
selectOptionByText(AssayConstants.TARGET_STUDY_FIELD_LOCATOR, "/" + getProjectName() + "/" + STUDY_FOLDER + " (" + STUDY_FOLDER + " Study)");
231+
// Target study is fixed
232+
assertFalse("Target study selector visibility", AssayConstants.TARGET_STUDY_FIELD_LOCATOR.findElement(getDriver()).isDisplayed());
231233
clickButton("Next");
232234
assertTitleContains("Link to " + STUDY_FOLDER + " Study: Verify Results");
233235
// verify specimen information is filled in for '118795.fcs' FCS file

src/org/labkey/test/tests/issues/IssuesTest.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ public class IssuesTest extends BaseWebDriverTest
8686
private static final String USER2 = "[email protected]";
8787
private static final String USER3 = "[email protected]";
8888
private static final String USER4 = "[email protected]";
89+
private static final String CLIENT_USER1 = "[email protected]";
8990
private static final String user = "[email protected]";
9091
private static final Map<String, String> ISSUE_0 = new HashMap<>(Maps.of("title", ISSUE_TITLE_0, "Priority", "2", "comment", "a bright flash of light"));
9192
private static final Map<String, String> ISSUE_1 = new HashMap<>(Maps.of("title", ISSUE_TITLE_1, "Priority", "1", "comment", "alien autopsy"));
9293
private static final String ISSUE_SUMMARY_WEBPART_NAME = "Issues Summary";
9394
private static final String ISSUE_LIST_REGION_NAME = "issues-issues";
9495
private static final String TEST_GROUP = "testers";
96+
private static final String CLIENT_GROUP = "clients";
9597
private static final String TEST_EMAIL_TEMPLATE =
9698
"You can review this issue here: ^detailsURL^\n" +
9799
"Modified by: ^user^\n" +
@@ -105,6 +107,7 @@ public class IssuesTest extends BaseWebDriverTest
105107
private static String NAME;
106108
protected IssuesHelper _issuesHelper;
107109
private final ApiPermissionsHelper _permissionsHelper = new ApiPermissionsHelper(this);
110+
private static String CLIENT_PORTAL = "Client Issues";
108111

109112
public IssuesTest()
110113
{
@@ -158,8 +161,9 @@ protected String getProjectName()
158161
@Override
159162
protected void doCleanup(boolean afterTest) throws TestTimeoutException
160163
{
161-
_userHelper.deleteUsers(false, USER1, USER2, USER3, USER4);
164+
_userHelper.deleteUsers(false, USER1, USER2, USER3, CLIENT_USER1);
162165
_containerHelper.deleteProject(getProjectName(), afterTest);
166+
_containerHelper.deleteProject(CLIENT_PORTAL, afterTest);
163167
}
164168

165169
public void doInit()
@@ -193,6 +197,15 @@ public void doInit()
193197
waitAndClickAndWait(Locator.linkContainingText(ISSUE_SUMMARY_WEBPART_NAME));
194198
_issuesHelper.addIssue(ISSUE_0);
195199
_issuesHelper.addIssue(ISSUE_1);
200+
201+
// Create a second project with different permissions
202+
_containerHelper.createProject(CLIENT_PORTAL);
203+
goToProjectHome(CLIENT_PORTAL);
204+
_userHelper.createUser(CLIENT_USER1);
205+
_permissionsHelper.createPermissionsGroup(CLIENT_GROUP);
206+
_permissionsHelper.setPermissions(CLIENT_GROUP, "Editor");
207+
_permissionsHelper.addUserToProjGroup(CLIENT_USER1, CLIENT_PORTAL, CLIENT_GROUP);
208+
_issuesHelper.createNewIssuesList("tickets", _containerHelper);
196209
}
197210

198211
@Before
@@ -834,7 +847,32 @@ public void relatedIssueTest()
834847
.clickSubMenu(false, "Hide related comments");
835848
assertElementNotVisible(related);
836849

837-
// NOTE: still need to test for case where user doesn't have permission to related issue...
850+
// related issue permission tests
851+
Locator commentLocator = Locator.name("related");
852+
goToProjectHome(CLIENT_PORTAL);
853+
waitAndClickAndWait(Locator.linkContainingText(ISSUE_SUMMARY_WEBPART_NAME));
854+
String clientIssueId = _issuesHelper.addIssue(Maps.of("assignedTo", NAME, "title", "Client ticket", "priority", "3", "related", issueIdA)).getIssueId();
855+
856+
// impersonate a user without permissions to the related issues
857+
impersonate(CLIENT_USER1);
858+
clickAndWait(Locator.linkWithText("Issues List"));
859+
clickAndWait(Locator.linkWithText(clientIssueId));
860+
updateIssue();
861+
setFormElement(Locator.name("comment"), "This should work");
862+
clickButton("Save");
863+
864+
// try to add related issue they don't have permission to see
865+
updateIssue();
866+
setFormElement(relatedLocator, String.format("%s,%s", issueIdA, issueIdB));
867+
clickButton("Save");
868+
assertTextPresent("User does not have Read Permission for related issue");
869+
870+
// Issue 53820 try to remove a related issue they don't have permission to see
871+
setFormElement(relatedLocator, "");
872+
clickButton("Save");
873+
assertTextPresent(String.format("User does not have Read Permission for related issue '%s'", issueIdA));
874+
clickButton("Cancel");
875+
stopImpersonating();
838876
}
839877

840878
@Test

src/org/labkey/test/tests/list/ListTest.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ protected String getProjectName()
208208
return PROJECT_VERIFY;
209209
}
210210

211+
@Override
212+
protected void doCleanup(boolean afterTest)
213+
{
214+
_containerHelper.deleteProject(PROJECT_VERIFY, afterTest);
215+
_containerHelper.deleteProject(PROJECT_OTHER, afterTest);
216+
}
217+
211218
@BeforeClass
212219
public static void setupProject()
213220
{
@@ -1629,7 +1636,7 @@ public void testAutoIncrementKeyEncoded()
16291636
// setup a list with an auto-increment key that we need to make sure is encoded in the form input
16301637
String encodedListName = "autoIncrementEncodeList";
16311638
String keyName = "'><script>alert(\":(\")</script>'";
1632-
String encodedKeyFieldName = EscapeUtil.getFormFieldName(keyName).replaceAll("\"", "&quot;");
1639+
String encodedKeyFieldName = EscapeUtil.getFormFieldName(keyName);
16331640
_listHelper.createList(PROJECT_VERIFY, encodedListName, keyName, col("Name", ColumnType.String));
16341641
_listHelper.goToList(encodedListName);
16351642

@@ -1639,10 +1646,9 @@ public void testAutoIncrementKeyEncoded()
16391646
customizeView.addColumn(EscapeUtil.fieldKeyEncodePart(keyName));
16401647
customizeView.applyCustomView();
16411648

1642-
// insert a new row and verify the key is encoded in the form input
1649+
// insert a new row and verify the key field is not present
16431650
table.clickInsertNewRow();
1644-
String html = getHtmlSource();
1645-
checker().verifyFalse("List key hidden input not present.", html.contains(encodedKeyFieldName));
1651+
checker().withScreenshot().verifyEquals("List fields on insert form.", List.of("quf_Name"), getQueryFormFieldNames());
16461652
String nameValue = "test";
16471653
setFormElement(Locator.name(EscapeUtil.getFormFieldName("Name")), nameValue);
16481654
clickButton("Submit");
@@ -1654,8 +1660,7 @@ public void testAutoIncrementKeyEncoded()
16541660

16551661
// verify name value can be updated
16561662
table.clickEditRow(0);
1657-
html = getHtmlSource();
1658-
checker().verifyTrue("List key hidden input not present.", html.contains(encodedKeyFieldName));
1663+
checker().withScreenshot().verifyEquals("List fields on update form.", List.of("quf_Name", encodedKeyFieldName), getQueryFormFieldNames());
16591664
nameValue = "test updated";
16601665
setFormElement(Locator.name(EscapeUtil.getFormFieldName("Name")), nameValue);
16611666
clickButton("Submit");
@@ -1668,6 +1673,14 @@ public void testAutoIncrementKeyEncoded()
16681673
_listHelper.deleteList();
16691674
}
16701675

1676+
private List<String> getQueryFormFieldNames()
1677+
{
1678+
return Locator.tag("input").attributeStartsWith("name", "quf_")
1679+
.findElements(getDriver()).stream()
1680+
.map(el -> el.getDomAttribute("name"))
1681+
.toList();
1682+
}
1683+
16711684
private void viewRawTableMetadata(String listName)
16721685
{
16731686
goToSchemaBrowser();

src/org/labkey/test/tests/upgrade/BaseUpgradeTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import static org.apache.commons.lang3.StringUtils.trimToNull;
2525

2626
/**
27-
* Base test class for tests that setup data and configure a server then verify the persistence or modification of those
28-
* data and configurations after upgrading to a newer version of LabKey.<br>
29-
* The {@code EariestVersion} and {@code LatestVersion} annotations can be used to skip particular tests when they are
27+
* Base test class for tests that set up data and configure a server, then verify the persistence or modification of
28+
* those data and configurations after upgrading to a newer version of LabKey.<br>
29+
* The {@link EarliestVersion} and {@link LatestVersion} annotations can be used to skip particular tests when they are
3030
* not relevant to the version of LabKey being upgraded from (specified in the {@code webtest.upgradePreviousVersion}
3131
* system property).<br>
3232
* The setup steps will be skipped if the {@code webtest.upgradeSetup} system property is set to {@code false}.
@@ -77,7 +77,8 @@ public List<String> getAssociatedModules()
7777
*/
7878
@Retention(RetentionPolicy.RUNTIME)
7979
@Target({ElementType.METHOD})
80-
protected @interface EariestVersion {
80+
protected @interface EarliestVersion
81+
{
8182
String value();
8283
}
8384

@@ -98,12 +99,12 @@ private static class UpgradeVersionCheck implements TestRule
9899
@Override
99100
public @NotNull Statement apply(Statement base, Description description)
100101
{
101-
String eariestVersion = Optional.ofNullable(description.getAnnotation(EariestVersion.class))
102-
.map(EariestVersion::value).orElse(null);
102+
String earliestVersion = Optional.ofNullable(description.getAnnotation(EarliestVersion.class))
103+
.map(EarliestVersion::value).orElse(null);
103104
String latestVersion = Optional.ofNullable(description.getAnnotation(LatestVersion.class))
104105
.map(LatestVersion::value).orElse(null);
105106

106-
if (isUpgradeSetupPhase || previousVersion == null || (eariestVersion == null && latestVersion == null))
107+
if (isUpgradeSetupPhase || previousVersion == null || (earliestVersion == null && latestVersion == null))
107108
{
108109
return base; // Run the test normally
109110
}
@@ -114,7 +115,7 @@ private static class UpgradeVersionCheck implements TestRule
114115
public void evaluate() throws Throwable
115116
{
116117
Assume.assumeTrue("Test doesn't support upgrading from version: " + previousVersion,
117-
VersionRange.versionRange(eariestVersion, latestVersion).contains(previousVersion)
118+
VersionRange.versionRange(earliestVersion, latestVersion).contains(previousVersion)
118119
);
119120
base.evaluate();
120121
}

0 commit comments

Comments
 (0)