Skip to content

Commit

Permalink
adding additional params for test case base grouping to snapshot and …
Browse files Browse the repository at this point in the history
…comparison (#1547)

* adding thTestCaseExecutionId params to snapshot and comparison

* revert test.js

* test update
  • Loading branch information
prklm10 committed Mar 15, 2024
1 parent 7c2bdcc commit 7daeb74
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/cli-upload/test/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ describe('percy upload', () => {
'scope-options': {},
'minimum-height': 10,
'enable-javascript': null,
'enable-layout': false
'enable-layout': false,
'th-test-case-execution-id': null
},
relationships: {
resources: {
Expand Down
4 changes: 3 additions & 1 deletion packages/client/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ export class PercyClient {
environmentInfo,
sync,
testCase,
thTestCaseExecutionId,
resources = []
} = {}) {
validateId('build', buildId);
Expand Down Expand Up @@ -388,7 +389,8 @@ export class PercyClient {
'scope-options': scopeOptions || {},
'minimum-height': minHeight || null,
'enable-javascript': enableJavaScript || null,
'enable-layout': enableLayout || false
'enable-layout': enableLayout || false,
'th-test-case-execution-id': thTestCaseExecutionId || null
},
relationships: {
resources: {
Expand Down
13 changes: 9 additions & 4 deletions packages/client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ describe('PercyClient', () => {
enableLayout: true,
clientInfo: 'sdk/info',
environmentInfo: 'sdk/env',
thTestCaseExecutionId: 'random-uuid',
resources: [{
url: '/foo',
content: 'foo',
Expand Down Expand Up @@ -694,7 +695,8 @@ describe('PercyClient', () => {
'minimum-height': 1000,
'scope-options': { scroll: true },
'enable-javascript': true,
'enable-layout': true
'enable-layout': true,
'th-test-case-execution-id': 'random-uuid'
},
relationships: {
resources: {
Expand Down Expand Up @@ -740,7 +742,8 @@ describe('PercyClient', () => {
'scope-options': {},
'minimum-height': null,
'enable-javascript': null,
'enable-layout': false
'enable-layout': false,
'th-test-case-execution-id': null
},
relationships: {
resources: {
Expand Down Expand Up @@ -809,7 +812,8 @@ describe('PercyClient', () => {
'enable-javascript': null,
'minimum-height': null,
widths: null,
'enable-layout': false
'enable-layout': false,
'th-test-case-execution-id': null
},
relationships: {
resources: {
Expand Down Expand Up @@ -1318,7 +1322,8 @@ describe('PercyClient', () => {
'minimum-height': null,
widths: null,
sync: false,
'enable-layout': false
'enable-layout': false,
'th-test-case-execution-id': null
},
relationships: {
resources: {
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export const configSchema = {
testCase: {
type: 'string'
},
thTestCaseExecutionId: {
type: 'string'
},
fullPage: {
type: 'boolean',
onlyAutomate: true
Expand Down Expand Up @@ -271,6 +274,7 @@ export const snapshotSchema = {
enableLayout: { $ref: '/config/snapshot#/properties/enableLayout' },
sync: { $ref: '/config/snapshot#/properties/sync' },
testCase: { $ref: '/config/snapshot#/properties/testCase' },
thTestCaseExecutionId: { $ref: '/config/snapshot#/properties/thTestCaseExecutionId' },
reshuffleInvalidTags: { $ref: '/config/snapshot#/properties/reshuffleInvalidTags' },
scopeOptions: { $ref: '/config/snapshot#/properties/scopeOptions' },
discovery: {
Expand Down Expand Up @@ -558,6 +562,12 @@ export const comparisonSchema = {
externalDebugUrl: { type: 'string' },
domInfoSha: { type: 'string' },
sync: { type: 'boolean' },
testCase: {
type: 'string'
},
thTestCaseExecutionId: {
type: 'string'
},
metadata: {
type: 'object',
additionalProperties: false,
Expand Down
8 changes: 6 additions & 2 deletions packages/core/test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ describe('API Server', () => {
freeze_animated_image: true,
freezeImageBySelectors: ['.selector-per-screenshot'],
ignore_region_xpaths: ['/xpath-per-screenshot'],
consider_region_xpaths: ['/xpath-per-screenshot']
consider_region_xpaths: ['/xpath-per-screenshot'],
testCase: 'random test case',
thTestCaseExecutionId: 'random uuid'
}
},
method: 'post'
Expand All @@ -374,7 +376,9 @@ describe('API Server', () => {
ignoreRegionSelectors: ['.selector-global'],
ignoreRegionXpaths: ['/xpath-per-screenshot'],
considerRegionXpaths: ['/xpath-global', '/xpath-per-screenshot'],
version: 'v2'
version: 'v2',
testCase: 'random test case',
thTestCaseExecutionId: 'random uuid'
}
}));

Expand Down
2 changes: 2 additions & 0 deletions packages/webdriver-utils/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export default class WebdriverUtils {
comparisonData.metadata.cliScreenshotStartTime = startTime;
comparisonData.metadata.cliScreenshotEndTime = Date.now();
comparisonData.sync = options.sync;
comparisonData.testCase = options.testCase;
comparisonData.thTestCaseExecutionId = options.thTestCaseExecutionId;
log.debug(`[${snapshotName}] : Comparison Data: ${JSON.stringify(comparisonData)}`);
return comparisonData;
} catch (e) {
Expand Down

0 comments on commit 7daeb74

Please sign in to comment.