diff --git a/packages/client/src/client.js b/packages/client/src/client.js index 26443d539..a4aa6f396 100644 --- a/packages/client/src/client.js +++ b/packages/client/src/client.js @@ -326,6 +326,12 @@ export class PercyClient { let tagsArr = tagsList(this.labels); + // PER-9724: internal-only priority request. Set by internal product + // orchestration (e.g. Scanner / LCA) via PERCY_PRIORITY; mirrors the + // PERCY_ORIGINATED_SOURCE internal signal above. percy-api only honors this + // for eligible internal build types, so it is a no-op for customer builds. + let priority = process.env.PERCY_PRIORITY === 'true'; + return this.post('builds', { data: { type: 'builds', @@ -351,7 +357,8 @@ export class PercyClient { 'skip-base-build': this.config.percy?.skipBaseBuild, 'testhub-build-uuid': this.env.testhubBuildUuid, 'testhub-build-run-id': this.env.testhubBuildRunId, - ...(visualConfig ? { 'visual-config': visualConfig } : {}) + ...(visualConfig ? { 'visual-config': visualConfig } : {}), + ...(priority ? { priority: true } : {}) }, relationships: { resources: { diff --git a/packages/client/test/client.test.js b/packages/client/test/client.test.js index 0527dc820..54406c81b 100644 --- a/packages/client/test/client.test.js +++ b/packages/client/test/client.test.js @@ -199,6 +199,7 @@ describe('PercyClient', () => { delete process.env.PERCY_AUTO_ENABLED_GROUP_BUILD; delete process.env.PERCY_ORIGINATED_SOURCE; delete process.env.PERCY_VISUAL_CONFIG; + delete process.env.PERCY_PRIORITY; }); it('creates a new build', async () => { @@ -238,6 +239,21 @@ describe('PercyClient', () => { })); }); + it('sends priority: true when PERCY_PRIORITY is set (internal signal)', async () => { + process.env.PERCY_PRIORITY = 'true'; + + await client.createBuild(); + + expect(api.requests['/builds'][0].body.data.attributes) + .toEqual(jasmine.objectContaining({ priority: true })); + }); + + it('does not send a priority attribute when PERCY_PRIORITY is unset', async () => { + await client.createBuild(); + + expect(api.requests['/builds'][0].body.data.attributes.priority).toBeUndefined(); + }); + it('creates a new build with projectType passed as null', async () => { await expectAsync(client.createBuild({ projectType: null })).toBeResolvedTo({ data: {