import { screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { VENDOR_DIALOG_SURFACE_MAX_HEIGHT, VendorDialog, } from "@/app/(protected)/workorders/_components/list/table/cells/vendor-dialog"; import { VendorDialogCompanyCard } from "@/app/(protected)/workorders/_components/list/table/cells/vendor-dialog-company-card"; import type { VendorDropdownItem } from "@/domain/work-orders/types/work-order"; import { renderWithProviders } from "@/test/test-utils"; vi.mock("@/domain/vendors/use-cases/use-add-technicians-to-company", () => ({ useAddTechniciansToCompany: () => ({ mutateAsync: vi.fn(), isPending: false, }), })); const LIVE_VENDOR: VendorDropdownItem = { id: 10, companyName: "Gateway Plumbing", contactName: "Jordan Lee", tradeSpecialties: "Plumbing", address: "900 Live St", distanceMiles: 4.2, email: "dispatch@gateway.test", }; describe("VendorDialogCompanyCard map preview queries", () => { it("embeds the live vendor address", () => { renderWithProviders( , { withAuth: false }, ); const frame = screen.getByTitle("Map of 900 Live St"); expect(frame).toHaveAttribute( "src", "https://www.google.com/maps?q=900%20Live%20St&output=embed", ); }); it("embeds the frozen company's composed snapshot address, not the live one", () => { renderWithProviders( , { withAuth: false }, ); const frame = screen.getByTitle("Map of 200 Vendor Ave, Chicago, IL, 60602"); expect(frame).toHaveAttribute( "src", "https://www.google.com/maps?q=200%20Vendor%20Ave%2C%20Chicago%2C%20IL%2C%2060602&output=embed", ); expect(screen.queryByTitle("Map of 900 Live St")).not.toBeInTheDocument(); }); }); describe("VendorDialog scroll boundary", () => { it("bounds the dialog surface and scrolls internally", () => { renderWithProviders( , ); const surface = screen.getByRole("dialog"); expect(VENDOR_DIALOG_SURFACE_MAX_HEIGHT).toBe("55vh"); expect(surface.style.maxHeight).toBe(VENDOR_DIALOG_SURFACE_MAX_HEIGHT); expect(surface.style.display).toBe("flex"); const content = screen.getByRole("dialog").querySelector(".MuiDialogContent-root"); expect(content).not.toBeNull(); expect(content).toHaveStyle({ overflowY: "auto", minHeight: "0px" }); }); });