refactor: remove redundant proxy query paths (#5928)

This commit is contained in:
SaladDay authored and GitHub committed 2026-07-31 08:52:22 +08:00
1 parent 3c1154bed9
commit 4317bd9981
9 files changed
+89 -273

No files matched your search

+16 -1
View File
@@ -3,6 +3,7 @@ import { renderHook, act, waitFor } from "@testing-library/react";
import { QueryClientProvider } from "@tanstack/react-query";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { useProxyStatus } from "@/hooks/useProxyStatus";
import { proxyKeys } from "@/lib/query/proxy";
import { createTestQueryClient } from "../utils/testQueryClient";
const toastSuccessMock = vi.fn();
@@ -99,12 +100,19 @@ describe("useProxyStatus", () => {
});
});
it("keeps the established proxy query key shapes", () => {
expect(proxyKeys.status).toEqual(["proxyStatus"]);
expect(proxyKeys.takeoverStatus).toEqual(["proxyTakeoverStatus"]);
expect(proxyKeys.globalConfig).toEqual(["globalProxyConfig"]);
expect(proxyKeys.appConfig("claude")).toEqual(["appProxyConfig", "claude"]);
});
it("shows interpolated address and port after proxy server starts", async () => {
const { wrapper } = createWrapper();
const { result } = renderHook(() => useProxyStatus(), { wrapper });
await waitFor(() => {
expect(result.current.isLoading).toBe(false);
expect(result.current.status).toBeDefined();
});
await act(async () => {
@@ -115,5 +123,12 @@ describe("useProxyStatus", () => {
"代理服务已启动 - 127.0.0.1:15721",
{ closeButton: true },
);
await act(async () => {
await result.current.stopProxyServer();
});
expect(invokeMock).toHaveBeenCalledWith("start_proxy_server");
expect(invokeMock).toHaveBeenCalledWith("stop_proxy_server");
});
});