import "../../../tests/web/test-utils"; import { render } from "@testing-library/react"; import { describe, expect, test, vi } from "bun:test"; import type { TargetStatus } from "../../../src/shared/api"; import { TargetBoard } from "../../../src/web/components/TargetBoard"; // Mock useMeta hook void vi.mock("../../../src/web/hooks/use-queries", () => ({ useMeta: () => ({ data: { checkerTypes: ["http", "cmd"] }, }), })); describe("TargetBoard", () => { const onTargetClick = vi.fn(); const targets: TargetStatus[] = [ { currentStreak: null, group: "default", id: "1", interval: "30s", latestCheck: null, name: "target-1", recentSamples: [], stats: { availability: 100, downChecks: 0, totalChecks: 0, upChecks: 0 }, target: "https://example.com", type: "http", }, { currentStreak: null, group: "production", id: "2", interval: "30s", latestCheck: null, name: "target-2", recentSamples: [], stats: { availability: 100, downChecks: 0, totalChecks: 0, upChecks: 0 }, target: "https://example.org", type: "http", }, ]; test("有 targets 时不崩溃", () => { const { container } = render(); expect(container.firstChild).not.toBeNull(); }); test("空 targets 列表不崩溃", () => { const { container } = render(); expect(container.firstChild).not.toBeNull(); }); });