Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import { request } from '@playwright/test';
import type { FullConfig, Reporter /*, FullResult, Suite */ } from '@playwright/test/reporter';
import { type UUID } from 'crypto';
import { execSync } from 'child_process';

// reporter: [
// ['reporter-playwright-reports-server', {
Expand Down Expand Up @@ -40,6 +41,26 @@ type ReporterOptions = {
triggerReportGeneration: boolean;
};

// Function to get user information
const getUsername = () => {
let username = process.env.QA_USERNAME || '';

if (username) {
return username;
}

try {
const gitUser = execSync('git config user.name', { encoding: 'utf8' }).trim();
if (gitUser) {
return gitUser;
}
} catch (error) {
// Git config not available, continue with system user
}

return '';
};

const DEFAULT_OPTIONS: Omit<ReporterOptions, 'url' | 'reportPath'> = {
enabled: true,
resultDetails: {},
Expand Down Expand Up @@ -101,6 +122,12 @@ class ReporterPlaywrightReportsServer implements Reporter {
Object.entries(this.rpOptions.resultDetails).map(([key, value]) => [key, value ?? '']),
);

// Add username to result details if not already provided
if (!clearedResDetails.username) {
const username = getUsername();
if (username) clearedResDetails.username = username;
}

const version = this.pwConfig.version ?? '';

const url = this.rpOptions.url.endsWith('/') ? this.rpOptions.url.slice(0, -1) : this.rpOptions.url;
Expand Down Expand Up @@ -131,6 +158,7 @@ class ReporterPlaywrightReportsServer implements Reporter {
size: string;
sizeBytes: number;
generatedReport: { reportId: string; reportUrl: string; metadata: { title: string; project: string } } | null;
username?: string;
} = (await resp.json()).data;

console.debug('[ReporterPlaywrightReportsServer] blob result uploaded: ', resultResponse);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cyborgtests/reporter-playwright-reports-server",
"version": "2.3.3",
"version": "2.3.4",
"description": "Reporter that uploads your blob reports to playwright reports server https://github.com/CyborgTests/playwright-reports-server",
"main": "index.js",
"repository": {
Expand Down
Loading