From 361f1079a2f196547a966f7dd54f201405eee7ba Mon Sep 17 00:00:00 2001 From: Ashutosh Shaha <61512480+ashutosh264@users.noreply.github.com> Date: Sun, 12 Jul 2026 21:39:50 +0530 Subject: [PATCH] [v3-3-test] Add expand/collapse all for Dag Run conf JSON in Dag Runs list (#69567) (cherry picked from commit dfd1ea30527af9dfd2c1662703f98a8f7de27796) Co-authored-by: Ashutosh Shaha <61512480+ashutosh264@users.noreply.github.com> --- .../airflow/ui/src/mocks/handlers/dag_runs.ts | 2 +- .../ui/src/pages/DagRuns/DagRuns.test.tsx | 44 ++++++++++++++++++- .../airflow/ui/src/pages/DagRuns/DagRuns.tsx | 21 +++++++-- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/airflow-core/src/airflow/ui/src/mocks/handlers/dag_runs.ts b/airflow-core/src/airflow/ui/src/mocks/handlers/dag_runs.ts index ed55e14b01986..7fcb78ebfc919 100644 --- a/airflow-core/src/airflow/ui/src/mocks/handlers/dag_runs.ts +++ b/airflow-core/src/airflow/ui/src/mocks/handlers/dag_runs.ts @@ -38,7 +38,7 @@ const dagRunBeforeFilter = { }; const dagRunInRange = { - conf: null, + conf: { batch: 42, env: "prod" }, dag_display_name: "test_dag", dag_id: "test_dag", dag_run_id: "run_in_range", diff --git a/airflow-core/src/airflow/ui/src/pages/DagRuns/DagRuns.test.tsx b/airflow-core/src/airflow/ui/src/pages/DagRuns/DagRuns.test.tsx index 50d1d9d8e6a61..3b9b19e0eabef 100644 --- a/airflow-core/src/airflow/ui/src/pages/DagRuns/DagRuns.test.tsx +++ b/airflow-core/src/airflow/ui/src/pages/DagRuns/DagRuns.test.tsx @@ -17,11 +17,19 @@ * under the License. */ import "@testing-library/jest-dom"; -import { render, screen, waitFor } from "@testing-library/react"; -import { describe, expect, it } from "vitest"; +import { fireEvent, render, screen, waitFor } from "@testing-library/react"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { AppWrapper } from "src/utils/AppWrapper"; +// Stand in for the Monaco-backed JSON viewer so the test can assert the collapse +// state without loading the editor. +vi.mock("src/components/RenderedJsonField", () => ({ + default: ({ collapsed }: { readonly collapsed?: boolean }) => ( +
+ ), +})); + // The dag_runs mock handler (see src/mocks/handlers/dag_runs.ts) returns: // - run_before_filter (logical_date: 2024-12-31) — excluded when filtering Jan 2025 // - run_in_range (logical_date: 2025-01-15) — included when filtering Jan 2025 @@ -46,3 +54,35 @@ describe("DagRuns logical date filter", () => { expect(screen.queryByText("run_before_filter")).not.toBeInTheDocument(); }); }); + +describe("DagRuns conf expand/collapse", () => { + beforeEach(() => { + // The conf column is hidden by default; reveal it so the JSON viewer renders. + globalThis.localStorage.setItem( + "dataTable:common:dagRun:columnVisibility", + JSON.stringify({ conf: true }), + ); + }); + + afterEach(() => { + globalThis.localStorage.clear(); + }); + + it("toggles conf JSON collapse state via the expand/collapse all buttons", async () => { + render(