feat: Implement Trace page (#500)

This commit is contained in:
Fine0830
2025-09-29 17:36:31 +08:00
committed by GitHub
parent dd90ab5ea7
commit a834cdb2eb
19 changed files with 386 additions and 79 deletions

View File

@@ -121,6 +121,39 @@ vi.mock("../notFound", () => ({
],
}));
vi.mock("../trace", () => ({
routesTrace: [
{
name: "Trace",
path: "",
meta: {
title: "Trace",
i18nKey: "trace",
icon: "timeline",
hasGroup: false,
activate: true,
breadcrumb: true,
notShow: false,
},
children: [
{
name: "ViewTrace",
path: "/traces/:traceId",
meta: {
title: "Trace View",
i18nKey: "traceView",
icon: "timeline",
hasGroup: false,
activate: true,
breadcrumb: true,
notShow: false,
},
},
],
},
],
}));
// Mock guards
vi.mock("../guards", () => ({
applyGuards: vi.fn(),
@@ -144,6 +177,7 @@ describe("Router Index - Route Structure", () => {
expect.objectContaining({ name: "Dashboard" }),
expect.objectContaining({ name: "Settings" }),
expect.objectContaining({ name: "NotFound" }),
expect.objectContaining({ name: "Trace" }),
]);
});
@@ -186,6 +220,14 @@ describe("Router Index - Route Structure", () => {
}),
);
});
it("should include trace routes", () => {
expect(routes).toContainEqual(
expect.objectContaining({
name: "Trace",
}),
);
});
});
describe("Route Export", () => {

View File

@@ -0,0 +1,55 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect, vi } from "vitest";
import { ROUTE_NAMES, ROUTE_PATHS, META_KEYS } from "../constants";
// Mock Vue SFC imports used by the route module
vi.mock("@/layout/Index.vue", () => ({ default: {} }));
vi.mock("@/views/dashboard/Trace.vue", () => ({ default: {} }));
// Import after mocks
import { routesTrace } from "../trace";
describe("Trace Routes", () => {
it("should export trace routes array", () => {
expect(routesTrace).toBeDefined();
expect(Array.isArray(routesTrace)).toBe(true);
expect(routesTrace).toHaveLength(1);
});
it("should have correct root trace route structure", () => {
const rootRoute = routesTrace[0];
expect(rootRoute.name).toBe(ROUTE_NAMES.TRACE);
expect(rootRoute.path).toBe("");
expect(rootRoute.meta?.[META_KEYS.NOT_SHOW]).toBe(false);
expect(rootRoute.children).toBeDefined();
expect(rootRoute.children).toHaveLength(1);
});
it("should have child view trace route with correct path and meta", () => {
const rootRoute = routesTrace[0];
const childRoute = rootRoute.children?.[0];
expect(childRoute).toBeDefined();
expect(childRoute?.name).toBe("ViewTrace");
expect(childRoute?.path).toBe(ROUTE_PATHS.TRACE);
expect(childRoute?.meta?.[META_KEYS.NOT_SHOW]).toBe(false);
});
});