Skip to content

Commit

Permalink
ignored element support implementation (#1229)
Browse files Browse the repository at this point in the history
  • Loading branch information
prklm10 committed Apr 7, 2023
1 parent 473ae89 commit eb03b7e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/client/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}...`);
Expand All @@ -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: {
Expand Down
34 changes: 30 additions & 4 deletions packages/client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -882,7 +906,8 @@ describe('PercyClient', () => {
data: {
type: 'comparisons',
attributes: {
'external-debug-url': null
'external-debug-url': null,
'ignore-elements-data': null
},
relationships: {
tag: {
Expand Down Expand Up @@ -1130,7 +1155,8 @@ describe('PercyClient', () => {
data: {
type: 'comparisons',
attributes: {
'external-debug-url': null
'external-debug-url': null,
'ignore-elements-data': null
},
relationships: {
tag: {
Expand Down
40 changes: 40 additions & 0 deletions packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
}
}
}
}
}
};
Expand Down

0 comments on commit eb03b7e

Please sign in to comment.