diff --git a/src/app/(protected)/locations/_components/site-form-fields.tsx b/src/app/(protected)/locations/_components/site-form-fields.tsx
index dfc94ead..29be2a4f 100644
--- a/src/app/(protected)/locations/_components/site-form-fields.tsx
+++ b/src/app/(protected)/locations/_components/site-form-fields.tsx
@@ -27,7 +27,11 @@ export function SiteFormFields({
register,
formState: { errors },
} = form;
- const [address, city, state] = useWatch({ control, name: ["address", "city", "state"] });
+ // ZIP is carried through unedited, so the preview shows the same line as the Street Address link.
+ const [address, city, state, zipCode] = useWatch({
+ control,
+ name: ["address", "city", "state", "zipCode"],
+ });
const { field: addressField } = useController({ control, name: "address" });
const { field: cityField } = useController({ control, name: "city" });
const { field: stateField } = useController({ control, name: "state" });
@@ -84,7 +88,13 @@ export function SiteFormFields({
/>
-
+
{
).not.toBeInTheDocument();
});
- it("edit mode swaps the map for the placeholder while City is cleared", async () => {
+ it("edit mode previews the stored ZIP and swaps the map for the placeholder while City is cleared", async () => {
renderWithProviders(, { withAuth: false });
const region = await openSite("DAL1");
fireEvent.click(within(region).getByRole("button", { name: "Edit" }));
- expect(within(region).getByTitle("Site location map")).toBeInTheDocument();
+ expect(within(region).getByTitle("Site location map")).toHaveAttribute(
+ "src",
+ "https://www.google.com/maps?q=3811%20Distribution%20Dr%2C%20Dallas%2C%20TX%2075201&output=embed",
+ );
const city = within(region).getByRole("textbox", { name: "City" });
fireEvent.change(city, { target: { value: "" } });
@@ -162,7 +165,7 @@ describe("Sites page detail panel", () => {
fireEvent.change(city, { target: { value: "Fort Worth" } });
expect(await within(region).findByTitle("Site location map")).toHaveAttribute(
"src",
- "https://www.google.com/maps?q=3811%20Distribution%20Dr%2C%20Fort%20Worth%2C%20TX&output=embed",
+ "https://www.google.com/maps?q=3811%20Distribution%20Dr%2C%20Fort%20Worth%2C%20TX%2075201&output=embed",
);
});