@crvy/rprtr 0.0.8 → 0.1.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.
- package/CHANGELOG.md +55 -0
- package/dist/{chunk-XU5VQ3FZ.js → chunk-35CZLYSW.js} +223 -192
- package/dist/{chunk-EJRLZZ22.js → chunk-43JLQN36.js} +45 -5
- package/dist/ci.d.ts +2 -0
- package/dist/ci.d.ts.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -4
- package/dist/index.js +338 -46
- package/dist/report-utils.d.ts.map +1 -1
- package/dist/reporter-artifact-ops.d.ts +1 -3
- package/dist/reporter-artifact-ops.d.ts.map +1 -1
- package/dist/reporter.cjs +285 -198
- package/dist/reporter.d.ts +5 -3
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +81 -31
- package/dist/schemas.d.ts +210 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/server/app.d.ts +6 -0
- package/dist/server/app.d.ts.map +1 -1
- package/dist/server/artifact-routes.d.ts +8 -0
- package/dist/server/artifact-routes.d.ts.map +1 -0
- package/dist/server/file-utils.d.ts.map +1 -1
- package/dist/server/handlers.d.ts +6 -2
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/routes.d.ts +2 -2
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/utils.d.ts +3 -0
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/server.cjs +281 -228
- package/dist/server.js +2 -2
- package/dist/snapshot-path-resolver.d.ts +2 -0
- package/dist/snapshot-path-resolver.d.ts.map +1 -1
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/server/report-watch.d.ts +0 -9
- package/dist/server/report-watch.d.ts.map +0 -1
|
@@ -131,9 +131,15 @@ function resolveNamedTarget(input, declaration) {
|
|
|
131
131
|
function reporterTitlesWithoutProjectAndFile(reporterTitlePath) {
|
|
132
132
|
return reporterTitlePath.slice(3).filter((part) => part !== "");
|
|
133
133
|
}
|
|
134
|
+
function anonymousNameFromTitles(titles, occurrenceIndex) {
|
|
135
|
+
return sanitizeFilePathBeforeExtension(trimLongString(`${titles.join(" ")} ${occurrenceIndex}.png`), ".png");
|
|
136
|
+
}
|
|
134
137
|
function anonymousName(reporterTitlePath, occurrenceIndex) {
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
return anonymousNameFromTitles(reporterTitlesWithoutProjectAndFile(reporterTitlePath), occurrenceIndex);
|
|
139
|
+
}
|
|
140
|
+
function playwrightAnonymousVisualName(reporterTitlePath, occurrenceIndex) {
|
|
141
|
+
const titles = reporterTitlesWithoutProjectAndFile(reporterTitlePath);
|
|
142
|
+
return titles.length === 0 ? null : removeExtension(anonymousNameFromTitles(titles, occurrenceIndex), ".png");
|
|
137
143
|
}
|
|
138
144
|
function resolveTarget(input, declaration) {
|
|
139
145
|
switch (declaration.kind) {
|
|
@@ -147,6 +153,15 @@ function resolveTarget(input, declaration) {
|
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
}
|
|
156
|
+
function withResolvedVisualNames(declarations, reporterTitlePath) {
|
|
157
|
+
return declarations.map((declaration) => {
|
|
158
|
+
if (declaration.kind !== "unnamed") {
|
|
159
|
+
return declaration;
|
|
160
|
+
}
|
|
161
|
+
const resolvedName = playwrightAnonymousVisualName(reporterTitlePath, declaration.occurrenceIndex);
|
|
162
|
+
return resolvedName === null ? declaration : { ...declaration, visualName: resolvedName };
|
|
163
|
+
});
|
|
164
|
+
}
|
|
150
165
|
function resolveBaselineTargets(input) {
|
|
151
166
|
return input.declarations.flatMap((declaration) => {
|
|
152
167
|
const resolvedTarget = resolveTarget(input, declaration);
|
|
@@ -224,10 +239,29 @@ var CrvyRprtrSuiteSchema = z.lazy(
|
|
|
224
239
|
children: z.record(z.string(), z.union([CrvyRprtrSuiteSchema, CrvyRprtrTestSchema])).optional()
|
|
225
240
|
})
|
|
226
241
|
);
|
|
227
|
-
var
|
|
242
|
+
var IncomingWebSocketMessageSchema = z.object({
|
|
228
243
|
type: z.enum(["test-begin", "test-end", "run-end", "approve", "sync"]),
|
|
229
244
|
data: z.unknown()
|
|
230
245
|
});
|
|
246
|
+
var WebSocketMessageSchema = z.discriminatedUnion("type", [
|
|
247
|
+
z.object({ type: z.literal("test-begin"), data: TestDataSchema }),
|
|
248
|
+
z.object({ type: z.literal("test-update"), data: TestDataSchema }),
|
|
249
|
+
z.object({
|
|
250
|
+
type: z.literal("run-end"),
|
|
251
|
+
data: z.object({
|
|
252
|
+
status: z.enum(["passed", "failed", "skipped"]),
|
|
253
|
+
removedTestIds: z.array(z.string())
|
|
254
|
+
})
|
|
255
|
+
}),
|
|
256
|
+
z.object({
|
|
257
|
+
type: z.literal("sync"),
|
|
258
|
+
data: z.object({
|
|
259
|
+
tests: z.record(z.string(), TestDataSchema),
|
|
260
|
+
isUpdateMode: z.boolean().optional()
|
|
261
|
+
})
|
|
262
|
+
}),
|
|
263
|
+
z.object({ type: z.literal("approve"), data: z.unknown() })
|
|
264
|
+
]);
|
|
231
265
|
var TestBeginDataSchema = z.object({
|
|
232
266
|
id: z.string(),
|
|
233
267
|
title: z.string(),
|
|
@@ -247,6 +281,9 @@ var TestEndDataSchema = z.object({
|
|
|
247
281
|
error: z.string().optional(),
|
|
248
282
|
duration: z.number().optional()
|
|
249
283
|
});
|
|
284
|
+
var RunEndDataSchema = z.object({
|
|
285
|
+
status: z.enum(["passed", "failed", "skipped"])
|
|
286
|
+
});
|
|
250
287
|
var ReportDataSchema = z.object({
|
|
251
288
|
isRunning: z.boolean(),
|
|
252
289
|
tests: z.record(z.string(), TestDataSchema),
|
|
@@ -297,6 +334,7 @@ function safeParse(schema, data) {
|
|
|
297
334
|
}
|
|
298
335
|
|
|
299
336
|
// src/report-utils.ts
|
|
337
|
+
import { isAbsolute } from "path";
|
|
300
338
|
function normalizeScreenshotsBaseUrl(baseUrl) {
|
|
301
339
|
return baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
302
340
|
}
|
|
@@ -341,7 +379,7 @@ function attachmentsToImages(attachments, screenshotsBaseUrl = "/screenshots/")
|
|
|
341
379
|
const role = match[2];
|
|
342
380
|
if (baseName === null || baseName === void 0 || role === null || role === void 0) continue;
|
|
343
381
|
images[baseName] ??= {};
|
|
344
|
-
const url = `${baseUrl}${attachment.path}`;
|
|
382
|
+
const url = isAbsolute(attachment.path) ? `/file/${encodeURIComponent(attachment.path)}` : `${baseUrl}${attachment.path}`;
|
|
345
383
|
const img = images[baseName];
|
|
346
384
|
if (img !== null && img !== void 0) {
|
|
347
385
|
if (role === "actual") img.actual = url;
|
|
@@ -488,13 +526,15 @@ export {
|
|
|
488
526
|
applyTestBeginEvent,
|
|
489
527
|
applyTestEndEvent,
|
|
490
528
|
finalizeRunEvent,
|
|
491
|
-
|
|
529
|
+
IncomingWebSocketMessageSchema,
|
|
492
530
|
TestBeginDataSchema,
|
|
493
531
|
TestEndDataSchema,
|
|
532
|
+
RunEndDataSchema,
|
|
494
533
|
LoadedReportDataSchema,
|
|
495
534
|
OfflineReportSchema,
|
|
496
535
|
ApproveRequestBodySchema,
|
|
497
536
|
ClientBootstrapDataSchema,
|
|
498
537
|
safeParse,
|
|
538
|
+
withResolvedVisualNames,
|
|
499
539
|
resolveBaselineTargets
|
|
500
540
|
};
|
package/dist/ci.d.ts
ADDED
package/dist/ci.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../src/ci.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,OAAO,CAGnF"}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAKA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAKA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAO7D,UAAU,kBAAmB,SAAQ,aAAa;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,kBAAkB,CA4BpE"}
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
startServer
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-35CZLYSW.js";
|
|
5
|
+
import "./chunk-43JLQN36.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import { join } from "path";
|
|
@@ -31,6 +31,7 @@ function isDirectExecution(moduleUrl) {
|
|
|
31
31
|
var DEFAULT_PORT = 3e3;
|
|
32
32
|
var DEFAULT_SCREENSHOT_DIR = "./screenshots";
|
|
33
33
|
var DEFAULT_REPORT_PATH = "./report.json";
|
|
34
|
+
var DEFAULT_OUTPUT_DIR = "./test-results";
|
|
34
35
|
function resolveCliOptions(args) {
|
|
35
36
|
const { values, positionals } = parseArgs({
|
|
36
37
|
args,
|
|
@@ -38,7 +39,8 @@ function resolveCliOptions(args) {
|
|
|
38
39
|
options: {
|
|
39
40
|
port: { type: "string", short: "p", default: `${DEFAULT_PORT}` },
|
|
40
41
|
"screenshot-dir": { type: "string", short: "s" },
|
|
41
|
-
"report-path": { type: "string", short: "r" }
|
|
42
|
+
"report-path": { type: "string", short: "r" },
|
|
43
|
+
"output-dir": { type: "string", short: "o" }
|
|
42
44
|
}
|
|
43
45
|
});
|
|
44
46
|
if (positionals.length > 1) {
|
|
@@ -50,7 +52,8 @@ function resolveCliOptions(args) {
|
|
|
50
52
|
return {
|
|
51
53
|
port: parseInt(values.port ?? `${DEFAULT_PORT}`, 10),
|
|
52
54
|
screenshotDir,
|
|
53
|
-
reportPath
|
|
55
|
+
reportPath,
|
|
56
|
+
outputDir: values["output-dir"] ?? DEFAULT_OUTPUT_DIR
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
if (isDirectExecution(import.meta.url)) {
|