Skip to content

Commit 0659706

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_plateEditorNpe
2 parents a21be8b + e8d9a6b commit 0659706

4 files changed

Lines changed: 82 additions & 10 deletions

File tree

modules/simpletest/resources/scripts/validationTest/simpleQueryTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var testFunctions = [
4949

5050
function() //testResults[3]
5151
{
52-
testResults[testResults.length] = LABKEY.Query.executeSql({schemaName: schemaName, sort: "Date", sql: "select audit.Date from audit"});
52+
testResults[testResults.length] = LABKEY.Query.executeSql({schemaName: schemaName, sort: "Date", sql: "select Date from UserAuditEvent"});
5353
executeNext();
5454
},
5555

@@ -100,7 +100,7 @@ var testFunctions = [
100100
if (!testResults[0].rowsAffected || testResults[0].rowsAffected != 1)
101101
errors[errors.length] = new Error("Query.insertRows() = "+Ext.util.JSON.encode(testResults[0]));
102102

103-
if (!testResults[1].rows || testResults[1].rows.length != 1)
103+
if (!testResults[1].rows || testResults[1].rows.length != 1)
104104
errors[errors.length] = new Error("Query.selectRows() = "+Ext.util.JSON.encode(testResults[1]));
105105

106106
if (!testResults[2].exception)

src/org/labkey/test/WebDriverWrapper.java

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.labkey.test.util.EscapeUtil;
5454
import org.labkey.test.util.Ext4Helper;
5555
import org.labkey.test.util.ExtHelper;
56+
import org.labkey.test.util.HtmlFragmentSelection;
5657
import org.labkey.test.util.LabKeyExpectedConditions;
5758
import org.labkey.test.util.LogMethod;
5859
import org.labkey.test.util.LoggedParam;
@@ -3503,14 +3504,14 @@ public void actionClear(WebElement input)
35033504
}
35043505

35053506
/**
3506-
* puts the specified text into the clipboard, then pastes it into the specified element,
3507+
* puts the specified text and html into the clipboard, then pastes it into the specified element,
35073508
* or whatever has focus at the moment.
35083509
*/
3509-
public void actionPaste(WebElement input, String text)
3510+
public void actionPaste(WebElement input, String text, boolean isHtml)
35103511
{
35113512
Keys cmdKey = WebDriverUtils.MODIFIER_KEY;
35123513

3513-
setClipboardContent(text);
3514+
setClipboardContent(text, isHtml);
35143515

35153516
if (input == null)
35163517
{
@@ -3531,16 +3532,40 @@ public void actionPaste(WebElement input, String text)
35313532
}
35323533
}
35333534

3535+
/**
3536+
* puts the specified text into the clipboard, then pastes it into the specified element,
3537+
* or whatever has focus at the moment.
3538+
*/
3539+
public void actionPaste(WebElement input, String text)
3540+
{
3541+
actionPaste(input, text, false);
3542+
}
3543+
35343544
public void clearClipboardContent()
35353545
{
35363546
setClipboardContent(" ");
35373547
}
35383548

3539-
protected void setClipboardContent(String text)
3549+
protected void setClipboardContent(String text, boolean isHtml)
35403550
{
35413551
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
3542-
StringSelection sel = new StringSelection(text);
3543-
c.setContents(sel, sel);
3552+
Transferable sel;
3553+
3554+
if (isHtml)
3555+
{
3556+
sel = new HtmlFragmentSelection(text);
3557+
}
3558+
else
3559+
{
3560+
sel = new StringSelection(text);
3561+
}
3562+
3563+
c.setContents(sel, null);
3564+
}
3565+
3566+
protected void setClipboardContent(String text)
3567+
{
3568+
setClipboardContent(text, false);
35443569
}
35453570

35463571
public String getClipboardContent() throws IOException, UnsupportedFlavorException

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,21 @@
2727
import java.util.Map;
2828

2929
import static org.junit.Assert.assertEquals;
30+
import static org.labkey.test.util.TestDataGenerator.ALL_CHARS_PLACEHOLDER;
31+
import static org.labkey.test.util.TestDataGenerator.REPEAT_PLACEHOLDER;
3032

3133
// Issue 52098, Issue 49422
3234
@Category({Daily.class, Data.class, Hosting.class})
3335
public class ListLookupTest extends BaseWebDriverTest
3436
{
3537
private static final String lookToListName = TestDataGenerator.randomDomainName("lookToList", DomainUtils.DomainKind.IntList);
36-
private static final String lookToKeyFieldName = TestDataGenerator.randomFieldName("lookToKeyField", null, DomainUtils.DomainKind.IntList);
38+
private static final String lookToKeyFieldName = TestDataGenerator.randomFieldName("lookToKeyField", 5, 5, "" + REPEAT_PLACEHOLDER + ALL_CHARS_PLACEHOLDER, DomainUtils.DomainKind.IntList);
3739
private static final String lookToFieldName = TestDataGenerator.randomFieldName("lookToField", null, DomainUtils.DomainKind.IntList);
3840
private static List<Map<String, String>> lookToListValues;
3941
private static String lookupKeyAsNameNumber;
4042
private static String lookupKeyAsNameFieldValue;
4143
private static final String lookFromListName = TestDataGenerator.randomDomainName("lookFromList", DomainUtils.DomainKind.IntList);
42-
private static final String lookFromKeyFieldName = TestDataGenerator.randomFieldName("Look From Key Field", null, DomainUtils.DomainKind.IntList);
44+
private static final String lookFromKeyFieldName = TestDataGenerator.randomFieldName("Look From Key Field", 5, 5, "" + REPEAT_PLACEHOLDER + ALL_CHARS_PLACEHOLDER, DomainUtils.DomainKind.IntList);
4345
private static final String lookFromLookupFieldName = TestDataGenerator.randomFieldName("Look From Lookup Field", null, DomainUtils.DomainKind.IntList);
4446
private static final String lookFromLookupFieldKey = EscapeUtil.fieldKeyEncodePart(lookFromLookupFieldName);
4547

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.labkey.test.util;
2+
3+
import org.jetbrains.annotations.NotNull;
4+
5+
import java.awt.datatransfer.DataFlavor;
6+
import java.awt.datatransfer.Transferable;
7+
import java.awt.datatransfer.UnsupportedFlavorException;
8+
9+
/**
10+
* Used when you want to put an HTML payload on the clipboard, allowing you to emulate things like copy/pasting from
11+
* ELN/Google Docs.
12+
*/
13+
public class HtmlFragmentSelection implements Transferable
14+
{
15+
// You might be tempted to add support for DataFlavor.stringFlavor to this class in addition to
16+
// DataFlavor.fragmentHtmlFlavor, because that's what the examples show across the Internet do, and that's what the
17+
// various AI tools will tell you to do, but it simply doesn't work. If you put a text and HTML payload in the Java
18+
// clipboard it will only paste the text, and not the HTML.
19+
private static final DataFlavor[] transferDataFlavors = {DataFlavor.fragmentHtmlFlavor};
20+
private final String html;
21+
22+
public HtmlFragmentSelection(String html) {
23+
this.html = html;
24+
}
25+
26+
@Override
27+
public DataFlavor[] getTransferDataFlavors() {
28+
return transferDataFlavors;
29+
}
30+
31+
@Override
32+
public boolean isDataFlavorSupported(DataFlavor flavor) {
33+
return flavor.equals(DataFlavor.fragmentHtmlFlavor);
34+
}
35+
36+
@Override
37+
@NotNull
38+
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException
39+
{
40+
if (flavor == DataFlavor.fragmentHtmlFlavor) {
41+
return html;
42+
}
43+
throw new UnsupportedFlavorException(flavor);
44+
}
45+
}

0 commit comments

Comments
 (0)