diff --git a/visual-dotnet/SauceLabs.Visual/VisualClient.cs b/visual-dotnet/SauceLabs.Visual/VisualClient.cs index bc34b135..a5314f9b 100644 --- a/visual-dotnet/SauceLabs.Visual/VisualClient.cs +++ b/visual-dotnet/SauceLabs.Visual/VisualClient.cs @@ -173,7 +173,7 @@ private async Task VisualCheckAsync(string name, VisualCheckOptions opti buildUuid: Build.Id, name: name, jobId: _jobId, - diffingMethod: options.DiffingMethod ?? DiffingMethod.Simple, + diffingMethod: options.DiffingMethod ?? DiffingMethod.Balanced, regions: ignoredRegions.RegionsIn, ignoredElements: ignoredRegions.ElementsIn, sessionId: _sessionId, diff --git a/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java b/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java index a40f555e..ea0e971d 100644 --- a/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java +++ b/visual-java/src/main/java/com/saucelabs/visual/VisualApi.java @@ -431,16 +431,16 @@ public void sauceVisualCheck(String snapshotName, CheckOptions options) { private static DiffingMethod toDiffingMethod(CheckOptions options) { if (options == null || options.getDiffingMethod() == null) { - return null; + return DiffingMethod.BALANCED; } switch (options.getDiffingMethod()) { - case BALANCED: - return DiffingMethod.BALANCED; + case SIMPLE: + return DiffingMethod.SIMPLE; case EXPERIMENTAL: return DiffingMethod.EXPERIMENTAL; default: - return DiffingMethod.SIMPLE; + return DiffingMethod.BALANCED; } } diff --git a/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java b/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java index 10a1d544..8d712d49 100644 --- a/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java +++ b/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java @@ -4,7 +4,6 @@ import com.saucelabs.saucebindings.UnhandledPromptBehavior; import com.saucelabs.saucebindings.junit5.SauceBaseTest; import com.saucelabs.saucebindings.options.SauceOptions; -import com.saucelabs.visual.CheckOptions.DiffingMethod; import com.saucelabs.visual.junit5.TestMetaInfoExtension; import com.saucelabs.visual.model.FullPageScreenshotConfig; import com.saucelabs.visual.model.IgnoreRegion; @@ -51,7 +50,6 @@ void testBuildSnapshotAndResults() throws InterruptedException { WebElement cookieBanner = driver.findElement(By.id("onetrust-banner-sdk")); CheckOptions checkOptions = new CheckOptions(); - checkOptions.setDiffingMethod(DiffingMethod.EXPERIMENTAL); checkOptions.setIgnoreRegions( IgnoreRegion.forElement(driver, Arrays.asList(header, caroussel, cookieBanner))); diff --git a/visual-js/.changeset/funny-shrimps-compete.md b/visual-js/.changeset/funny-shrimps-compete.md new file mode 100644 index 00000000..994b0797 --- /dev/null +++ b/visual-js/.changeset/funny-shrimps-compete.md @@ -0,0 +1,9 @@ +--- +'@saucelabs/nightwatch-sauce-visual-service': minor +'@saucelabs/visual-storybook': minor +'@saucelabs/cypress-visual-plugin': minor +'@saucelabs/wdio-sauce-visual-service': minor +'@saucelabs/visual': minor +--- + +Change default diffingMethod to BALANCED diff --git a/visual-js/visual-cypress/src/index.ts b/visual-js/visual-cypress/src/index.ts index 20157617..1d4f55a5 100644 --- a/visual-js/visual-cypress/src/index.ts +++ b/visual-js/visual-cypress/src/index.ts @@ -381,7 +381,10 @@ Sauce Labs Visual: Unable to create new build. ? `Desktop (${metadata.viewport.width}x${metadata.viewport.height})` : 'Desktop', devicePixelRatio: metadata.devicePixelRatio, - diffingMethod: metadata.diffingMethod || this.diffingMethod, + diffingMethod: + metadata.diffingMethod || + this.diffingMethod || + DiffingMethod.Balanced, jobUrl: this.jobId ? this.region.jobUrl(this.jobId) : undefined, }); logger.info(` ${chalk.green('✔')} ${metadata.name} `); diff --git a/visual-js/visual-cypress/src/types.ts b/visual-js/visual-cypress/src/types.ts index e5461ba5..347c22b8 100644 --- a/visual-js/visual-cypress/src/types.ts +++ b/visual-js/visual-cypress/src/types.ts @@ -62,7 +62,7 @@ export type VisualCheckOptions = { */ ignoredRegions?: (PlainRegion | Cypress.Chainable)[]; /** - * The diffing method we should use when finding visual changes. Defaults to DiffingMethod.Simple. + * The diffing method we should use when finding visual changes. Defaults to DiffingMethod.Balanced */ diffingMethod?: DiffingMethod; /** @@ -70,7 +70,7 @@ export type VisualCheckOptions = { */ diffingOptions?: DiffingOptionsIn; /** - * The diffing method we should use when finding visual changes. Defaults to DiffingMethod.Simple. + * Specify what kind of checks needs to be done in a specific region */ regions?: VisualRegion[]; /** diff --git a/visual-js/visual-nightwatch/src/nightwatch/commands/sauceVisualCheck.ts b/visual-js/visual-nightwatch/src/nightwatch/commands/sauceVisualCheck.ts index fdf8fdc5..905dde81 100644 --- a/visual-js/visual-nightwatch/src/nightwatch/commands/sauceVisualCheck.ts +++ b/visual-js/visual-nightwatch/src/nightwatch/commands/sauceVisualCheck.ts @@ -1,4 +1,5 @@ import { + DiffingMethod, ElementIn, ensureError, getFullPageConfig, @@ -151,6 +152,7 @@ class SauceVisualCheck implements NightwatchCustomCommandsModel { clipElement: (await options.clipElement?.getId()) ?? clipElementFromClipSelector, captureDom: options.captureDom ?? globalCaptureDom, + diffingMethod: options.diffingMethod ?? DiffingMethod.Balanced, }); global.uploadedDiffIds.push( diff --git a/visual-js/visual-storybook/src/api.ts b/visual-js/visual-storybook/src/api.ts index 794baa2b..24191b2b 100644 --- a/visual-js/visual-storybook/src/api.ts +++ b/visual-js/visual-storybook/src/api.ts @@ -151,6 +151,7 @@ export const postVisit = async (page: Page, context: TestContext) => { delay, captureDom, ignoreRegions: userIgnoreRegions, + diffingMethod, } = sauceVisualParams ?? {}; const { animations = 'disabled', caret } = screenshotOptions; let ignoreRegions: RegionIn[] = []; @@ -292,6 +293,7 @@ export const postVisit = async (page: Page, context: TestContext) => { buildId, name: `${context.title}/${context.name}`, ignoreRegions, + diffingMethod, }); await api.createSnapshot({ diff --git a/visual-js/visual-storybook/src/types.ts b/visual-js/visual-storybook/src/types.ts index eb704a03..b7d511a7 100644 --- a/visual-js/visual-storybook/src/types.ts +++ b/visual-js/visual-storybook/src/types.ts @@ -1,4 +1,4 @@ -import { RegionIn, SauceRegion } from '@saucelabs/visual'; +import { DiffingMethod, RegionIn, SauceRegion } from '@saucelabs/visual'; import { PageScreenshotOptions } from 'playwright-core'; export interface SauceVisualParams { @@ -25,6 +25,10 @@ export interface SauceVisualParams { * don't want to diff. */ ignoreRegions?: (RegionIn | string)[]; + /** + * The diffing method we should use when finding visual changes. Defaults to DiffingMethod.Balanced + */ + diffingMethod?: DiffingMethod; } export interface VisualOpts { diff --git a/visual-js/visual-storybook/src/utils.ts b/visual-js/visual-storybook/src/utils.ts index 59487a7a..ff18071b 100644 --- a/visual-js/visual-storybook/src/utils.ts +++ b/visual-js/visual-storybook/src/utils.ts @@ -2,6 +2,7 @@ import { VisualOpts } from './types'; import * as os from 'os'; import { Browser, + DiffingMethod, OperatingSystem, SauceRegion, SnapshotIn, @@ -159,6 +160,7 @@ export const buildSnapshotMetadata = ({ buildId, name, ignoreRegions, + diffingMethod, }: { browserName: string | undefined; browserVersion: string | undefined; @@ -167,9 +169,10 @@ export const buildSnapshotMetadata = ({ buildId: string; name: string; ignoreRegions: SnapshotIn['ignoreRegions']; + diffingMethod: DiffingMethod | undefined; }): Omit => { return { - diffingMethod: null, + diffingMethod: diffingMethod || DiffingMethod.Balanced, browser: getKnownBrowserType(browserName), browserVersion: browserVersion ? `Playwright - ${browserVersion}` : null, buildUuid: buildId, diff --git a/visual-js/visual-wdio/src/SauceVisualService.ts b/visual-js/visual-wdio/src/SauceVisualService.ts index 3f356108..74846e72 100644 --- a/visual-js/visual-wdio/src/SauceVisualService.ts +++ b/visual-js/visual-wdio/src/SauceVisualService.ts @@ -438,7 +438,8 @@ export default class SauceVisualService implements Services.ServiceInstance { disableOnly: options.disable ?? [], }), sessionMetadata: metaInfo, - diffingMethod: options.diffingMethod || this.diffingMethod, + diffingMethod: + options.diffingMethod || this.diffingMethod || DiffingMethod.Balanced, suiteName: this.test?.parent, testName: this.test?.title, fullPageConfig: getFullPageConfig(this.fullPage, options.fullPage), diff --git a/visual-python/src/saucelabs_visual/client.py b/visual-python/src/saucelabs_visual/client.py index d156b3d6..9bb56ab1 100644 --- a/visual-python/src/saucelabs_visual/client.py +++ b/visual-python/src/saucelabs_visual/client.py @@ -310,7 +310,7 @@ def create_snapshot_from_webdriver( for element in group.as_dict_array() ] if ignore_elements is not None else None, "fullPageConfig": asdict(full_page_config) if full_page_config is not None else None, - "diffingMethod": (diffing_method or DiffingMethod.SIMPLE).value, + "diffingMethod": (diffing_method or DiffingMethod.BALANCED).value, "diffingOptions": diffing_options, "baselineOverride": { key: value for key, value in asdict(baseline_override).items() if value is not None