test: implement unit tests for hooks and refactor some types (#493)

This commit is contained in:
Fine0830
2025-08-21 12:09:32 +07:00
committed by GitHub
parent a8c5ec8dd2
commit 1b6f011f0e
25 changed files with 3140 additions and 285 deletions

View File

@@ -165,7 +165,7 @@ limitations under the License. -->
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
EntityType[2].value,
);
currentEndpoints.value = params.data;
currentEndpoints.value = params.data as Endpoint[];
colMetrics.value = params.names;
colSubMetrics.value = params.subNames;
metricConfig.value = params.metricConfigArr;

View File

@@ -91,6 +91,7 @@ limitations under the License. -->
import getDashboard from "@/hooks/useDashboardsSession";
import type { MetricConfigOpt } from "@/types/dashboard";
import ColumnGraph from "./components/ColumnGraph.vue";
import type { PodWithMetrics } from "@/hooks/useExpressionsProcessor";
/*global defineProps */
const props = defineProps({
@@ -176,11 +177,11 @@ limitations under the License. -->
if (expressions.length && expressions[0]) {
const params = await useExpressionsQueryPodsMetrics(
currentInstances,
currentInstances as PodWithMetrics[],
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
EntityType[3].value,
);
instances.value = params.data;
instances.value = params.data as Instance[];
colMetrics.value = params.names;
colSubMetrics.value = params.subNames;
typesOfMQE.value = params.metricTypesArr;

View File

@@ -78,14 +78,14 @@ limitations under the License. -->
import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app";
import type { Service } from "@/types/selector";
import { useExpressionsQueryPodsMetrics } from "@/hooks/useExpressionsProcessor";
import { useExpressionsQueryPodsMetrics, PodWithMetrics } from "@/hooks/useExpressionsProcessor";
import { EntityType } from "../data";
import router from "@/router";
import getDashboard from "@/hooks/useDashboardsSession";
import type { MetricConfigOpt } from "@/types/dashboard";
import ColumnGraph from "./components/ColumnGraph.vue";
interface ServiceWithGroup extends Service {
export interface ServiceWithGroup extends Service {
merge: boolean;
group: string;
}
@@ -219,11 +219,11 @@ limitations under the License. -->
if (expressions.length && expressions[0]) {
const params = await useExpressionsQueryPodsMetrics(
currentServices,
currentServices as PodWithMetrics[],
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
EntityType[0].value,
);
services.value = params.data;
services.value = params.data as ServiceWithGroup[];
colMetrics.value = params.names;
colSubMetrics.value = params.subNames;
metricConfig.value = params.metricConfigArr;