From b8a53f9e36ed29bc9dd49fdd7940de5de40135b5 Mon Sep 17 00:00:00 2001 From: YoVinchen Date: Fri, 30 Jan 2026 00:11:11 +0800 Subject: [PATCH] fix(test): move orphaned test into describe block Move "clears loading flag when all mutations idle" test inside the describe("useProviderActions") block for proper test isolation. --- src/hooks/commonConfigAdapters.ts | 14 +++++--------- src/hooks/useCommonConfigBase.ts | 5 ++++- tests/hooks/useProviderActions.test.tsx | 23 ++++++++++++----------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/hooks/commonConfigAdapters.ts b/src/hooks/commonConfigAdapters.ts index badb7d870..d7763eb8b 100644 --- a/src/hooks/commonConfigAdapters.ts +++ b/src/hooks/commonConfigAdapters.ts @@ -205,7 +205,9 @@ export const codexAdapter: CommonConfigAdapter = { } const error = validateTomlFormat(snippet); if (error) { - return t("codexConfig.tomlFormatError", { defaultValue: "TOML 格式错误" }); + return t("codexConfig.tomlFormatError", { + defaultValue: "TOML 格式错误", + }); } return ""; }, @@ -214,11 +216,7 @@ export const codexAdapter: CommonConfigAdapter = { return extractConfigToml(input); }, - computeFinal: ( - custom: string, - common: string, - enabled: boolean, - ): string => { + computeFinal: (custom: string, common: string, enabled: boolean): string => { if (!enabled || !hasTomlContent(common)) { return custom; } @@ -274,9 +272,7 @@ export function createGeminiAdapter( defaultSnippet: GEMINI_DEFAULT_SNIPPET, legacyStorageKey: GEMINI_LEGACY_STORAGE_KEY, - parseSnippet: ( - snippet: string, - ): ParseResult> => { + parseSnippet: (snippet: string): ParseResult> => { const result = parseGeminiCommonConfigSnippet(snippet, { strictForbiddenKeys: true, }); diff --git a/src/hooks/useCommonConfigBase.ts b/src/hooks/useCommonConfigBase.ts index 49c5caf1a..cd7d8230a 100644 --- a/src/hooks/useCommonConfigBase.ts +++ b/src/hooks/useCommonConfigBase.ts @@ -176,7 +176,10 @@ export function useCommonConfigBase({ initialData, selectedPresetId, enabled = true, -}: UseCommonConfigBaseProps): UseCommonConfigBaseReturn { +}: UseCommonConfigBaseProps< + TConfig, + TFinal +>): UseCommonConfigBaseReturn { const { t } = useTranslation(); // ============================================================================ diff --git a/tests/hooks/useProviderActions.test.tsx b/tests/hooks/useProviderActions.test.tsx index b02226ba9..0703df9e9 100644 --- a/tests/hooks/useProviderActions.test.tsx +++ b/tests/hooks/useProviderActions.test.tsx @@ -450,17 +450,18 @@ describe("useProviderActions", () => { expect(result.current.isLoading).toBe(true); }); -}); -it("clears loading flag when all mutations idle", () => { - addProviderMutation.isPending = false; - updateProviderMutation.isPending = false; - deleteProviderMutation.isPending = false; - switchProviderMutation.isPending = false; - const { wrapper } = createWrapper(); - const { result } = renderHook(() => useProviderActions("claude"), { - wrapper, + it("clears loading flag when all mutations idle", () => { + addProviderMutation.isPending = false; + updateProviderMutation.isPending = false; + deleteProviderMutation.isPending = false; + switchProviderMutation.isPending = false; + + const { wrapper } = createWrapper(); + const { result } = renderHook(() => useProviderActions("claude"), { + wrapper, + }); + + expect(result.current.isLoading).toBe(false); }); - - expect(result.current.isLoading).toBe(false); });