Skip to content

Commit cfcfd45

Browse files
committed
test(dashboard-agent): assert the chart validation window outside the fetch stub, where a failure counts
1 parent d1c39a9 commit cfcfd45

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

internal-packages/dashboard-agent/src/dashboard-agent.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,19 +2071,21 @@ describe("buildDashboardAgentTools", () => {
20712071
});
20722072

20732073
it("render_view commits the chart when its query runs, validating it once", async () => {
2074+
// Collected, never asserted here: render_view swallows a throw out of the stub, as
2075+
// the sibling test below relies on.
2076+
const queryBodies: unknown[] = [];
20742077
const fetchStub = stubFetch((url, init) => {
20752078
if (url.endsWith("/jwt")) return { body: { token: "jwt_1" } };
2076-
// The validation runs the same window the panel will render.
2077-
expect(JSON.parse(String(init?.body))).toMatchObject({
2078-
scope: "environment",
2079-
period: "24h",
2080-
});
2079+
queryBodies.push(JSON.parse(String(init?.body)));
20812080
return { body: { results: [{ bucket: "2026-01-01T00:00:00Z", runs: 1 }] } };
20822081
});
20832082
try {
20842083
// The rows aren't embedded in the block — the panel stays the runner.
20852084
await expect(renderView(ENV_CTX, CHART_SPEC)).resolves.toEqual({ blocks: CHART_SPEC.blocks });
20862085
expect(queryRequests(fetchStub.requests)).toHaveLength(1);
2086+
// The validation runs the same window the panel will render.
2087+
expect(queryBodies).toHaveLength(1);
2088+
expect(queryBodies[0]).toMatchObject({ scope: "environment", period: "24h" });
20872089
} finally {
20882090
fetchStub.restore();
20892091
}

0 commit comments

Comments
 (0)