@arghajit/dummy 0.1.0-beta-11 → 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.
|
@@ -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}
|
|
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-
|
|
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
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
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
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
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
|