Skip to content

Commit 319eaa3

Browse files
omacrangerLogan Graham
and
Logan Graham
authored
[Java] Allow test/suitename to be optional when not using TestMetaExtension utility (#237)
Co-authored-by: Logan Graham <[email protected]>
1 parent 23811dc commit 319eaa3

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

visual-java/src/main/java/com/saucelabs/visual/graphql/CreateSnapshotFromWebDriverMutation.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ public CreateSnapshotFromWebDriverIn(
100100
}
101101

102102
public void setTestName(String testName) {
103-
this.testName = Optional.of(testName);
103+
this.testName = Optional.ofNullable(testName);
104104
}
105105

106106
public void setSuiteName(String suiteName) {
107-
this.suiteName = Optional.of(suiteName);
107+
this.suiteName = Optional.ofNullable(suiteName);
108108
}
109109

110110
public void setCaptureDom(Boolean captureDom) {

visual-java/src/test/java/com/saucelabs/visual/integration/IntegrationBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public static void tearDown() {
7474
driver.quit();
7575
}
7676

77-
protected void sauceVisualCheck(String name) {
78-
sauceVisualCheck(name, new CheckOptions());
77+
protected String sauceVisualCheck(String name) {
78+
return sauceVisualCheck(name, new CheckOptions());
7979
}
8080

8181
protected String sauceVisualCheck(String name, CheckOptions checkOptions) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.saucelabs.visual.integration;
2+
3+
import au.com.origin.snapshots.Expect;
4+
import au.com.origin.snapshots.junit5.SnapshotExtension;
5+
import com.saucelabs.visual.CheckOptions;
6+
import org.junit.jupiter.api.BeforeAll;
7+
import org.junit.jupiter.api.Test;
8+
import org.junit.jupiter.api.extension.ExtendWith;
9+
10+
@ExtendWith({SnapshotExtension.class})
11+
public class WithoutTestMetaIT extends IntegrationBase {
12+
Expect expect;
13+
14+
@BeforeAll
15+
public static void login() {
16+
LoginPage loginPage = new LoginPage();
17+
loginPage.open();
18+
loginPage.login();
19+
InventoryLongPage inventoryPage = new InventoryLongPage();
20+
inventoryPage.open();
21+
}
22+
23+
@Test
24+
public void checkWithoutTestMeta() {
25+
String id = sauceVisualCheck("No Test Meta");
26+
String result = getSnapshotResult(id);
27+
expect.toMatchSnapshot(result);
28+
}
29+
30+
@Test
31+
public void checkSupplyingValuesManually() {
32+
String id =
33+
sauceVisualCheck(
34+
"Manual Test Meta",
35+
new CheckOptions.Builder()
36+
.withSuiteName("Custom Suite Name")
37+
.withTestName("Custom Test Name")
38+
.build());
39+
String result = getSnapshotResult(id);
40+
expect.toMatchSnapshot(result);
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
com.saucelabs.visual.integration.WithoutTestMetaIT.checkSupplyingValuesManually=[
2+
{
3+
"snapshot" : {
4+
"name" : "Manual Test Meta (Sauce)",
5+
"suiteName" : "Custom Suite Name",
6+
"testName" : "Custom Test Name",
7+
"operatingSystem" : "WINDOWS",
8+
"operatingSystemVersion" : "10",
9+
"device" : "Desktop (1384x1007)",
10+
"devicePixelRatio" : 1,
11+
"hasDom" : true,
12+
"diffs" : {
13+
"nodes" : [ {
14+
"status" : "EQUAL",
15+
"diffClusters" : [ ]
16+
} ]
17+
},
18+
"ignoreRegions" : [ ]
19+
}
20+
}
21+
]
22+
23+
24+
com.saucelabs.visual.integration.WithoutTestMetaIT.checkWithoutTestMeta=[
25+
{
26+
"snapshot" : {
27+
"name" : "No Test Meta (Sauce)",
28+
"suiteName" : null,
29+
"testName" : null,
30+
"operatingSystem" : "WINDOWS",
31+
"operatingSystemVersion" : "10",
32+
"device" : "Desktop (1384x1007)",
33+
"devicePixelRatio" : 1,
34+
"hasDom" : true,
35+
"diffs" : {
36+
"nodes" : [ {
37+
"status" : "EQUAL",
38+
"diffClusters" : [ ]
39+
} ]
40+
},
41+
"ignoreRegions" : [ ]
42+
}
43+
}
44+
]

0 commit comments

Comments
 (0)