From a3f9d5cc5ee0b23cadd097ae2b8c1ea8594f0eec Mon Sep 17 00:00:00 2001 From: Kerem Date: Wed, 21 Aug 2024 11:49:34 +0200 Subject: [PATCH] set default diffingMethod to Balanced --- visual-dotnet/SauceLabs.Visual/VisualClient.cs | 2 +- .../src/main/java/com/saucelabs/visual/VisualApi.java | 8 ++++---- .../src/test/java/com/saucelabs/visual/SmokeTest.java | 2 +- visual-js/visual-cypress/src/index.ts | 5 ++++- visual-js/visual-cypress/src/types.ts | 4 ++-- .../src/nightwatch/commands/sauceVisualCheck.ts | 2 ++ visual-js/visual-wdio/src/SauceVisualService.ts | 3 ++- 7 files changed, 16 insertions(+), 10 deletions(-) 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..65bdb53a 100644 --- a/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java +++ b/visual-java/src/test/java/com/saucelabs/visual/SmokeTest.java @@ -51,7 +51,7 @@ void testBuildSnapshotAndResults() throws InterruptedException { WebElement cookieBanner = driver.findElement(By.id("onetrust-banner-sdk")); CheckOptions checkOptions = new CheckOptions(); - checkOptions.setDiffingMethod(DiffingMethod.EXPERIMENTAL); + checkOptions.setDiffingMethod(DiffingMethod.BALANCED); checkOptions.setIgnoreRegions( IgnoreRegion.forElement(driver, Arrays.asList(header, caroussel, cookieBanner))); 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..bd3dfa09 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. + * The diffing method we should use when finding visual changes. Defaults to DiffingMethod.Balanced */ 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-wdio/src/SauceVisualService.ts b/visual-js/visual-wdio/src/SauceVisualService.ts index 6f8a9e19..91ee50e4 100644 --- a/visual-js/visual-wdio/src/SauceVisualService.ts +++ b/visual-js/visual-wdio/src/SauceVisualService.ts @@ -433,7 +433,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),