Skip to content

Commit cccec83

Browse files
committed
F!! ImageWebReporter has copyToClipboard button
1 parent b0a76ac commit cccec83

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

approvaltests/src/main/java/org/approvaltests/reporters/ClipboardReporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static String getAcceptApprovalText(String received, String approved, boo
4545
}
4646
else
4747
{
48-
return String.format("mv %s %s", formatFilePathForCommandLine(received),
48+
return String.format("mv -f %s %s", formatFilePathForCommandLine(received),
4949
formatFilePathForCommandLine(approved));
5050
}
5151
}

approvaltests/src/main/java/org/approvaltests/reporters/ImageWebReporter.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,36 @@ public class ImageWebReporter implements EnvironmentAwareReporter
1010
@Override
1111
public void report(String received, String approved)
1212
{
13-
String text = "<html><body><center><table border=1><tr><td><img src=\"file:///%s\"></td><td><img src=\"file:///%s\"></td></tr><tr><td>approved</td><td>received</td></tr></table> %s <br/> <b>to approve :</b> copy clipboard to command window <br/> <font size=1>%s</font></center></body></html>";
13+
//language=HTML
14+
String text = "<html>\n" +
15+
"<script>\n" +
16+
" function copyToClipboard() {\n" +
17+
" const copyText = document.getElementById(\"moveText\");\n" +
18+
" navigator.clipboard.writeText(copyText.textContent);\n" +
19+
" }\n" +
20+
"</script>\n" +
21+
"<body>\n" +
22+
"<center>\n" +
23+
" <table border=1>\n" +
24+
" <tr>\n" +
25+
" <td><img src=\"file:///%s\"></td>\n" +
26+
" <td><img src=\"file:///%s\"></td>\n" +
27+
" </tr>\n" +
28+
" <tr>\n" +
29+
" <td>approved</td>\n" +
30+
" <td>received</td>\n" +
31+
" </tr>\n" +
32+
" </table>\n" +
33+
" %s <br/> <b>to approve :</b> copy clipboard to command window <br/> <font size=1 id=\"moveText\">%s</font>\n" +
34+
" <br /><button onclick=\"copyToClipboard()\">Copy to clipboard</button>\n" +
35+
"</center>\n" +
36+
"</body>\n" +
37+
"</html>\n";
1438
String moveText = ClipboardReporter.getAcceptApprovalText(received, approved);
1539
text = String.format(text, approved, received, received, moveText);
1640
TestUtils.displayHtml(text);
1741
}
42+
1843
/**
1944
* We assume any environment that is not headless will have a web browser to display the image in a web page.
2045
*/

0 commit comments

Comments
 (0)