test(ui): select accessible dialog and scroll region without DOM traversal

This commit is contained in:
Gabriele Della Malva 2026-10-10 00:30:25 +02:00
parent 4242c9485d
commit 1bd67cde1d

View file

@ -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", () => {