Skip to content

Commit

Permalink
Change freezeAnimation -> freezeAnimatedImage (#1382)
Browse files Browse the repository at this point in the history
* Change freezeAnimation -> freezeAnimatedImage

* Support backward compatibility for freezeAnimation
  • Loading branch information
chinmay-browserstack authored Sep 27, 2023
1 parent 19d8767 commit 0eeeb9a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
25 changes: 24 additions & 1 deletion packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions packages/core/test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'] };

Expand All @@ -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']
}
Expand All @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion packages/webdriver-utils/src/providers/genericProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 0eeeb9a

Please sign in to comment.