@plune-ai/playwright 0.1.0 → 0.2.1
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/README.md +18 -3
- package/dist/index.cjs +91 -9
- package/dist/index.js +91 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,12 +52,27 @@ fills in what you left out. Anything set in the config file wins.
|
|
|
52
52
|
| `PLUNE_PROCEED` | the job closes the run itself, later |
|
|
53
53
|
| `PLUNE_BATCH_SIZE` | results per request (default 100, max 500) |
|
|
54
54
|
| `PLUNE_FALLBACK` | where unsent batches are written |
|
|
55
|
+
| `PLUNE_RUN_TITLE` | what to call the run in the list |
|
|
56
|
+
| `PLUNE_ENV` | where it ran — `staging`, `prod`, a preview name |
|
|
57
|
+
| `PLUNE_LABELS` | comma-separated marks: `smoke,nightly` |
|
|
58
|
+
| `PLUNE_CREATE` | offer tests Plune has no case for to the review queue |
|
|
55
59
|
|
|
56
60
|
Flags are read by value, not by presence: `PLUNE_PROCEED=0` in a matrix cell means off.
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
The first shard to set a title owns it; a shard arriving later fills a field the first one left
|
|
63
|
+
empty rather than overwriting it. Blank entries in `PLUNE_LABELS` are dropped — `a,,b` is a template
|
|
64
|
+
that had nothing for the middle slot, not a request for an empty label.
|
|
65
|
+
|
|
66
|
+
`PLUNE_CREATE=1` sends every test that resolved to no case to the review queue — the keys it was
|
|
67
|
+
looked up by, its title, its file and line, and how it went. Never steps and never an expected
|
|
68
|
+
result: a reporter sees a test's result, not its source, and a body nobody wrote is exactly what the
|
|
69
|
+
queue exists to keep out. A person decides whether the project tracks the test; approving attaches
|
|
70
|
+
the keys, so the next run resolves instead of offering it again.
|
|
71
|
+
|
|
72
|
+
`PLUNE_GROUP` is **not supported yet** — a group of runs is a Plune feature that does not exist, and
|
|
73
|
+
a group of one run means nothing. Setting it prints a line saying it was ignored, rather than
|
|
74
|
+
accepting it and quietly dropping it. If you report to a deployment older than run titles, the
|
|
75
|
+
reporter says that too: the run is recorded in full, the description is not.
|
|
61
76
|
|
|
62
77
|
## Sharding
|
|
63
78
|
|
package/dist/index.cjs
CHANGED
|
@@ -119,12 +119,7 @@ function createClient(opts) {
|
|
|
119
119
|
}
|
|
120
120
|
return { post };
|
|
121
121
|
}
|
|
122
|
-
var UNSUPPORTED_VARS = [
|
|
123
|
-
"PLUNE_RUN_TITLE",
|
|
124
|
-
"PLUNE_ENV",
|
|
125
|
-
"PLUNE_LABELS",
|
|
126
|
-
"PLUNE_GROUP"
|
|
127
|
-
];
|
|
122
|
+
var UNSUPPORTED_VARS = ["PLUNE_GROUP"];
|
|
128
123
|
function value(env, name) {
|
|
129
124
|
const raw = env[name]?.trim();
|
|
130
125
|
return raw === void 0 || raw === "" ? void 0 : raw;
|
|
@@ -139,19 +134,35 @@ function count(env, name) {
|
|
|
139
134
|
const n = Number(raw);
|
|
140
135
|
return Number.isInteger(n) && n > 0 ? n : void 0;
|
|
141
136
|
}
|
|
137
|
+
function list(env, name) {
|
|
138
|
+
const raw = value(env, name);
|
|
139
|
+
if (raw === void 0) return void 0;
|
|
140
|
+
const items = raw.split(",").map((s) => s.trim()).filter((s) => s !== "");
|
|
141
|
+
return items.length === 0 ? void 0 : items;
|
|
142
|
+
}
|
|
142
143
|
function readEnv(env = process.env) {
|
|
143
144
|
const externalKey = value(env, "PLUNE_RUN");
|
|
144
145
|
const token = value(env, "PLUNE_TOKEN");
|
|
145
146
|
const apiUrl = value(env, "PLUNE_API_URL");
|
|
146
147
|
const fallbackPath = value(env, "PLUNE_FALLBACK");
|
|
147
148
|
const batchSize = count(env, "PLUNE_BATCH_SIZE");
|
|
149
|
+
const title = value(env, "PLUNE_RUN_TITLE");
|
|
150
|
+
const environment = value(env, "PLUNE_ENV");
|
|
151
|
+
const labels = list(env, "PLUNE_LABELS");
|
|
152
|
+
const offerDiscovered = flag(env, "PLUNE_CREATE");
|
|
148
153
|
return {
|
|
149
154
|
config: {
|
|
150
155
|
...externalKey !== void 0 ? { externalKey } : {},
|
|
151
156
|
...token !== void 0 ? { token } : {},
|
|
152
157
|
...apiUrl !== void 0 ? { apiUrl } : {},
|
|
153
158
|
...fallbackPath !== void 0 ? { fallbackPath } : {},
|
|
154
|
-
...batchSize !== void 0 ? { batchSize } : {}
|
|
159
|
+
...batchSize !== void 0 ? { batchSize } : {},
|
|
160
|
+
...title !== void 0 ? { title } : {},
|
|
161
|
+
...environment !== void 0 ? { environment } : {},
|
|
162
|
+
...labels !== void 0 ? { labels } : {},
|
|
163
|
+
// Only when set: `false` here would outrank a config file that asked for it, and an unset
|
|
164
|
+
// variable is not an instruction.
|
|
165
|
+
...offerDiscovered ? { offerDiscovered } : {}
|
|
155
166
|
},
|
|
156
167
|
// Two names for two situations that end the same way. `SHARED_RUN` says other processes are
|
|
157
168
|
// reporting into this run; `PROCEED` says the job will close it on its own schedule. Either
|
|
@@ -174,6 +185,7 @@ function appendBatch(file, batch) {
|
|
|
174
185
|
}
|
|
175
186
|
var RESOLVE_CHUNK = 500;
|
|
176
187
|
var BATCH_MAX = 500;
|
|
188
|
+
var DISCOVER_MAX = 500;
|
|
177
189
|
var BATCH_DEFAULT = 100;
|
|
178
190
|
var EXPECTED_MAX = 1e4;
|
|
179
191
|
function chunk(items, size) {
|
|
@@ -181,6 +193,14 @@ function chunk(items, size) {
|
|
|
181
193
|
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
182
194
|
return out;
|
|
183
195
|
}
|
|
196
|
+
function warnIfDropped(sent, run, log) {
|
|
197
|
+
const names = Object.keys(sent);
|
|
198
|
+
if (names.length === 0) return;
|
|
199
|
+
if (names.some((name) => run[name] != null)) return;
|
|
200
|
+
log(
|
|
201
|
+
`plune: this deployment stored none of ${names.join(", ")} \u2014 it is older than the fields. The run is otherwise reported in full.`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
184
204
|
async function startRun(passed, expected) {
|
|
185
205
|
const env = readEnv();
|
|
186
206
|
const stated = Object.fromEntries(Object.entries(passed).filter(([, v]) => v !== void 0));
|
|
@@ -190,6 +210,7 @@ async function startRun(passed, expected) {
|
|
|
190
210
|
const fallbackPath = cfg.fallbackPath ?? DEFAULT_FALLBACK_PATH;
|
|
191
211
|
const externalKey = cfg.externalKey ?? null;
|
|
192
212
|
const batchSize = Math.min(cfg.batchSize ?? BATCH_DEFAULT, BATCH_MAX);
|
|
213
|
+
const offerDiscovered = cfg.offerDiscovered ?? false;
|
|
193
214
|
const token = cfg.token ?? loadToken() ?? "";
|
|
194
215
|
const client = createClient({
|
|
195
216
|
apiUrl: resolveApiUrl(cfg.apiUrl),
|
|
@@ -202,10 +223,13 @@ async function startRun(passed, expected) {
|
|
|
202
223
|
conflict: 0,
|
|
203
224
|
rejected: 0,
|
|
204
225
|
unresolved: 0,
|
|
226
|
+
offered: 0,
|
|
227
|
+
unoffered: 0,
|
|
205
228
|
deferred: 0
|
|
206
229
|
};
|
|
207
230
|
const resolved = /* @__PURE__ */ new Map();
|
|
208
231
|
let buffer = [];
|
|
232
|
+
const discoveries = /* @__PURE__ */ new Map();
|
|
209
233
|
let runId = null;
|
|
210
234
|
let joined = false;
|
|
211
235
|
let offline = token === "";
|
|
@@ -248,16 +272,23 @@ async function startRun(passed, expected) {
|
|
|
248
272
|
if (expected !== void 0 && expected.length > EXPECTED_MAX) {
|
|
249
273
|
log(`plune: ${expected.length} tests is more than the run configuration holds \u2014 reporting the first ${EXPECTED_MAX}.`);
|
|
250
274
|
}
|
|
275
|
+
const described = {
|
|
276
|
+
...cfg.title !== void 0 ? { title: cfg.title } : {},
|
|
277
|
+
...cfg.environment !== void 0 ? { environment: cfg.environment } : {},
|
|
278
|
+
...cfg.labels !== void 0 ? { labels: cfg.labels } : {}
|
|
279
|
+
};
|
|
251
280
|
const start = await client.post("/v1/runs", {
|
|
252
281
|
schemaVersion: 2,
|
|
253
282
|
kind: cfg.kind ?? "automated",
|
|
254
283
|
...externalKey !== null ? { externalKey } : {},
|
|
255
284
|
...cfg.meta !== void 0 ? { meta: cfg.meta } : {},
|
|
256
|
-
...configuration !== void 0 ? { configuration } : {}
|
|
285
|
+
...configuration !== void 0 ? { configuration } : {},
|
|
286
|
+
...described
|
|
257
287
|
});
|
|
258
288
|
if (start.ok) {
|
|
259
289
|
runId = start.body.run.id;
|
|
260
290
|
joined = start.status === 200;
|
|
291
|
+
warnIfDropped(described, start.body.run, log);
|
|
261
292
|
} else {
|
|
262
293
|
log(`plune: could not start the run (${start.detail || start.kind}). Results will be written to ${fallbackPath}.`);
|
|
263
294
|
}
|
|
@@ -272,6 +303,36 @@ async function startRun(passed, expected) {
|
|
|
272
303
|
}
|
|
273
304
|
return unanswered ? { kind: "unanswered" } : { kind: "unmatched" };
|
|
274
305
|
}
|
|
306
|
+
function remember(result) {
|
|
307
|
+
if (!offerDiscovered) return;
|
|
308
|
+
if (result.title === void 0 || result.specRef === void 0) return;
|
|
309
|
+
if (result.keys.length === 0) return;
|
|
310
|
+
discoveries.set(result.keys[0].value, {
|
|
311
|
+
keys: result.keys,
|
|
312
|
+
title: result.title,
|
|
313
|
+
source: result.source,
|
|
314
|
+
specRef: result.specRef,
|
|
315
|
+
rawStatus: result.rawStatus
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
async function offer() {
|
|
319
|
+
if (discoveries.size === 0 || offline || runId === null) return;
|
|
320
|
+
const batches = chunk([...discoveries.values()], DISCOVER_MAX);
|
|
321
|
+
for (const [index, batch] of batches.entries()) {
|
|
322
|
+
const out = await client.post("/v1/review-items/discovered", {
|
|
323
|
+
discovered: batch,
|
|
324
|
+
runId
|
|
325
|
+
});
|
|
326
|
+
if (!out.ok) {
|
|
327
|
+
stats.unoffered = batches.slice(index).reduce((n, rest) => n + rest.length, 0);
|
|
328
|
+
log(
|
|
329
|
+
`plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.detail || out.kind}).`
|
|
330
|
+
);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
stats.offered += out.body.results.filter((r) => r.outcome === "queued").length;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
275
336
|
async function flush() {
|
|
276
337
|
if (buffer.length === 0) return;
|
|
277
338
|
const pending = buffer;
|
|
@@ -290,12 +351,16 @@ async function startRun(passed, expected) {
|
|
|
290
351
|
submissions.push({ ...rest, testCaseId: match.testCaseId });
|
|
291
352
|
} else if (match.kind === "unmatched") {
|
|
292
353
|
stats.unresolved += 1;
|
|
354
|
+
remember(result);
|
|
293
355
|
} else {
|
|
294
356
|
unanswered.push(result);
|
|
295
357
|
}
|
|
296
358
|
}
|
|
297
359
|
if (unanswered.length > 0) defer(unanswered);
|
|
298
|
-
if (submissions.length === 0)
|
|
360
|
+
if (submissions.length === 0) {
|
|
361
|
+
progress();
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
299
364
|
const out = await client.post(
|
|
300
365
|
`/v1/runs/${runId}/results`,
|
|
301
366
|
{ results: submissions }
|
|
@@ -305,6 +370,7 @@ async function startRun(passed, expected) {
|
|
|
305
370
|
stats.duplicate += out.body.counts.duplicate ?? 0;
|
|
306
371
|
stats.conflict += out.body.counts.conflict ?? 0;
|
|
307
372
|
stats.rejected += out.body.counts.rejected ?? 0;
|
|
373
|
+
progress();
|
|
308
374
|
return;
|
|
309
375
|
}
|
|
310
376
|
if (out.kind === "auth") {
|
|
@@ -317,12 +383,19 @@ async function startRun(passed, expected) {
|
|
|
317
383
|
}
|
|
318
384
|
defer(submissions);
|
|
319
385
|
}
|
|
386
|
+
function progress() {
|
|
387
|
+
const total = expected?.length ?? 0;
|
|
388
|
+
if (total <= batchSize) return;
|
|
389
|
+
const done2 = stats.accepted + stats.duplicate + stats.conflict + stats.rejected + stats.unresolved;
|
|
390
|
+
log(`plune: ${Math.min(done2, total)} of ${total} results sent`);
|
|
391
|
+
}
|
|
320
392
|
function summarise() {
|
|
321
393
|
const parts = [`${stats.accepted} accepted`];
|
|
322
394
|
if (stats.duplicate > 0) parts.push(`${stats.duplicate} already reported`);
|
|
323
395
|
if (stats.conflict > 0) parts.push(`${stats.conflict} conflicting`);
|
|
324
396
|
if (stats.rejected > 0) parts.push(`${stats.rejected} rejected`);
|
|
325
397
|
if (stats.unresolved > 0) parts.push(`${stats.unresolved} with no matching test case`);
|
|
398
|
+
if (stats.offered > 0) parts.push(`${stats.offered} offered for review`);
|
|
326
399
|
if (stats.deferred > 0) parts.push(`${stats.deferred} written to ${fallbackPath}`);
|
|
327
400
|
log(`plune: ${parts.join(" \xB7 ")}`);
|
|
328
401
|
}
|
|
@@ -345,6 +418,7 @@ async function startRun(passed, expected) {
|
|
|
345
418
|
if (done) return;
|
|
346
419
|
done = true;
|
|
347
420
|
await flush();
|
|
421
|
+
await offer();
|
|
348
422
|
if (runId !== null && !offline) {
|
|
349
423
|
const out = await client.post(`/v1/runs/${runId}/events`, {
|
|
350
424
|
event: "finish",
|
|
@@ -358,6 +432,7 @@ async function startRun(passed, expected) {
|
|
|
358
432
|
if (done) return;
|
|
359
433
|
done = true;
|
|
360
434
|
await flush();
|
|
435
|
+
await offer();
|
|
361
436
|
if (runId !== null) {
|
|
362
437
|
log(`plune: run ${runId} is still open \u2014 close it with "plune run finish ${runId}".`);
|
|
363
438
|
}
|
|
@@ -430,6 +505,13 @@ function pendingFrom(test, result) {
|
|
|
430
505
|
// Anything the test named itself comes before what we derived from its location: a Qase or
|
|
431
506
|
// TestRail id written by a fixture is a deliberate statement, and a file path is a guess.
|
|
432
507
|
keys: [...metadata?.keys ?? [], ...keysFor(test)],
|
|
508
|
+
// Read only if nothing resolves this test, and then it is what the review queue shows (D14).
|
|
509
|
+
// The full `describe > title` path rather than `test.title` alone: two suites in one file
|
|
510
|
+
// routinely share a title, and "adds an item" on its own is not something a person can judge.
|
|
511
|
+
title: titlesOf(test).join(" \u203A "),
|
|
512
|
+
// The line as well as the file. A reviewer's first move on an unknown test is to open it, and
|
|
513
|
+
// `specRef` is the only thing the entry carries that can take them there.
|
|
514
|
+
specRef: `${fileOf(test)}:${test.location.line}`,
|
|
433
515
|
source: SOURCE,
|
|
434
516
|
// The runner's own word, untouched. Mapping it is the platform's job and a project's setting.
|
|
435
517
|
rawStatus: result.status,
|
package/dist/index.js
CHANGED
|
@@ -85,12 +85,7 @@ function createClient(opts) {
|
|
|
85
85
|
}
|
|
86
86
|
return { post };
|
|
87
87
|
}
|
|
88
|
-
var UNSUPPORTED_VARS = [
|
|
89
|
-
"PLUNE_RUN_TITLE",
|
|
90
|
-
"PLUNE_ENV",
|
|
91
|
-
"PLUNE_LABELS",
|
|
92
|
-
"PLUNE_GROUP"
|
|
93
|
-
];
|
|
88
|
+
var UNSUPPORTED_VARS = ["PLUNE_GROUP"];
|
|
94
89
|
function value(env, name) {
|
|
95
90
|
const raw = env[name]?.trim();
|
|
96
91
|
return raw === void 0 || raw === "" ? void 0 : raw;
|
|
@@ -105,19 +100,35 @@ function count(env, name) {
|
|
|
105
100
|
const n = Number(raw);
|
|
106
101
|
return Number.isInteger(n) && n > 0 ? n : void 0;
|
|
107
102
|
}
|
|
103
|
+
function list(env, name) {
|
|
104
|
+
const raw = value(env, name);
|
|
105
|
+
if (raw === void 0) return void 0;
|
|
106
|
+
const items = raw.split(",").map((s) => s.trim()).filter((s) => s !== "");
|
|
107
|
+
return items.length === 0 ? void 0 : items;
|
|
108
|
+
}
|
|
108
109
|
function readEnv(env = process.env) {
|
|
109
110
|
const externalKey = value(env, "PLUNE_RUN");
|
|
110
111
|
const token = value(env, "PLUNE_TOKEN");
|
|
111
112
|
const apiUrl = value(env, "PLUNE_API_URL");
|
|
112
113
|
const fallbackPath = value(env, "PLUNE_FALLBACK");
|
|
113
114
|
const batchSize = count(env, "PLUNE_BATCH_SIZE");
|
|
115
|
+
const title = value(env, "PLUNE_RUN_TITLE");
|
|
116
|
+
const environment = value(env, "PLUNE_ENV");
|
|
117
|
+
const labels = list(env, "PLUNE_LABELS");
|
|
118
|
+
const offerDiscovered = flag(env, "PLUNE_CREATE");
|
|
114
119
|
return {
|
|
115
120
|
config: {
|
|
116
121
|
...externalKey !== void 0 ? { externalKey } : {},
|
|
117
122
|
...token !== void 0 ? { token } : {},
|
|
118
123
|
...apiUrl !== void 0 ? { apiUrl } : {},
|
|
119
124
|
...fallbackPath !== void 0 ? { fallbackPath } : {},
|
|
120
|
-
...batchSize !== void 0 ? { batchSize } : {}
|
|
125
|
+
...batchSize !== void 0 ? { batchSize } : {},
|
|
126
|
+
...title !== void 0 ? { title } : {},
|
|
127
|
+
...environment !== void 0 ? { environment } : {},
|
|
128
|
+
...labels !== void 0 ? { labels } : {},
|
|
129
|
+
// Only when set: `false` here would outrank a config file that asked for it, and an unset
|
|
130
|
+
// variable is not an instruction.
|
|
131
|
+
...offerDiscovered ? { offerDiscovered } : {}
|
|
121
132
|
},
|
|
122
133
|
// Two names for two situations that end the same way. `SHARED_RUN` says other processes are
|
|
123
134
|
// reporting into this run; `PROCEED` says the job will close it on its own schedule. Either
|
|
@@ -140,6 +151,7 @@ function appendBatch(file, batch) {
|
|
|
140
151
|
}
|
|
141
152
|
var RESOLVE_CHUNK = 500;
|
|
142
153
|
var BATCH_MAX = 500;
|
|
154
|
+
var DISCOVER_MAX = 500;
|
|
143
155
|
var BATCH_DEFAULT = 100;
|
|
144
156
|
var EXPECTED_MAX = 1e4;
|
|
145
157
|
function chunk(items, size) {
|
|
@@ -147,6 +159,14 @@ function chunk(items, size) {
|
|
|
147
159
|
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
148
160
|
return out;
|
|
149
161
|
}
|
|
162
|
+
function warnIfDropped(sent, run, log) {
|
|
163
|
+
const names = Object.keys(sent);
|
|
164
|
+
if (names.length === 0) return;
|
|
165
|
+
if (names.some((name) => run[name] != null)) return;
|
|
166
|
+
log(
|
|
167
|
+
`plune: this deployment stored none of ${names.join(", ")} \u2014 it is older than the fields. The run is otherwise reported in full.`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
150
170
|
async function startRun(passed, expected) {
|
|
151
171
|
const env = readEnv();
|
|
152
172
|
const stated = Object.fromEntries(Object.entries(passed).filter(([, v]) => v !== void 0));
|
|
@@ -156,6 +176,7 @@ async function startRun(passed, expected) {
|
|
|
156
176
|
const fallbackPath = cfg.fallbackPath ?? DEFAULT_FALLBACK_PATH;
|
|
157
177
|
const externalKey = cfg.externalKey ?? null;
|
|
158
178
|
const batchSize = Math.min(cfg.batchSize ?? BATCH_DEFAULT, BATCH_MAX);
|
|
179
|
+
const offerDiscovered = cfg.offerDiscovered ?? false;
|
|
159
180
|
const token = cfg.token ?? loadToken() ?? "";
|
|
160
181
|
const client = createClient({
|
|
161
182
|
apiUrl: resolveApiUrl(cfg.apiUrl),
|
|
@@ -168,10 +189,13 @@ async function startRun(passed, expected) {
|
|
|
168
189
|
conflict: 0,
|
|
169
190
|
rejected: 0,
|
|
170
191
|
unresolved: 0,
|
|
192
|
+
offered: 0,
|
|
193
|
+
unoffered: 0,
|
|
171
194
|
deferred: 0
|
|
172
195
|
};
|
|
173
196
|
const resolved = /* @__PURE__ */ new Map();
|
|
174
197
|
let buffer = [];
|
|
198
|
+
const discoveries = /* @__PURE__ */ new Map();
|
|
175
199
|
let runId = null;
|
|
176
200
|
let joined = false;
|
|
177
201
|
let offline = token === "";
|
|
@@ -214,16 +238,23 @@ async function startRun(passed, expected) {
|
|
|
214
238
|
if (expected !== void 0 && expected.length > EXPECTED_MAX) {
|
|
215
239
|
log(`plune: ${expected.length} tests is more than the run configuration holds \u2014 reporting the first ${EXPECTED_MAX}.`);
|
|
216
240
|
}
|
|
241
|
+
const described = {
|
|
242
|
+
...cfg.title !== void 0 ? { title: cfg.title } : {},
|
|
243
|
+
...cfg.environment !== void 0 ? { environment: cfg.environment } : {},
|
|
244
|
+
...cfg.labels !== void 0 ? { labels: cfg.labels } : {}
|
|
245
|
+
};
|
|
217
246
|
const start = await client.post("/v1/runs", {
|
|
218
247
|
schemaVersion: 2,
|
|
219
248
|
kind: cfg.kind ?? "automated",
|
|
220
249
|
...externalKey !== null ? { externalKey } : {},
|
|
221
250
|
...cfg.meta !== void 0 ? { meta: cfg.meta } : {},
|
|
222
|
-
...configuration !== void 0 ? { configuration } : {}
|
|
251
|
+
...configuration !== void 0 ? { configuration } : {},
|
|
252
|
+
...described
|
|
223
253
|
});
|
|
224
254
|
if (start.ok) {
|
|
225
255
|
runId = start.body.run.id;
|
|
226
256
|
joined = start.status === 200;
|
|
257
|
+
warnIfDropped(described, start.body.run, log);
|
|
227
258
|
} else {
|
|
228
259
|
log(`plune: could not start the run (${start.detail || start.kind}). Results will be written to ${fallbackPath}.`);
|
|
229
260
|
}
|
|
@@ -238,6 +269,36 @@ async function startRun(passed, expected) {
|
|
|
238
269
|
}
|
|
239
270
|
return unanswered ? { kind: "unanswered" } : { kind: "unmatched" };
|
|
240
271
|
}
|
|
272
|
+
function remember(result) {
|
|
273
|
+
if (!offerDiscovered) return;
|
|
274
|
+
if (result.title === void 0 || result.specRef === void 0) return;
|
|
275
|
+
if (result.keys.length === 0) return;
|
|
276
|
+
discoveries.set(result.keys[0].value, {
|
|
277
|
+
keys: result.keys,
|
|
278
|
+
title: result.title,
|
|
279
|
+
source: result.source,
|
|
280
|
+
specRef: result.specRef,
|
|
281
|
+
rawStatus: result.rawStatus
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
async function offer() {
|
|
285
|
+
if (discoveries.size === 0 || offline || runId === null) return;
|
|
286
|
+
const batches = chunk([...discoveries.values()], DISCOVER_MAX);
|
|
287
|
+
for (const [index, batch] of batches.entries()) {
|
|
288
|
+
const out = await client.post("/v1/review-items/discovered", {
|
|
289
|
+
discovered: batch,
|
|
290
|
+
runId
|
|
291
|
+
});
|
|
292
|
+
if (!out.ok) {
|
|
293
|
+
stats.unoffered = batches.slice(index).reduce((n, rest) => n + rest.length, 0);
|
|
294
|
+
log(
|
|
295
|
+
`plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.detail || out.kind}).`
|
|
296
|
+
);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
stats.offered += out.body.results.filter((r) => r.outcome === "queued").length;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
241
302
|
async function flush() {
|
|
242
303
|
if (buffer.length === 0) return;
|
|
243
304
|
const pending = buffer;
|
|
@@ -256,12 +317,16 @@ async function startRun(passed, expected) {
|
|
|
256
317
|
submissions.push({ ...rest, testCaseId: match.testCaseId });
|
|
257
318
|
} else if (match.kind === "unmatched") {
|
|
258
319
|
stats.unresolved += 1;
|
|
320
|
+
remember(result);
|
|
259
321
|
} else {
|
|
260
322
|
unanswered.push(result);
|
|
261
323
|
}
|
|
262
324
|
}
|
|
263
325
|
if (unanswered.length > 0) defer(unanswered);
|
|
264
|
-
if (submissions.length === 0)
|
|
326
|
+
if (submissions.length === 0) {
|
|
327
|
+
progress();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
265
330
|
const out = await client.post(
|
|
266
331
|
`/v1/runs/${runId}/results`,
|
|
267
332
|
{ results: submissions }
|
|
@@ -271,6 +336,7 @@ async function startRun(passed, expected) {
|
|
|
271
336
|
stats.duplicate += out.body.counts.duplicate ?? 0;
|
|
272
337
|
stats.conflict += out.body.counts.conflict ?? 0;
|
|
273
338
|
stats.rejected += out.body.counts.rejected ?? 0;
|
|
339
|
+
progress();
|
|
274
340
|
return;
|
|
275
341
|
}
|
|
276
342
|
if (out.kind === "auth") {
|
|
@@ -283,12 +349,19 @@ async function startRun(passed, expected) {
|
|
|
283
349
|
}
|
|
284
350
|
defer(submissions);
|
|
285
351
|
}
|
|
352
|
+
function progress() {
|
|
353
|
+
const total = expected?.length ?? 0;
|
|
354
|
+
if (total <= batchSize) return;
|
|
355
|
+
const done2 = stats.accepted + stats.duplicate + stats.conflict + stats.rejected + stats.unresolved;
|
|
356
|
+
log(`plune: ${Math.min(done2, total)} of ${total} results sent`);
|
|
357
|
+
}
|
|
286
358
|
function summarise() {
|
|
287
359
|
const parts = [`${stats.accepted} accepted`];
|
|
288
360
|
if (stats.duplicate > 0) parts.push(`${stats.duplicate} already reported`);
|
|
289
361
|
if (stats.conflict > 0) parts.push(`${stats.conflict} conflicting`);
|
|
290
362
|
if (stats.rejected > 0) parts.push(`${stats.rejected} rejected`);
|
|
291
363
|
if (stats.unresolved > 0) parts.push(`${stats.unresolved} with no matching test case`);
|
|
364
|
+
if (stats.offered > 0) parts.push(`${stats.offered} offered for review`);
|
|
292
365
|
if (stats.deferred > 0) parts.push(`${stats.deferred} written to ${fallbackPath}`);
|
|
293
366
|
log(`plune: ${parts.join(" \xB7 ")}`);
|
|
294
367
|
}
|
|
@@ -311,6 +384,7 @@ async function startRun(passed, expected) {
|
|
|
311
384
|
if (done) return;
|
|
312
385
|
done = true;
|
|
313
386
|
await flush();
|
|
387
|
+
await offer();
|
|
314
388
|
if (runId !== null && !offline) {
|
|
315
389
|
const out = await client.post(`/v1/runs/${runId}/events`, {
|
|
316
390
|
event: "finish",
|
|
@@ -324,6 +398,7 @@ async function startRun(passed, expected) {
|
|
|
324
398
|
if (done) return;
|
|
325
399
|
done = true;
|
|
326
400
|
await flush();
|
|
401
|
+
await offer();
|
|
327
402
|
if (runId !== null) {
|
|
328
403
|
log(`plune: run ${runId} is still open \u2014 close it with "plune run finish ${runId}".`);
|
|
329
404
|
}
|
|
@@ -396,6 +471,13 @@ function pendingFrom(test, result) {
|
|
|
396
471
|
// Anything the test named itself comes before what we derived from its location: a Qase or
|
|
397
472
|
// TestRail id written by a fixture is a deliberate statement, and a file path is a guess.
|
|
398
473
|
keys: [...metadata?.keys ?? [], ...keysFor(test)],
|
|
474
|
+
// Read only if nothing resolves this test, and then it is what the review queue shows (D14).
|
|
475
|
+
// The full `describe > title` path rather than `test.title` alone: two suites in one file
|
|
476
|
+
// routinely share a title, and "adds an item" on its own is not something a person can judge.
|
|
477
|
+
title: titlesOf(test).join(" \u203A "),
|
|
478
|
+
// The line as well as the file. A reviewer's first move on an unknown test is to open it, and
|
|
479
|
+
// `specRef` is the only thing the entry carries that can take them there.
|
|
480
|
+
specRef: `${fileOf(test)}:${test.location.line}`,
|
|
399
481
|
source: SOURCE,
|
|
400
482
|
// The runner's own word, untouched. Mapping it is the platform's job and a project's setting.
|
|
401
483
|
rawStatus: result.status,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plune-ai/playwright",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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.9.1"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|