From dc2ab0b2a4ca95e1a0f7cdcab207062d024094ad Mon Sep 17 00:00:00 2001 From: Manas Srivastava Date: Fri, 5 Jun 2026 13:16:20 +0530 Subject: [PATCH] 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:{: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) --- e2e/live-reads.spec.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/e2e/live-reads.spec.ts b/e2e/live-reads.spec.ts index b1ce33f..d7eac69 100644 --- a/e2e/live-reads.spec.ts +++ b/e2e/live-reads.spec.ts @@ -350,11 +350,18 @@ test.describe('LIVE — Batch A read flows (W-OBS / W-RES / W-VAULT / W-APIKEYS if (metrics.status() === STATUS_OK) { const m = await bodyJSON(metrics) expect(m.ok, 'metrics ok flag').toBe(true) + // Real prod shape: { ok, data_source, metrics: { : number[] , ... } } + // (metrics is an OBJECT keyed by series name, not a top-level array). expect( - Array.isArray(m.metrics), - `metrics must carry a metrics[] series; got ${JSON.stringify(m).slice(0, 200)}.`, + m.metrics != null && typeof m.metrics === 'object' && !Array.isArray(m.metrics), + `metrics must be an object keyed by metric name; got ${JSON.stringify(m).slice(0, 200)}.`, ).toBe(true) - expect(m.window_seconds, 'metrics must echo the resolved window_seconds').toBeTruthy() + const series = Object.values(m.metrics ?? {}) + expect( + series.length > 0 && Array.isArray(series[0]), + `metrics must carry at least one named time-series array; got ${JSON.stringify(m).slice(0, 200)}.`, + ).toBe(true) + expect(m.data_source, 'metrics must declare a data_source').toBeTruthy() } // ── Explicit DELETE assertion (W-RES formalizes the authed reap) ─────────