@yext/visual-editor 1.4.14 → 2.0.0-beta.10

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 (234) hide show
  1. package/dist/SectionLibraryVisualEditorProvider-DN65KSX7.js +119824 -0
  2. package/dist/SectionLibraryVisualEditorProvider.css +1 -0
  3. package/dist/cli/assets/directory-locator-source/components/contentBlocks/Address.tsx +251 -0
  4. package/dist/cli/assets/directory-locator-source/components/contentBlocks/HeadingText.tsx +147 -0
  5. package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursStatus.tsx +157 -0
  6. package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursTable.tsx +164 -0
  7. package/dist/cli/assets/directory-locator-source/components/contentBlocks/MapboxStaticMap.tsx +205 -0
  8. package/dist/cli/assets/directory-locator-source/components/contentBlocks/Phone.tsx +155 -0
  9. package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/EmptyImageState.tsx +168 -0
  10. package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/Image.tsx +275 -0
  11. package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/styling.ts +66 -0
  12. package/dist/cli/assets/directory-locator-source/components/contentBlocks/index.ts +13 -0
  13. package/dist/cli/assets/directory-locator-source/components/sections/Breadcrumbs.tsx +298 -0
  14. package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.test.tsx +872 -0
  15. package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.tsx +298 -0
  16. package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryCard.tsx +507 -0
  17. package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryWrapper.tsx +499 -0
  18. package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.test.tsx +226 -0
  19. package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.tsx +98 -0
  20. package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.test.tsx +147 -0
  21. package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.tsx +691 -0
  22. package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.test.tsx +1551 -0
  23. package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.tsx +541 -0
  24. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts +43 -0
  25. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorResultCard.tsx +1594 -0
  26. package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.tsx +1157 -0
  27. package/dist/cli/assets/directory-locator-source/components/sections/locator/Map.tsx +304 -0
  28. package/dist/cli/assets/directory-locator-source/components/sections/locator/MapPinIcon.tsx +160 -0
  29. package/dist/cli/assets/directory-locator-source/components/sections/locator/Results.tsx +267 -0
  30. package/dist/cli/assets/directory-locator-source/sectionLibrarySupport.ts +277 -0
  31. package/dist/cli/yextve.js +16992 -0
  32. package/dist/createYextFieldTransforms-CrIkiJ_X.d.ts +2157 -0
  33. package/dist/index.d.ts +534 -6352
  34. package/dist/locales/page/cs/visual-editor.json +85 -0
  35. package/dist/locales/page/da/visual-editor.json +73 -0
  36. package/dist/locales/page/de/visual-editor.json +73 -0
  37. package/dist/locales/page/en/visual-editor.json +73 -0
  38. package/dist/locales/page/en-GB/visual-editor.json +73 -0
  39. package/dist/locales/page/es/visual-editor.json +79 -0
  40. package/dist/locales/page/et/visual-editor.json +73 -0
  41. package/dist/locales/page/fi/visual-editor.json +73 -0
  42. package/dist/locales/page/fr/visual-editor.json +79 -0
  43. package/dist/locales/page/hr/visual-editor.json +79 -0
  44. package/dist/locales/page/hu/visual-editor.json +73 -0
  45. package/dist/locales/page/it/visual-editor.json +79 -0
  46. package/dist/locales/page/ja/visual-editor.json +73 -0
  47. package/dist/locales/page/lt/visual-editor.json +85 -0
  48. package/dist/locales/page/lv/visual-editor.json +77 -0
  49. package/dist/locales/page/nb/visual-editor.json +73 -0
  50. package/dist/locales/page/nl/visual-editor.json +73 -0
  51. package/dist/locales/page/pl/visual-editor.json +85 -0
  52. package/dist/locales/page/pt/visual-editor.json +79 -0
  53. package/dist/locales/page/ro/visual-editor.json +79 -0
  54. package/dist/locales/page/sk/visual-editor.json +85 -0
  55. package/dist/locales/page/sv/visual-editor.json +73 -0
  56. package/dist/locales/page/tr/visual-editor.json +73 -0
  57. package/dist/locales/page/zh/visual-editor.json +73 -0
  58. package/dist/locales/page/zh-TW/visual-editor.json +73 -0
  59. package/dist/locales/platform/cs/visual-editor.json +651 -0
  60. package/dist/locales/platform/da/visual-editor.json +625 -0
  61. package/dist/locales/platform/de/visual-editor.json +625 -0
  62. package/dist/locales/platform/en/visual-editor.json +625 -0
  63. package/dist/locales/platform/en-GB/visual-editor.json +625 -0
  64. package/dist/locales/platform/es/visual-editor.json +638 -0
  65. package/dist/locales/platform/et/visual-editor.json +625 -0
  66. package/dist/locales/platform/fi/visual-editor.json +625 -0
  67. package/dist/locales/platform/fr/visual-editor.json +638 -0
  68. package/dist/locales/platform/hr/visual-editor.json +638 -0
  69. package/dist/locales/platform/hu/visual-editor.json +625 -0
  70. package/dist/locales/platform/it/visual-editor.json +638 -0
  71. package/dist/locales/platform/ja/visual-editor.json +625 -0
  72. package/dist/locales/platform/lt/visual-editor.json +651 -0
  73. package/dist/locales/platform/lv/visual-editor.json +633 -0
  74. package/dist/locales/platform/nb/visual-editor.json +625 -0
  75. package/dist/locales/platform/nl/visual-editor.json +625 -0
  76. package/dist/locales/platform/pl/visual-editor.json +651 -0
  77. package/dist/locales/platform/pt/visual-editor.json +638 -0
  78. package/dist/locales/platform/ro/visual-editor.json +638 -0
  79. package/dist/locales/platform/sk/visual-editor.json +651 -0
  80. package/dist/locales/platform/sv/visual-editor.json +625 -0
  81. package/dist/locales/platform/tr/visual-editor.json +625 -0
  82. package/dist/locales/platform/zh/visual-editor.json +625 -0
  83. package/dist/locales/platform/zh-TW/visual-editor.json +625 -0
  84. package/dist/plugin/internal/layoutGeneration/limits.d.ts +28 -0
  85. package/dist/plugin/internal/sectionLibraryValidation/builtInTranslationResources.d.ts +3 -0
  86. package/dist/plugin/internal/sectionLibraryValidation/stages/api/api.d.ts +7 -0
  87. package/dist/plugin/internal/sectionLibraryValidation/stages/api/libraryMetadata.d.ts +7 -0
  88. package/dist/plugin/internal/sectionLibraryValidation/stages/code/importRules.d.ts +13 -0
  89. package/dist/plugin/internal/sectionLibraryValidation/stages/code/validateCode.d.ts +10 -0
  90. package/dist/plugin/internal/sectionLibraryValidation/stages/code/xssRules.d.ts +7 -0
  91. package/dist/plugin/internal/sectionLibraryValidation/stages/structure/structure.d.ts +7 -0
  92. package/dist/plugin/internal/sectionLibraryValidation/types.d.ts +48 -0
  93. package/dist/plugin/internal/sectionLibraryValidation/validateSectionLibrary.d.ts +8 -0
  94. package/dist/plugin/internal/sectionLibraryValidation/validationError.d.ts +6 -0
  95. package/dist/plugin/plugin.js +7013 -5873
  96. package/dist/plugin/types/entityFields.d.ts +21 -0
  97. package/dist/plugin/types/generationPrompts.d.ts +19 -0
  98. package/dist/plugin/types/generationSettings.d.ts +12 -0
  99. package/dist/plugin/types/images.d.ts +62 -0
  100. package/dist/plugin/types/sectionLibrary.d.ts +101 -0
  101. package/dist/plugin/types/types.d.ts +204 -0
  102. package/dist/plugin/types/videos.d.ts +24 -0
  103. package/dist/plugin/utils/i18n/locales.d.ts +5 -0
  104. package/dist/plugin/utils/i18n/translationResources.d.ts +41 -0
  105. package/dist/plugin/utils/normalizeLocale.d.ts +8 -0
  106. package/dist/plugin/utils/plainText.d.ts +6 -0
  107. package/dist/plugin/vite-plugin/index.d.ts +2 -0
  108. package/dist/plugin/vite-plugin/layout-generation/generationLogger.d.ts +5 -0
  109. package/dist/plugin/vite-plugin/layout-generation/generationReports.d.ts +13 -0
  110. package/dist/plugin/vite-plugin/layout-generation/middleware.d.ts +14 -0
  111. package/dist/plugin/vite-plugin/layout-generation/modelProxy.d.ts +9 -0
  112. package/dist/plugin/vite-plugin/layout-generation/prompts.d.ts +17 -0
  113. package/dist/plugin/vite-plugin/layout-generation/settings.d.ts +3 -0
  114. package/dist/plugin/vite-plugin/local-editor/artifacts.d.ts +20 -0
  115. package/dist/plugin/vite-plugin/local-editor/config.d.ts +11 -0
  116. package/dist/plugin/vite-plugin/local-editor/data.d.ts +12 -0
  117. package/dist/plugin/vite-plugin/local-editor/entityFields.d.ts +13 -0
  118. package/dist/plugin/vite-plugin/local-editor/fixtureData.d.ts +12 -0
  119. package/dist/plugin/vite-plugin/local-editor/generatedFiles.d.ts +33 -0
  120. package/dist/plugin/vite-plugin/local-editor/server.d.ts +34 -0
  121. package/dist/plugin/vite-plugin/local-editor/types.d.ts +125 -0
  122. package/dist/plugin/vite-plugin/local-editor/utils.d.ts +16 -0
  123. package/dist/plugin/vite-plugin/plugin.d.ts +8 -0
  124. package/dist/plugin/vite-plugin/section-library/migrationRegistry.d.ts +6 -0
  125. package/dist/plugin/vite-plugin/section-library/sectionFrontmatter.d.ts +3 -0
  126. package/dist/plugin/vite-plugin/section-library/sectionLibraryGenerator.d.ts +21 -0
  127. package/dist/plugin/vite-plugin/section-library/sharedComponentRegistry.d.ts +16 -0
  128. package/dist/section-library-support.js +178 -0
  129. package/dist/sectionLibrarySupport.d.ts +703 -0
  130. package/dist/style.css +1 -1
  131. package/dist/visual-editor-6mKs9VUe.js +842 -0
  132. package/dist/visual-editor-BK6fTU7k.js +804 -0
  133. package/dist/visual-editor-BXYlpe7B.js +145 -0
  134. package/dist/visual-editor-BruRrJYN.js +804 -0
  135. package/dist/visual-editor-Bs3wAslG.js +804 -0
  136. package/dist/visual-editor-Bxy81Ezy.js +145 -0
  137. package/dist/visual-editor-C0vq2BRM.js +145 -0
  138. package/dist/visual-editor-C9TLeAzP.js +804 -0
  139. package/dist/visual-editor-CCgmYV5S.js +169 -0
  140. package/dist/visual-editor-CERViyTJ.js +145 -0
  141. package/dist/visual-editor-CHWtMtlu.js +823 -0
  142. package/dist/visual-editor-CcfUKpnd.js +804 -0
  143. package/dist/visual-editor-CjORnP1D.js +169 -0
  144. package/dist/visual-editor-ClC6hoz3.js +804 -0
  145. package/dist/visual-editor-CmomGJB8.js +157 -0
  146. package/dist/visual-editor-CtQwadxQ.js +842 -0
  147. package/dist/visual-editor-Cymg8ID2.js +169 -0
  148. package/dist/visual-editor-D2Hk1nhM.js +145 -0
  149. package/dist/visual-editor-D7VeTRK_.js +816 -0
  150. package/dist/visual-editor-D8MRFn5x.js +157 -0
  151. package/dist/visual-editor-DOXtCqRv.js +145 -0
  152. package/dist/visual-editor-DQEd3xwY.js +145 -0
  153. package/dist/visual-editor-DTE5kxrA.js +804 -0
  154. package/dist/visual-editor-DUngIOnE.js +157 -0
  155. package/dist/visual-editor-DeZVZYfd.js +169 -0
  156. package/dist/visual-editor-DfJMZpiP.js +145 -0
  157. package/dist/visual-editor-DgAsQK9D.js +145 -0
  158. package/dist/visual-editor-Dhi__-7_.js +145 -0
  159. package/dist/visual-editor-DjTEbi-1.js +842 -0
  160. package/dist/visual-editor-DjdqpJU-.js +145 -0
  161. package/dist/visual-editor-DkHhrFsX.js +804 -0
  162. package/dist/visual-editor-DtL-Zuv_.js +804 -0
  163. package/dist/visual-editor-Duishbsa.js +842 -0
  164. package/dist/visual-editor-DvuH3jyL.js +157 -0
  165. package/dist/visual-editor-LXMNWXry.js +823 -0
  166. package/dist/visual-editor-QpGupjY5.js +823 -0
  167. package/dist/visual-editor-TfVDfO5_.js +145 -0
  168. package/dist/visual-editor-W_ZDmMFn.js +145 -0
  169. package/dist/visual-editor-_TatCCAS.js +804 -0
  170. package/dist/visual-editor-b7ALusk8.js +145 -0
  171. package/dist/visual-editor-erGXf3kS.js +157 -0
  172. package/dist/visual-editor-gEaWoNRu.js +804 -0
  173. package/dist/visual-editor-gjpr-NAN.js +804 -0
  174. package/dist/visual-editor-qJW0uCiQ.js +804 -0
  175. package/dist/visual-editor-sOPDMkOR.js +823 -0
  176. package/dist/visual-editor-tPb7n5l8.js +823 -0
  177. package/dist/visual-editor-vomNdlNO.js +804 -0
  178. package/dist/visual-editor-xnDHZFuO.js +153 -0
  179. package/dist/visual-editor-yiWZqIH0.js +157 -0
  180. package/dist/visual-editor-zKhC7_0C.js +823 -0
  181. package/dist/visual-editor.css +1 -0
  182. package/dist/visual-editor.js +18578 -137536
  183. package/package.json +50 -26
  184. package/dist/editor.css +0 -1
  185. package/dist/visual-editor-6pnSx-yp.js +0 -223
  186. package/dist/visual-editor-9ZW3nq5u.js +0 -247
  187. package/dist/visual-editor-B1RXDqNi.js +0 -1063
  188. package/dist/visual-editor-BAahiZ1l.js +0 -223
  189. package/dist/visual-editor-BC2LjdoF.js +0 -223
  190. package/dist/visual-editor-BPnfBfk1.js +0 -1051
  191. package/dist/visual-editor-BQiE5eVW.js +0 -1051
  192. package/dist/visual-editor-BTv-6Pnk.js +0 -1051
  193. package/dist/visual-editor-BUWp03gX.js +0 -235
  194. package/dist/visual-editor-Bb3c6iGV.js +0 -223
  195. package/dist/visual-editor-BipczqTj.js +0 -1075
  196. package/dist/visual-editor-BlIUd_n_.js +0 -1051
  197. package/dist/visual-editor-BoPLXEu2.js +0 -223
  198. package/dist/visual-editor-Bzmpi_9a.js +0 -1063
  199. package/dist/visual-editor-C38IiBTR.js +0 -235
  200. package/dist/visual-editor-C9tacnim.js +0 -247
  201. package/dist/visual-editor-CVa3iu5h.js +0 -1051
  202. package/dist/visual-editor-CXTL8Ik0.js +0 -1051
  203. package/dist/visual-editor-CYeahjFX.js +0 -231
  204. package/dist/visual-editor-CZ2SM6Jc.js +0 -1063
  205. package/dist/visual-editor-CZDmQI-A.js +0 -1063
  206. package/dist/visual-editor-C_cHJ6BN.js +0 -1051
  207. package/dist/visual-editor-Cf3nFbw3.js +0 -235
  208. package/dist/visual-editor-CiR0metz.js +0 -1051
  209. package/dist/visual-editor-CoX_NnS-.js +0 -223
  210. package/dist/visual-editor-Cu8II23Y.js +0 -223
  211. package/dist/visual-editor-CvXFxocc.js +0 -1063
  212. package/dist/visual-editor-Cxu6nkib.js +0 -1051
  213. package/dist/visual-editor-D-3VVfjR.js +0 -223
  214. package/dist/visual-editor-D-ktbg7q.js +0 -223
  215. package/dist/visual-editor-D9G5eAAU.js +0 -1051
  216. package/dist/visual-editor-D9MrqEya.js +0 -223
  217. package/dist/visual-editor-DAKXBbjV.js +0 -1075
  218. package/dist/visual-editor-DBmJk7ZR.js +0 -235
  219. package/dist/visual-editor-DG-c2LU9.js +0 -1051
  220. package/dist/visual-editor-DI_Vk989.js +0 -1051
  221. package/dist/visual-editor-DOOYgnjP.js +0 -235
  222. package/dist/visual-editor-DRx3Ax_O.js +0 -1075
  223. package/dist/visual-editor-DZ66sria.js +0 -1051
  224. package/dist/visual-editor-DZTPhYcr.js +0 -247
  225. package/dist/visual-editor-DcH7WJVI.js +0 -223
  226. package/dist/visual-editor-DdYXgEbR.js +0 -1059
  227. package/dist/visual-editor-DeWzgcue.js +0 -1063
  228. package/dist/visual-editor-Dm5ZNn8C.js +0 -223
  229. package/dist/visual-editor-DqLCIWPQ.js +0 -1051
  230. package/dist/visual-editor-NoU28r5Y.js +0 -223
  231. package/dist/visual-editor-WjrJ9nPc.js +0 -235
  232. package/dist/visual-editor-_h-sdbID.js +0 -223
  233. package/dist/visual-editor-r4gSQqFM.js +0 -1075
  234. package/dist/visual-editor-ujQ29mao.js +0 -247
@@ -0,0 +1,1551 @@
1
+ import * as React from "react";
2
+ import { afterEach, describe, expect, it, vi } from "vitest";
3
+ import {
4
+ axe,
5
+ ComponentTest,
6
+ logSuppressedWcagViolations,
7
+ transformTests,
8
+ } from "../../testing/componentTests.setup.ts";
9
+ import {
10
+ act,
11
+ render as reactRender,
12
+ screen,
13
+ waitFor,
14
+ } from "@testing-library/react";
15
+ import { injectTranslations } from "../../../utils/i18n/page.ts";
16
+ import { migrate } from "../../../utils/migrate.ts";
17
+ import { migrationRegistry } from "../../migrations/migrationRegistry.ts";
18
+ import { VisualEditorProvider } from "../../../utils/VisualEditorProvider.tsx";
19
+ import { LocatorComponent } from "./Locator.tsx";
20
+ import { Render, Config, resolveAllData } from "@puckeditor/core";
21
+ import { page } from "@vitest/browser/context";
22
+ import { getUserLocation } from "@yext/search-ui-react";
23
+ import { backgroundColors } from "../../../utils/themeConfigOptions.ts";
24
+ import { MainContent } from "../../helpers/MainContent.tsx";
25
+
26
+ vi.mock("@yext/search-ui-react", async () => {
27
+ const actual = await vi.importActual<typeof import("@yext/search-ui-react")>(
28
+ "@yext/search-ui-react"
29
+ );
30
+
31
+ return {
32
+ ...actual,
33
+ useCardAnalyticsCallback: vi.fn(() => vi.fn()),
34
+ getUserLocation: vi
35
+ .fn()
36
+ .mockRejectedValue(
37
+ new Error("Locator screenshot tests use fixture search data.")
38
+ ),
39
+ };
40
+ });
41
+
42
+ const LOCATOR_TEST_IMAGE_URL = `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(
43
+ `<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80">
44
+ <rect width="80" height="80" rx="16" fill="#0f172a"/>
45
+ <circle cx="40" cy="28" r="16" fill="#fbbf24"/>
46
+ <rect x="18" y="50" width="44" height="12" rx="6" fill="#f8fafc"/>
47
+ </svg>`
48
+ )}`;
49
+
50
+ const LOCATOR_TEST_ENV = {
51
+ YEXT_PUBLIC_VISUAL_EDITOR_APP_API_KEY: "fixture-visual-editor-app-api-key",
52
+ YEXT_CLOUD_CHOICE: "GLOBAL-MULTI",
53
+ YEXT_CLOUD_REGION: "US",
54
+ YEXT_ENVIRONMENT: "PROD",
55
+ YEXT_EDIT_LAYOUT_MODE_MAPBOX_API_KEY: "fixture-mapbox-api-key",
56
+ YEXT_MAPBOX_API_KEY: "fixture-mapbox-api-key",
57
+ YEXT_SEARCH_API_KEY: "fixture-search-api-key",
58
+ };
59
+
60
+ const LOCATOR_TEST_HOURS = {
61
+ sunday: { openIntervals: [{ start: "09:00", end: "17:00" }] },
62
+ monday: { openIntervals: [{ start: "09:00", end: "17:00" }] },
63
+ tuesday: { openIntervals: [{ start: "09:00", end: "17:00" }] },
64
+ wednesday: { openIntervals: [{ start: "09:00", end: "17:00" }] },
65
+ thursday: { openIntervals: [{ start: "09:00", end: "17:00" }] },
66
+ friday: { openIntervals: [{ start: "09:00", end: "17:00" }] },
67
+ saturday: { openIntervals: [{ start: "09:00", end: "17:00" }] },
68
+ };
69
+
70
+ const createLocatorApiResult = ({
71
+ id,
72
+ name,
73
+ entityType,
74
+ line1,
75
+ city,
76
+ region,
77
+ postalCode,
78
+ latitude,
79
+ longitude,
80
+ distance,
81
+ distanceFromFilter,
82
+ services,
83
+ comingSoon = false,
84
+ }: {
85
+ id: string;
86
+ name: string;
87
+ entityType: string;
88
+ line1: string;
89
+ city: string;
90
+ region: string;
91
+ postalCode: string;
92
+ latitude: number;
93
+ longitude: number;
94
+ distance: number;
95
+ distanceFromFilter: number;
96
+ services: string[];
97
+ comingSoon?: boolean;
98
+ }) => ({
99
+ data: {
100
+ id,
101
+ slug: id,
102
+ type: entityType,
103
+ name,
104
+ timezone: "America/New_York",
105
+ address: {
106
+ line1,
107
+ city,
108
+ region,
109
+ postalCode,
110
+ countryCode: "US",
111
+ },
112
+ additionalHoursText: "Holiday hours may vary",
113
+ hours: LOCATOR_TEST_HOURS,
114
+ comingSoon,
115
+ mainPhone: "+12025550101",
116
+ emails: [`${id}@example.com`],
117
+ services,
118
+ headshot: {
119
+ url: LOCATOR_TEST_IMAGE_URL,
120
+ height: 80,
121
+ width: 80,
122
+ alternateText: name,
123
+ },
124
+ website: `https://example.com/${id}`,
125
+ yextDisplayCoordinate: {
126
+ latitude,
127
+ longitude,
128
+ },
129
+ meta: {
130
+ locale: "en",
131
+ isPrimaryLocale: true,
132
+ },
133
+ },
134
+ distance,
135
+ distanceFromFilter,
136
+ highlightedFields: {},
137
+ });
138
+
139
+ const DEFAULT_LOCATOR_RESULTS = [
140
+ createLocatorApiResult({
141
+ id: "galaxy-grill",
142
+ name: "Galaxy Grill",
143
+ entityType: "location",
144
+ line1: "1101 Wilson Blvd",
145
+ city: "Arlington",
146
+ region: "VA",
147
+ postalCode: "22209",
148
+ latitude: 38.895546,
149
+ longitude: -77.069915,
150
+ distance: 1609,
151
+ distanceFromFilter: 804,
152
+ services: ["Dine-in", "Delivery", "Takeout"],
153
+ }),
154
+ createLocatorApiResult({
155
+ id: "nebula-bites",
156
+ name: "Nebula Bites",
157
+ entityType: "location",
158
+ line1: "725 14th St NW",
159
+ city: "Washington",
160
+ region: "DC",
161
+ postalCode: "20005",
162
+ latitude: 38.90362,
163
+ longitude: -77.03118,
164
+ distance: 3218,
165
+ distanceFromFilter: 1609,
166
+ services: ["Pickup", "Curbside"],
167
+ }),
168
+ createLocatorApiResult({
169
+ id: "comet-cafe",
170
+ name: "Comet Cafe",
171
+ entityType: "location",
172
+ line1: "1500 Market St",
173
+ city: "Philadelphia",
174
+ region: "PA",
175
+ postalCode: "19102",
176
+ latitude: 39.95289,
177
+ longitude: -75.16624,
178
+ distance: 8046,
179
+ distanceFromFilter: 4828,
180
+ services: ["Coffee", "Breakfast"],
181
+ }),
182
+ ];
183
+
184
+ const MULTI_PAGESET_LOCATOR_RESULTS = [
185
+ createLocatorApiResult({
186
+ id: "galaxy-grill",
187
+ name: "Galaxy Grill",
188
+ entityType: "location",
189
+ line1: "1101 Wilson Blvd",
190
+ city: "Arlington",
191
+ region: "VA",
192
+ postalCode: "22209",
193
+ latitude: 38.895546,
194
+ longitude: -77.069915,
195
+ distance: 1609,
196
+ distanceFromFilter: 804,
197
+ services: ["Dine-in", "Delivery", "Takeout"],
198
+ }),
199
+ createLocatorApiResult({
200
+ id: "nebula-noodles",
201
+ name: "Nebula Noodles",
202
+ entityType: "restaurant",
203
+ line1: "19 W 44th St",
204
+ city: "New York",
205
+ region: "NY",
206
+ postalCode: "10036",
207
+ latitude: 40.75562,
208
+ longitude: -73.98093,
209
+ distance: 4023,
210
+ distanceFromFilter: 2414,
211
+ services: ["Lunch", "Dinner"],
212
+ }),
213
+ createLocatorApiResult({
214
+ id: "orbit-atm",
215
+ name: "Orbit ATM",
216
+ entityType: "atm",
217
+ line1: "401 7th St NW",
218
+ city: "Washington",
219
+ region: "DC",
220
+ postalCode: "20004",
221
+ latitude: 38.89341,
222
+ longitude: -77.01714,
223
+ distance: 6437,
224
+ distanceFromFilter: 3218,
225
+ services: ["24/7 Access"],
226
+ }),
227
+ ];
228
+
229
+ const createLocatorVerticalSearchResponse = (results: any[]) => ({
230
+ meta: {
231
+ uuid: "locator-fixture-uuid",
232
+ errors: [],
233
+ },
234
+ response: {
235
+ queryId: "locator-fixture-query-id",
236
+ verticalConfigId: "locations",
237
+ source: "KNOWLEDGE_MANAGER",
238
+ resultsCount: results.length,
239
+ results,
240
+ facets: [],
241
+ },
242
+ });
243
+
244
+ const createLocatorFilterSearchResponse = () => ({
245
+ meta: {
246
+ uuid: "locator-filter-fixture-uuid",
247
+ errors: [],
248
+ },
249
+ response: {
250
+ businessId: "4174974",
251
+ queryId: "locator-filter-query-id",
252
+ sections: [
253
+ {
254
+ label: "Locations",
255
+ results: [
256
+ {
257
+ value: "Arlington, VA",
258
+ key: "arlington-va",
259
+ matchedSubstrings: [],
260
+ filter: {
261
+ "builtin.location": {
262
+ NEAR: {
263
+ lat: 38.895546,
264
+ lng: -77.069915,
265
+ radius: 40233,
266
+ },
267
+ },
268
+ },
269
+ },
270
+ ],
271
+ },
272
+ ],
273
+ },
274
+ });
275
+
276
+ const getLocatorFixtureResults = (document: Record<string, any>) =>
277
+ document.__?.locatorSourcePageSets
278
+ ? MULTI_PAGESET_LOCATOR_RESULTS
279
+ : DEFAULT_LOCATOR_RESULTS;
280
+
281
+ const createLocatorFetchMock = (document: Record<string, any>) => {
282
+ const results = getLocatorFixtureResults(document);
283
+
284
+ return vi.fn(async (input: string | URL | Request) => {
285
+ const url =
286
+ typeof input === "string"
287
+ ? input
288
+ : input instanceof URL
289
+ ? input.toString()
290
+ : input.url;
291
+
292
+ if (url.includes("/search/vertical/query")) {
293
+ return new Response(
294
+ JSON.stringify(
295
+ createLocatorVerticalSearchResponse(
296
+ document.comingSoon
297
+ ? results.map((result: any) => ({
298
+ ...result,
299
+ data: {
300
+ ...result.data,
301
+ comingSoon: true,
302
+ },
303
+ }))
304
+ : results
305
+ )
306
+ ),
307
+ {
308
+ status: 200,
309
+ }
310
+ );
311
+ }
312
+
313
+ if (url.includes("/search/filtersearch")) {
314
+ return new Response(JSON.stringify(createLocatorFilterSearchResponse()), {
315
+ status: 200,
316
+ });
317
+ }
318
+
319
+ throw new Error(`Unexpected fetch in Locator test: ${url}`);
320
+ });
321
+ };
322
+
323
+ afterEach(() => {
324
+ vi.unstubAllGlobals();
325
+ });
326
+
327
+ // Uses the content endpoint from
328
+ // https://www.yext.com/s/4174974/yextsites/155048/editor#pageSetId=locations
329
+ const tests: ComponentTest[] = [
330
+ {
331
+ name: "latest version default props with empty document",
332
+ document: {},
333
+ props: { ...LocatorComponent.defaultProps },
334
+ version: migrationRegistry.length,
335
+ },
336
+ {
337
+ name: "latest version default props",
338
+ document: {
339
+ locale: "en",
340
+ businessId: "4174974",
341
+ __: {
342
+ isPrimaryLocale: true,
343
+ },
344
+ _env: {
345
+ ...LOCATOR_TEST_ENV,
346
+ },
347
+ _pageset: JSON.stringify({
348
+ type: "LOCATOR",
349
+ typeConfig: {
350
+ locatorConfig: {
351
+ source: "accounts/4174974/sites/155048/pagesets/locations",
352
+ experienceKey: "locator-41",
353
+ entityType: "location",
354
+ },
355
+ },
356
+ config: {
357
+ urlTemplate: {
358
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
359
+ },
360
+ },
361
+ }),
362
+ },
363
+ props: { ...LocatorComponent.defaultProps },
364
+ version: migrationRegistry.length,
365
+ },
366
+ {
367
+ name: "version 74 comingSoon",
368
+ document: {
369
+ locale: "en",
370
+ businessId: "4174974",
371
+ comingSoon: true,
372
+ __: {
373
+ isPrimaryLocale: true,
374
+ },
375
+ _env: {
376
+ ...LOCATOR_TEST_ENV,
377
+ },
378
+ _pageset: JSON.stringify({
379
+ type: "LOCATOR",
380
+ typeConfig: {
381
+ locatorConfig: {
382
+ source: "accounts/4174974/sites/155048/pagesets/locations",
383
+ experienceKey: "locator-41",
384
+ entityType: "location",
385
+ },
386
+ },
387
+ config: {
388
+ urlTemplate: {
389
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
390
+ },
391
+ },
392
+ }),
393
+ },
394
+ props: { ...LocatorComponent.defaultProps },
395
+ version: 74,
396
+ },
397
+ {
398
+ name: "latest version multi-pageset default props",
399
+ document: {
400
+ locale: "en",
401
+ businessId: "4174974",
402
+ __: {
403
+ isPrimaryLocale: true,
404
+ locatorSourcePageSets: JSON.stringify({
405
+ "accounts/4174974/sites/163770/pagesets/locations": {
406
+ pathInfo: {
407
+ template:
408
+ "locations/[[address.region]]/[[address.city]]/[[address.line1]]",
409
+ primaryLocale: "en",
410
+ includeLocalePrefixForPrimaryLocale: false,
411
+ },
412
+ entityType: "location",
413
+ savedFilter: "1415752775",
414
+ internalSavedSearchId: 262225,
415
+ },
416
+ "accounts/4174974/sites/163770/pagesets/restaurants": {
417
+ pathInfo: {
418
+ template:
419
+ "restaurants/[[address.region]]/[[address.city]]/[[address.line1]]",
420
+ primaryLocale: "en",
421
+ includeLocalePrefixForPrimaryLocale: false,
422
+ },
423
+ entityType: "restaurant",
424
+ savedFilter: "1491716705",
425
+ internalSavedSearchId: 276295,
426
+ },
427
+ "accounts/4174974/sites/163770/pagesets/atms": {
428
+ pathInfo: {
429
+ template:
430
+ "atms/[[address.region]]/[[address.city]]/[[address.line1]]",
431
+ primaryLocale: "en",
432
+ includeLocalePrefixForPrimaryLocale: false,
433
+ },
434
+ entityType: "atm",
435
+ },
436
+ }),
437
+ },
438
+ _env: {
439
+ ...LOCATOR_TEST_ENV,
440
+ },
441
+ _pageset: JSON.stringify({
442
+ type: "LOCATOR",
443
+ typeConfig: {
444
+ locatorConfig: {
445
+ experienceKey: "locator-41",
446
+ sources: [
447
+ "accounts/4174974/sites/163770/pagesets/locations",
448
+ "accounts/4174974/sites/163770/pagesets/restaurants",
449
+ "accounts/4174974/sites/163770/pagesets/atms",
450
+ ],
451
+ entityTypeScope: [
452
+ {
453
+ entityType: "financialProfessional",
454
+ savedFilter: "1491722104",
455
+ },
456
+ ],
457
+ },
458
+ },
459
+ }),
460
+ },
461
+ props: { ...LocatorComponent.defaultProps },
462
+ version: migrationRegistry.length,
463
+ },
464
+ {
465
+ name: "latest version non-default props",
466
+ document: {
467
+ locale: "en",
468
+ businessId: "4174974",
469
+ __: {
470
+ isPrimaryLocale: true,
471
+ },
472
+ _env: {
473
+ ...LOCATOR_TEST_ENV,
474
+ },
475
+ _pageset: JSON.stringify({
476
+ type: "LOCATOR",
477
+ typeConfig: {
478
+ locatorConfig: {
479
+ source: "accounts/4174974/sites/155048/pagesets/locations",
480
+ experienceKey: "locator-41",
481
+ entityType: "location",
482
+ },
483
+ },
484
+ config: {
485
+ urlTemplate: {
486
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
487
+ },
488
+ },
489
+ }),
490
+ },
491
+ props: {
492
+ mapStyle: "mapbox://styles/mapbox/dark-v11",
493
+ locationStyles: [
494
+ {
495
+ entityType: "location",
496
+ pinIcon: {
497
+ type: "none",
498
+ },
499
+ pinColor: backgroundColors.background6.value,
500
+ },
501
+ ],
502
+ distanceDisplay: "bothDistances",
503
+ filters: {
504
+ openNowButton: true,
505
+ showDistanceOptions: true,
506
+ },
507
+ resultCard: [
508
+ {
509
+ props: {
510
+ entityType: "location",
511
+ primaryHeading: {
512
+ field: "name",
513
+ constantValue: { en: "", hasLocalizedValue: "true" },
514
+ constantValueEnabled: false,
515
+ headingLevel: 5,
516
+ },
517
+ secondaryHeading: {
518
+ field: "name",
519
+ constantValue: { en: "", hasLocalizedValue: "true" },
520
+ constantValueEnabled: false,
521
+ variant: "base",
522
+ liveVisibility: false,
523
+ },
524
+ tertiaryHeading: {
525
+ field: "name",
526
+ constantValue: { en: "", hasLocalizedValue: "true" },
527
+ constantValueEnabled: false,
528
+ variant: "base",
529
+ liveVisibility: false,
530
+ },
531
+ icons: true,
532
+ hours: {
533
+ table: {
534
+ startOfWeek: "monday",
535
+ collapseDays: true,
536
+ showAdditionalHoursText: false,
537
+ },
538
+ liveVisibility: true,
539
+ },
540
+ address: {
541
+ showGetDirectionsLink: true,
542
+ liveVisibility: true,
543
+ },
544
+ phone: {
545
+ field: "mainPhone",
546
+ phoneFormat: "domestic",
547
+ includePhoneHyperlink: true,
548
+ liveVisibility: false,
549
+ },
550
+ email: {
551
+ field: "emails",
552
+ liveVisibility: false,
553
+ },
554
+ services: {
555
+ field: "services",
556
+ liveVisibility: false,
557
+ },
558
+ primaryCTA: {
559
+ label: "Visit Page",
560
+ variant: "primary",
561
+ liveVisibility: true,
562
+ },
563
+ secondaryCTA: {
564
+ label: "Call to Action",
565
+ link: "https://www.yext.com",
566
+ variant: "secondary",
567
+ liveVisibility: true,
568
+ },
569
+ image: {
570
+ field: "headshot",
571
+ constantValue: {
572
+ en: { url: "", height: 0, width: 0 },
573
+ hasLocalizedValue: "true",
574
+ },
575
+ constantValueEnabled: false,
576
+ liveVisibility: false,
577
+ },
578
+ },
579
+ },
580
+ ],
581
+ },
582
+ version: migrationRegistry.length,
583
+ },
584
+ {
585
+ name: "version 24 with filters",
586
+ document: {
587
+ locale: "en",
588
+ businessId: "4174974",
589
+ __: {
590
+ isPrimaryLocale: true,
591
+ },
592
+ _env: {
593
+ ...LOCATOR_TEST_ENV,
594
+ },
595
+ _pageset: JSON.stringify({
596
+ type: "LOCATOR",
597
+ typeConfig: {
598
+ locatorConfig: {
599
+ source: "accounts/4174974/sites/155048/pagesets/locations",
600
+ experienceKey: "locator-41",
601
+ entityType: "location",
602
+ },
603
+ },
604
+ config: {
605
+ urlTemplate: {
606
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
607
+ },
608
+ },
609
+ }),
610
+ },
611
+ props: {
612
+ filters: {
613
+ openNowButton: true,
614
+ showDistanceOptions: true,
615
+ },
616
+ resultCard: {
617
+ primaryHeading: {
618
+ field: "name",
619
+ headingLevel: 3,
620
+ },
621
+ secondaryHeading: {
622
+ field: "name",
623
+ variant: "base",
624
+ liveVisibility: false,
625
+ },
626
+ tertiaryHeading: {
627
+ field: "name",
628
+ variant: "base",
629
+ liveVisibility: false,
630
+ },
631
+ icons: true,
632
+ hours: {
633
+ table: {
634
+ startOfWeek: "today",
635
+ collapseDays: false,
636
+ showAdditionalHoursText: false,
637
+ },
638
+ liveVisibility: true,
639
+ },
640
+ address: {
641
+ showGetDirectionsLink: true,
642
+ liveVisibility: true,
643
+ },
644
+ phone: {
645
+ field: "mainPhone",
646
+ phoneFormat: "domestic",
647
+ includePhoneHyperlink: true,
648
+ liveVisibility: true,
649
+ },
650
+ email: {
651
+ field: "emails",
652
+ liveVisibility: false,
653
+ },
654
+ services: {
655
+ field: "services",
656
+ liveVisibility: false,
657
+ },
658
+ primaryCTA: {
659
+ variant: "primary",
660
+ liveVisibility: true,
661
+ },
662
+ secondaryCTA: {
663
+ label: "Call to Action",
664
+ link: "#",
665
+ variant: "secondary",
666
+ liveVisibility: false,
667
+ },
668
+ image: {
669
+ field: "headshot",
670
+ liveVisibility: false,
671
+ },
672
+ },
673
+ },
674
+ interactions: async (page) => {
675
+ const filterButton = page.getByText("Filter");
676
+ await act(async () => {
677
+ await filterButton.click();
678
+ });
679
+ },
680
+ version: 24,
681
+ },
682
+ {
683
+ name: "version 60 custom heading",
684
+ document: {
685
+ locale: "en",
686
+ businessId: "4174974",
687
+ __: {
688
+ isPrimaryLocale: true,
689
+ },
690
+ _env: {
691
+ ...LOCATOR_TEST_ENV,
692
+ },
693
+ _pageset: JSON.stringify({
694
+ type: "LOCATOR",
695
+ typeConfig: {
696
+ locatorConfig: {
697
+ source: "accounts/4174974/sites/155048/pagesets/locations",
698
+ experienceKey: "locator-41",
699
+ entityType: "location",
700
+ },
701
+ },
702
+ config: {
703
+ urlTemplate: {
704
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
705
+ },
706
+ },
707
+ }),
708
+ },
709
+ props: {
710
+ filters: {
711
+ openNowButton: false,
712
+ showDistanceOptions: false,
713
+ },
714
+ pageHeading: {
715
+ title: { en: "Custom Heading", hasLocalizedValue: "true" },
716
+ },
717
+ resultCard: {
718
+ primaryHeading: {
719
+ field: "name",
720
+ headingLevel: 3,
721
+ },
722
+ secondaryHeading: {
723
+ field: "name",
724
+ variant: "base",
725
+ liveVisibility: false,
726
+ },
727
+ tertiaryHeading: {
728
+ field: "name",
729
+ variant: "base",
730
+ liveVisibility: false,
731
+ },
732
+ icons: true,
733
+ hours: {
734
+ table: {
735
+ startOfWeek: "today",
736
+ collapseDays: false,
737
+ showAdditionalHoursText: false,
738
+ },
739
+ liveVisibility: true,
740
+ },
741
+ address: {
742
+ showGetDirectionsLink: true,
743
+ liveVisibility: true,
744
+ },
745
+ phone: {
746
+ field: "mainPhone",
747
+ phoneFormat: "domestic",
748
+ includePhoneHyperlink: true,
749
+ liveVisibility: true,
750
+ },
751
+ email: {
752
+ field: "emails",
753
+ liveVisibility: false,
754
+ },
755
+ services: {
756
+ field: "services",
757
+ liveVisibility: false,
758
+ },
759
+ primaryCTA: {
760
+ variant: "primary",
761
+ liveVisibility: true,
762
+ },
763
+ secondaryCTA: {
764
+ label: "Call to Action",
765
+ link: "#",
766
+ variant: "secondary",
767
+ liveVisibility: false,
768
+ },
769
+ image: {
770
+ field: "headshot",
771
+ liveVisibility: false,
772
+ },
773
+ },
774
+ },
775
+ version: 60,
776
+ },
777
+ {
778
+ name: "version 60 custom heading with site color 2",
779
+ document: {
780
+ locale: "en",
781
+ businessId: "4174974",
782
+ __: {
783
+ isPrimaryLocale: true,
784
+ },
785
+ _env: {
786
+ ...LOCATOR_TEST_ENV,
787
+ },
788
+ _pageset: JSON.stringify({
789
+ type: "LOCATOR",
790
+ typeConfig: {
791
+ locatorConfig: {
792
+ source: "accounts/4174974/sites/155048/pagesets/locations",
793
+ experienceKey: "locator-41",
794
+ entityType: "location",
795
+ },
796
+ },
797
+ config: {
798
+ urlTemplate: {
799
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
800
+ },
801
+ },
802
+ }),
803
+ },
804
+ props: {
805
+ filters: {
806
+ openNowButton: false,
807
+ showDistanceOptions: false,
808
+ },
809
+ pageHeading: {
810
+ title: { en: "Custom Heading", hasLocalizedValue: "true" },
811
+ color: backgroundColors.color2.value,
812
+ },
813
+ resultCard: {
814
+ primaryHeading: {
815
+ field: "name",
816
+ headingLevel: 3,
817
+ },
818
+ secondaryHeading: {
819
+ field: "name",
820
+ variant: "base",
821
+ liveVisibility: false,
822
+ },
823
+ tertiaryHeading: {
824
+ field: "name",
825
+ variant: "base",
826
+ liveVisibility: false,
827
+ },
828
+ icons: true,
829
+ hours: {
830
+ table: {
831
+ startOfWeek: "today",
832
+ collapseDays: false,
833
+ showAdditionalHoursText: false,
834
+ },
835
+ liveVisibility: true,
836
+ },
837
+ address: {
838
+ showGetDirectionsLink: true,
839
+ liveVisibility: true,
840
+ },
841
+ phone: {
842
+ field: "mainPhone",
843
+ phoneFormat: "domestic",
844
+ includePhoneHyperlink: true,
845
+ liveVisibility: true,
846
+ },
847
+ email: {
848
+ field: "emails",
849
+ liveVisibility: false,
850
+ },
851
+ services: {
852
+ field: "services",
853
+ liveVisibility: false,
854
+ },
855
+ primaryCTA: {
856
+ variant: "primary",
857
+ liveVisibility: true,
858
+ },
859
+ secondaryCTA: {
860
+ label: "Call to Action",
861
+ link: "#",
862
+ variant: "secondary",
863
+ liveVisibility: false,
864
+ },
865
+ image: {
866
+ field: "headshot",
867
+ liveVisibility: false,
868
+ },
869
+ },
870
+ },
871
+ version: 60,
872
+ },
873
+ {
874
+ name: "version 60 custom title and result cards with site color 3",
875
+ document: {
876
+ locale: "en",
877
+ businessId: "4174974",
878
+ __: {
879
+ isPrimaryLocale: true,
880
+ },
881
+ _env: {
882
+ ...LOCATOR_TEST_ENV,
883
+ },
884
+ _pageset: JSON.stringify({
885
+ type: "LOCATOR",
886
+ typeConfig: {
887
+ locatorConfig: {
888
+ source: "accounts/4174974/sites/155048/pagesets/locations",
889
+ experienceKey: "locator-41",
890
+ entityType: "location",
891
+ },
892
+ },
893
+ config: {
894
+ urlTemplate: {
895
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
896
+ },
897
+ },
898
+ }),
899
+ },
900
+ props: {
901
+ filters: {
902
+ openNowButton: false,
903
+ showDistanceOptions: false,
904
+ },
905
+ pageHeading: {
906
+ title: { en: "Custom Heading", hasLocalizedValue: "true" },
907
+ },
908
+ resultCard: {
909
+ primaryHeading: {
910
+ field: "name",
911
+ headingLevel: 3,
912
+ color: backgroundColors.color3.value,
913
+ },
914
+ secondaryHeading: {
915
+ field: "name",
916
+ variant: "base",
917
+ liveVisibility: false,
918
+ },
919
+ tertiaryHeading: {
920
+ field: "name",
921
+ variant: "base",
922
+ liveVisibility: false,
923
+ },
924
+ icons: true,
925
+ hours: {
926
+ table: {
927
+ startOfWeek: "today",
928
+ collapseDays: false,
929
+ showAdditionalHoursText: false,
930
+ },
931
+ liveVisibility: true,
932
+ },
933
+ address: {
934
+ showGetDirectionsLink: true,
935
+ liveVisibility: true,
936
+ },
937
+ phone: {
938
+ field: "mainPhone",
939
+ phoneFormat: "domestic",
940
+ includePhoneHyperlink: true,
941
+ liveVisibility: true,
942
+ },
943
+ email: {
944
+ field: "emails",
945
+ liveVisibility: false,
946
+ },
947
+ services: {
948
+ field: "services",
949
+ liveVisibility: false,
950
+ },
951
+ primaryCTA: {
952
+ variant: "primary",
953
+ liveVisibility: true,
954
+ },
955
+ secondaryCTA: {
956
+ label: "Call to Action",
957
+ link: "#",
958
+ variant: "secondary",
959
+ liveVisibility: false,
960
+ },
961
+ image: {
962
+ field: "headshot",
963
+ liveVisibility: false,
964
+ },
965
+ },
966
+ },
967
+ version: 60,
968
+ },
969
+ {
970
+ name: "version 64 static headings",
971
+ document: {
972
+ locale: "en",
973
+ businessId: "4174974",
974
+ __: {
975
+ isPrimaryLocale: true,
976
+ },
977
+ _env: {
978
+ ...LOCATOR_TEST_ENV,
979
+ },
980
+ _pageset: JSON.stringify({
981
+ type: "LOCATOR",
982
+ typeConfig: {
983
+ locatorConfig: {
984
+ source: "accounts/4174974/sites/155048/pagesets/locations",
985
+ experienceKey: "locator-41",
986
+ entityType: "location",
987
+ },
988
+ },
989
+ config: {
990
+ urlTemplate: {
991
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
992
+ },
993
+ },
994
+ }),
995
+ },
996
+ props: {
997
+ filters: {
998
+ openNowButton: false,
999
+ showDistanceOptions: false,
1000
+ },
1001
+ resultCard: {
1002
+ primaryHeading: {
1003
+ field: "name",
1004
+ constantValue: { en: "", hasLocalizedValue: "true" },
1005
+ constantValueEnabled: false,
1006
+ headingLevel: 3,
1007
+ },
1008
+ secondaryHeading: {
1009
+ field: "name",
1010
+ constantValue: {
1011
+ en: "Secondary Static",
1012
+ hasLocalizedValue: "true",
1013
+ },
1014
+ constantValueEnabled: true,
1015
+ variant: "base",
1016
+ liveVisibility: true,
1017
+ },
1018
+ tertiaryHeading: {
1019
+ field: "name",
1020
+ constantValue: { en: "Tertiary Static", hasLocalizedValue: "true" },
1021
+ constantValueEnabled: true,
1022
+ variant: "base",
1023
+ liveVisibility: true,
1024
+ },
1025
+ icons: true,
1026
+ hours: {
1027
+ table: {
1028
+ startOfWeek: "today",
1029
+ collapseDays: false,
1030
+ showAdditionalHoursText: false,
1031
+ },
1032
+ liveVisibility: true,
1033
+ },
1034
+ address: {
1035
+ showGetDirectionsLink: true,
1036
+ liveVisibility: true,
1037
+ },
1038
+ phone: {
1039
+ field: "mainPhone",
1040
+ phoneFormat: "domestic",
1041
+ includePhoneHyperlink: true,
1042
+ liveVisibility: true,
1043
+ },
1044
+ email: {
1045
+ field: "emails",
1046
+ liveVisibility: false,
1047
+ },
1048
+ services: {
1049
+ field: "services",
1050
+ liveVisibility: false,
1051
+ },
1052
+ primaryCTA: {
1053
+ variant: "primary",
1054
+ liveVisibility: true,
1055
+ },
1056
+ secondaryCTA: {
1057
+ label: "Call to Action",
1058
+ link: "#",
1059
+ variant: "secondary",
1060
+ liveVisibility: false,
1061
+ },
1062
+ image: {
1063
+ field: "headshot",
1064
+ constantValue: {
1065
+ en: { url: "", height: 0, width: 0 },
1066
+ hasLocalizedValue: "true",
1067
+ },
1068
+ constantValueEnabled: false,
1069
+ liveVisibility: false,
1070
+ },
1071
+ },
1072
+ },
1073
+ interactions: async (page) => {
1074
+ await expect
1075
+ .element(page.getByText("Secondary Static").first())
1076
+ .toBeVisible();
1077
+ },
1078
+ version: 64,
1079
+ },
1080
+ {
1081
+ name: "version 64 static image",
1082
+ document: {
1083
+ locale: "en",
1084
+ businessId: "4174974",
1085
+ __: {
1086
+ isPrimaryLocale: true,
1087
+ },
1088
+ _env: {
1089
+ ...LOCATOR_TEST_ENV,
1090
+ },
1091
+ _pageset: JSON.stringify({
1092
+ type: "LOCATOR",
1093
+ typeConfig: {
1094
+ locatorConfig: {
1095
+ source: "accounts/4174974/sites/155048/pagesets/locations",
1096
+ experienceKey: "locator-41",
1097
+ entityType: "location",
1098
+ },
1099
+ },
1100
+ config: {
1101
+ urlTemplate: {
1102
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
1103
+ },
1104
+ },
1105
+ }),
1106
+ },
1107
+ props: {
1108
+ filters: {
1109
+ openNowButton: false,
1110
+ showDistanceOptions: false,
1111
+ },
1112
+ resultCard: {
1113
+ primaryHeading: {
1114
+ field: "name",
1115
+ constantValue: { en: "", hasLocalizedValue: "true" },
1116
+ constantValueEnabled: false,
1117
+ headingLevel: 3,
1118
+ },
1119
+ secondaryHeading: {
1120
+ field: "name",
1121
+ constantValue: { en: "", hasLocalizedValue: "true" },
1122
+ constantValueEnabled: false,
1123
+ variant: "base",
1124
+ liveVisibility: false,
1125
+ },
1126
+ tertiaryHeading: {
1127
+ field: "name",
1128
+ constantValue: { en: "", hasLocalizedValue: "true" },
1129
+ constantValueEnabled: false,
1130
+ variant: "base",
1131
+ liveVisibility: false,
1132
+ },
1133
+ icons: true,
1134
+ hours: {
1135
+ table: {
1136
+ startOfWeek: "today",
1137
+ collapseDays: false,
1138
+ showAdditionalHoursText: false,
1139
+ },
1140
+ liveVisibility: true,
1141
+ },
1142
+ address: {
1143
+ showGetDirectionsLink: true,
1144
+ liveVisibility: true,
1145
+ },
1146
+ phone: {
1147
+ field: "mainPhone",
1148
+ phoneFormat: "domestic",
1149
+ includePhoneHyperlink: true,
1150
+ liveVisibility: true,
1151
+ },
1152
+ email: {
1153
+ field: "emails",
1154
+ liveVisibility: false,
1155
+ },
1156
+ services: {
1157
+ field: "services",
1158
+ liveVisibility: false,
1159
+ },
1160
+ primaryCTA: {
1161
+ variant: "primary",
1162
+ liveVisibility: true,
1163
+ },
1164
+ secondaryCTA: {
1165
+ label: "Call to Action",
1166
+ link: "#",
1167
+ variant: "secondary",
1168
+ liveVisibility: false,
1169
+ },
1170
+ image: {
1171
+ field: "headshot",
1172
+ constantValue: {
1173
+ en: {
1174
+ url: LOCATOR_TEST_IMAGE_URL,
1175
+ height: 80,
1176
+ width: 80,
1177
+ },
1178
+ hasLocalizedValue: "true",
1179
+ },
1180
+ constantValueEnabled: true,
1181
+ liveVisibility: true,
1182
+ },
1183
+ },
1184
+ },
1185
+ version: 64,
1186
+ },
1187
+ ];
1188
+
1189
+ const wrappedSelectorValuesMigrationFixture = {
1190
+ document: {
1191
+ locale: "en",
1192
+ businessId: "4174974",
1193
+ __: {
1194
+ isPrimaryLocale: true,
1195
+ },
1196
+ _env: {
1197
+ ...LOCATOR_TEST_ENV,
1198
+ },
1199
+ _pageset: JSON.stringify({
1200
+ type: "LOCATOR",
1201
+ typeConfig: {
1202
+ locatorConfig: {
1203
+ source: "accounts/4174974/sites/155048/pagesets/locations",
1204
+ experienceKey: "locator-41",
1205
+ entityType: "location",
1206
+ },
1207
+ },
1208
+ config: {
1209
+ urlTemplate: {
1210
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
1211
+ },
1212
+ },
1213
+ }),
1214
+ },
1215
+ data: {
1216
+ root: {
1217
+ props: {
1218
+ version: 73,
1219
+ },
1220
+ },
1221
+ content: [
1222
+ {
1223
+ type: "MainContent",
1224
+ props: {
1225
+ id: "MainContent-default",
1226
+ content: [
1227
+ {
1228
+ type: "Locator",
1229
+ props: {
1230
+ filters: {
1231
+ openNowButton: false,
1232
+ showDistanceOptions: false,
1233
+ },
1234
+ resultCard: [
1235
+ {
1236
+ props: {
1237
+ entityType: "location",
1238
+ primaryHeading: {
1239
+ field: { selection: { value: "name" } },
1240
+ constantValue: { en: "", hasLocalizedValue: "true" },
1241
+ constantValueEnabled: false,
1242
+ headingLevel: 3,
1243
+ },
1244
+ secondaryHeading: {
1245
+ field: { selection: { value: "name" } },
1246
+ constantValue: { en: "", hasLocalizedValue: "true" },
1247
+ constantValueEnabled: false,
1248
+ variant: "base",
1249
+ liveVisibility: false,
1250
+ },
1251
+ tertiaryHeading: {
1252
+ field: { selection: { value: "name" } },
1253
+ constantValue: { en: "", hasLocalizedValue: "true" },
1254
+ constantValueEnabled: false,
1255
+ variant: "base",
1256
+ liveVisibility: false,
1257
+ },
1258
+ icons: true,
1259
+ hours: {
1260
+ field: { selection: { value: "hours" } },
1261
+ table: {
1262
+ startOfWeek: "today",
1263
+ collapseDays: false,
1264
+ showAdditionalHoursText: false,
1265
+ },
1266
+ liveVisibility: true,
1267
+ },
1268
+ address: {
1269
+ showGetDirectionsLink: true,
1270
+ liveVisibility: true,
1271
+ },
1272
+ phone: {
1273
+ field: { selection: { value: "mainPhone" } },
1274
+ phoneFormat: "domestic",
1275
+ includePhoneHyperlink: true,
1276
+ liveVisibility: true,
1277
+ },
1278
+ email: {
1279
+ field: { selection: { value: "emails" } },
1280
+ liveVisibility: false,
1281
+ },
1282
+ services: {
1283
+ field: { selection: { value: "services" } },
1284
+ liveVisibility: false,
1285
+ },
1286
+ primaryCTA: {
1287
+ label: "Visit Page",
1288
+ variant: "primary",
1289
+ liveVisibility: true,
1290
+ },
1291
+ secondaryCTA: {
1292
+ label: "Call to Action",
1293
+ link: "#",
1294
+ variant: "secondary",
1295
+ liveVisibility: false,
1296
+ },
1297
+ image: {
1298
+ field: { selection: { value: "headshot" } },
1299
+ constantValue: {
1300
+ en: { url: "", height: 0, width: 0 },
1301
+ hasLocalizedValue: "true",
1302
+ },
1303
+ constantValueEnabled: false,
1304
+ liveVisibility: false,
1305
+ },
1306
+ },
1307
+ },
1308
+ ],
1309
+ },
1310
+ },
1311
+ ],
1312
+ },
1313
+ },
1314
+ ],
1315
+ zones: {},
1316
+ },
1317
+ };
1318
+
1319
+ const screenshotThreshold = 30;
1320
+
1321
+ describe("Locator", async () => {
1322
+ const puckConfig: Config = {
1323
+ components: { Locator: LocatorComponent, MainContent },
1324
+ root: {
1325
+ render: ({ children }: { children: React.ReactNode }) => {
1326
+ return <>{children}</>;
1327
+ },
1328
+ },
1329
+ };
1330
+
1331
+ it("flattens wrapped result card selector fields during migration", () => {
1332
+ const data = migrate(
1333
+ puckConfig,
1334
+ wrappedSelectorValuesMigrationFixture.data as any,
1335
+ wrappedSelectorValuesMigrationFixture.document as any,
1336
+ migrationRegistry
1337
+ );
1338
+
1339
+ const mainContent = data.content[0] as any;
1340
+ expect(mainContent.type).toBe("MainContent");
1341
+
1342
+ const locator = mainContent.props.content.find(
1343
+ (item: any) => item.type === "Locator"
1344
+ );
1345
+ expect(locator).toBeDefined();
1346
+
1347
+ const resultCardProps = locator.props.resultCard[0].props;
1348
+
1349
+ expect(resultCardProps.primaryHeading.field).toBe("name");
1350
+ expect(resultCardProps.secondaryHeading.field).toBe("name");
1351
+ expect(resultCardProps.tertiaryHeading.field).toBe("name");
1352
+ expect(resultCardProps.hours.field).toBe("hours");
1353
+ expect(resultCardProps.phone.field).toBe("mainPhone");
1354
+ expect(resultCardProps.email.field).toBe("emails");
1355
+ expect(resultCardProps.services.field).toBe("services");
1356
+ expect(resultCardProps.image.field).toBe("headshot");
1357
+ });
1358
+
1359
+ it.each(transformTests(tests))(
1360
+ "$viewport.name $name",
1361
+ async ({
1362
+ name,
1363
+ document,
1364
+ props,
1365
+ interactions,
1366
+ version,
1367
+ viewport: { width, height, name: viewportName },
1368
+ }) => {
1369
+ let data = migrate(
1370
+ puckConfig,
1371
+ {
1372
+ root: {
1373
+ props: {
1374
+ version,
1375
+ },
1376
+ },
1377
+ content: [
1378
+ {
1379
+ type: "Locator",
1380
+ props: props,
1381
+ },
1382
+ ],
1383
+ },
1384
+ document,
1385
+ migrationRegistry
1386
+ );
1387
+
1388
+ data = await resolveAllData(data, puckConfig, {
1389
+ streamDocument: document,
1390
+ });
1391
+
1392
+ const translations = await injectTranslations(document);
1393
+ vi.stubGlobal("fetch", createLocatorFetchMock(document));
1394
+
1395
+ await page.viewport(width, height);
1396
+
1397
+ const { container } = reactRender(
1398
+ <VisualEditorProvider templateProps={{ document, translations }}>
1399
+ <Render config={puckConfig} data={data} />
1400
+ </VisualEditorProvider>
1401
+ );
1402
+
1403
+ // Unless testing empty state, wait for search to load
1404
+ if (!name.includes("empty document")) {
1405
+ await waitFor(() => {
1406
+ screen.getAllByText("Galaxy Grill");
1407
+ const opacityContainer = container.querySelector("#innerDiv div");
1408
+ if (opacityContainer) {
1409
+ expect(getComputedStyle(opacityContainer).opacity).toBe("1");
1410
+ }
1411
+ });
1412
+ }
1413
+
1414
+ await expect(`Locator/[${viewportName}] ${name}`).toMatchScreenshot({
1415
+ customThreshold: screenshotThreshold,
1416
+ });
1417
+ const results = await axe(container);
1418
+ logSuppressedWcagViolations(results);
1419
+ // TODO: Re-enable WCAG test
1420
+ // expect(results).toHaveNoViolations()
1421
+
1422
+ if (interactions) {
1423
+ await interactions(page);
1424
+ await expect(
1425
+ `Locator/[${viewportName}] ${name} (after interactions)`
1426
+ ).toMatchScreenshot({ customThreshold: screenshotThreshold });
1427
+ const results = await axe(container);
1428
+ logSuppressedWcagViolations(results);
1429
+ }
1430
+ }
1431
+ );
1432
+
1433
+ it("restores coordinate q without a filter search request", async () => {
1434
+ const originalUrl = window.location.href;
1435
+ const fixture = tests[1];
1436
+ const fetchMock = createLocatorFetchMock(fixture.document);
1437
+ const startingUrl = new URL(originalUrl);
1438
+ startingUrl.search =
1439
+ "?initialLocation=Boston&q=38.895546%2C-77.069915%2C40233&ref=campaign";
1440
+ window.history.replaceState(window.history.state, "", startingUrl);
1441
+
1442
+ try {
1443
+ let data = migrate(
1444
+ puckConfig,
1445
+ {
1446
+ root: { props: { version: fixture.version } },
1447
+ content: [{ type: "Locator", props: fixture.props }],
1448
+ },
1449
+ fixture.document,
1450
+ migrationRegistry
1451
+ );
1452
+ data = await resolveAllData(data, puckConfig, {
1453
+ streamDocument: fixture.document,
1454
+ });
1455
+ vi.stubGlobal("fetch", fetchMock);
1456
+ reactRender(
1457
+ <VisualEditorProvider templateProps={{ document: fixture.document }}>
1458
+ <Render config={puckConfig} data={data} />
1459
+ </VisualEditorProvider>
1460
+ );
1461
+
1462
+ await waitFor(() =>
1463
+ expect(
1464
+ fetchMock.mock.calls.some(([input]) =>
1465
+ String(input).includes("/search/vertical/query")
1466
+ )
1467
+ ).toBe(true)
1468
+ );
1469
+ expect(
1470
+ fetchMock.mock.calls.some(([input]) =>
1471
+ String(input).includes("/search/filtersearch")
1472
+ )
1473
+ ).toBe(false);
1474
+ expect(screen.getByText(/Custom Search Area/)).toBeInTheDocument();
1475
+ } finally {
1476
+ window.history.replaceState(window.history.state, "", originalUrl);
1477
+ }
1478
+ });
1479
+
1480
+ it("writes current-location coordinates to q without another lookup", async () => {
1481
+ const originalUrl = window.location.href;
1482
+ const fixture = tests[1];
1483
+ const startingUrl = new URL(originalUrl);
1484
+ startingUrl.search = "?ref=campaign";
1485
+ window.history.replaceState(window.history.state, "", startingUrl);
1486
+ const position = {
1487
+ coords: { latitude: 38.895546, longitude: -77.069915, accuracy: 10 },
1488
+ } as GeolocationPosition;
1489
+ vi.mocked(getUserLocation).mockResolvedValue(position);
1490
+ const getCurrentPosition = vi
1491
+ .spyOn(navigator.geolocation, "getCurrentPosition")
1492
+ .mockImplementation((success) => success(position));
1493
+ const fetchMock = createLocatorFetchMock(fixture.document);
1494
+ const mapboxFetch = vi.fn(
1495
+ async () =>
1496
+ new Response(
1497
+ JSON.stringify({ features: [{ place_name: "Arlington, VA" }] }),
1498
+ { status: 200 }
1499
+ )
1500
+ );
1501
+ vi.stubGlobal(
1502
+ "fetch",
1503
+ vi.fn((input: string | URL | Request) =>
1504
+ String(input).includes("api.mapbox.com/geocoding")
1505
+ ? mapboxFetch()
1506
+ : fetchMock(input)
1507
+ )
1508
+ );
1509
+
1510
+ try {
1511
+ let data = migrate(
1512
+ puckConfig,
1513
+ {
1514
+ root: { props: { version: fixture.version } },
1515
+ content: [{ type: "Locator", props: fixture.props }],
1516
+ },
1517
+ fixture.document,
1518
+ migrationRegistry
1519
+ );
1520
+ data = await resolveAllData(data, puckConfig, {
1521
+ streamDocument: fixture.document,
1522
+ });
1523
+ reactRender(
1524
+ <VisualEditorProvider templateProps={{ document: fixture.document }}>
1525
+ <Render config={puckConfig} data={data} />
1526
+ </VisualEditorProvider>
1527
+ );
1528
+
1529
+ const currentLocationButton = await screen.findByRole("button", {
1530
+ name: "Use Current Location",
1531
+ });
1532
+ const lookupsBeforeClick = mapboxFetch.mock.calls.length;
1533
+ await act(async () => currentLocationButton.click());
1534
+ await waitFor(() =>
1535
+ expect(new URL(window.location.href).searchParams.get("q")).toBe(
1536
+ "38.895546,-77.069915,40233.6"
1537
+ )
1538
+ );
1539
+ expect(mapboxFetch.mock.calls.length).toBe(lookupsBeforeClick);
1540
+ expect(new URL(window.location.href).searchParams.get("ref")).toBe(
1541
+ "campaign"
1542
+ );
1543
+ } finally {
1544
+ getCurrentPosition.mockRestore();
1545
+ vi.mocked(getUserLocation).mockRejectedValue(
1546
+ new Error("Locator screenshot tests use fixture search data.")
1547
+ );
1548
+ window.history.replaceState(window.history.state, "", originalUrl);
1549
+ }
1550
+ });
1551
+ });