Skip to content

[Java] Allow test/suitename to be optional when not using TestMetaExtension utility #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ public CreateSnapshotFromWebDriverIn(
}

public void setTestName(String testName) {
this.testName = Optional.of(testName);
this.testName = Optional.ofNullable(testName);
}

public void setSuiteName(String suiteName) {
this.suiteName = Optional.of(suiteName);
this.suiteName = Optional.ofNullable(suiteName);
}

public void setCaptureDom(Boolean captureDom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static void tearDown() {
driver.quit();
}

protected void sauceVisualCheck(String name) {
sauceVisualCheck(name, new CheckOptions());
protected String sauceVisualCheck(String name) {
return sauceVisualCheck(name, new CheckOptions());
}

protected String sauceVisualCheck(String name, CheckOptions checkOptions) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.saucelabs.visual.integration;

import au.com.origin.snapshots.Expect;
import au.com.origin.snapshots.junit5.SnapshotExtension;
import com.saucelabs.visual.CheckOptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

@ExtendWith({SnapshotExtension.class})
public class WithoutTestMetaIT extends IntegrationBase {
Expect expect;

@BeforeAll
public static void login() {
LoginPage loginPage = new LoginPage();
loginPage.open();
loginPage.login();
InventoryLongPage inventoryPage = new InventoryLongPage();
inventoryPage.open();
}

@Test
public void checkWithoutTestMeta() {
String id = sauceVisualCheck("No Test Meta");
String result = getSnapshotResult(id);
expect.toMatchSnapshot(result);
}

@Test
public void checkSupplyingValuesManually() {
String id =
sauceVisualCheck(
"Manual Test Meta",
new CheckOptions.Builder()
.withSuiteName("Custom Suite Name")
.withTestName("Custom Test Name")
.build());
String result = getSnapshotResult(id);
expect.toMatchSnapshot(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
com.saucelabs.visual.integration.WithoutTestMetaIT.checkSupplyingValuesManually=[
{
"snapshot" : {
"name" : "Manual Test Meta (Sauce)",
"suiteName" : "Custom Suite Name",
"testName" : "Custom Test Name",
"operatingSystem" : "WINDOWS",
"operatingSystemVersion" : "10",
"device" : "Desktop (1384x1007)",
"devicePixelRatio" : 1,
"hasDom" : true,
"diffs" : {
"nodes" : [ {
"status" : "EQUAL",
"diffClusters" : [ ]
} ]
},
"ignoreRegions" : [ ]
}
}
]


com.saucelabs.visual.integration.WithoutTestMetaIT.checkWithoutTestMeta=[
{
"snapshot" : {
"name" : "No Test Meta (Sauce)",
"suiteName" : null,
"testName" : null,
"operatingSystem" : "WINDOWS",
"operatingSystemVersion" : "10",
"device" : "Desktop (1384x1007)",
"devicePixelRatio" : 1,
"hasDom" : true,
"diffs" : {
"nodes" : [ {
"status" : "EQUAL",
"diffClusters" : [ ]
} ]
},
"ignoreRegions" : [ ]
}
}
]