From e4c3bea85f6921ef7d5d4bcd18a90289124bfe9d Mon Sep 17 00:00:00 2001 From: rishigupta1599 Date: Fri, 20 Dec 2024 02:25:25 +0530 Subject: [PATCH] Adding prodBuild param for scanner alt env --- packages/client/src/client.js | 3 +- packages/client/test/client.test.js | 45 +++++++++++++++++++++++++++++ packages/core/src/config.js | 4 +++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/packages/client/src/client.js b/packages/client/src/client.js index 6e8beca41..9aa087687 100644 --- a/packages/client/src/client.js +++ b/packages/client/src/client.js @@ -172,7 +172,8 @@ export class PercyClient { partial: this.env.partial, tags: tagsArr, 'cli-start-time': cliStartTime, - source: source + source: source, + 'prod-build': this.config.percy?.prodBuild }, relationships: { resources: { diff --git a/packages/client/test/client.test.js b/packages/client/test/client.test.js index c7299cfaa..7e00b4526 100644 --- a/packages/client/test/client.test.js +++ b/packages/client/test/client.test.js @@ -150,6 +150,10 @@ describe('PercyClient', () => { describe('#createBuild()', () => { let cliStartTime = new Date().toISOString(); + beforeEach(() => { + delete process.env.PERCY_AUTO_ENABLED_GROUP_BUILD; + }); + it('creates a new build', async () => { await expectAsync(client.createBuild()).toBeResolvedTo({ data: { @@ -384,6 +388,47 @@ describe('PercyClient', () => { } })); }); + + it('creates a new build with prodBuild config', async () => { + client = new PercyClient({ + token: 'PERCY_TOKEN', + config: { percy: { prodBuild: true } } + }); + await expectAsync(client.createBuild({ projectType: 'web' })).toBeResolvedTo({ + data: { + id: '123', + attributes: { + 'build-number': 1, + 'web-url': 'https://percy.io/test/test/123' + } + } + }); + + expect(api.requests['/builds'][0].body.data) + .toEqual(jasmine.objectContaining({ + attributes: { + branch: client.env.git.branch, + type: 'web', + 'target-branch': client.env.target.branch, + 'target-commit-sha': client.env.target.commit, + 'commit-sha': client.env.git.sha, + 'commit-committed-at': client.env.git.committedAt, + 'commit-author-name': client.env.git.authorName, + 'commit-author-email': client.env.git.authorEmail, + 'commit-committer-name': client.env.git.committerName, + 'commit-committer-email': client.env.git.committerEmail, + 'commit-message': client.env.git.message, + 'pull-request-number': client.env.pullRequest, + 'parallel-nonce': client.env.parallel.nonce, + 'parallel-total-shards': client.env.parallel.total, + 'cli-start-time': null, + source: 'user_created', + partial: client.env.partial, + 'prod-build': true, + tags: [] + } + })); + }); }); describe('#getBuild()', () => { diff --git a/packages/core/src/config.js b/packages/core/src/config.js index e0eae19e5..c56f93511 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -16,6 +16,10 @@ export const configSchema = { }, labels: { type: 'string' + }, + prodBuild: { + type: 'boolean', + default: false } } },