artes 1.4.13 → 1.5.0

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.
@@ -172,6 +172,15 @@ module.exports = {
172
172
  worldParameters: artesConfig.worldParameters || {}, // Custom world parameters
173
173
  },
174
174
  report: {
175
+ logo: process.env.LOGO
176
+ ? process.env.LOGO
177
+ : artesConfig?.logo || "./logo.png",
178
+ brandName: process.env.BRAND_NAME
179
+ ? process.env.BRAND_NAME
180
+ : artesConfig?.brandName || "ARTES",
181
+ reportName: process.env.REPORT_NAME
182
+ ? process.env.REPORT_NAME
183
+ : artesConfig?.reportName || "ARTES REPORT",
175
184
  singleFileReport:
176
185
  process.env.SINGLE_FILE_REPORT == "true"
177
186
  ? true
package/executer.js CHANGED
@@ -37,6 +37,9 @@ const flags = {
37
37
  trace: args.includes("-t") || args.includes("--trace"),
38
38
  reportWithTrace: args.includes("-rwt") || args.includes("--reportWithTrace"),
39
39
  singleFileReport: args.includes("--singleFileReport"),
40
+ customLogo: args.includes("--logo"),
41
+ customBrandName:args.includes("--brandName"),
42
+ customReportName:args.includes("--reportName"),
40
43
  zip: args.includes("--zip"),
41
44
  features: args.includes("--features"),
42
45
  stepDef: args.includes("--stepDef"),
@@ -63,6 +66,9 @@ const flags = {
63
66
 
64
67
  const env = getArgValue("--env");
65
68
  const vars = getArgValue("--saveVar");
69
+ const logo = getArgValue("--logo");
70
+ const brandName = getArgValue("--brandName");
71
+ const reportName = getArgValue("--reportName");
66
72
  const featureFiles = getArgValue("--features");
67
73
  const features = flags.features && featureFiles;
68
74
  const stepDef = getArgValue("--stepDef");
@@ -93,6 +99,10 @@ artesConfig.report
93
99
  ]))
94
100
  : "";
95
101
 
102
+ flags.customLogo ? (process.env.LOGO = logo) : "";
103
+ flags.customBrandName ? (process.env.BRAND_NAME = brandName) : "";
104
+ flags.customReportName ? (process.env.REPORT_NAME = reportName) : "";
105
+
96
106
  flags.reportSuccess ? (process.env.REPORT_SUCCESS = true) : "";
97
107
 
98
108
  flags.tags && console.log("Running tags:", tags);
@@ -443,10 +453,12 @@ if (fs.existsSync(source)) {
443
453
  ){
444
454
  const executor = getExecutor();
445
455
 
456
+ if(fs.existsSync(path.join(process.cwd(), "node_modules", "artes",'allure-result'))){
446
457
  fs.writeFileSync(
447
458
  path.join(process.cwd(), "node_modules", "artes",'allure-result',"executor.json"),
448
459
  JSON.stringify(executor, null, 2)
449
460
  );
461
+ }
450
462
 
451
463
  generateReport();
452
464
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.4.13",
3
+ "version": "1.5.0",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,97 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const CSS_START_MARKER = "/* ARTES_DYNAMIC_START */";
5
+ const CSS_END_MARKER = "/* ARTES_DYNAMIC_END */";
6
+
7
+ function reportCustomizer() {
8
+ delete require.cache[require.resolve("../../../cucumber.config.js")];
9
+ const cucumberConfig = require("../../../cucumber.config.js");
10
+
11
+ const report = cucumberConfig.report;
12
+ const today = new Date().toLocaleDateString("en-US", { month: "numeric", day: "numeric", year: "numeric" });
13
+ const reportName = typeof report.reportName === "string" ? report.reportName : report.reportName.name || "";
14
+
15
+ const logoSrc = path.resolve(process.cwd(), "node_modules", "artes", "assets", path.basename(report.logo));
16
+ const logoBase64 = fs.readFileSync(logoSrc).toString("base64");
17
+ const logoExt = path.extname(report.logo).replace(".", "");
18
+ const logoMime = logoExt === "svg" ? "image/svg+xml" : `image/${logoExt}`;
19
+ const logoDataUrl = `data:${logoMime};base64,${logoBase64}`;
20
+
21
+ if (cucumberConfig.report.singleFileReport) {
22
+ const htmlPath = path.resolve(__dirname, "../../../../../report/index.html");
23
+ const srcCssPath = path.resolve(__dirname, "../../../assets/styles.css");
24
+
25
+ const dynamicCss = generateCss(report, today, reportName, logoDataUrl);
26
+ const modifiedCss = injectCssAndReturn(srcCssPath, dynamicCss);
27
+ const cssBase64 = Buffer.from(modifiedCss).toString("base64");
28
+ const cssDataUrl = `data:text/css;base64,${cssBase64}`;
29
+
30
+ updateSingleFileHtml(htmlPath, report, reportName, logoDataUrl, cssDataUrl);
31
+
32
+ } else {
33
+ const htmlPath = path.resolve(__dirname, "../../../../../report/index.html");
34
+ const srcCssPath = path.resolve(__dirname, "../../../assets/styles.css");
35
+ const reportDir = path.resolve(__dirname, "../../../../../report");
36
+ const reportCssPath = path.join(reportDir, "styles.css");
37
+
38
+ const logoDest = path.join(reportDir, "logo.png");
39
+ fs.copyFileSync(logoSrc, logoDest);
40
+
41
+ const dynamicCss = generateCss(report, today, reportName, path.basename(report.logo));
42
+ injectCss(srcCssPath, dynamicCss);
43
+ fs.copyFileSync(srcCssPath, reportCssPath);
44
+
45
+ updateHtml(htmlPath, report, reportName, logoDataUrl);
46
+ }
47
+ }
48
+
49
+ function generateCss(report, today, reportName, logoUrl) {
50
+ return `.side-nav__brand{background:url('${logoUrl}') no-repeat center left !important;background-size:70px 70px !important;height:80px;width:200px;display:flex !important;align-items:center;padding-left:65px}.side-nav__brand img,.side-nav__brand svg{display:none !important}.side-nav__brand-text{font-size:0 !important;display:block !important;padding: 0 8px;}.side-nav__brand-text::after{content:'${report.brandName}';font-size:26px;color:white;}.widget__title{font-weight:lighter;margin-bottom:15px;margin-top:0;text-transform:uppercase}.widget__flex-line:first-child .widget__title{font-size:0}.widget__flex-line:first-child .widget__title::before{content:'${reportName} ${today}';font-size:18px;font-weight:lighter;text-transform:uppercase}.widget__flex-line:first-child .widget__subtitle{font-size:14px}.widget__flex-line:not(:first-child) .widget__title{font-size:inherit;font-weight:lighter}`;
51
+ }
52
+
53
+ function injectCssAndReturn(cssPath, dynamicCss) {
54
+ let css = fs.readFileSync(cssPath, "utf8");
55
+
56
+ const startIdx = css.indexOf(CSS_START_MARKER);
57
+ const endIdx = css.indexOf(CSS_END_MARKER);
58
+ if (startIdx !== -1 && endIdx !== -1) {
59
+ css = css.slice(0, startIdx) + css.slice(endIdx + CSS_END_MARKER.length);
60
+ }
61
+
62
+ css += `\n${CSS_START_MARKER}\n${dynamicCss}\n${CSS_END_MARKER}`;
63
+ return css;
64
+ }
65
+
66
+ function injectCss(cssPath, dynamicCss) {
67
+ const css = injectCssAndReturn(cssPath, dynamicCss);
68
+ fs.writeFileSync(cssPath, css, "utf8");
69
+ }
70
+
71
+ function updateSingleFileHtml(htmlPath, report, reportName, logoDataUrl, cssDataUrl) {
72
+ let html = fs.readFileSync(htmlPath, "utf8");
73
+
74
+ html = html.replace(/<title>.*?<\/title>/, `<title>ARTES REPORT</title>`);
75
+
76
+ html = html.replace(
77
+ /<link rel="icon" href="data:image\/[^"]+"/,
78
+ `<link rel="icon" href="${logoDataUrl}"`
79
+ );
80
+
81
+ html = html.replace(
82
+ /<link rel="stylesheet" type="text\/css" href="data:text\/css;base64,[^"]+"/,
83
+ `<link rel="stylesheet" type="text/css" href="${cssDataUrl}"`
84
+ );
85
+
86
+ fs.writeFileSync(htmlPath, html, "utf8");
87
+ }
88
+
89
+ function updateHtml(htmlPath, report, reportName, logoDataUrl) {
90
+ let html = fs.readFileSync(htmlPath, "utf8");
91
+ html = html.replace(/<title>.*?<\/title>/, `<title>ARTES REPORT</title>`);
92
+ html = html.replace(/<link rel="icon" href=".*?">/, `<link rel="icon" href="${logoDataUrl}">`);
93
+ fs.writeFileSync(htmlPath, html, "utf8");
94
+ }
95
+
96
+ module.exports = { reportCustomizer };
97
+
@@ -3,6 +3,7 @@ const path = require("path");
3
3
  const archiver = require("archiver");
4
4
  const { spawnSync } = require("child_process");
5
5
  const { moduleConfig } = require("../imports/commons");
6
+ const { reportCustomizer } = require("../../helper/controller/reportCustomizer");
6
7
 
7
8
  function generateReport() {
8
9
  try {
@@ -29,6 +30,8 @@ function generateReport() {
29
30
  `📋 Report generated successfully in ${moduleConfig.reportPath}!`,
30
31
  );
31
32
 
33
+ reportCustomizer();
34
+
32
35
  if (fs.existsSync(moduleConfig.reportPath) && process.env.ZIP === "true") {
33
36
  console.log(`🗜️ Zipping report folder...`);
34
37