diff --git a/packages/client/src/client.js b/packages/client/src/client.js index f14b170b9..19cfcdf83 100644 --- a/packages/client/src/client.js +++ b/packages/client/src/client.js @@ -366,7 +366,7 @@ export class PercyClient { return snapshot; } - async createComparison(snapshotId, { tag, tiles = [], externalDebugUrl } = {}) { + async createComparison(snapshotId, { tag, tiles = [], externalDebugUrl, ignoredElementsData } = {}) { validateId('snapshot', snapshotId); this.log.debug(`Creating comparision: ${tag.name}...`); @@ -385,7 +385,8 @@ export class PercyClient { data: { type: 'comparisons', attributes: { - 'external-debug-url': externalDebugUrl || null + 'external-debug-url': externalDebugUrl || null, + 'ignore-elements-data': ignoredElementsData || null }, relationships: { tag: { diff --git a/packages/client/test/client.test.js b/packages/client/test/client.test.js index e7b3b69d7..84b264203 100644 --- a/packages/client/test/client.test.js +++ b/packages/client/test/client.test.js @@ -780,6 +780,28 @@ describe('PercyClient', () => { .withArgs('foo/bar').and.resolveTo('bar'); let tile1Content = 'screenshot'; + let ignoredElementsData = { + ignoreElementsData: [ + { + selector: 'xpaths', + 'co-ordinates': { + top: 1042, + bottom: 1147, + left: 108, + right: 972 + } + }, + { + selector: 'appiumWebElement', + 'co-ordinates': { + top: 1199, + bottom: 1304, + left: 108, + right: 972 + } + } + ] + }; await expectAsync(client.createComparison(4567, { tag: { @@ -812,14 +834,16 @@ describe('PercyClient', () => { fullscreen: true, sha: sha256hash('somesha') }], - externalDebugUrl: 'http://debug.localhost' + externalDebugUrl: 'http://debug.localhost', + ignoredElementsData: ignoredElementsData })).toBeResolved(); expect(api.requests['/snapshots/4567/comparisons'][0].body).toEqual({ data: { type: 'comparisons', attributes: { - 'external-debug-url': 'http://debug.localhost' + 'external-debug-url': 'http://debug.localhost', + 'ignore-elements-data': ignoredElementsData }, relationships: { tag: { @@ -882,7 +906,8 @@ describe('PercyClient', () => { data: { type: 'comparisons', attributes: { - 'external-debug-url': null + 'external-debug-url': null, + 'ignore-elements-data': null }, relationships: { tag: { @@ -1130,7 +1155,8 @@ describe('PercyClient', () => { data: { type: 'comparisons', attributes: { - 'external-debug-url': null + 'external-debug-url': null, + 'ignore-elements-data': null }, relationships: { tag: { diff --git a/packages/core/src/config.js b/packages/core/src/config.js index ea6c782d3..5778ba623 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -453,6 +453,46 @@ export const comparisonSchema = { } } } + }, + ignoredElementsData: { + type: 'object', + additionalProperties: false, + required: ['ignoreElementsData'], + properties: { + ignoreElementsData: { + type: 'array', + items: { + type: 'object', + additionalProperties: false, + properties: { + selector: { + type: 'string' + }, + coOrdinates: { + type: 'object', + properties: { + top: { + type: 'integer', + minimum: 0 + }, + left: { + type: 'integer', + minimum: 0 + }, + bottom: { + type: 'integer', + minimum: 0 + }, + right: { + type: 'integer', + minimum: 0 + } + } + } + } + } + } + } } } };