Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/client/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: {
Expand Down
16 changes: 16 additions & 0 deletions packages/client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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: {
Expand Down
Loading