Skip to content

Commit

Permalink
set default diffingMethod to Balanced
Browse files Browse the repository at this point in the history
  • Loading branch information
kb-kerem committed Aug 21, 2024
1 parent 1b8ae7d commit a3f9d5c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion visual-dotnet/SauceLabs.Visual/VisualClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private async Task<string> 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,
Expand Down
8 changes: 4 additions & 4 deletions visual-java/src/main/java/com/saucelabs/visual/VisualApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));

Expand Down
5 changes: 4 additions & 1 deletion visual-js/visual-cypress/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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} `);
Expand Down
4 changes: 2 additions & 2 deletions visual-js/visual-cypress/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ 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;
/**
* The diffing options that should be applied by default.
*/
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[];
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
DiffingMethod,
ElementIn,
ensureError,
getFullPageConfig,
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion visual-js/visual-wdio/src/SauceVisualService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit a3f9d5c

Please sign in to comment.