@arghajit/dummy 0.1.0-beta-10 → 0.1.0-beta-12

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.
@@ -113,7 +113,7 @@ class PlaywrightPulseReporter {
113
113
  const project = (_a = test.parent) === null || _a === void 0 ? void 0 : _a.project(); // project() can return undefined if not in a project context
114
114
  const projectConfig = project === null || project === void 0 ? void 0 : project.use; // This is where options like userAgent, defaultBrowserType are
115
115
  const userAgent = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.userAgent;
116
- const configuredBrowserType = (_b = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.defaultBrowserType) === null || _b === void 0 ? void 0 : _b.toLowerCase();
116
+ const configuredBrowserType = (_b = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.browserName) === null || _b === void 0 ? void 0 : _b.toLowerCase();
117
117
  const parser = new ua_parser_js_1.UAParser(userAgent);
118
118
  const result = parser.getResult();
119
119
  let browserName = result.browser.name;
@@ -382,7 +382,7 @@ class PlaywrightPulseReporter {
382
382
  }
383
383
  const runEndTime = Date.now();
384
384
  const duration = runEndTime - this.runStartTime;
385
- const runId = `run-${this.runStartTime}-${(0, crypto_1.randomUUID)()}`;
385
+ const runId = `run-${this.runStartTime}-581d5ad8-ce75-4ca5-94a6-ed29c466c815`; // Need not to change
386
386
  const runData = {
387
387
  id: runId,
388
388
  timestamp: new Date(this.runStartTime),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arghajit/dummy",
3
3
  "author": "Arghajit Singha",
4
- "version": "0.1.0-beta-10",
4
+ "version": "0.1.0-beta-12",
5
5
  "description": "A Playwright reporter and dashboard for visualizing test results.",
6
6
  "keywords": [
7
7
  "playwright",
@@ -58,7 +58,8 @@
58
58
  "recharts": "^2.15.1",
59
59
  "ua-parser-js": "^2.0.3",
60
60
  "zod": "^3.24.2",
61
- "lucide-react": "^0.475.0"
61
+ "lucide-react": "^0.475.0",
62
+ "node-fetch": "^3.3.2"
62
63
  },
63
64
  "devDependencies": {
64
65
  "@types/node": "^20",
@@ -1065,113 +1065,97 @@ function generateHTML(reportData, trendData = null) {
1065
1065
  : ""
1066
1066
  }
1067
1067
 
1068
- ${(() => {
1069
- if (
1070
- !test.screenshots ||
1071
- test.screenshots.length === 0
1072
- )
1073
- return "";
1074
-
1075
- // Define base output directory to resolve relative screenshot paths
1076
- // This assumes screenshot paths in your JSON are relative to DEFAULT_OUTPUT_DIR
1077
- const baseOutputDir = path.resolve(
1078
- process.cwd(),
1079
- DEFAULT_OUTPUT_DIR
1080
- );
1081
-
1082
- // Helper to escape HTML special characters (safer than the global sanitizeHTML)
1083
- const escapeHTML = (str) => {
1084
- if (str === null || str === undefined) return "";
1085
- return String(str).replace(
1086
- /[&<>"']/g,
1087
- (match) => {
1088
- const replacements = {
1089
- "&": "&",
1090
- "<": "<",
1091
- ">": ">",
1092
- '"': '"',
1093
- "'": "'",
1094
- };
1095
- return replacements[match] || match;
1096
- }
1097
- );
1098
- };
1099
-
1100
- const renderScreenshot = (
1101
- screenshotPathOrData,
1102
- index
1103
- ) => {
1104
- let base64ImageData = "";
1105
- const uniqueSuffix = `${Date.now()}-${index}-${Math.random()
1106
- .toString(36)
1107
- .substring(2, 7)}`;
1108
-
1109
- try {
1110
- if (
1111
- typeof screenshotPathOrData === "string" &&
1112
- !screenshotPathOrData.startsWith("data:image")
1113
- ) {
1114
- // It's likely a file path, try to read and convert
1115
- const imagePath = path.resolve(
1116
- baseOutputDir,
1117
- screenshotPathOrData
1118
- );
1119
-
1120
- if (fsExistsSync(imagePath)) {
1121
- // Use imported fsExistsSync
1122
- const imageBuffer = readFileSync(imagePath); // Use imported readFileSync
1123
- base64ImageData =
1124
- imageBuffer.toString("base64");
1125
- } else {
1126
- console.warn(
1127
- chalk.yellow(
1128
- `[Reporter] Screenshot file not found: ${imagePath}`
1129
- )
1130
- );
1131
- return `<div class="attachment-item error" style="padding:10px; color:red;">Screenshot not found: ${escapeHTML(
1132
- screenshotPathOrData
1133
- )}</div>`;
1134
- }
1135
- } else if (
1136
- typeof screenshotPathOrData === "string" &&
1137
- screenshotPathOrData.startsWith(
1138
- "data:image/png;base64,"
1139
- )
1140
- ) {
1141
- // It's already a data URI, extract base64 part
1142
- base64ImageData =
1143
- screenshotPathOrData.substring(
1144
- "data:image/png;base64,".length
1145
- );
1146
- } else if (
1147
- typeof screenshotPathOrData === "string"
1148
- ) {
1149
- // Assume it's raw Base64 data if it's a string but not a known path or full data URI
1150
- base64ImageData = screenshotPathOrData;
1151
- } else {
1152
- console.warn(
1153
- chalk.yellow(
1154
- `[Reporter] Invalid screenshot data type for item at index ${index}.`
1155
- )
1156
- );
1157
- return `<div class="attachment-item error" style="padding:10px; color:red;">Invalid screenshot data</div>`;
1158
- }
1159
-
1160
- if (!base64ImageData) {
1161
- // This case should ideally be caught above, but as a fallback:
1162
- console.warn(
1163
- chalk.yellow(
1164
- `[Reporter] Could not obtain base64 data for screenshot: ${escapeHTML(
1165
- String(screenshotPathOrData)
1166
- )}`
1167
- )
1168
- );
1169
- return `<div class="attachment-item error" style="padding:10px; color:red;">Error loading screenshot: ${escapeHTML(
1170
- String(screenshotPathOrData)
1171
- )}</div>`;
1172
- }
1173
-
1174
- return `
1068
+ ${(() => {
1069
+ if (!test.screenshots || test.screenshots.length === 0) return "";
1070
+
1071
+ // Define base output directory to resolve relative screenshot paths
1072
+ // This assumes screenshot paths in your JSON are relative to DEFAULT_OUTPUT_DIR
1073
+ const baseOutputDir = path.resolve(
1074
+ process.cwd(),
1075
+ DEFAULT_OUTPUT_DIR
1076
+ );
1077
+
1078
+ // Helper to escape HTML special characters (safer than the global sanitizeHTML)
1079
+ const escapeHTML = (str) => {
1080
+ if (str === null || str === undefined) return "";
1081
+ return String(str).replace(/[&<>"']/g, (match) => {
1082
+ const replacements = {
1083
+ "&": "&",
1084
+ "<": "<",
1085
+ ">": ">",
1086
+ '"': '"',
1087
+ "'": "'",
1088
+ };
1089
+ return replacements[match] || match;
1090
+ });
1091
+ };
1092
+
1093
+ const renderScreenshot = (screenshotPathOrData, index) => {
1094
+ let base64ImageData = "";
1095
+ const uniqueSuffix = `${Date.now()}-${index}-${Math.random()
1096
+ .toString(36)
1097
+ .substring(2, 7)}`;
1098
+
1099
+ try {
1100
+ if (
1101
+ typeof screenshotPathOrData === "string" &&
1102
+ !screenshotPathOrData.startsWith("data:image")
1103
+ ) {
1104
+ // It's likely a file path, try to read and convert
1105
+ const imagePath = path.resolve(
1106
+ baseOutputDir,
1107
+ screenshotPathOrData
1108
+ );
1109
+
1110
+ if (fsExistsSync(imagePath)) {
1111
+ // Use imported fsExistsSync
1112
+ const imageBuffer = readFileSync(imagePath); // Use imported readFileSync
1113
+ base64ImageData = imageBuffer.toString("base64");
1114
+ } else {
1115
+ console.warn(
1116
+ chalk.yellow(
1117
+ `[Reporter] Screenshot file not found: ${imagePath}`
1118
+ )
1119
+ );
1120
+ return `<div class="attachment-item error" style="padding:10px; color:red;">Screenshot not found: ${escapeHTML(
1121
+ screenshotPathOrData
1122
+ )}</div>`;
1123
+ }
1124
+ } else if (
1125
+ typeof screenshotPathOrData === "string" &&
1126
+ screenshotPathOrData.startsWith("data:image/png;base64,")
1127
+ ) {
1128
+ // It's already a data URI, extract base64 part
1129
+ base64ImageData = screenshotPathOrData.substring(
1130
+ "data:image/png;base64,".length
1131
+ );
1132
+ } else if (typeof screenshotPathOrData === "string") {
1133
+ // Assume it's raw Base64 data if it's a string but not a known path or full data URI
1134
+ base64ImageData = screenshotPathOrData;
1135
+ } else {
1136
+ console.warn(
1137
+ chalk.yellow(
1138
+ `[Reporter] Invalid screenshot data type for item at index ${index}.`
1139
+ )
1140
+ );
1141
+ return `<div class="attachment-item error" style="padding:10px; color:red;">Invalid screenshot data</div>`;
1142
+ }
1143
+
1144
+ if (!base64ImageData) {
1145
+ // This case should ideally be caught above, but as a fallback:
1146
+ console.warn(
1147
+ chalk.yellow(
1148
+ `[Reporter] Could not obtain base64 data for screenshot: ${escapeHTML(
1149
+ String(screenshotPathOrData)
1150
+ )}`
1151
+ )
1152
+ );
1153
+ return `<div class="attachment-item error" style="padding:10px; color:red;">Error loading screenshot: ${escapeHTML(
1154
+ String(screenshotPathOrData)
1155
+ )}</div>`;
1156
+ }
1157
+
1158
+ return `
1175
1159
  <div class="attachment-item">
1176
1160
  <img src="data:image/png;base64,${base64ImageData}"
1177
1161
  alt="Screenshot ${index + 1}"
@@ -1194,21 +1178,21 @@ function generateHTML(reportData, trendData = null) {
1194
1178
  </div>
1195
1179
  </div>
1196
1180
  </div>`;
1197
- } catch (e) {
1198
- console.error(
1199
- chalk.red(
1200
- `[Reporter] Error processing screenshot ${escapeHTML(
1201
- String(screenshotPathOrData)
1202
- )}: ${e.message}`
1203
- )
1204
- );
1205
- return `<div class="attachment-item error" style="padding:10px; color:red;">Failed to load screenshot: ${escapeHTML(
1206
- String(screenshotPathOrData)
1207
- )}</div>`;
1208
- }
1209
- }; // end of renderScreenshot
1210
-
1211
- return `
1181
+ } catch (e) {
1182
+ console.error(
1183
+ chalk.red(
1184
+ `[Reporter] Error processing screenshot ${escapeHTML(
1185
+ String(screenshotPathOrData)
1186
+ )}: ${e.message}`
1187
+ )
1188
+ );
1189
+ return `<div class="attachment-item error" style="padding:10px; color:red;">Failed to load screenshot: ${escapeHTML(
1190
+ String(screenshotPathOrData)
1191
+ )}</div>`;
1192
+ }
1193
+ }; // end of renderScreenshot
1194
+
1195
+ return `
1212
1196
  <div class="attachments-section">
1213
1197
  <h4>Screenshots (${test.screenshots.length})</h4>
1214
1198
  <div class="attachments-grid">
@@ -1216,7 +1200,7 @@ function generateHTML(reportData, trendData = null) {
1216
1200
  </div>
1217
1201
  </div>
1218
1202
  `;
1219
- })()}
1203
+ })()}
1220
1204
 
1221
1205
  ${
1222
1206
  test.videoPath