Skip to content

Commit

Permalink
make sure that the same recording is not uloaded more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Jun 19, 2024
1 parent be5d659 commit 8a2f377
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/test-utils/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,14 @@ class ReplayReporter<TRecordingMetadata extends UnstructuredMetadata = Unstructu
private _runner: TestRunner;
private _errors: ReporterError[] = [];
private _apiKey?: string;
private _pendingWork: Promise<PendingWork>[] = [];
private _pendingWork: Promise<PendingWork | undefined>[] = [];
private _upload = false;
private _filter?: (r: RecordingEntry<TRecordingMetadata>) => boolean;
private _minimizeUploads = false;
private _uploadableResults: Map<string, UploadableTestResult<TRecordingMetadata>> = new Map();
private _testRunShardIdPromise: Promise<TestRunPendingWork> | null = null;
private _uploadStatusThreshold: UploadStatusThresholdInternal = "none";
private _uploadedRecordings = new Set<string>();

constructor(
runner: TestRunner,
Expand Down Expand Up @@ -688,7 +689,13 @@ class ReplayReporter<TRecordingMetadata extends UnstructuredMetadata = Unstructu

private async _uploadRecording(
recording: RecordingEntry<TRecordingMetadata>
): Promise<UploadPendingWork> {
): Promise<UploadPendingWork | undefined> {
// Cypress retries are on the same recordings, we only want to upload a single recording once
if (this._uploadedRecordings.has(recording.id)) {
debug("Recording %s was already scheduled to be uploaded", recording.id);
return;
}
this._uploadedRecordings.add(recording.id);
debug("Starting upload of %s", recording.id);

try {
Expand Down Expand Up @@ -1068,7 +1075,7 @@ class ReplayReporter<TRecordingMetadata extends UnstructuredMetadata = Unstructu
debug("onEnd");

const output: string[] = [];
let completedWork: PromiseSettledResult<PendingWork>[] = [];
let completedWork: PromiseSettledResult<PendingWork | undefined>[] = [];

if (this._pendingWork.length) {
log("🕑 Completing some outstanding work ...");
Expand Down Expand Up @@ -1099,7 +1106,9 @@ class ReplayReporter<TRecordingMetadata extends UnstructuredMetadata = Unstructu
}

const results = completedWork
.filter((r): r is PromiseFulfilledResult<PendingWork> => r.status === "fulfilled")
.filter(
(r): r is PromiseFulfilledResult<PendingWork> => r.status === "fulfilled" && !!r.value
)
.map(r => r.value);

const errors = {
Expand Down

0 comments on commit 8a2f377

Please sign in to comment.