diff --git a/airflow-core/src/airflow/ui/src/components/Graph/TaskLink.test.tsx b/airflow-core/src/airflow/ui/src/components/Graph/TaskLink.test.tsx new file mode 100644 index 0000000000000..0332c129dfbe4 --- /dev/null +++ b/airflow-core/src/airflow/ui/src/components/Graph/TaskLink.test.tsx @@ -0,0 +1,49 @@ +/*! + * 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 "@testing-library/jest-dom"; +import { render, screen } from "@testing-library/react"; +import { MemoryRouter, Route, Routes } from "react-router-dom"; +import { describe, expect, it } from "vitest"; + +import { BaseWrapper } from "src/utils/Wrapper"; + +import { TaskLink } from "./TaskLink"; + +describe("TaskLink", () => { + it("removes the selected try when linking to another task", () => { + render( + + + } + path="/dags/:dagId/runs/:runId/tasks/:taskId" + /> + + , + { wrapper: BaseWrapper }, + ); + + expect(screen.getByRole("link", { name: "one_try" })).toHaveAttribute( + "href", + "/dags/test_dag/runs/test_run/tasks/one_try?log_level=error", + ); + }); +}); diff --git a/airflow-core/src/airflow/ui/src/components/Graph/TaskLink.tsx b/airflow-core/src/airflow/ui/src/components/Graph/TaskLink.tsx index fb96238601f85..5ec36b34c2460 100644 --- a/airflow-core/src/airflow/ui/src/components/Graph/TaskLink.tsx +++ b/airflow-core/src/airflow/ui/src/components/Graph/TaskLink.tsx @@ -20,6 +20,7 @@ import { forwardRef } from "react"; import { useParams, useSearchParams, Link as RouterLink } from "react-router-dom"; import { TaskName, type TaskNameProps } from "src/components/TaskName"; +import { SearchParamsKeys } from "src/constants/searchParams"; import { taskNodeSeparator } from "src/utils/assetGraph"; type Props = { @@ -55,8 +56,12 @@ export const TaskLink = forwardRef(({ id, isGroup, isM ? "" : `/tasks/${taskId}${isMapped && urlTaskId !== taskId && runId !== undefined ? "/mapped" : ""}`; + const targetSearchParams = new URLSearchParams(searchParams); + + targetSearchParams.delete(SearchParamsKeys.TRY_NUMBER); + return ( - + );