Skip to content

Commit e67c290

Browse files
fetch results support and rebased code
1 parent db96d96 commit e67c290

File tree

7 files changed

+131
-59
lines changed

7 files changed

+131
-59
lines changed

src/lib/ctx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default (options: Record<string, string>): Context => {
132132
cliVersion: version,
133133
totalSnapshots: -1,
134134
isStartExec: false,
135-
isSnapshotCaptured: false
135+
isSnapshotCaptured: false,
136136
sessionCapabilitiesMap: new Map<string, any[]>(),
137137
sessionToBuildMap: new Map<string, string>(),
138138
buildToSnapshotCountMap: new Map<string, number>(),

src/lib/httpClient.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,28 @@ export default class httpClient {
255255
}
256256
}, ctx.log)
257257
}
258+
259+
processSnapshotCaps(ctx: Context, snapshot: ProcessedSnapshot, snapshotUuid: string, capsBuildId: string, capsProjectToken: string) {
260+
return this.request({
261+
url: `/build/${capsBuildId}/snapshot`,
262+
method: 'POST',
263+
headers: {
264+
'Content-Type': 'application/json',
265+
projectToken: capsProjectToken !== '' ? capsProjectToken : this.projectToken
266+
},
267+
data: {
268+
name: snapshot.name,
269+
url: snapshot.url,
270+
snapshotUuid: snapshotUuid,
271+
test: {
272+
type: ctx.testType,
273+
source: 'cli'
274+
},
275+
async: false,
276+
}
277+
}, ctx.log)
278+
}
279+
258280
uploadSnapshotForCaps(ctx: Context, snapshot: ProcessedSnapshot, capsBuildId: string, capsProjectToken: string) {
259281
// Use capsBuildId if provided, otherwise fallback to ctx.build.id
260282
const buildId = capsBuildId !== '' ? capsBuildId : ctx.build.id;
@@ -371,6 +393,22 @@ export default class httpClient {
371393
}, ctx.log)
372394
}
373395

396+
getS3PresignedURLForSnapshotUploadCaps(ctx: Context, snapshotName: string, snapshotUuid: string, capsBuildId: string, capsProjectToken: string) {
397+
return this.request({
398+
url: `/snapshotuploadurl`,
399+
method: 'POST',
400+
headers: {
401+
'Content-Type': 'application/json',
402+
projectToken: capsProjectToken !== '' ? capsProjectToken : this.projectToken
403+
},
404+
data: {
405+
buildId: capsBuildId,
406+
snapshotName: snapshotName,
407+
snapshotUuid: snapshotUuid
408+
}
409+
}, ctx.log)
410+
}
411+
374412
uploadLogs(ctx: Context, uploadURL: string) {
375413
const fileStream = fs.createReadStream(constants.LOG_FILE_PATH);
376414
const { size } = fs.statSync(constants.LOG_FILE_PATH);
@@ -401,6 +439,20 @@ export default class httpClient {
401439
}, ctx.log)
402440
}
403441

442+
uploadSnapshotToS3Caps(ctx: Context, uploadURL: string, snapshot: Snapshot, capsProjectToken: string) {
443+
return this.request({
444+
url: uploadURL,
445+
method: 'PUT',
446+
headers: {
447+
'Content-Type': 'application/json',
448+
projectToken: capsProjectToken !== '' ? capsProjectToken : this.projectToken
449+
},
450+
data: snapshot,
451+
maxBodyLength: Infinity, // prevent axios from limiting the body size
452+
maxContentLength: Infinity, // prevent axios from limiting the content size
453+
}, ctx.log)
454+
}
455+
404456
processWebFigma(requestBody: any, log: Logger) {
405457
return this.request({
406458
url: "figma-web/upload",

src/lib/schemaValidation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ const ConfigSchema = {
168168
useGlobalCache: {
169169
type: "boolean",
170170
errorMessage: "Invalid config; useGlobalCache must be true/false"
171+
},
171172
skipBuildCreation: {
172173
type: "boolean",
173174
errorMessage: "Invalid config; skipBuildCreation must be true/false"

src/lib/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
7272
startPolling(ctx, capsBuildId, is_baseline, fetchedCapabilitiesResp.projectToken)
7373
}
7474
}
75+
console.log(`fetch caps for sessionId: ${sessionId} are ${JSON.stringify(fetchedCapabilitiesResp)}`)
7576
} catch (error: any) {
7677
// console.log(`Failed to fetch capabilities for sessionId ${sessionId}: ${error.message}`);
7778
}

0 commit comments

Comments
 (0)