@qualflare/cypress 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  // src/plugin/attachment-reader.ts
2
- import * as fs from "fs";
3
- import * as path from "path";
2
+ import * as fs2 from "fs";
3
+ import * as path2 from "path";
4
4
 
5
5
  // src/shared/logger.ts
6
6
  var PREFIX = "[qualflare-cypress]";
@@ -19,6 +19,46 @@ var logger = {
19
19
  }
20
20
  };
21
21
 
22
+ // src/plugin/video-uploader.ts
23
+ import * as fs from "fs";
24
+ import * as path from "path";
25
+ import { randomUUID } from "crypto";
26
+ var VIDEO_MIME_TYPES_BY_EXTENSION = {
27
+ ".mp4": "video/mp4",
28
+ ".webm": "video/webm",
29
+ ".mov": "video/quicktime"
30
+ };
31
+ function copyVideoAttachment(filePath, outputDir, maxVideoBytes) {
32
+ const ext = path.extname(filePath).toLowerCase();
33
+ const mimeType = VIDEO_MIME_TYPES_BY_EXTENSION[ext];
34
+ if (!mimeType) {
35
+ logger.warn(`skipping video attachment "${filePath}": unsupported video format.`);
36
+ return void 0;
37
+ }
38
+ let fileSize;
39
+ try {
40
+ fileSize = fs.statSync(filePath).size;
41
+ } catch (err) {
42
+ logger.warn(`skipping video attachment "${filePath}": could not stat file: ${err.message}`);
43
+ return void 0;
44
+ }
45
+ if (fileSize > maxVideoBytes) {
46
+ logger.warn(
47
+ `skipping video attachment "${filePath}": ${fileSize} bytes exceeds the configured maxVideoBytes cap of ${maxVideoBytes} bytes.`
48
+ );
49
+ return void 0;
50
+ }
51
+ const localVideoPath = `${randomUUID()}${ext}`;
52
+ try {
53
+ fs.mkdirSync(outputDir, { recursive: true });
54
+ fs.copyFileSync(filePath, path.join(outputDir, localVideoPath));
55
+ } catch (err) {
56
+ logger.warn(`skipping video attachment "${filePath}": could not copy file: ${err.message}`);
57
+ return void 0;
58
+ }
59
+ return { localVideoPath, fileSize, mimeType };
60
+ }
61
+
22
62
  // src/plugin/attachment-reader.ts
23
63
  var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".webm", ".mov", ".avi", ".mkv"]);
24
64
  var AttachmentBudget = class {
@@ -44,7 +84,7 @@ function isVideoLike(attachment) {
44
84
  if (attachment.mimeType?.toLowerCase().startsWith("video/")) {
45
85
  return true;
46
86
  }
47
- if (attachment.path && VIDEO_EXTENSIONS.has(path.extname(attachment.path).toLowerCase())) {
87
+ if (attachment.path && VIDEO_EXTENSIONS.has(path2.extname(attachment.path).toLowerCase())) {
48
88
  return true;
49
89
  }
50
90
  return false;
@@ -52,7 +92,7 @@ function isVideoLike(attachment) {
52
92
  function readAttachmentFile(filePath, maxAttachmentBytes, budget) {
53
93
  let size;
54
94
  try {
55
- size = fs.statSync(filePath).size;
95
+ size = fs2.statSync(filePath).size;
56
96
  } catch (err) {
57
97
  return { skipped: true, reason: `could not stat file: ${err.message}` };
58
98
  }
@@ -69,7 +109,7 @@ function readAttachmentFile(filePath, maxAttachmentBytes, budget) {
69
109
  };
70
110
  }
71
111
  try {
72
- const content = fs.readFileSync(filePath).toString("base64");
112
+ const content = fs2.readFileSync(filePath).toString("base64");
73
113
  return { skipped: false, content };
74
114
  } catch (err) {
75
115
  return { skipped: true, reason: `could not read file: ${err.message}` };
@@ -85,9 +125,20 @@ function resolveAttachments(attachments, config, budget) {
85
125
  const resolved = [];
86
126
  for (const attachment of attachments) {
87
127
  if (isVideoLike(attachment)) {
88
- logger.warn(
89
- `refusing to attach "${attachment.name}": video attachments are not supported yet (${attachment.path ?? attachment.mimeType ?? "unknown"}).`
90
- );
128
+ if (!attachment.path) {
129
+ logger.warn(`skipping video attachment "${attachment.name}": no local file path to copy.`);
130
+ continue;
131
+ }
132
+ const copied = copyVideoAttachment(attachment.path, config.outputDir, config.maxVideoBytes);
133
+ if (!copied) {
134
+ continue;
135
+ }
136
+ resolved.push({
137
+ ...attachment,
138
+ mimeType: copied.mimeType,
139
+ localVideoPath: copied.localVideoPath,
140
+ fileSize: copied.fileSize
141
+ });
91
142
  continue;
92
143
  }
93
144
  if (attachment.content !== void 0 || !attachment.path) {
@@ -104,228 +155,18 @@ function resolveAttachments(attachments, config, budget) {
104
155
  return resolved.length > 0 ? resolved : void 0;
105
156
  }
106
157
 
107
- // src/http/client.ts
108
- import { request } from "undici";
158
+ // src/plugin/events.ts
159
+ import * as fs3 from "fs";
160
+ import * as path3 from "path";
161
+ import { randomUUID as randomUUID2 } from "crypto";
109
162
 
110
163
  // src/shared/constants.ts
111
164
  var TASK_REPORT_CASE = "qualflareReportCase";
112
165
  var TASK_MARK_TEST_PHASE_STARTED = "qualflareMarkTestPhaseStarted";
113
- var HEADER_TOKEN = "QF_TOKEN";
114
- var HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
115
- var HEADER_CONTENT_TYPE = "Content-Type";
116
- var HEADER_ACCEPT = "Accept";
117
- var HEADER_USER_AGENT = "User-Agent";
118
166
  var MAX_SUITES_PER_LAUNCH = 2e3;
119
167
  var MAX_CASES_PER_SUITE = 5e3;
120
- var MAX_IDEMPOTENCY_KEY_CHARS = 255;
121
-
122
- // src/http/backoff.ts
123
- function computeDelay(attempt, baseDelayMs, maxDelayMs, retryAfterMs) {
124
- const exponential = baseDelayMs * 2 ** Math.max(0, attempt - 1);
125
- const jittered = Math.random() * Math.min(exponential, maxDelayMs);
126
- const floor = retryAfterMs !== void 0 ? retryAfterMs : 0;
127
- return Math.min(Math.max(jittered, floor), maxDelayMs);
128
- }
129
-
130
- // src/http/errors.ts
131
- function friendlyHint(code) {
132
- switch (code) {
133
- case "environment.not_found":
134
- return "Environment not found. Check the `environment` option or create it in Qualflare.";
135
- case "milestone.not_found":
136
- return "Milestone not found. Check the `milestone` option or its sequence number in Qualflare.";
137
- case "common.validation_failed":
138
- return "Validation failed. Check the request data below.";
139
- default:
140
- return void 0;
141
- }
142
- }
143
- function actionHint(statusCode) {
144
- switch (statusCode) {
145
- case 401:
146
- return "the configured token is missing or invalid \u2014 check `token`/QUALFLARE_TOKEN";
147
- case 403:
148
- return "the token lacks access to this project";
149
- case 402:
150
- return "a plan limit was reached \u2014 check your Qualflare subscription";
151
- default:
152
- return void 0;
153
- }
154
- }
155
- function renderFields(fields) {
156
- if (!fields || fields.length === 0) {
157
- return void 0;
158
- }
159
- return fields.map((f) => {
160
- const rule = f.rule ? ` (${f.rule})` : "";
161
- const msg = f.message ? `: ${f.message}` : "";
162
- return `${f.field}${rule}${msg}`;
163
- }).join("; ");
164
- }
165
- var QualflareApiError = class extends Error {
166
- code;
167
- statusCode;
168
- requestId;
169
- fields;
170
- constructor(init) {
171
- const parts = [init.message];
172
- const fieldsRendered = renderFields(init.fields);
173
- if (fieldsRendered) {
174
- parts.push(`fields: ${fieldsRendered}`);
175
- }
176
- const hint = actionHint(init.statusCode);
177
- if (hint) {
178
- parts.push(`(${hint})`);
179
- }
180
- if (init.requestId) {
181
- parts.push(`[request_id: ${init.requestId}]`);
182
- }
183
- super(parts.join(" \u2014 "), init.cause !== void 0 ? { cause: init.cause } : void 0);
184
- this.name = "QualflareApiError";
185
- this.code = init.code;
186
- this.statusCode = init.statusCode;
187
- this.requestId = init.requestId;
188
- this.fields = init.fields;
189
- }
190
- };
191
- function buildApiError(statusCode, body) {
192
- const code = body?.code;
193
- const message = body?.message || friendlyHint(code) || body?.error || `request failed with status ${statusCode}`;
194
- return new QualflareApiError({
195
- message,
196
- code,
197
- statusCode,
198
- requestId: body?.request_id,
199
- fields: body?.fields
200
- });
201
- }
202
-
203
- // src/http/idempotency.ts
204
- import { randomUUID } from "crypto";
205
- function newIdempotencyKey() {
206
- const key = randomUUID();
207
- if (key.length > MAX_IDEMPOTENCY_KEY_CHARS) {
208
- return key.slice(0, MAX_IDEMPOTENCY_KEY_CHARS);
209
- }
210
- return key;
211
- }
212
-
213
- // src/http/client.ts
214
- var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
215
- function redactToken(token) {
216
- return token.length > 0 ? "***REDACTED***" : "(none)";
217
- }
218
- var QualflareHttpClient = class {
219
- constructor(opts) {
220
- this.opts = opts;
221
- }
222
- opts;
223
- async send(collect) {
224
- const url = `${this.opts.endpoint.replace(/\/+$/, "")}/api/v1/collect`;
225
- const idempotencyKey = newIdempotencyKey();
226
- const body = JSON.stringify(collect);
227
- const maxAttempts = Math.max(1, this.opts.retry.max + 1);
228
- let lastError;
229
- for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
230
- if (this.opts.debug) {
231
- logger.debug(
232
- `POST ${url} (attempt ${attempt}/${maxAttempts}, QF_TOKEN: ${redactToken(this.opts.token)})`
233
- );
234
- }
235
- let statusCode;
236
- let responseBody;
237
- let responseHeaders;
238
- try {
239
- const res = await request(url, {
240
- method: "POST",
241
- headers: {
242
- [HEADER_TOKEN]: this.opts.token,
243
- [HEADER_CONTENT_TYPE]: "application/json",
244
- [HEADER_ACCEPT]: "application/json",
245
- [HEADER_USER_AGENT]: this.opts.userAgent,
246
- [HEADER_IDEMPOTENCY_KEY]: idempotencyKey
247
- },
248
- body,
249
- maxRedirections: 0,
250
- signal: AbortSignal.timeout(this.opts.timeoutMs)
251
- });
252
- statusCode = res.statusCode;
253
- responseHeaders = res.headers;
254
- responseBody = await res.body.text();
255
- } catch (err) {
256
- lastError = err;
257
- if (this.opts.debug) {
258
- logger.debug(`attempt ${attempt} transport error: ${err?.message ?? err}`);
259
- }
260
- if (attempt < maxAttempts) {
261
- await sleep(computeDelay(attempt, this.opts.retry.baseDelayMs, this.opts.retry.maxDelayMs));
262
- continue;
263
- }
264
- throw new QualflareApiError({
265
- message: `failed to send request to ${url}`,
266
- cause: err
267
- });
268
- }
269
- if (this.opts.debug) {
270
- logger.debug(`attempt ${attempt} response: ${statusCode}`);
271
- }
272
- if (statusCode >= 200 && statusCode < 300) {
273
- return parseSuccess(responseBody);
274
- }
275
- const parsedError = parseErrorBody(responseBody);
276
- if (!RETRYABLE_STATUS_CODES.has(statusCode) || attempt === maxAttempts) {
277
- throw buildApiError(statusCode, parsedError);
278
- }
279
- const retryAfterMs = parseRetryAfter(responseHeaders["retry-after"]);
280
- const delay = computeDelay(
281
- attempt,
282
- this.opts.retry.baseDelayMs,
283
- this.opts.retry.maxDelayMs,
284
- retryAfterMs
285
- );
286
- if (this.opts.debug) {
287
- logger.debug(`retrying after ${Math.round(delay)}ms (status ${statusCode})`);
288
- }
289
- await sleep(delay);
290
- }
291
- throw lastError instanceof Error ? lastError : new QualflareApiError({ message: "request failed for an unknown reason" });
292
- }
293
- };
294
- function parseSuccess(responseBody) {
295
- try {
296
- const parsed = JSON.parse(responseBody);
297
- if (typeof parsed.seq !== "number") {
298
- throw new Error('response body missing numeric "seq"');
299
- }
300
- return parsed;
301
- } catch (err) {
302
- throw new QualflareApiError({
303
- message: "server returned a success status but an unparseable body",
304
- cause: err
305
- });
306
- }
307
- }
308
- function parseErrorBody(responseBody) {
309
- if (!responseBody) {
310
- return void 0;
311
- }
312
- try {
313
- return JSON.parse(responseBody);
314
- } catch {
315
- return void 0;
316
- }
317
- }
318
- function parseRetryAfter(value) {
319
- const raw = Array.isArray(value) ? value[0] : value;
320
- if (!raw) {
321
- return void 0;
322
- }
323
- const seconds = Number(raw);
324
- return Number.isFinite(seconds) && seconds >= 0 ? seconds * 1e3 : void 0;
325
- }
326
- function sleep(ms) {
327
- return new Promise((resolve) => setTimeout(resolve, ms));
328
- }
168
+ var MAX_ATTACHMENTS_PER_CASE = 50;
169
+ var MAX_VIDEO_UPLOAD_BYTES = 50 * 1024 * 1024;
329
170
 
330
171
  // src/shared/duration.ts
331
172
  var NS_PER_MS = 1e6;
@@ -336,11 +177,13 @@ function msToNs(ms) {
336
177
  return Math.round(ms * NS_PER_MS);
337
178
  }
338
179
 
180
+ // src/plugin/collect-builder.ts
181
+ import * as os from "os";
182
+
339
183
  // src/plugin/version.ts
340
- var PACKAGE_VERSION = "0.1.0";
184
+ var PACKAGE_VERSION = "0.2.0";
341
185
 
342
186
  // src/plugin/collect-builder.ts
343
- import * as os from "os";
344
187
  function resolveOs(config, info) {
345
188
  if (config.os) {
346
189
  return config.os;
@@ -432,6 +275,7 @@ var PendingAttachmentQueue = class {
432
275
  };
433
276
 
434
277
  // src/plugin/events.ts
278
+ var FAILURE_STATUSES = /* @__PURE__ */ new Set(["failed", "error", "timeout"]);
435
279
  function registerEvents(on, config, buffer, pendingAttachments, testPhaseGate) {
436
280
  const accumulator = new LaunchAccumulator();
437
281
  let browserInfo;
@@ -447,7 +291,7 @@ function registerEvents(on, config, buffer, pendingAttachments, testPhaseGate) {
447
291
  on("after:screenshot", (details) => {
448
292
  if (!testPhaseGate.hasStarted()) {
449
293
  logger.warn(
450
- `a screenshot ("${details.name || "unnamed"}") was captured before any test in this spec had started (likely in a root \`before()\` hook) and cannot be attributed to a specific test \u2014 it was not uploaded.`
294
+ `a screenshot ("${details.name || "unnamed"}") was captured before any test in this spec had started (likely in a root \`before()\` hook) and cannot be attributed to a specific test \u2014 it was not included in the report.`
451
295
  );
452
296
  return;
453
297
  }
@@ -462,59 +306,77 @@ function registerEvents(on, config, buffer, pendingAttachments, testPhaseGate) {
462
306
  testPhaseGate.reset();
463
307
  buffer.drain();
464
308
  });
465
- on("after:spec", (spec, results) => {
309
+ on("after:spec", async (spec, results) => {
466
310
  const cases = buffer.drain();
311
+ if (results.video) {
312
+ const failedCase = cases.find((c) => FAILURE_STATUSES.has(c.status));
313
+ if (failedCase) {
314
+ const copied = copyVideoAttachment(results.video, config.outputDir, config.maxVideoBytes);
315
+ if (copied) {
316
+ attachVideo(failedCase, copied);
317
+ }
318
+ } else {
319
+ logger.info(`spec ${spec.relative} recorded a video but no test failed \u2014 not attached.`);
320
+ }
321
+ }
467
322
  const suite = {
468
323
  name: spec.relative,
469
- category: "e2e",
324
+ category: "cypress",
470
325
  duration: msToNs(results.stats.duration ?? Date.now() - currentSpecStart),
471
326
  timestamp: new Date(results.stats.startedAt ?? Date.now()).toISOString(),
472
327
  cases
473
328
  };
474
329
  if (cases.length !== results.stats.tests) {
475
330
  logger.warn(
476
- `spec ${spec.relative}: captured ${cases.length} case(s) but Cypress reported ${results.stats.tests} test(s) \u2014 some results may be missing from the uploaded report.`
331
+ `spec ${spec.relative}: captured ${cases.length} case(s) but Cypress reported ${results.stats.tests} test(s) \u2014 some results may be missing from the report.`
477
332
  );
478
333
  }
479
334
  accumulator.addSuite(suite);
480
335
  const orphaned = pendingAttachments.drain();
481
336
  if (orphaned.length > 0) {
482
337
  logger.warn(
483
- `spec ${spec.relative}: ${orphaned.length} screenshot(s) could not be attributed to a specific test (likely taken outside a test body, e.g. in an \`after\` hook) and were not uploaded.`
484
- );
485
- }
486
- if (results.video) {
487
- logger.info(
488
- `spec ${spec.relative} recorded a video at ${results.video} \u2014 not uploaded (qualflare-cypress does not support video attachments yet).`
338
+ `spec ${spec.relative}: ${orphaned.length} screenshot(s) could not be attributed to a specific test (likely taken outside a test body, e.g. in an \`after\` hook) and were not included in the report.`
489
339
  );
490
340
  }
491
341
  });
492
342
  on("after:run", async () => {
493
343
  const suites = accumulator.getSuites();
494
344
  if (suites.length === 0) {
495
- logger.info("no test results were captured this run \u2014 skipping upload.");
345
+ logger.info("no test results were captured this run \u2014 skipping file write.");
496
346
  return;
497
347
  }
498
348
  const collect = buildCollectPayload(accumulator, config, browserInfo);
499
- const client = new QualflareHttpClient({
500
- endpoint: config.apiEndpoint,
501
- token: config.token,
502
- timeoutMs: config.timeoutMs,
503
- retry: config.retry,
504
- userAgent: `qualflare-cypress/${PACKAGE_VERSION}`,
505
- debug: config.debug
506
- });
507
- try {
508
- const result = await client.send(collect);
509
- logger.info(`uploaded launch #${result.seq} to Qualflare.`);
510
- } catch (err) {
511
- logger.error(`failed to upload results to Qualflare: ${err.message}`);
512
- if (config.failOnUploadError) {
513
- throw err;
349
+ if (config.shardIndex !== void 0) {
350
+ for (const suite of collect.suites) {
351
+ for (const c of suite.cases) {
352
+ c.shardIndex = config.shardIndex;
353
+ }
514
354
  }
515
355
  }
356
+ fs3.mkdirSync(config.outputDir, { recursive: true });
357
+ const outputPath = path3.join(config.outputDir, `${randomUUID2()}.json`);
358
+ fs3.writeFileSync(outputPath, JSON.stringify(collect));
359
+ logger.info(`wrote Collect payload to ${outputPath} \u2014 run \`qualflare-cli collect ${config.outputDir}\` to upload it.`);
516
360
  });
517
361
  }
362
+ function attachVideo(testCase, copied) {
363
+ const attachments = testCase.attachments ?? [];
364
+ if (attachments.length >= MAX_ATTACHMENTS_PER_CASE) {
365
+ logger.warn(
366
+ `not attaching video to "${testCase.name}": already at the server's ${MAX_ATTACHMENTS_PER_CASE}-attachment-per-case cap.`
367
+ );
368
+ return;
369
+ }
370
+ testCase.attachments = [
371
+ ...attachments,
372
+ {
373
+ name: "video",
374
+ mimeType: copied.mimeType,
375
+ localVideoPath: copied.localVideoPath,
376
+ fileSize: copied.fileSize
377
+ }
378
+ ];
379
+ }
518
380
 
519
381
  // src/plugin/ci-detect.ts
520
382
  import * as ciInfo from "ci-info";
@@ -697,12 +559,8 @@ function resolveConfig(options, deps = {}) {
697
559
  const doDetectGit = deps.detectGit ?? detectGit;
698
560
  const doDetectCi = deps.detectCi ?? detectCi;
699
561
  const enabled = options.enabled ?? envBool("QUALFLARE_ENABLED") ?? true;
700
- const token = options.token ?? firstEnv2("QUALFLARE_TOKEN", "QF_TOKEN") ?? "";
701
- if (enabled && token === "") {
702
- throw new QualflareConfigError(
703
- "qualflare-cypress: no token configured. Set the `token` option or the QUALFLARE_TOKEN (or QF_TOKEN) environment variable, or pass `enabled: false` to disable this plugin."
704
- );
705
- }
562
+ const outputDir = options.outputDir || firstEnv2("QUALFLARE_OUTPUT_DIR") || "./qualflare-results";
563
+ const shardIndex = options.shardIndex ?? envInt("QUALFLARE_SHARD_INDEX");
706
564
  const milestoneRaw = options.milestone !== void 0 ? options.milestone : envInt("QUALFLARE_MILESTONE", "QF_MILESTONE");
707
565
  const milestone = milestoneRaw !== void 0 && milestoneRaw !== null && milestoneRaw >= 1 ? milestoneRaw : null;
708
566
  const envBranch = firstEnv2("QUALFLARE_BRANCH", "QF_BRANCH");
@@ -717,17 +575,14 @@ function resolveConfig(options, deps = {}) {
717
575
  const ciRunUrl = options.ciRunUrl ?? detectedCi.ciRunUrl;
718
576
  const ciPrNumber = options.ciPrNumber ?? detectedCi.ciPrNumber;
719
577
  return {
720
- token,
721
- apiEndpoint: options.apiEndpoint ?? firstEnv2("QUALFLARE_API_ENDPOINT") ?? "https://api.qualflare.com",
722
578
  // `||` (truthy check), not `??`, for these three REQUIRED-non-empty wire
723
579
  // fields — matching `collect-builder.ts`'s `resolveOs`/`resolveBrowser`,
724
580
  // which already correctly treat an explicit `''` option as "not set."
725
581
  // `??` only falls back on `null`/`undefined`, so `environment: ''` would
726
582
  // previously win outright over the `'development'` default, silently
727
583
  // 400ing the whole launch (the server rejects an empty `environment`)
728
- // and — since `failOnUploadError` defaults `false`failing the entire
729
- // upload with no visible error by default. Found via deep adversarial
730
- // self-review.
584
+ // and — since this process no longer attempts uploads — the error would
585
+ // be deferred until qualflare-cli tries to upload.
731
586
  environment: (options.environment || void 0) ?? firstEnv2("QUALFLARE_ENVIRONMENT", "QF_ENVIRONMENT") ?? "development",
732
587
  language: (options.language || void 0) ?? firstEnv2("QUALFLARE_LANGUAGE", "QF_LANGUAGE") ?? "en-US",
733
588
  milestone,
@@ -742,18 +597,13 @@ function resolveConfig(options, deps = {}) {
742
597
  ciBuildNumber,
743
598
  ciRunUrl,
744
599
  ciPrNumber,
745
- timeoutMs: options.timeoutMs ?? envInt("QUALFLARE_TIMEOUT_MS") ?? 12e4,
746
- retry: {
747
- max: options.retry?.max ?? envInt("QUALFLARE_RETRY_MAX", "QF_RETRY_MAX") ?? 3,
748
- baseDelayMs: options.retry?.baseDelayMs ?? envInt("QUALFLARE_RETRY_BASE_DELAY_MS") ?? 1e3,
749
- maxDelayMs: options.retry?.maxDelayMs ?? envInt("QUALFLARE_RETRY_MAX_DELAY_MS") ?? 3e4
750
- },
751
- failOnUploadError: options.failOnUploadError ?? envBool("QUALFLARE_FAIL_ON_UPLOAD_ERROR") ?? false,
752
600
  attachScreenshots: options.attachScreenshots ?? envBool("QUALFLARE_ATTACH_SCREENSHOTS") ?? true,
753
601
  maxAttachmentBytes: options.maxAttachmentBytes ?? envInt("QUALFLARE_MAX_ATTACHMENT_BYTES") ?? 15e5,
754
602
  maxTotalAttachmentBytes: options.maxTotalAttachmentBytes ?? envInt("QUALFLARE_MAX_TOTAL_ATTACHMENT_BYTES") ?? 75e4,
755
- debug: options.debug ?? envBool("QUALFLARE_DEBUG", "QF_DEBUG") ?? false,
756
- enabled
603
+ maxVideoBytes: options.maxVideoBytes ?? envInt("QUALFLARE_MAX_VIDEO_BYTES") ?? MAX_VIDEO_UPLOAD_BYTES,
604
+ enabled,
605
+ outputDir,
606
+ shardIndex
757
607
  };
758
608
  }
759
609
 
@@ -785,9 +635,9 @@ var CaseBuffer = class {
785
635
  };
786
636
  function registerTasks(on, buffer, attachmentConfig, attachmentBudget, pendingAttachments, testPhaseGate) {
787
637
  on("task", {
788
- [TASK_REPORT_CASE](testCase) {
638
+ async [TASK_REPORT_CASE](testCase) {
789
639
  const attachments = [...testCase.attachments ?? [], ...pendingAttachments.drain()];
790
- const resolved = resolveAttachments(
640
+ const resolved = await resolveAttachments(
791
641
  attachments.length > 0 ? attachments : void 0,
792
642
  attachmentConfig,
793
643
  attachmentBudget
@@ -812,7 +662,8 @@ function qualflareCypress(on, config, options = {}) {
812
662
  const pendingAttachments = new PendingAttachmentQueue();
813
663
  const testPhaseGate = new TestPhaseGate();
814
664
  const attachmentBudget = new AttachmentBudget(resolved.maxTotalAttachmentBytes);
815
- registerTasks(on, buffer, resolved, attachmentBudget, pendingAttachments, testPhaseGate);
665
+ const attachmentConfig = resolved;
666
+ registerTasks(on, buffer, attachmentConfig, attachmentBudget, pendingAttachments, testPhaseGate);
816
667
  if (resolved.enabled) {
817
668
  registerEvents(on, resolved, buffer, pendingAttachments, testPhaseGate);
818
669
  }