Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(playwrighttesting): handling other attachments #31950

Merged
merged 6 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ class MPTReporter implements Reporter {
this.testResultBatch.add(testResultObject);
// Store test attachments in array
const testAttachments: string[] = [];
const regionAndSessionIdAttachment: any[] = [];
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
for (const attachment of result.attachments) {
if (attachment.name === "Region" || attachment.name === "SessionId") {
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
regionAndSessionIdAttachment.push(attachment);
this.uploadMetadata.numTotalAttachments++;
}
if (attachment.path !== undefined && attachment.path !== "") {
testAttachments.push(attachment.path);
this.uploadMetadata.numTotalAttachments++;
Expand All @@ -283,7 +288,11 @@ class MPTReporter implements Reporter {
const rawTestResult: RawTestResult = this.reporterUtils.getRawTestResultObject(result);
this.testRawResults.set(testResultObject.testExecutionId, JSON.stringify(rawTestResult));
this._testEndPromises.push(
this._uploadTestResultAttachments(testResultObject.testExecutionId, testAttachments),
this._uploadTestResultAttachments(
testResultObject.testExecutionId,
testAttachments,
regionAndSessionIdAttachment,
),
);
} catch (err: any) {
this._addError(`Name: ${err.name}, Message: ${err.message}, Stack: ${err.stack}`);
Expand Down Expand Up @@ -313,6 +322,7 @@ class MPTReporter implements Reporter {
private async _uploadTestResultAttachments(
testExecutionId: string,
testAttachments: string[],
regionAndSessionIdAttachment: any[],
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
): Promise<void> {
try {
this.isTestRunStartSuccess = await this.promiseOnBegin;
Expand All @@ -336,6 +346,20 @@ class MPTReporter implements Reporter {
}
await this.storageClient.uploadFile(this.sasUri.uri, attachmentPath, fileRelativePath);
}
for (const regionAndSessionId of regionAndSessionIdAttachment) {
if (
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
this.sasUri === undefined ||
!ReporterUtils.isTimeGreaterThanCurrentPlus10Minutes(this.sasUri)
) {
// Renew the sas uri
this.sasUri = await this.serviceClient.createStorageUri();
}
await this.storageClient.uploadBuffer(
kashish2508 marked this conversation as resolved.
Show resolved Hide resolved
this.sasUri.uri,
regionAndSessionId.body.toString("utf-8"),
`${testExecutionId}/${regionAndSessionId.name}.txt`,
);
}
const rawTestResult = this.testRawResults.get(testExecutionId);
if (
this.sasUri === undefined ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ class ReporterUtils {
attachmentStatus += ",";
}
attachmentStatus += "trace";
} else if (attachment.contentType === "text/plain") {
if (attachmentStatus !== "") {
attachmentStatus += ",";
}
attachmentStatus += "txt";
}
}
return attachmentStatus;
Expand Down
Loading