Skip to content

Commit 43c4f35

Browse files
committed
changes for threshold
1 parent 1a66531 commit 43c4f35

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

src/lib/ctx.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ export default (options: Record<string, string>): Context => {
132132
requestHeaders: config.requestHeaders || {},
133133
allowDuplicateSnapshotNames: allowDuplicateSnapshotNames,
134134
useLambdaInternal: useLambdaInternal,
135+
approvalThreshold: config.approvalThreshold,
136+
rejectionThreshold: config.rejectionThreshold,
135137
},
136138
uploadFilePath: '',
137139
webStaticConfig: [],

src/lib/httpClient.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -343,24 +343,33 @@ export default class httpClient {
343343
}, ctx.log)
344344
}
345345

346-
processSnapshot(ctx: Context, snapshot: ProcessedSnapshot, snapshotUuid: string, discoveryErrors: DiscoveryErrors, variantCount: number, sync: boolean = false) {
346+
processSnapshot(ctx: Context, snapshot: ProcessedSnapshot, snapshotUuid: string, discoveryErrors: DiscoveryErrors, variantCount: number, sync: boolean = false, approvalThreshold: number| undefined, rejectionThreshold: number| undefined) {
347+
const requestData: any = {
348+
name: snapshot.name,
349+
url: snapshot.url,
350+
snapshotUuid: snapshotUuid,
351+
variantCount: variantCount,
352+
test: {
353+
type: ctx.testType,
354+
source: 'cli'
355+
},
356+
discoveryErrors: discoveryErrors,
357+
doRemoteDiscovery: snapshot.options.doRemoteDiscovery,
358+
sync: sync
359+
};
360+
361+
if (approvalThreshold !== undefined) {
362+
requestData.approvalThreshold = approvalThreshold;
363+
}
364+
if (rejectionThreshold !== undefined) {
365+
requestData.rejectionThreshold = rejectionThreshold;
366+
}
367+
347368
return this.request({
348369
url: `/build/${ctx.build.id}/snapshot`,
349370
method: 'POST',
350371
headers: { 'Content-Type': 'application/json' },
351-
data: {
352-
name: snapshot.name,
353-
url: snapshot.url,
354-
snapshotUuid: snapshotUuid,
355-
variantCount: variantCount,
356-
test: {
357-
type: ctx.testType,
358-
source: 'cli'
359-
},
360-
doRemoteDiscovery: snapshot.options.doRemoteDiscovery,
361-
discoveryErrors: discoveryErrors,
362-
sync: sync
363-
}
372+
data: requestData
364373
}, ctx.log)
365374
}
366375

src/lib/snapshotQueue.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,9 @@ export default class Queue {
427427
}
428428
this.processNext();
429429
} else {
430-
await this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors,calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config),snapshot?.options?.sync);
430+
let approvalThreshold = snapshot?.options?.approvalThreshold || this.ctx.config.approvalThreshold;
431+
let rejectionThreshold = snapshot?.options?.rejectionThreshold || this.ctx.config.rejectionThreshold;
432+
await this.ctx.client.processSnapshot(this.ctx, processedSnapshot, snapshotUuid, discoveryErrors,calculateVariantCountFromSnapshot(processedSnapshot, this.ctx.config),snapshot?.options?.sync, approvalThreshold, rejectionThreshold);
431433
if(snapshot?.options?.contextId && this.ctx.contextToSnapshotMap?.has(snapshot.options.contextId)){
432434
this.ctx.contextToSnapshotMap.set(snapshot.options.contextId, 1);
433435
}

src/types.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export interface Context {
3838
requestHeaders?: Array<Record<string, string>>;
3939
allowDuplicateSnapshotNames?: boolean;
4040
useLambdaInternal?: boolean;
41+
approvalThreshold?: number;
42+
rejectionThreshold?: number;
4143
};
4244
uploadFilePath: string;
4345
webStaticConfig: WebStaticConfig;
@@ -148,9 +150,11 @@ export interface Snapshot {
148150
},
149151
loadDomContent?: boolean;
150152
ignoreType?: string[],
151-
sessionId?: string
152-
sync?: boolean;
153-
contextId?: string;
153+
sessionId?: string,
154+
sync?: boolean,
155+
contextId?: string,
156+
approvalThreshold?: number,
157+
rejectionThreshold?: number
154158
}
155159
}
156160

0 commit comments

Comments
 (0)