Skip to content

Commit 00ae134

Browse files
maria-hambardzumianmaria-hambardzumian
andauthored
EPMRPP-104898 || Add semantic names for playwright test artefacts (#177)
Co-authored-by: maria-hambardzumian <maria_hambardzumyan@gmail.com>
1 parent c1e8c63 commit 00ae134

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/reporter.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,14 @@ export class RPReporter implements Reporter {
479479
// TODO: cover with tests
480480
if (result.attachments?.length) {
481481
const { uploadVideo, uploadTrace } = this.config;
482-
const attachmentsFiles = await getAttachments(result.attachments, {
483-
uploadVideo,
484-
uploadTrace,
485-
});
486-
482+
const attachmentsFiles = await getAttachments(
483+
result.attachments,
484+
{
485+
uploadVideo,
486+
uploadTrace,
487+
},
488+
test.title,
489+
);
487490
// TODO: use bulk log request
488491
attachmentsFiles.forEach((file) => {
489492
this.sendLog(testItemId, {

src/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export const fileExists = async (filePath: string) => {
109109
export const getAttachments = async (
110110
attachments: TestResult['attachments'],
111111
{ uploadTrace, uploadVideo }: AttachmentsConfig = { uploadTrace: true, uploadVideo: true },
112+
testTitle?: string,
112113
): Promise<Attachment[]> => {
113114
const isTraceNotAllowed = isFalse(uploadTrace);
114115
const isVideoNotAllowed = isFalse(uploadVideo);
@@ -146,9 +147,16 @@ export const getAttachments = async (
146147
console.error(e);
147148
return;
148149
}
150+
const attachmentName = testTitle
151+
? testTitle
152+
.toLowerCase()
153+
.replace(/[^a-z0-9 _-]/g, '')
154+
.replace(/\s+/g, '-')
155+
.concat('_', name)
156+
: name;
149157

150158
return {
151-
name,
159+
name: attachmentName,
152160
type: contentType,
153161
content: fileContent,
154162
};

0 commit comments

Comments
 (0)