This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/rocketmq-studio by this push:
new 6a68042fa fix(web): type the metrics explorer test fixture as
MetricData (#5305)
6a68042fa is described below
commit 6a68042fa73a513f40436ca721944b4de48181ec
Author: lizhimins <[email protected]>
AuthorDate: Fri Oct 2 00:36:45 2026 +0800
fix(web): type the metrics explorer test fixture as MetricData (#5305)
`metricData` had no annotation, so TypeScript inferred `series[].labels` as
the
literal `{ cluster: string; node_id: string }` instead of the
`Record<string, string>`
that `MetricSeries` declares. `createDeferred<typeof metricData>()` then
pinned that
narrow shape as the deferred's payload type, so the case added by #4888 -
which resolves
a custom-query series labelled `{ cluster: 'prod', query: 'custom' }` -
fails the excess
property check:
src/components/__tests__/MetricsExplorer.test.tsx(516,38): error TS2353:
Object literal may only specify known properties, and 'query' does
not exist
in type '{ cluster: string; node_id: string; }'.
`tsc -b` therefore fails, which breaks `npm run build` (it is `tsc -b &&
vite build &&
npm run license:check`) and with it the frontend CI job and
`web/Dockerfile`. `npm test`
stays green because vitest transpiles through esbuild and never
type-checks, so nothing
in the test pipeline caught it.
Annotating the fixture with the API contract type it is standing in for
restores the
open `Record<string, string>` label map. Type-only: no runtime behaviour
changes.
---
web/src/components/__tests__/MetricsExplorer.test.tsx | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/web/src/components/__tests__/MetricsExplorer.test.tsx
b/web/src/components/__tests__/MetricsExplorer.test.tsx
index 97a1425b7..70660aeb3 100644
--- a/web/src/components/__tests__/MetricsExplorer.test.tsx
+++ b/web/src/components/__tests__/MetricsExplorer.test.tsx
@@ -22,7 +22,12 @@ import type React from 'react';
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from
'vitest';
import { listDataSources } from '../../api/settings';
-import { listMetricProfiles, queryByDataSource, queryMetrics } from
'../../api/metrics';
+import {
+ listMetricProfiles,
+ queryByDataSource,
+ queryMetrics,
+ type MetricData,
+} from '../../api/metrics';
import { LangProvider, useLang } from '../../i18n/LangContext';
import { downloadCsv } from '../../utils/download';
import {
@@ -83,7 +88,7 @@ const profiles = [
},
];
-const metricData = {
+const metricData: MetricData = {
resultType: 'matrix',
series: [
{