Skip to content

Commit dc2ab0b

Browse files
fix(e2e): assert real prod metrics shape (object keyed by series, not array)
Batch A read run failed: /api/v1/resources/:id/metrics returns {ok, data_source, metrics:{<name>:number[]}} (object keyed by metric name), but the spec asserted Array.isArray(metrics). Assert the real shape: metrics is a non-array object with >=1 named time-series array + a data_source. Supersedes the conflicted #182. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 27b6005 commit dc2ab0b

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

e2e/live-reads.spec.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,18 @@ test.describe('LIVE — Batch A read flows (W-OBS / W-RES / W-VAULT / W-APIKEYS
350350
if (metrics.status() === STATUS_OK) {
351351
const m = await bodyJSON(metrics)
352352
expect(m.ok, 'metrics ok flag').toBe(true)
353+
// Real prod shape: { ok, data_source, metrics: { <metricName>: number[] , ... } }
354+
// (metrics is an OBJECT keyed by series name, not a top-level array).
353355
expect(
354-
Array.isArray(m.metrics),
355-
`metrics must carry a metrics[] series; got ${JSON.stringify(m).slice(0, 200)}.`,
356+
m.metrics != null && typeof m.metrics === 'object' && !Array.isArray(m.metrics),
357+
`metrics must be an object keyed by metric name; got ${JSON.stringify(m).slice(0, 200)}.`,
356358
).toBe(true)
357-
expect(m.window_seconds, 'metrics must echo the resolved window_seconds').toBeTruthy()
359+
const series = Object.values(m.metrics ?? {})
360+
expect(
361+
series.length > 0 && Array.isArray(series[0]),
362+
`metrics must carry at least one named time-series array; got ${JSON.stringify(m).slice(0, 200)}.`,
363+
).toBe(true)
364+
expect(m.data_source, 'metrics must declare a data_source').toBeTruthy()
358365
}
359366

360367
// ── Explicit DELETE assertion (W-RES formalizes the authed reap) ─────────

0 commit comments

Comments
 (0)