From 1bd67cde1dffbf1e8ee2e38e8eff1a48b792c058 Mon Sep 17 00:00:00 2001 From: Gabriele Della Malva Date: Sat, 10 Oct 2026 00:30:25 +0200 Subject: [PATCH] test(ui): select accessible dialog and scroll region without DOM traversal --- .../guardrails/_components/add_guardrail_form.test.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/add_guardrail_form.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/add_guardrail_form.test.tsx index 73182fd9e8e..8e88e72bb40 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/add_guardrail_form.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails/_components/add_guardrail_form.test.tsx @@ -25,13 +25,12 @@ describe("AddGuardrailForm close behavior", () => { it("keeps the wizard bounded and scrollable on narrow viewports", () => { renderForm(); - const dialog = screen.getByText("Create guardrail").closest('[data-slot="dialog-content"]'); + const dialog = screen.getByRole("dialog"); expect(dialog).toHaveClass("max-w-[1000px]"); expect(dialog).toHaveClass("w-[calc(100vw-2rem)]"); - const scrollRegion = dialog?.querySelector(".overflow-x-auto.overflow-y-auto"); - expect(scrollRegion).not.toBeNull(); - expect(scrollRegion).toHaveClass("max-w-full"); + const scrollRegion = screen.getByTestId("guardrail-wizard-scroll-region"); + expect(scrollRegion).toHaveClass("max-w-full", "overflow-x-auto", "overflow-y-auto"); }); it("does not close when the user clicks outside the modal on the mask", () => {