playwright-slack-report-burak 3.0.37 → 3.0.39

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.
@@ -18,9 +18,10 @@ try {
18
18
  AdmZip = null;
19
19
  }
20
20
 
21
- const SUMMARIES_DIR = path.join('./', 'playwright-report');
21
+ const SUMMARIES_DIR = path.join('./', 'playwright-artifacts');
22
22
  const NODE_ARTIFACTS_DIR = path.join(SUMMARIES_DIR, 'nodeArtifacts');
23
- const FINAL_OUTPUT_DIR = path.join('./', 'finalOutput');
23
+ const PLAYWRIGHT_REPORT_DIR = path.join('./', 'playwright-report');
24
+ const FINAL_OUTPUT_DIR = path.join('./', 'playwright-report');
24
25
 
25
26
  class ResultsParser {
26
27
  result;
@@ -339,38 +340,23 @@ class ResultsParser {
339
340
  }
340
341
 
341
342
  async fetchAllArtifacts() {
342
- // Ensure playwright-report directory exists
343
+ // Ensure summaries directory exists
343
344
  if (!fs.existsSync(SUMMARIES_DIR)) {
344
345
  fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
345
346
  }
346
347
 
347
- // Create nodeArtifacts directory under playwright-report
348
+ // Create nodeArtifacts directory under summaries
348
349
  if (!fs.existsSync(NODE_ARTIFACTS_DIR)) {
349
350
  fs.mkdirSync(NODE_ARTIFACTS_DIR, { recursive: true });
350
351
  }
351
352
 
352
- // Copy artifacts from node 1 to nodeArtifacts
353
- // Check multiple potential locations for node 1's blob file
354
- const possibleNode1BlobSources = [
355
- path.join(SUMMARIES_DIR, 'blob-report-node-1.zip'),
356
- path.join('./', 'blob-report-node-1.zip'),
357
- path.join(SUMMARIES_DIR, 'blob-report-1.zip'),
358
- ];
359
-
360
- const node1BlobDest = path.join(NODE_ARTIFACTS_DIR, 'blob-report-node-1.zip');
361
- let node1BlobCopied = false;
362
-
363
- for (const source of possibleNode1BlobSources) {
364
- if (fs.existsSync(source)) {
365
- fs.copyFileSync(source, node1BlobDest);
366
- console.log(`Copied ${source} to nodeArtifacts`);
367
- node1BlobCopied = true;
368
- break;
369
- }
370
- }
371
-
372
- if (!node1BlobCopied) {
373
- console.warn('Warning: blob-report-node-1.zip not found in expected locations');
353
+ // Copy entire contents of playwright-report to NODE_ARTIFACTS_DIR
354
+ const playwrightReportDir = path.join('./', 'playwright-report');
355
+ if (fs.existsSync(playwrightReportDir)) {
356
+ this.copyDirectoryRecursive(playwrightReportDir, NODE_ARTIFACTS_DIR);
357
+ console.log(`Copied entire contents of playwright-report to ${NODE_ARTIFACTS_DIR}`);
358
+ } else {
359
+ console.warn('Warning: playwright-report directory not found');
374
360
  }
375
361
 
376
362
  while (!this.allNodeSummaryFilesExist() || !this.allBlobZipsExist()) {
@@ -443,7 +429,7 @@ class ResultsParser {
443
429
 
444
430
  // Extract ZIP and find the specific file
445
431
  const zip = new AdmZip(downloadResponse.data);
446
- const zipEntry = zip.getEntry(file) || zip.getEntry(`playwright-report/${file}`);
432
+ const zipEntry = zip.getEntry(file) || zip.getEntry(`playwright-artifacts/${file}`);
447
433
 
448
434
  if (zipEntry) {
449
435
  fs.writeFileSync(filePath, zipEntry.getData());
@@ -471,38 +457,27 @@ class ResultsParser {
471
457
  mergeReports() {
472
458
  let breakMergeWaiter = false;
473
459
  try {
474
- // Ensure playwright-report directory exists
475
- if (!fs.existsSync(SUMMARIES_DIR)) {
476
- fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
477
- }
478
-
479
- // Create finalOutput directory under playwright-report
480
- if (!fs.existsSync(FINAL_OUTPUT_DIR)) {
481
- fs.mkdirSync(FINAL_OUTPUT_DIR, { recursive: true });
482
- }
483
460
 
484
- // Copy blob files before merging (Playwright merge-reports expects blob files)
485
- // We'll copy them to FINAL_OUTPUT_DIR for merging, then extract later for resource copying
486
-
487
- // Copy all blob zip files to FINAL_OUTPUT_DIR for merging
461
+ // Copy all blob files to playwright-report before merging
488
462
  for (let i = 1; i <= this.totalShardCount; i++) {
489
463
  const blobZipFile = path.join(NODE_ARTIFACTS_DIR, `blob-report-node-${i}.zip`);
490
464
  if (fs.existsSync(blobZipFile)) {
491
465
  try {
492
- const destFile = path.join(FINAL_OUTPUT_DIR, `blob-report-node-${i}.zip`);
466
+ const destFile = path.join(PLAYWRIGHT_REPORT_DIR, `blob-report-node-${i}.zip`);
493
467
  fs.copyFileSync(blobZipFile, destFile);
494
- console.log(`Copied blob-report-node-${i}.zip for merging`);
468
+ console.log(`Copied blob-report-node-${i}.zip to playwright-report for merging`);
495
469
  } catch (error) {
496
470
  console.warn(`Failed to copy blob-report-node-${i}.zip for merging:`, error.message);
497
471
  }
498
472
  }
499
473
  }
500
474
 
501
- // Execute the command to merge reports IN FINAL_OUTPUT_DIR
502
- exec(`npx playwright merge-reports --reporter html ${FINAL_OUTPUT_DIR}`);
475
+ // Execute the command to merge reports FROM playwright-report
476
+ // Playwright will output to playwright-report directory
477
+ exec(`npx playwright merge-reports --reporter html ${PLAYWRIGHT_REPORT_DIR}`);
503
478
 
504
- // Wait until index.html exists in finalOutput
505
- while (!fs.existsSync(path.join(FINAL_OUTPUT_DIR, 'index.html'))) {
479
+ // Wait until index.html exists in playwright-report
480
+ while (!fs.existsSync(path.join(PLAYWRIGHT_REPORT_DIR, 'index.html'))) {
506
481
  console.log('Waiting 2 seconds for merged html report to be generated...');
507
482
  const currentTime = new Date().getTime();
508
483
  breakMergeWaiter = false;
@@ -514,15 +489,34 @@ class ResultsParser {
514
489
  }
515
490
  console.log('Reports merged successfully.');
516
491
 
517
- // Once merge is complete, unzip all blobs in nodeArtifacts into separate folders
518
- this.unzipBlobsAndCopyResources(NODE_ARTIFACTS_DIR, FINAL_OUTPUT_DIR);
492
+ // After merge, extract all blobs from nodeArtifacts to playwright-report
493
+ this.unzipBlobsAndCopyResources(NODE_ARTIFACTS_DIR, PLAYWRIGHT_REPORT_DIR);
519
494
  } catch (error) {
520
495
  // Log a warning instead of throwing an error
521
496
  console.warn('Warning: Failed to merge reports. This may not affect the overall process.', error.message);
522
497
  }
523
498
  }
524
499
 
525
- unzipBlobsAndCopyResources(nodeArtifactsDir, finalOutputDir) {
500
+ copyDirectoryRecursive(srcDir, destDir) {
501
+ if (!fs.existsSync(destDir)) {
502
+ fs.mkdirSync(destDir, { recursive: true });
503
+ }
504
+
505
+ const entries = fs.readdirSync(srcDir, { withFileTypes: true });
506
+
507
+ for (const entry of entries) {
508
+ const srcPath = path.join(srcDir, entry.name);
509
+ const destPath = path.join(destDir, entry.name);
510
+
511
+ if (entry.isDirectory()) {
512
+ this.copyDirectoryRecursive(srcPath, destPath);
513
+ } else {
514
+ fs.copyFileSync(srcPath, destPath);
515
+ }
516
+ }
517
+ }
518
+
519
+ unzipBlobsAndCopyResources(NODE_ARTIFACTS_DIR, FINAL_OUTPUT_DIR) {
526
520
  if (!AdmZip) {
527
521
  console.error('adm-zip is required for blob extraction. Please install it: npm install adm-zip');
528
522
  return;
@@ -530,9 +524,9 @@ class ResultsParser {
530
524
 
531
525
  // Unzip all blob files in nodeArtifacts into separate folders
532
526
  for (let i = 1; i <= this.totalShardCount; i++) {
533
- const blobZipFile = path.join(nodeArtifactsDir, `blob-report-node-${i}.zip`);
527
+ const blobZipFile = path.join(NODE_ARTIFACTS_DIR, `blob-report-node-${i}.zip`);
534
528
  if (fs.existsSync(blobZipFile)) {
535
- const extractDir = path.join(nodeArtifactsDir, `node-${i}`);
529
+ const extractDir = path.join(NODE_ARTIFACTS_DIR, `node-${i}`);
536
530
  if (!fs.existsSync(extractDir)) {
537
531
  fs.mkdirSync(extractDir, { recursive: true });
538
532
  }
@@ -550,7 +544,7 @@ class ResultsParser {
550
544
 
551
545
  if (zipFiles.length > 0) {
552
546
  // Copy the resources folder to finalOutput
553
- const finalResourcesDir = path.join(finalOutputDir, 'resources');
547
+ const finalResourcesDir = path.join(FINAL_OUTPUT_DIR, 'resources');
554
548
  if (!fs.existsSync(finalResourcesDir)) {
555
549
  fs.mkdirSync(finalResourcesDir, { recursive: true });
556
550
  }
package/package.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "lint-fix": "npx eslint . --ext .ts --fix"
33
33
  },
34
34
  "name": "playwright-slack-report-burak",
35
- "version": "3.0.37",
35
+ "version": "3.0.39",
36
36
  "main": "index.js",
37
37
  "types": "dist/index.d.ts",
38
38
  "author": "Burak B. <burak.boluk@hotmail.com>",