@yext/visual-editor 2.0.0-beta.11 → 2.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/{SectionLibraryVisualEditorProvider-DJMXab-H.js → SectionLibraryVisualEditorProvider-64whofF8.js} +5861 -5761
  2. package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.test.tsx +1 -0
  3. package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.tsx +9 -8
  4. package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.test.tsx +1 -1
  5. package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.tsx +104 -0
  6. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts +66 -0
  7. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorRadius.test.ts +700 -0
  8. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorResultCard.tsx +29 -1
  9. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.test.ts +370 -0
  10. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.tsx +270 -39
  11. package/dist/cli/assets/directory-locator-source/components/sections/locator/Map.tsx +91 -12
  12. package/dist/cli/assets/directory-locator-source/components/sections/locator/Results.tsx +11 -6
  13. package/dist/cli/assets/directory-locator-source/components/sections/locator/distanceUnits.ts +7 -0
  14. package/dist/cli/assets/directory-locator-source/sectionLibrarySupport.ts +4 -0
  15. package/dist/cli/yextve.js +3 -3
  16. package/dist/{createYextFieldTransforms-B7vqqb3m.d.ts → createYextFieldTransforms-w-U4b5Zf.d.ts} +27 -17
  17. package/dist/index.d.ts +36 -11
  18. package/dist/locales/platform/cs/visual-editor.json +10 -0
  19. package/dist/locales/platform/da/visual-editor.json +10 -0
  20. package/dist/locales/platform/de/visual-editor.json +10 -0
  21. package/dist/locales/platform/en/visual-editor.json +10 -0
  22. package/dist/locales/platform/en-GB/visual-editor.json +10 -0
  23. package/dist/locales/platform/es/visual-editor.json +10 -0
  24. package/dist/locales/platform/et/visual-editor.json +10 -0
  25. package/dist/locales/platform/fi/visual-editor.json +10 -0
  26. package/dist/locales/platform/fr/visual-editor.json +10 -0
  27. package/dist/locales/platform/hr/visual-editor.json +10 -0
  28. package/dist/locales/platform/hu/visual-editor.json +10 -0
  29. package/dist/locales/platform/it/visual-editor.json +10 -0
  30. package/dist/locales/platform/ja/visual-editor.json +10 -0
  31. package/dist/locales/platform/lt/visual-editor.json +10 -0
  32. package/dist/locales/platform/lv/visual-editor.json +10 -0
  33. package/dist/locales/platform/nb/visual-editor.json +10 -0
  34. package/dist/locales/platform/nl/visual-editor.json +10 -0
  35. package/dist/locales/platform/pl/visual-editor.json +10 -0
  36. package/dist/locales/platform/pt/visual-editor.json +10 -0
  37. package/dist/locales/platform/ro/visual-editor.json +10 -0
  38. package/dist/locales/platform/sk/visual-editor.json +10 -0
  39. package/dist/locales/platform/sv/visual-editor.json +10 -0
  40. package/dist/locales/platform/tr/visual-editor.json +10 -0
  41. package/dist/locales/platform/zh/visual-editor.json +10 -0
  42. package/dist/locales/platform/zh-TW/visual-editor.json +10 -0
  43. package/dist/plugin/plugin.js +2 -1
  44. package/dist/plugin/vite-plugin/layout-generation/modelProxy.d.ts +1 -1
  45. package/dist/section-library-support.js +67 -67
  46. package/dist/sectionLibrarySupport.d.ts +2 -2
  47. package/dist/{visual-editor-DTE5kxrA.js → visual-editor-B84T0Hz5.js} +84 -74
  48. package/dist/{visual-editor-6mKs9VUe.js → visual-editor-B8eVGZjZ.js} +26 -16
  49. package/dist/{visual-editor-Bs3wAslG.js → visual-editor-BTv1Bren.js} +62 -52
  50. package/dist/{visual-editor-DkHhrFsX.js → visual-editor-BWJvQ6QT.js} +110 -100
  51. package/dist/{visual-editor-D7VeTRK_.js → visual-editor-BWk-Ri1i.js} +73 -63
  52. package/dist/{visual-editor-LXMNWXry.js → visual-editor-BdM7VUac.js} +76 -66
  53. package/dist/{visual-editor-ClC6hoz3.js → visual-editor-BmM2bYhg.js} +82 -72
  54. package/dist/{visual-editor-qJW0uCiQ.js → visual-editor-BuRftlWt.js} +89 -79
  55. package/dist/{visual-editor-DjTEbi-1.js → visual-editor-BxnbtD_z.js} +63 -53
  56. package/dist/{visual-editor-CcfUKpnd.js → visual-editor-C4Nretnd.js} +59 -49
  57. package/dist/{visual-editor-Duishbsa.js → visual-editor-CFE4ijeV.js} +54 -44
  58. package/dist/{visual-editor-DtL-Zuv_.js → visual-editor-CMfDvLU2.js} +86 -76
  59. package/dist/{visual-editor-BK6fTU7k.js → visual-editor-CauX7_Ur.js} +27 -17
  60. package/dist/{visual-editor-QpGupjY5.js → visual-editor-D5d9meOo.js} +93 -83
  61. package/dist/{visual-editor-gEaWoNRu.js → visual-editor-D9U8TxD-.js} +51 -41
  62. package/dist/{visual-editor-CtQwadxQ.js → visual-editor-DBZwjDQd.js} +47 -37
  63. package/dist/{visual-editor-_TatCCAS.js → visual-editor-DI6rS2dP.js} +116 -106
  64. package/dist/{visual-editor-sOPDMkOR.js → visual-editor-DOioJ5CW.js} +84 -74
  65. package/dist/{visual-editor-zKhC7_0C.js → visual-editor-D_EvXM08.js} +71 -61
  66. package/dist/{visual-editor-BruRrJYN.js → visual-editor-DguhAL12.js} +10 -0
  67. package/dist/{visual-editor-CHWtMtlu.js → visual-editor-DmsRSmAI.js} +90 -80
  68. package/dist/{visual-editor-vomNdlNO.js → visual-editor-DnNNHiLS.js} +86 -76
  69. package/dist/{visual-editor-C9TLeAzP.js → visual-editor-DvksDrGT.js} +59 -49
  70. package/dist/{visual-editor-tPb7n5l8.js → visual-editor-XsBMHUSs.js} +66 -56
  71. package/dist/{visual-editor-gjpr-NAN.js → visual-editor-kiT3ocKi.js} +60 -50
  72. package/dist/visual-editor.css +1 -1
  73. package/dist/visual-editor.js +7003 -6609
  74. package/package.json +3 -3
@@ -15,6 +15,7 @@ import {
15
15
  import { Body, BodyProps } from "../../atoms/body.tsx";
16
16
  import { CTA, CTAVariant } from "../../atoms/cta.tsx";
17
17
  import { Heading } from "../../atoms/heading.tsx";
18
+ import type { DistanceUnit } from "./distanceUnits.ts";
18
19
  import { Image } from "../../atoms/image.tsx";
19
20
  import { msg, pt } from "../../../utils/i18n/platform.ts";
20
21
  import { PhoneAtom } from "../../atoms/phone.tsx";
@@ -176,6 +177,12 @@ export interface LocatorResultCardProps {
176
177
  /** Whether to show the "Get Directions" link */
177
178
  showGetDirectionsLink: boolean;
178
179
 
180
+ /**
181
+ * Whether to open the Get Directions link in a new tab.
182
+ * @defaultValue false
183
+ */
184
+ openInNewTab?: boolean;
185
+
179
186
  /** Whether the address block is visible in live mode */
180
187
  liveVisibility: boolean;
181
188
  };
@@ -299,6 +306,7 @@ export const DEFAULT_LOCATOR_RESULT_CARD_PROPS: LocatorResultCardProps = {
299
306
  showRegion: true,
300
307
  showCountry: false,
301
308
  showGetDirectionsLink: true,
309
+ openInNewTab: false,
302
310
  liveVisibility: true,
303
311
  },
304
312
  phone: {
@@ -613,6 +621,14 @@ export const LocatorResultCardFields: YextObjectField<LocatorResultCardProps> =
613
621
  { label: msg("fields.options.no", "No"), value: false },
614
622
  ],
615
623
  },
624
+ openInNewTab: {
625
+ label: msg("fields.openInNewTab", "Open in new tab"),
626
+ type: "radio",
627
+ options: [
628
+ { label: msg("fields.options.yes", "Yes"), value: true },
629
+ { label: msg("fields.options.no", "No"), value: false },
630
+ ],
631
+ },
616
632
  liveVisibility: {
617
633
  label: msg("fields.visibleOnLivePage", "Visible on Live Page"),
618
634
  type: "radio",
@@ -831,12 +847,14 @@ export const LocatorResultCard = React.memo(
831
847
  result,
832
848
  resultCardProps: props,
833
849
  distanceDisplay = "distanceFromUser",
850
+ distanceUnit,
834
851
  searchLocationName,
835
852
  isSelected,
836
853
  }: {
837
854
  result: CardProps<Location>["result"];
838
855
  resultCardProps: LocatorResultCardProps;
839
856
  distanceDisplay?: DistanceDisplayOption;
857
+ distanceUnit?: DistanceUnit;
840
858
  searchLocationName?: string;
841
859
  isSelected?: boolean;
842
860
  }): React.JSX.Element => {
@@ -854,7 +872,7 @@ export const LocatorResultCard = React.memo(
854
872
  ? result.distanceFromFilter
855
873
  : undefined;
856
874
 
857
- const unit = getPreferredDistanceUnit(i18n.language);
875
+ const unit = distanceUnit ?? getPreferredDistanceUnit(i18n.language);
858
876
  const unitLabel = unit === "mile" ? "mi" : "km"; // Abbreviations do not need translation
859
877
  const displayDistance =
860
878
  typeof distance === "number"
@@ -1029,6 +1047,16 @@ export const LocatorResultCard = React.memo(
1029
1047
  props.address.showGetDirectionsLink && (
1030
1048
  <a
1031
1049
  href={getDirectionsLink}
1050
+ target={
1051
+ props.address.openInNewTab
1052
+ ? "_blank"
1053
+ : undefined
1054
+ }
1055
+ rel={
1056
+ props.address.openInNewTab
1057
+ ? "noopener noreferrer"
1058
+ : undefined
1059
+ }
1032
1060
  onClick={handleGetDirectionsClick}
1033
1061
  aria-label={t("getDirectionsForLocation", {
1034
1062
  address: location.address.line1,
@@ -0,0 +1,370 @@
1
+ import React from "react";
2
+ import {
3
+ act,
4
+ cleanup,
5
+ fireEvent,
6
+ render,
7
+ screen,
8
+ } from "@testing-library/react";
9
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
10
+ import type { OnDragHandler, OnSelectParams } from "@yext/search-ui-react";
11
+ import type { State } from "@yext/search-headless-react";
12
+ import type { WithPuckProps } from "@puckeditor/core";
13
+ import type { StreamDocument } from "../../../utils/types/StreamDocument.ts";
14
+ import type { LocatorProps } from "./Locator.tsx";
15
+ import { LocatorWrapper } from "./LocatorWrapper.tsx";
16
+
17
+ const mocks = vi.hoisted(() => ({
18
+ streamDocument: { id: "locator", locale: "en" } as StreamDocument,
19
+ onDrag: undefined as OnDragHandler | undefined,
20
+ cameraPolicy: undefined as React.MutableRefObject<boolean> | undefined,
21
+ onSelect: undefined as ((params: OnSelectParams) => void) | undefined,
22
+ onOpenNow: undefined as ((selected: boolean) => void) | undefined,
23
+ onCurrentLocation: undefined as
24
+ ((position: GeolocationPosition) => void) | undefined,
25
+ actions: {
26
+ setSessionTrackingEnabled: vi.fn(),
27
+ setFacetAllowList: vi.fn(),
28
+ setVerticalLimit: vi.fn(),
29
+ setOffset: vi.fn(),
30
+ setStaticFilters: vi.fn(),
31
+ setFilterOption: vi.fn(),
32
+ executeVerticalQuery: vi.fn(),
33
+ },
34
+ state: {
35
+ vertical: { results: [], resultsCount: 0, offset: 0 },
36
+ filters: { static: [], facets: [] },
37
+ searchStatus: { isLoading: false },
38
+ },
39
+ }));
40
+
41
+ vi.mock("../../../hooks/useDocument.tsx", () => ({
42
+ useDocument: (): StreamDocument => mocks.streamDocument,
43
+ }));
44
+ vi.mock("../../../utils/searchHeadlessConfig.ts", () => ({
45
+ createSearchHeadlessConfig: () => ({}),
46
+ createSearchAnalyticsConfig: () => ({}),
47
+ }));
48
+ vi.mock("react-i18next", async (importOriginal) => ({
49
+ ...(await importOriginal<typeof import("react-i18next")>()),
50
+ useTranslation: () => ({
51
+ t: (_key: string, fallback: string): string => fallback,
52
+ i18n: { language: "en" },
53
+ }),
54
+ }));
55
+ vi.mock("@yext/pages-components", async (importOriginal) => ({
56
+ ...(await importOriginal<typeof import("@yext/pages-components")>()),
57
+ useAnalytics: () => undefined,
58
+ }));
59
+ vi.mock("@yext/search-headless-react", async (importOriginal) => ({
60
+ ...(await importOriginal<typeof import("@yext/search-headless-react")>()),
61
+ provideHeadless: () => mocks.actions,
62
+ useSearchActions: () => mocks.actions,
63
+ useSearchState: (selector: (state: State) => unknown): unknown =>
64
+ selector(mocks.state as unknown as State),
65
+ SearchHeadlessProvider: ({ children }: React.PropsWithChildren) => children,
66
+ }));
67
+ vi.mock("@yext/search-ui-react", async (importOriginal) => ({
68
+ ...(await importOriginal<typeof import("@yext/search-ui-react")>()),
69
+ AnalyticsProvider: ({ children }: React.PropsWithChildren) => children,
70
+ SearchI18nextProvider: ({ children }: React.PropsWithChildren) => children,
71
+ useAnalytics: () => undefined,
72
+ executeSearch: (): void => {
73
+ mocks.actions.executeVerticalQuery();
74
+ },
75
+ AppliedFilters: () => null,
76
+ FilterSearch: (props: {
77
+ onSelect: typeof mocks.onSelect;
78
+ geolocationProps: { handleClick: typeof mocks.onCurrentLocation };
79
+ }) => {
80
+ mocks.onSelect = props.onSelect;
81
+ mocks.onCurrentLocation = props.geolocationProps.handleClick;
82
+ return null;
83
+ },
84
+ }));
85
+ vi.mock("./Map.tsx", async (importOriginal) => ({
86
+ ...(await importOriginal<typeof import("./Map.tsx")>()),
87
+ LocatorMap: ({
88
+ onDragHandler,
89
+ preserveMapView,
90
+ }: {
91
+ onDragHandler: OnDragHandler;
92
+ preserveMapView: React.MutableRefObject<boolean>;
93
+ }) => {
94
+ mocks.cameraPolicy = preserveMapView;
95
+ mocks.onDrag = onDragHandler;
96
+ return null;
97
+ },
98
+ }));
99
+ vi.mock("./Filters.tsx", async (importOriginal) => ({
100
+ ...(await importOriginal<typeof import("./Filters.tsx")>()),
101
+ FilterModal: ({
102
+ handleOpenNowClick,
103
+ }: {
104
+ handleOpenNowClick: (selected: boolean) => void;
105
+ }) => {
106
+ mocks.onOpenNow = handleOpenNowClick;
107
+ return null;
108
+ },
109
+ }));
110
+ vi.mock("./Results.tsx", () => ({
111
+ RESULTS_LIMIT: 20,
112
+ ResultsCountSummary: () => null,
113
+ }));
114
+
115
+ /** Send the map callback with a center and a radius in meters. */
116
+ const moveMap = (latitude: number, radius: number): void => {
117
+ act((): void => {
118
+ mocks.onDrag?.(
119
+ {
120
+ latitude,
121
+ longitude: -74,
122
+ distanceTo: (): number => radius,
123
+ } as unknown as Parameters<OnDragHandler>[0],
124
+ {
125
+ getNorthEast: () => ({ latitude: latitude + 1, longitude: -73 }),
126
+ } as Parameters<OnDragHandler>[1]
127
+ );
128
+ });
129
+ };
130
+
131
+ describe("Locator map search", () => {
132
+ beforeEach((): void => {
133
+ vi.useFakeTimers();
134
+ vi.clearAllMocks();
135
+ mocks.streamDocument.__ = undefined;
136
+ mocks.onDrag = undefined;
137
+ window.history.replaceState({}, "", "/?q=40,-74,10000&ref=test");
138
+ });
139
+ afterEach((): void => {
140
+ cleanup();
141
+ vi.useRealTimers();
142
+ });
143
+
144
+ it.each([undefined, false, true])(
145
+ "when autoSearchOnMapMove is %s then map search uses the selected mode",
146
+ (autoSearchOnMapMove): void => {
147
+ render(
148
+ React.createElement(LocatorWrapper, {
149
+ autoSearchOnMapMove,
150
+ filters: { openNowButton: false, showDistanceOptions: false },
151
+ resultCard: [],
152
+ locationStyles: [],
153
+ puck: {
154
+ metadata: {},
155
+ isEditing: false,
156
+ dragRef: null,
157
+ renderDropZone: () => null,
158
+ },
159
+ } as WithPuckProps<LocatorProps>)
160
+ );
161
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(1);
162
+ act((): void => {
163
+ vi.advanceTimersByTime(1000);
164
+ });
165
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(1);
166
+ moveMap(41, 5000);
167
+ act((): void => {
168
+ vi.advanceTimersByTime(400);
169
+ });
170
+ moveMap(42, 2000);
171
+ act((): void => {
172
+ vi.advanceTimersByTime(499);
173
+ });
174
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(1);
175
+ act((): void => {
176
+ vi.advanceTimersByTime(1);
177
+ });
178
+ if (!autoSearchOnMapMove) {
179
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(1);
180
+ fireEvent.click(
181
+ screen.getByRole("button", { name: "Search This Area" })
182
+ );
183
+ } else {
184
+ expect(
185
+ screen.queryByRole("button", { name: "Search This Area" })
186
+ ).toBeNull();
187
+ }
188
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(2);
189
+ expect(mocks.cameraPolicy?.current).toBe(!!autoSearchOnMapMove);
190
+ expect(mocks.actions.setOffset).toHaveBeenLastCalledWith(0);
191
+ expect(mocks.actions.setStaticFilters).toHaveBeenLastCalledWith([
192
+ expect.objectContaining({
193
+ filter: expect.objectContaining({
194
+ value: {
195
+ lat: 42,
196
+ lng: -74,
197
+ radius: 2000,
198
+ name: "Custom Search Area",
199
+ },
200
+ }),
201
+ }),
202
+ expect.objectContaining({ selected: false }),
203
+ ]);
204
+ expect(new URLSearchParams(window.location.search).get("q")).toBe(
205
+ "42,-74,2000"
206
+ );
207
+ expect(new URLSearchParams(window.location.search).get("ref")).toBe(
208
+ "test"
209
+ );
210
+ act((): void => {
211
+ vi.advanceTimersByTime(1000);
212
+ });
213
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(2);
214
+ }
215
+ );
216
+
217
+ it.each([
218
+ "disable",
219
+ "disableMap",
220
+ "unmount",
221
+ "navigate",
222
+ "select",
223
+ "geolocate",
224
+ ])(
225
+ "when %s occurs then the pending map search is canceled",
226
+ (action): void => {
227
+ const props = {
228
+ autoSearchOnMapMove: true,
229
+ filters: { openNowButton: false, showDistanceOptions: false },
230
+ resultCard: [],
231
+ locationStyles: [],
232
+ puck: {
233
+ metadata: {},
234
+ isEditing: false,
235
+ dragRef: null,
236
+ renderDropZone: () => null,
237
+ },
238
+ } as WithPuckProps<LocatorProps>;
239
+ const { rerender, unmount } = render(
240
+ React.createElement(LocatorWrapper, props)
241
+ );
242
+ moveMap(41, 5000);
243
+ act((): void => {
244
+ vi.advanceTimersByTime(400);
245
+ });
246
+ act((): void => {
247
+ if (action === "disable") {
248
+ rerender(
249
+ React.createElement(LocatorWrapper, {
250
+ ...props,
251
+ autoSearchOnMapMove: false,
252
+ })
253
+ );
254
+ } else if (action === "disableMap") {
255
+ (window as unknown as { disableMap: () => void }).disableMap();
256
+ } else if (action === "unmount") {
257
+ unmount();
258
+ } else if (action === "navigate") {
259
+ window.history.replaceState({}, "", "/?q=39,-73,3000");
260
+ window.dispatchEvent(new PopStateEvent("popstate"));
261
+ } else if (action === "select") {
262
+ mocks.onSelect?.({
263
+ newDisplayName: "Boston",
264
+ newFilter: {
265
+ kind: "fieldValue",
266
+ fieldId: "builtin.location",
267
+ matcher: "$near",
268
+ value: { lat: 42, lng: -71, radius: 3000 },
269
+ },
270
+ } as OnSelectParams);
271
+ } else {
272
+ mocks.onCurrentLocation?.({
273
+ coords: { latitude: 43, longitude: -72, accuracy: 100 },
274
+ } as GeolocationPosition);
275
+ }
276
+ });
277
+ const searchCount = mocks.actions.executeVerticalQuery.mock.calls.length;
278
+ act((): void => {
279
+ vi.advanceTimersByTime(1000);
280
+ });
281
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(
282
+ searchCount
283
+ );
284
+ }
285
+ );
286
+
287
+ it("when Open Now changes during the delay then map search uses the current filter", (): void => {
288
+ render(
289
+ React.createElement(LocatorWrapper, {
290
+ autoSearchOnMapMove: true,
291
+ filters: { openNowButton: true, showDistanceOptions: false },
292
+ resultCard: [],
293
+ locationStyles: [],
294
+ puck: {
295
+ metadata: {},
296
+ isEditing: false,
297
+ dragRef: null,
298
+ renderDropZone: () => null,
299
+ },
300
+ } as WithPuckProps<LocatorProps>)
301
+ );
302
+ moveMap(41, 5000);
303
+ act((): void => {
304
+ vi.advanceTimersByTime(400);
305
+ });
306
+ act((): void => {
307
+ mocks.onOpenNow?.(true);
308
+ });
309
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(2);
310
+ act((): void => {
311
+ vi.advanceTimersByTime(100);
312
+ });
313
+ expect(mocks.actions.executeVerticalQuery).toHaveBeenCalledTimes(3);
314
+ expect(mocks.actions.setStaticFilters).toHaveBeenLastCalledWith([
315
+ expect.objectContaining({
316
+ filter: expect.objectContaining({
317
+ value: expect.objectContaining({ lat: 41, radius: 5000 }),
318
+ }),
319
+ }),
320
+ expect.objectContaining({ selected: true }),
321
+ ]);
322
+ });
323
+ it.each(["select", "geolocate", "navigate", "filter"])(
324
+ "when %s follows automatic area search then camera changes are allowed",
325
+ (action: string): void => {
326
+ render(
327
+ React.createElement(LocatorWrapper, {
328
+ autoSearchOnMapMove: true,
329
+ filters: { openNowButton: true, showDistanceOptions: false },
330
+ resultCard: [],
331
+ locationStyles: [],
332
+ puck: {
333
+ metadata: {},
334
+ isEditing: false,
335
+ dragRef: null,
336
+ renderDropZone: () => null,
337
+ },
338
+ } as WithPuckProps<LocatorProps>)
339
+ );
340
+ moveMap(41, 5000);
341
+ act((): void => {
342
+ vi.advanceTimersByTime(500);
343
+ });
344
+ expect(mocks.cameraPolicy?.current).toBe(true);
345
+ act((): void => {
346
+ if (action === "select") {
347
+ mocks.onSelect?.({
348
+ newDisplayName: "Boston",
349
+ newFilter: {
350
+ kind: "fieldValue",
351
+ fieldId: "builtin.location",
352
+ matcher: "$near",
353
+ value: { lat: 42, lng: -71, radius: 3000 },
354
+ },
355
+ } as OnSelectParams);
356
+ } else if (action === "geolocate") {
357
+ mocks.onCurrentLocation?.({
358
+ coords: { latitude: 43, longitude: -72, accuracy: 100 },
359
+ } as GeolocationPosition);
360
+ } else if (action === "navigate") {
361
+ window.history.replaceState({}, "", "/?q=39,-73,3000");
362
+ window.dispatchEvent(new PopStateEvent("popstate"));
363
+ } else {
364
+ mocks.onOpenNow?.(true);
365
+ }
366
+ });
367
+ expect(mocks.cameraPolicy?.current).toBe(false);
368
+ }
369
+ );
370
+ });