nathadfield commented on code in PR #63884: URL: https://github.com/apache/airflow/pull/63884#discussion_r3067104638
########## airflow-core/src/airflow/ui/src/components/Clear/useRerunWithLatestVersion.test.tsx: ########## @@ -0,0 +1,119 @@ +/*! + * 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 { act, renderHook } from "@testing-library/react"; +import { describe, expect, it, vi } from "vitest"; + +import { useConfig } from "src/queries/useConfig"; + +import { useRerunWithLatestVersion } from "./useRerunWithLatestVersion"; + +// Mock useConfig to control the global config value +vi.mock("src/queries/useConfig", () => ({ + useConfig: vi.fn(), +})); + +const mockUseConfig = vi.mocked(useConfig); + +describe("useRerunWithLatestVersion — precedence", () => { + it("returns undefined before config is resolved", () => { + mockUseConfig.mockReturnValue(undefined); + + const { result } = renderHook(() => useRerunWithLatestVersion({ dagLevelConfig: undefined })); + + expect(result.current.value).toBeUndefined(); + }); Review Comment: Good catch. Added a test that verifies the hook applies the global config when dagLevelConfig is still undefined, then correctly overrides when DAG details load with an explicit value. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
