From 0eeeb9a73eaa5b9ac53f0a1772a7356acd80fad5 Mon Sep 17 00:00:00 2001 From: chinmay-browserstack <92926953+chinmay-browserstack@users.noreply.github.com> Date: Wed, 27 Sep 2023 18:27:54 +0530 Subject: [PATCH] Change freezeAnimation -> freezeAnimatedImage (#1382) * Change freezeAnimation -> freezeAnimatedImage * Support backward compatibility for freezeAnimation --- packages/core/src/config.js | 25 ++++++++++++++++++- packages/core/src/utils.js | 4 ++- packages/core/test/api.test.js | 10 +++++--- .../src/providers/genericProvider.js | 2 +- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/packages/core/src/config.js b/packages/core/src/config.js index 58874b7d5..05ac86e95 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -50,10 +50,33 @@ export const configSchema = { scope: { type: 'string' }, - freezeAnimation: { + freezeAnimation: { // for backward compatibility type: 'boolean', onlyAutomate: true }, + freezeAnimatedImage: { + type: 'boolean', + onlyAutomate: true + }, + freezeAnimatedImageOptions: { + type: 'object', + additionalProperties: false, + onlyAutomate: true, + properties: { + freezeImageBySelectors: { + type: 'array', + items: { + type: 'string' + } + }, + freezeImageByXpaths: { + type: 'array', + items: { + type: 'string' + } + } + } + }, ignoreRegions: { type: 'object', additionalProperties: false, diff --git a/packages/core/src/utils.js b/packages/core/src/utils.js index e3a9bab57..38babfdd4 100644 --- a/packages/core/src/utils.js +++ b/packages/core/src/utils.js @@ -42,7 +42,9 @@ export function percyAutomateRequestHandler(req, percy) { req.body.options = merge([{ percyCSS: percy.config.snapshot.percyCSS, - freezeAnimation: percy.config.snapshot.freezeAnimation, + freezeAnimatedImage: percy.config.snapshot.freezeAnimatedImage || percy.config.snapshot.freezeAnimation, + freezeImageBySelectors: percy.config.snapshot.freezeAnimatedImageOptions?.freezeImageBySelectors, + freezeImageByXpaths: percy.config.snapshot.freezeAnimatedImageOptions?.freezeImageByXpaths, ignoreRegionSelectors: percy.config.snapshot.ignoreRegions?.ignoreRegionSelectors, ignoreRegionXpaths: percy.config.snapshot.ignoreRegions?.ignoreRegionXpaths, considerRegionSelectors: percy.config.snapshot.considerRegions?.considerRegionSelectors, diff --git a/packages/core/test/api.test.js b/packages/core/test/api.test.js index 536037c13..764d440fa 100644 --- a/packages/core/test/api.test.js +++ b/packages/core/test/api.test.js @@ -275,7 +275,8 @@ describe('API Server', () => { await percy.start(); percy.config.snapshot.percyCSS = '.global { color: blue }'; - percy.config.snapshot.freezeAnimation = false; + percy.config.snapshot.freezeAnimatedImage = false; + percy.config.snapshot.freezeAnimatedImageOptions = { freezeImageByXpaths: ['/xpath-global'] }; percy.config.snapshot.ignoreRegions = { ignoreRegionSelectors: ['.selector-global'] }; percy.config.snapshot.considerRegions = { considerRegionXpaths: ['/xpath-global'] }; @@ -286,7 +287,8 @@ describe('API Server', () => { environment_info: 'environment', options: { percyCSS: '.percy-screenshot: { color: red }', - freeze_animation: true, + freeze_animated_image: true, + freezeImageBySelectors: ['.selector-per-screenshot'], ignore_region_xpaths: ['/xpath-per-screenshot'], consider_region_xpaths: ['/xpath-per-screenshot'] } @@ -299,7 +301,9 @@ describe('API Server', () => { environmentInfo: 'environment', buildInfo: { id: '123', url: 'https://percy.io/test/test/123', number: 1 }, options: { - freezeAnimation: true, + freezeAnimatedImage: true, + freezeImageBySelectors: ['.selector-per-screenshot'], + freezeImageByXpaths: ['/xpath-global'], percyCSS: '.global { color: blue }\n.percy-screenshot: { color: red }', ignoreRegionSelectors: ['.selector-global'], ignoreRegionXpaths: ['/xpath-per-screenshot'], diff --git a/packages/webdriver-utils/src/providers/genericProvider.js b/packages/webdriver-utils/src/providers/genericProvider.js index e17ebfd8d..bacf51903 100644 --- a/packages/webdriver-utils/src/providers/genericProvider.js +++ b/packages/webdriver-utils/src/providers/genericProvider.js @@ -39,7 +39,7 @@ export default class GenericProvider { } addDefaultOptions() { - this.options.freezeAnimation = this.options.freezeAnimation || false; + this.options.freezeAnimation = this.options.freezeAnimatedImage || this.options.freezeAnimation || false; } async createDriver() {