@plune-ai/playwright 0.2.0 → 0.2.2
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/dist/index.cjs +75 -16
- package/dist/index.js +75 -16
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -36,12 +36,13 @@ module.exports = __toCommonJS(src_exports);
|
|
|
36
36
|
var import_node_fs = require("fs");
|
|
37
37
|
|
|
38
38
|
// ../../dist/reporter-core.js
|
|
39
|
+
var import_crypto = require("crypto");
|
|
39
40
|
var import_fs = require("fs");
|
|
40
41
|
var import_os = require("os");
|
|
41
42
|
var import_path = require("path");
|
|
42
43
|
var fs = __toESM(require("fs"), 1);
|
|
43
44
|
var path = __toESM(require("path"), 1);
|
|
44
|
-
var
|
|
45
|
+
var import_crypto2 = require("crypto");
|
|
45
46
|
var DEFAULT_API_URL = "https://beta-api.plune.ai";
|
|
46
47
|
function resolveApiUrl(explicit) {
|
|
47
48
|
const raw = explicit ?? process.env["PLUNE_API_URL"] ?? DEFAULT_API_URL;
|
|
@@ -87,7 +88,7 @@ function createClient(opts) {
|
|
|
87
88
|
const wait = opts.wait ?? sleep;
|
|
88
89
|
const base = opts.apiUrl.replace(/\/+$/, "");
|
|
89
90
|
const scrub = (text) => opts.token === "" ? text : text.split(opts.token).join("***");
|
|
90
|
-
async function
|
|
91
|
+
async function send(method, path2, body) {
|
|
91
92
|
let last = {
|
|
92
93
|
kind: "unavailable",
|
|
93
94
|
status: null,
|
|
@@ -97,16 +98,22 @@ function createClient(opts) {
|
|
|
97
98
|
let res;
|
|
98
99
|
try {
|
|
99
100
|
res = await doFetch(`${base}${path2}`, {
|
|
100
|
-
method
|
|
101
|
+
method,
|
|
101
102
|
headers: { "content-type": "application/json", authorization: `Bearer ${opts.token}` },
|
|
102
|
-
|
|
103
|
+
// A DELETE carries none. Sending `"undefined"` as a body is what a naive
|
|
104
|
+
// `JSON.stringify(body)` would do, and some proxies answer that with a 400 nobody can
|
|
105
|
+
// explain.
|
|
106
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
103
107
|
});
|
|
104
108
|
} catch (err) {
|
|
105
109
|
last = { kind: "unavailable", status: null, detail: scrub(String(err)) };
|
|
106
110
|
if (attempt < RETRY_DELAYS_MS.length) await wait(RETRY_DELAYS_MS[attempt]);
|
|
107
111
|
continue;
|
|
108
112
|
}
|
|
109
|
-
if (res.ok)
|
|
113
|
+
if (res.ok) {
|
|
114
|
+
if (res.status === 204) return { ok: true, status: res.status, body: void 0 };
|
|
115
|
+
return { ok: true, status: res.status, body: await res.json() };
|
|
116
|
+
}
|
|
110
117
|
const detail = scrub(await detailOf(res));
|
|
111
118
|
const kind = classify(res.status);
|
|
112
119
|
last = { kind, status: res.status, detail };
|
|
@@ -117,7 +124,10 @@ function createClient(opts) {
|
|
|
117
124
|
}
|
|
118
125
|
return { ok: false, ...last };
|
|
119
126
|
}
|
|
120
|
-
return {
|
|
127
|
+
return {
|
|
128
|
+
post: (path2, body) => send("POST", path2, body),
|
|
129
|
+
del: (path2) => send("DELETE", path2)
|
|
130
|
+
};
|
|
121
131
|
}
|
|
122
132
|
var UNSUPPORTED_VARS = ["PLUNE_GROUP"];
|
|
123
133
|
function value(env, name) {
|
|
@@ -188,6 +198,18 @@ var BATCH_MAX = 500;
|
|
|
188
198
|
var DISCOVER_MAX = 500;
|
|
189
199
|
var BATCH_DEFAULT = 100;
|
|
190
200
|
var EXPECTED_MAX = 1e4;
|
|
201
|
+
var KEY_MAX = 1024;
|
|
202
|
+
var TITLE_MAX = 300;
|
|
203
|
+
function boundKey(key) {
|
|
204
|
+
if (key.value.length <= KEY_MAX) return key;
|
|
205
|
+
const digest = (0, import_crypto.createHash)("sha256").update(key.value).digest("hex").slice(0, 16);
|
|
206
|
+
let head = key.value.slice(0, KEY_MAX - digest.length - 1);
|
|
207
|
+
if (/[\uD800-\uDBFF]$/.test(head)) head = head.slice(0, -1);
|
|
208
|
+
return { ...key, value: `${head}#${digest}` };
|
|
209
|
+
}
|
|
210
|
+
function boundTitle(title) {
|
|
211
|
+
return title.length <= TITLE_MAX ? title : `${title.slice(0, TITLE_MAX - 1)}\u2026`;
|
|
212
|
+
}
|
|
191
213
|
function chunk(items, size) {
|
|
192
214
|
const out = [];
|
|
193
215
|
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
@@ -201,7 +223,7 @@ function warnIfDropped(sent, run, log) {
|
|
|
201
223
|
`plune: this deployment stored none of ${names.join(", ")} \u2014 it is older than the fields. The run is otherwise reported in full.`
|
|
202
224
|
);
|
|
203
225
|
}
|
|
204
|
-
async function startRun(passed,
|
|
226
|
+
async function startRun(passed, declared) {
|
|
205
227
|
const env = readEnv();
|
|
206
228
|
const stated = Object.fromEntries(Object.entries(passed).filter(([, v]) => v !== void 0));
|
|
207
229
|
const cfg = { ...env.config, ...stated };
|
|
@@ -224,6 +246,8 @@ async function startRun(passed, expected) {
|
|
|
224
246
|
rejected: 0,
|
|
225
247
|
unresolved: 0,
|
|
226
248
|
offered: 0,
|
|
249
|
+
created: 0,
|
|
250
|
+
unoffered: 0,
|
|
227
251
|
deferred: 0
|
|
228
252
|
};
|
|
229
253
|
const resolved = /* @__PURE__ */ new Map();
|
|
@@ -233,6 +257,22 @@ async function startRun(passed, expected) {
|
|
|
233
257
|
let joined = false;
|
|
234
258
|
let offline = token === "";
|
|
235
259
|
let done = false;
|
|
260
|
+
const shortened = /* @__PURE__ */ new Set();
|
|
261
|
+
function bound(keys) {
|
|
262
|
+
return keys.map((key) => {
|
|
263
|
+
const fit = boundKey(key);
|
|
264
|
+
if (fit !== key && !shortened.has(key.value)) {
|
|
265
|
+
shortened.add(key.value);
|
|
266
|
+
if (shortened.size === 1) {
|
|
267
|
+
log(
|
|
268
|
+
`plune: a test name longer than ${KEY_MAX} characters was shortened to fit its key \u2014 "${key.value.slice(0, 80)}\u2026". Give the test a shorter name; until then this is its identity.`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return fit;
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const expected = declared?.map(bound);
|
|
236
276
|
if (offline) {
|
|
237
277
|
log('plune: no API token \u2014 run "plune login" first. Results will be written to the fallback file.');
|
|
238
278
|
}
|
|
@@ -260,9 +300,9 @@ async function startRun(passed, expected) {
|
|
|
260
300
|
}
|
|
261
301
|
if (!offline) {
|
|
262
302
|
if (expected !== void 0) await resolveKeys(expected.flat());
|
|
263
|
-
const
|
|
264
|
-
const configuration =
|
|
265
|
-
expected:
|
|
303
|
+
const stated2 = expected?.slice(0, EXPECTED_MAX) ?? [];
|
|
304
|
+
const configuration = stated2.length === 0 ? void 0 : {
|
|
305
|
+
expected: stated2.flatMap((keys) => {
|
|
266
306
|
const hit = keys.map((k) => resolved.get(k.value)).find((v) => typeof v === "string");
|
|
267
307
|
if (typeof hit === "string") return [{ testCaseId: hit }];
|
|
268
308
|
return keys[0] === void 0 ? [] : [{ externalKey: keys[0] }];
|
|
@@ -306,9 +346,11 @@ async function startRun(passed, expected) {
|
|
|
306
346
|
if (!offerDiscovered) return;
|
|
307
347
|
if (result.title === void 0 || result.specRef === void 0) return;
|
|
308
348
|
if (result.keys.length === 0) return;
|
|
349
|
+
const title = boundTitle(result.title);
|
|
350
|
+
if (title !== result.title) shortened.add(result.title);
|
|
309
351
|
discoveries.set(result.keys[0].value, {
|
|
310
352
|
keys: result.keys,
|
|
311
|
-
title
|
|
353
|
+
title,
|
|
312
354
|
source: result.source,
|
|
313
355
|
specRef: result.specRef,
|
|
314
356
|
rawStatus: result.rawStatus
|
|
@@ -316,16 +358,21 @@ async function startRun(passed, expected) {
|
|
|
316
358
|
}
|
|
317
359
|
async function offer() {
|
|
318
360
|
if (discoveries.size === 0 || offline || runId === null) return;
|
|
319
|
-
|
|
361
|
+
const batches = chunk([...discoveries.values()], DISCOVER_MAX);
|
|
362
|
+
for (const [index, batch] of batches.entries()) {
|
|
320
363
|
const out = await client.post("/v1/review-items/discovered", {
|
|
321
364
|
discovered: batch,
|
|
322
365
|
runId
|
|
323
366
|
});
|
|
324
367
|
if (!out.ok) {
|
|
325
|
-
|
|
368
|
+
stats.unoffered = batches.slice(index).reduce((n, rest) => n + rest.length, 0);
|
|
369
|
+
log(
|
|
370
|
+
`plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.detail || out.kind}).`
|
|
371
|
+
);
|
|
326
372
|
return;
|
|
327
373
|
}
|
|
328
374
|
stats.offered += out.body.results.filter((r) => r.outcome === "queued").length;
|
|
375
|
+
stats.created += out.body.results.filter((r) => r.outcome === "created").length;
|
|
329
376
|
}
|
|
330
377
|
}
|
|
331
378
|
async function flush() {
|
|
@@ -352,7 +399,10 @@ async function startRun(passed, expected) {
|
|
|
352
399
|
}
|
|
353
400
|
}
|
|
354
401
|
if (unanswered.length > 0) defer(unanswered);
|
|
355
|
-
if (submissions.length === 0)
|
|
402
|
+
if (submissions.length === 0) {
|
|
403
|
+
progress();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
356
406
|
const out = await client.post(
|
|
357
407
|
`/v1/runs/${runId}/results`,
|
|
358
408
|
{ results: submissions }
|
|
@@ -362,6 +412,7 @@ async function startRun(passed, expected) {
|
|
|
362
412
|
stats.duplicate += out.body.counts.duplicate ?? 0;
|
|
363
413
|
stats.conflict += out.body.counts.conflict ?? 0;
|
|
364
414
|
stats.rejected += out.body.counts.rejected ?? 0;
|
|
415
|
+
progress();
|
|
365
416
|
return;
|
|
366
417
|
}
|
|
367
418
|
if (out.kind === "auth") {
|
|
@@ -374,6 +425,12 @@ async function startRun(passed, expected) {
|
|
|
374
425
|
}
|
|
375
426
|
defer(submissions);
|
|
376
427
|
}
|
|
428
|
+
function progress() {
|
|
429
|
+
const total = expected?.length ?? 0;
|
|
430
|
+
if (total <= batchSize) return;
|
|
431
|
+
const done2 = stats.accepted + stats.duplicate + stats.conflict + stats.rejected + stats.unresolved;
|
|
432
|
+
log(`plune: ${Math.min(done2, total)} of ${total} results sent`);
|
|
433
|
+
}
|
|
377
434
|
function summarise() {
|
|
378
435
|
const parts = [`${stats.accepted} accepted`];
|
|
379
436
|
if (stats.duplicate > 0) parts.push(`${stats.duplicate} already reported`);
|
|
@@ -381,7 +438,9 @@ async function startRun(passed, expected) {
|
|
|
381
438
|
if (stats.rejected > 0) parts.push(`${stats.rejected} rejected`);
|
|
382
439
|
if (stats.unresolved > 0) parts.push(`${stats.unresolved} with no matching test case`);
|
|
383
440
|
if (stats.offered > 0) parts.push(`${stats.offered} offered for review`);
|
|
441
|
+
if (stats.created > 0) parts.push(`${stats.created} added as cases (trusted source)`);
|
|
384
442
|
if (stats.deferred > 0) parts.push(`${stats.deferred} written to ${fallbackPath}`);
|
|
443
|
+
if (shortened.size > 0) parts.push(`${shortened.size} test name(s) shortened to fit a key`);
|
|
385
444
|
log(`plune: ${parts.join(" \xB7 ")}`);
|
|
386
445
|
}
|
|
387
446
|
return {
|
|
@@ -395,7 +454,7 @@ async function startRun(passed, expected) {
|
|
|
395
454
|
return stats;
|
|
396
455
|
},
|
|
397
456
|
async add(result) {
|
|
398
|
-
buffer.push(result);
|
|
457
|
+
buffer.push({ ...result, keys: bound(result.keys) });
|
|
399
458
|
if (buffer.length >= batchSize) await flush();
|
|
400
459
|
},
|
|
401
460
|
flush,
|
|
@@ -426,7 +485,7 @@ async function startRun(passed, expected) {
|
|
|
426
485
|
};
|
|
427
486
|
}
|
|
428
487
|
function sha256(input) {
|
|
429
|
-
return (0,
|
|
488
|
+
return (0, import_crypto2.createHash)("sha256").update(input, "utf8").digest("hex");
|
|
430
489
|
}
|
|
431
490
|
var RESULT_KEY_MAX = 200;
|
|
432
491
|
var HASH_CHARS = 32;
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import { readFileSync as readFileSync2 } from "fs";
|
|
3
3
|
|
|
4
4
|
// ../../dist/reporter-core.js
|
|
5
|
+
import { createHash } from "crypto";
|
|
5
6
|
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
6
7
|
import { homedir } from "os";
|
|
7
8
|
import { dirname, join } from "path";
|
|
8
9
|
import * as fs from "fs";
|
|
9
10
|
import * as path from "path";
|
|
10
|
-
import { createHash } from "crypto";
|
|
11
|
+
import { createHash as createHash2 } from "crypto";
|
|
11
12
|
var DEFAULT_API_URL = "https://beta-api.plune.ai";
|
|
12
13
|
function resolveApiUrl(explicit) {
|
|
13
14
|
const raw = explicit ?? process.env["PLUNE_API_URL"] ?? DEFAULT_API_URL;
|
|
@@ -53,7 +54,7 @@ function createClient(opts) {
|
|
|
53
54
|
const wait = opts.wait ?? sleep;
|
|
54
55
|
const base = opts.apiUrl.replace(/\/+$/, "");
|
|
55
56
|
const scrub = (text) => opts.token === "" ? text : text.split(opts.token).join("***");
|
|
56
|
-
async function
|
|
57
|
+
async function send(method, path2, body) {
|
|
57
58
|
let last = {
|
|
58
59
|
kind: "unavailable",
|
|
59
60
|
status: null,
|
|
@@ -63,16 +64,22 @@ function createClient(opts) {
|
|
|
63
64
|
let res;
|
|
64
65
|
try {
|
|
65
66
|
res = await doFetch(`${base}${path2}`, {
|
|
66
|
-
method
|
|
67
|
+
method,
|
|
67
68
|
headers: { "content-type": "application/json", authorization: `Bearer ${opts.token}` },
|
|
68
|
-
|
|
69
|
+
// A DELETE carries none. Sending `"undefined"` as a body is what a naive
|
|
70
|
+
// `JSON.stringify(body)` would do, and some proxies answer that with a 400 nobody can
|
|
71
|
+
// explain.
|
|
72
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
69
73
|
});
|
|
70
74
|
} catch (err) {
|
|
71
75
|
last = { kind: "unavailable", status: null, detail: scrub(String(err)) };
|
|
72
76
|
if (attempt < RETRY_DELAYS_MS.length) await wait(RETRY_DELAYS_MS[attempt]);
|
|
73
77
|
continue;
|
|
74
78
|
}
|
|
75
|
-
if (res.ok)
|
|
79
|
+
if (res.ok) {
|
|
80
|
+
if (res.status === 204) return { ok: true, status: res.status, body: void 0 };
|
|
81
|
+
return { ok: true, status: res.status, body: await res.json() };
|
|
82
|
+
}
|
|
76
83
|
const detail = scrub(await detailOf(res));
|
|
77
84
|
const kind = classify(res.status);
|
|
78
85
|
last = { kind, status: res.status, detail };
|
|
@@ -83,7 +90,10 @@ function createClient(opts) {
|
|
|
83
90
|
}
|
|
84
91
|
return { ok: false, ...last };
|
|
85
92
|
}
|
|
86
|
-
return {
|
|
93
|
+
return {
|
|
94
|
+
post: (path2, body) => send("POST", path2, body),
|
|
95
|
+
del: (path2) => send("DELETE", path2)
|
|
96
|
+
};
|
|
87
97
|
}
|
|
88
98
|
var UNSUPPORTED_VARS = ["PLUNE_GROUP"];
|
|
89
99
|
function value(env, name) {
|
|
@@ -154,6 +164,18 @@ var BATCH_MAX = 500;
|
|
|
154
164
|
var DISCOVER_MAX = 500;
|
|
155
165
|
var BATCH_DEFAULT = 100;
|
|
156
166
|
var EXPECTED_MAX = 1e4;
|
|
167
|
+
var KEY_MAX = 1024;
|
|
168
|
+
var TITLE_MAX = 300;
|
|
169
|
+
function boundKey(key) {
|
|
170
|
+
if (key.value.length <= KEY_MAX) return key;
|
|
171
|
+
const digest = createHash("sha256").update(key.value).digest("hex").slice(0, 16);
|
|
172
|
+
let head = key.value.slice(0, KEY_MAX - digest.length - 1);
|
|
173
|
+
if (/[\uD800-\uDBFF]$/.test(head)) head = head.slice(0, -1);
|
|
174
|
+
return { ...key, value: `${head}#${digest}` };
|
|
175
|
+
}
|
|
176
|
+
function boundTitle(title) {
|
|
177
|
+
return title.length <= TITLE_MAX ? title : `${title.slice(0, TITLE_MAX - 1)}\u2026`;
|
|
178
|
+
}
|
|
157
179
|
function chunk(items, size) {
|
|
158
180
|
const out = [];
|
|
159
181
|
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
@@ -167,7 +189,7 @@ function warnIfDropped(sent, run, log) {
|
|
|
167
189
|
`plune: this deployment stored none of ${names.join(", ")} \u2014 it is older than the fields. The run is otherwise reported in full.`
|
|
168
190
|
);
|
|
169
191
|
}
|
|
170
|
-
async function startRun(passed,
|
|
192
|
+
async function startRun(passed, declared) {
|
|
171
193
|
const env = readEnv();
|
|
172
194
|
const stated = Object.fromEntries(Object.entries(passed).filter(([, v]) => v !== void 0));
|
|
173
195
|
const cfg = { ...env.config, ...stated };
|
|
@@ -190,6 +212,8 @@ async function startRun(passed, expected) {
|
|
|
190
212
|
rejected: 0,
|
|
191
213
|
unresolved: 0,
|
|
192
214
|
offered: 0,
|
|
215
|
+
created: 0,
|
|
216
|
+
unoffered: 0,
|
|
193
217
|
deferred: 0
|
|
194
218
|
};
|
|
195
219
|
const resolved = /* @__PURE__ */ new Map();
|
|
@@ -199,6 +223,22 @@ async function startRun(passed, expected) {
|
|
|
199
223
|
let joined = false;
|
|
200
224
|
let offline = token === "";
|
|
201
225
|
let done = false;
|
|
226
|
+
const shortened = /* @__PURE__ */ new Set();
|
|
227
|
+
function bound(keys) {
|
|
228
|
+
return keys.map((key) => {
|
|
229
|
+
const fit = boundKey(key);
|
|
230
|
+
if (fit !== key && !shortened.has(key.value)) {
|
|
231
|
+
shortened.add(key.value);
|
|
232
|
+
if (shortened.size === 1) {
|
|
233
|
+
log(
|
|
234
|
+
`plune: a test name longer than ${KEY_MAX} characters was shortened to fit its key \u2014 "${key.value.slice(0, 80)}\u2026". Give the test a shorter name; until then this is its identity.`
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return fit;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const expected = declared?.map(bound);
|
|
202
242
|
if (offline) {
|
|
203
243
|
log('plune: no API token \u2014 run "plune login" first. Results will be written to the fallback file.');
|
|
204
244
|
}
|
|
@@ -226,9 +266,9 @@ async function startRun(passed, expected) {
|
|
|
226
266
|
}
|
|
227
267
|
if (!offline) {
|
|
228
268
|
if (expected !== void 0) await resolveKeys(expected.flat());
|
|
229
|
-
const
|
|
230
|
-
const configuration =
|
|
231
|
-
expected:
|
|
269
|
+
const stated2 = expected?.slice(0, EXPECTED_MAX) ?? [];
|
|
270
|
+
const configuration = stated2.length === 0 ? void 0 : {
|
|
271
|
+
expected: stated2.flatMap((keys) => {
|
|
232
272
|
const hit = keys.map((k) => resolved.get(k.value)).find((v) => typeof v === "string");
|
|
233
273
|
if (typeof hit === "string") return [{ testCaseId: hit }];
|
|
234
274
|
return keys[0] === void 0 ? [] : [{ externalKey: keys[0] }];
|
|
@@ -272,9 +312,11 @@ async function startRun(passed, expected) {
|
|
|
272
312
|
if (!offerDiscovered) return;
|
|
273
313
|
if (result.title === void 0 || result.specRef === void 0) return;
|
|
274
314
|
if (result.keys.length === 0) return;
|
|
315
|
+
const title = boundTitle(result.title);
|
|
316
|
+
if (title !== result.title) shortened.add(result.title);
|
|
275
317
|
discoveries.set(result.keys[0].value, {
|
|
276
318
|
keys: result.keys,
|
|
277
|
-
title
|
|
319
|
+
title,
|
|
278
320
|
source: result.source,
|
|
279
321
|
specRef: result.specRef,
|
|
280
322
|
rawStatus: result.rawStatus
|
|
@@ -282,16 +324,21 @@ async function startRun(passed, expected) {
|
|
|
282
324
|
}
|
|
283
325
|
async function offer() {
|
|
284
326
|
if (discoveries.size === 0 || offline || runId === null) return;
|
|
285
|
-
|
|
327
|
+
const batches = chunk([...discoveries.values()], DISCOVER_MAX);
|
|
328
|
+
for (const [index, batch] of batches.entries()) {
|
|
286
329
|
const out = await client.post("/v1/review-items/discovered", {
|
|
287
330
|
discovered: batch,
|
|
288
331
|
runId
|
|
289
332
|
});
|
|
290
333
|
if (!out.ok) {
|
|
291
|
-
|
|
334
|
+
stats.unoffered = batches.slice(index).reduce((n, rest) => n + rest.length, 0);
|
|
335
|
+
log(
|
|
336
|
+
`plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.detail || out.kind}).`
|
|
337
|
+
);
|
|
292
338
|
return;
|
|
293
339
|
}
|
|
294
340
|
stats.offered += out.body.results.filter((r) => r.outcome === "queued").length;
|
|
341
|
+
stats.created += out.body.results.filter((r) => r.outcome === "created").length;
|
|
295
342
|
}
|
|
296
343
|
}
|
|
297
344
|
async function flush() {
|
|
@@ -318,7 +365,10 @@ async function startRun(passed, expected) {
|
|
|
318
365
|
}
|
|
319
366
|
}
|
|
320
367
|
if (unanswered.length > 0) defer(unanswered);
|
|
321
|
-
if (submissions.length === 0)
|
|
368
|
+
if (submissions.length === 0) {
|
|
369
|
+
progress();
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
322
372
|
const out = await client.post(
|
|
323
373
|
`/v1/runs/${runId}/results`,
|
|
324
374
|
{ results: submissions }
|
|
@@ -328,6 +378,7 @@ async function startRun(passed, expected) {
|
|
|
328
378
|
stats.duplicate += out.body.counts.duplicate ?? 0;
|
|
329
379
|
stats.conflict += out.body.counts.conflict ?? 0;
|
|
330
380
|
stats.rejected += out.body.counts.rejected ?? 0;
|
|
381
|
+
progress();
|
|
331
382
|
return;
|
|
332
383
|
}
|
|
333
384
|
if (out.kind === "auth") {
|
|
@@ -340,6 +391,12 @@ async function startRun(passed, expected) {
|
|
|
340
391
|
}
|
|
341
392
|
defer(submissions);
|
|
342
393
|
}
|
|
394
|
+
function progress() {
|
|
395
|
+
const total = expected?.length ?? 0;
|
|
396
|
+
if (total <= batchSize) return;
|
|
397
|
+
const done2 = stats.accepted + stats.duplicate + stats.conflict + stats.rejected + stats.unresolved;
|
|
398
|
+
log(`plune: ${Math.min(done2, total)} of ${total} results sent`);
|
|
399
|
+
}
|
|
343
400
|
function summarise() {
|
|
344
401
|
const parts = [`${stats.accepted} accepted`];
|
|
345
402
|
if (stats.duplicate > 0) parts.push(`${stats.duplicate} already reported`);
|
|
@@ -347,7 +404,9 @@ async function startRun(passed, expected) {
|
|
|
347
404
|
if (stats.rejected > 0) parts.push(`${stats.rejected} rejected`);
|
|
348
405
|
if (stats.unresolved > 0) parts.push(`${stats.unresolved} with no matching test case`);
|
|
349
406
|
if (stats.offered > 0) parts.push(`${stats.offered} offered for review`);
|
|
407
|
+
if (stats.created > 0) parts.push(`${stats.created} added as cases (trusted source)`);
|
|
350
408
|
if (stats.deferred > 0) parts.push(`${stats.deferred} written to ${fallbackPath}`);
|
|
409
|
+
if (shortened.size > 0) parts.push(`${shortened.size} test name(s) shortened to fit a key`);
|
|
351
410
|
log(`plune: ${parts.join(" \xB7 ")}`);
|
|
352
411
|
}
|
|
353
412
|
return {
|
|
@@ -361,7 +420,7 @@ async function startRun(passed, expected) {
|
|
|
361
420
|
return stats;
|
|
362
421
|
},
|
|
363
422
|
async add(result) {
|
|
364
|
-
buffer.push(result);
|
|
423
|
+
buffer.push({ ...result, keys: bound(result.keys) });
|
|
365
424
|
if (buffer.length >= batchSize) await flush();
|
|
366
425
|
},
|
|
367
426
|
flush,
|
|
@@ -392,7 +451,7 @@ async function startRun(passed, expected) {
|
|
|
392
451
|
};
|
|
393
452
|
}
|
|
394
453
|
function sha256(input) {
|
|
395
|
-
return
|
|
454
|
+
return createHash2("sha256").update(input, "utf8").digest("hex");
|
|
396
455
|
}
|
|
397
456
|
var RESULT_KEY_MAX = 200;
|
|
398
457
|
var HASH_CHARS = 32;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plune-ai/playwright",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Report Playwright results to Plune — a reporter and, later, a test importer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"playwright",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tsup": "^8.0.0",
|
|
39
39
|
"typescript": "^5.4.0",
|
|
40
40
|
"vitest": "^1.6.0",
|
|
41
|
-
"@plune-ai/cli": "0.
|
|
41
|
+
"@plune-ai/cli": "0.10.0"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|