@yext/visual-editor 1.4.11 → 2.0.0-beta.2

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 (225) hide show
  1. package/dist/SectionLibraryVisualEditorProvider-fUGYIhyC.js +108668 -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 +260 -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 +491 -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 +245 -0
  31. package/dist/cli/yextve.js +16895 -0
  32. package/dist/index.d.ts +542 -6311
  33. package/dist/locales/page/cs/visual-editor.json +85 -0
  34. package/dist/locales/page/da/visual-editor.json +73 -0
  35. package/dist/locales/page/de/visual-editor.json +73 -0
  36. package/dist/locales/page/en/visual-editor.json +73 -0
  37. package/dist/locales/page/en-GB/visual-editor.json +73 -0
  38. package/dist/locales/page/es/visual-editor.json +79 -0
  39. package/dist/locales/page/et/visual-editor.json +73 -0
  40. package/dist/locales/page/fi/visual-editor.json +73 -0
  41. package/dist/locales/page/fr/visual-editor.json +79 -0
  42. package/dist/locales/page/hr/visual-editor.json +79 -0
  43. package/dist/locales/page/hu/visual-editor.json +73 -0
  44. package/dist/locales/page/it/visual-editor.json +79 -0
  45. package/dist/locales/page/ja/visual-editor.json +73 -0
  46. package/dist/locales/page/lt/visual-editor.json +85 -0
  47. package/dist/locales/page/lv/visual-editor.json +77 -0
  48. package/dist/locales/page/nb/visual-editor.json +73 -0
  49. package/dist/locales/page/nl/visual-editor.json +73 -0
  50. package/dist/locales/page/pl/visual-editor.json +85 -0
  51. package/dist/locales/page/pt/visual-editor.json +79 -0
  52. package/dist/locales/page/ro/visual-editor.json +79 -0
  53. package/dist/locales/page/sk/visual-editor.json +85 -0
  54. package/dist/locales/page/sv/visual-editor.json +73 -0
  55. package/dist/locales/page/tr/visual-editor.json +73 -0
  56. package/dist/locales/page/zh/visual-editor.json +73 -0
  57. package/dist/locales/page/zh-TW/visual-editor.json +73 -0
  58. package/dist/locales/platform/cs/visual-editor.json +531 -0
  59. package/dist/locales/platform/da/visual-editor.json +519 -0
  60. package/dist/locales/platform/de/visual-editor.json +519 -0
  61. package/dist/locales/platform/en/visual-editor.json +519 -0
  62. package/dist/locales/platform/en-GB/visual-editor.json +519 -0
  63. package/dist/locales/platform/es/visual-editor.json +525 -0
  64. package/dist/locales/platform/et/visual-editor.json +519 -0
  65. package/dist/locales/platform/fi/visual-editor.json +519 -0
  66. package/dist/locales/platform/fr/visual-editor.json +525 -0
  67. package/dist/locales/platform/hr/visual-editor.json +525 -0
  68. package/dist/locales/platform/hu/visual-editor.json +519 -0
  69. package/dist/locales/platform/it/visual-editor.json +525 -0
  70. package/dist/locales/platform/ja/visual-editor.json +519 -0
  71. package/dist/locales/platform/lt/visual-editor.json +531 -0
  72. package/dist/locales/platform/lv/visual-editor.json +523 -0
  73. package/dist/locales/platform/nb/visual-editor.json +519 -0
  74. package/dist/locales/platform/nl/visual-editor.json +519 -0
  75. package/dist/locales/platform/pl/visual-editor.json +531 -0
  76. package/dist/locales/platform/pt/visual-editor.json +525 -0
  77. package/dist/locales/platform/ro/visual-editor.json +525 -0
  78. package/dist/locales/platform/sk/visual-editor.json +531 -0
  79. package/dist/locales/platform/sv/visual-editor.json +519 -0
  80. package/dist/locales/platform/tr/visual-editor.json +519 -0
  81. package/dist/locales/platform/zh/visual-editor.json +519 -0
  82. package/dist/locales/platform/zh-TW/visual-editor.json +519 -0
  83. package/dist/locatorEntityTypes-s4dmT9l5.d.ts +1850 -0
  84. package/dist/plugin/internal/sectionLibraryValidation/builtInTranslationResources.d.ts +3 -0
  85. package/dist/plugin/internal/sectionLibraryValidation/stages/api/api.d.ts +7 -0
  86. package/dist/plugin/internal/sectionLibraryValidation/stages/api/libraryMetadata.d.ts +7 -0
  87. package/dist/plugin/internal/sectionLibraryValidation/stages/code/importRules.d.ts +13 -0
  88. package/dist/plugin/internal/sectionLibraryValidation/stages/code/validateCode.d.ts +10 -0
  89. package/dist/plugin/internal/sectionLibraryValidation/stages/code/xssRules.d.ts +7 -0
  90. package/dist/plugin/internal/sectionLibraryValidation/stages/structure/structure.d.ts +7 -0
  91. package/dist/plugin/internal/sectionLibraryValidation/types.d.ts +48 -0
  92. package/dist/plugin/internal/sectionLibraryValidation/validateSectionLibrary.d.ts +8 -0
  93. package/dist/plugin/internal/sectionLibraryValidation/validationError.d.ts +6 -0
  94. package/dist/plugin/plugin.js +2233 -5786
  95. package/dist/plugin/types/entityFields.d.ts +21 -0
  96. package/dist/plugin/types/images.d.ts +62 -0
  97. package/dist/plugin/types/sectionLibrary.d.ts +94 -0
  98. package/dist/plugin/types/types.d.ts +204 -0
  99. package/dist/plugin/types/videos.d.ts +24 -0
  100. package/dist/plugin/utils/i18n/locales.d.ts +5 -0
  101. package/dist/plugin/utils/i18n/translationResources.d.ts +41 -0
  102. package/dist/plugin/utils/normalizeLocale.d.ts +8 -0
  103. package/dist/plugin/utils/plainText.d.ts +6 -0
  104. package/dist/plugin/vite-plugin/index.d.ts +2 -0
  105. package/dist/plugin/vite-plugin/local-editor/artifacts.d.ts +18 -0
  106. package/dist/plugin/vite-plugin/local-editor/config.d.ts +11 -0
  107. package/dist/plugin/vite-plugin/local-editor/data.d.ts +10 -0
  108. package/dist/plugin/vite-plugin/local-editor/entityFields.d.ts +13 -0
  109. package/dist/plugin/vite-plugin/local-editor/fixtureData.d.ts +12 -0
  110. package/dist/plugin/vite-plugin/local-editor/generatedFiles.d.ts +34 -0
  111. package/dist/plugin/vite-plugin/local-editor/server.d.ts +18 -0
  112. package/dist/plugin/vite-plugin/local-editor/types.d.ts +109 -0
  113. package/dist/plugin/vite-plugin/local-editor/utils.d.ts +16 -0
  114. package/dist/plugin/vite-plugin/plugin.d.ts +8 -0
  115. package/dist/plugin/vite-plugin/section-library/migrationRegistry.d.ts +6 -0
  116. package/dist/plugin/vite-plugin/section-library/sectionFrontmatter.d.ts +3 -0
  117. package/dist/plugin/vite-plugin/section-library/sectionLibraryGenerator.d.ts +21 -0
  118. package/dist/plugin/vite-plugin/section-library/sharedComponentRegistry.d.ts +16 -0
  119. package/dist/section-library-support.js +158 -0
  120. package/dist/sectionLibrarySupport.d.ts +282 -0
  121. package/dist/style.css +1 -1
  122. package/dist/visual-editor-2Y77HmqL.js +718 -0
  123. package/dist/visual-editor-7P4U2T4q.js +694 -0
  124. package/dist/visual-editor-AXgoU7J5.js +694 -0
  125. package/dist/visual-editor-B-8ROr4n.js +694 -0
  126. package/dist/visual-editor-BDozYwKy.js +702 -0
  127. package/dist/visual-editor-BGMk-qTN.js +718 -0
  128. package/dist/visual-editor-BIqNAAcB.js +718 -0
  129. package/dist/visual-editor-BPI_dyYw.js +694 -0
  130. package/dist/visual-editor-BXYlpe7B.js +145 -0
  131. package/dist/visual-editor-Bkgub-3w.js +694 -0
  132. package/dist/visual-editor-Bo-tmHFc.js +694 -0
  133. package/dist/visual-editor-BuYrclmi.js +706 -0
  134. package/dist/visual-editor-Bxy81Ezy.js +145 -0
  135. package/dist/visual-editor-C0vq2BRM.js +145 -0
  136. package/dist/visual-editor-CCLIvOCf.js +694 -0
  137. package/dist/visual-editor-CCgmYV5S.js +169 -0
  138. package/dist/visual-editor-CE2J5pWp.js +694 -0
  139. package/dist/visual-editor-CERViyTJ.js +145 -0
  140. package/dist/visual-editor-CY2YjlX9.js +706 -0
  141. package/dist/visual-editor-CcuA4NSE.js +694 -0
  142. package/dist/visual-editor-Cd8yeRID.js +718 -0
  143. package/dist/visual-editor-CjORnP1D.js +169 -0
  144. package/dist/visual-editor-CmomGJB8.js +157 -0
  145. package/dist/visual-editor-CpCR_bSp.js +706 -0
  146. package/dist/visual-editor-Cymg8ID2.js +169 -0
  147. package/dist/visual-editor-D2Hk1nhM.js +145 -0
  148. package/dist/visual-editor-D8MRFn5x.js +157 -0
  149. package/dist/visual-editor-D96X4hBl.js +706 -0
  150. package/dist/visual-editor-DOXtCqRv.js +145 -0
  151. package/dist/visual-editor-DQEd3xwY.js +145 -0
  152. package/dist/visual-editor-DUngIOnE.js +157 -0
  153. package/dist/visual-editor-Dd-aD1iL.js +694 -0
  154. package/dist/visual-editor-DeZVZYfd.js +169 -0
  155. package/dist/visual-editor-DfJMZpiP.js +145 -0
  156. package/dist/visual-editor-DgAsQK9D.js +145 -0
  157. package/dist/visual-editor-Dhi__-7_.js +145 -0
  158. package/dist/visual-editor-DjN3MVkl.js +694 -0
  159. package/dist/visual-editor-DjdqpJU-.js +145 -0
  160. package/dist/visual-editor-DqddYaYq.js +694 -0
  161. package/dist/visual-editor-DrCmls4W.js +694 -0
  162. package/dist/visual-editor-DvuH3jyL.js +157 -0
  163. package/dist/visual-editor-TfVDfO5_.js +145 -0
  164. package/dist/visual-editor-VcrEkFyd.js +706 -0
  165. package/dist/visual-editor-W_ZDmMFn.js +145 -0
  166. package/dist/visual-editor-b7ALusk8.js +145 -0
  167. package/dist/visual-editor-bauJ9beX.js +694 -0
  168. package/dist/visual-editor-erGXf3kS.js +157 -0
  169. package/dist/visual-editor-hVELayZs.js +706 -0
  170. package/dist/visual-editor-xnDHZFuO.js +153 -0
  171. package/dist/visual-editor-yiWZqIH0.js +157 -0
  172. package/dist/visual-editor.css +1 -0
  173. package/dist/visual-editor.js +15074 -137463
  174. package/package.json +46 -25
  175. package/dist/editor.css +0 -1
  176. package/dist/visual-editor-1QC8zZX_.js +0 -221
  177. package/dist/visual-editor-5C5XV5rL.js +0 -221
  178. package/dist/visual-editor-B8-FoFxc.js +0 -1049
  179. package/dist/visual-editor-BJgCpnYV.js +0 -1073
  180. package/dist/visual-editor-BKLiin5z.js +0 -1049
  181. package/dist/visual-editor-BWbqw_QE.js +0 -233
  182. package/dist/visual-editor-Bb6upvTE.js +0 -221
  183. package/dist/visual-editor-BcZCBLFh.js +0 -1049
  184. package/dist/visual-editor-BecDYKH8.js +0 -1049
  185. package/dist/visual-editor-BllAUu_T.js +0 -1073
  186. package/dist/visual-editor-BmaYFuCe.js +0 -233
  187. package/dist/visual-editor-BnPFkJlo.js +0 -221
  188. package/dist/visual-editor-BoIXa-xl.js +0 -245
  189. package/dist/visual-editor-BtDJICJp.js +0 -1073
  190. package/dist/visual-editor-BwxWyr_L.js +0 -221
  191. package/dist/visual-editor-Bz7BlR_j.js +0 -221
  192. package/dist/visual-editor-CC0RAmib.js +0 -1049
  193. package/dist/visual-editor-CDY9slY9.js +0 -1061
  194. package/dist/visual-editor-CFebs6R8.js +0 -1049
  195. package/dist/visual-editor-CNL0HyVh.js +0 -1049
  196. package/dist/visual-editor-CYnzwNwX.js +0 -229
  197. package/dist/visual-editor-CZH605TK.js +0 -233
  198. package/dist/visual-editor-Cada46ZF.js +0 -1049
  199. package/dist/visual-editor-CheComxC.js +0 -1061
  200. package/dist/visual-editor-CuA8h_Xv.js +0 -221
  201. package/dist/visual-editor-CuRmgs-p.js +0 -245
  202. package/dist/visual-editor-D9_YWQQY.js +0 -1073
  203. package/dist/visual-editor-D9w4wRG8.js +0 -245
  204. package/dist/visual-editor-D9xTiOC0.js +0 -221
  205. package/dist/visual-editor-DA7CixSl.js +0 -1061
  206. package/dist/visual-editor-DAnBQ9H_.js +0 -221
  207. package/dist/visual-editor-DF8RsMvq.js +0 -233
  208. package/dist/visual-editor-DLrKYx7j.js +0 -1061
  209. package/dist/visual-editor-DQJc_Xok.js +0 -233
  210. package/dist/visual-editor-DTZFGKm7.js +0 -221
  211. package/dist/visual-editor-DXebihTA.js +0 -233
  212. package/dist/visual-editor-DZ4U1fk-.js +0 -221
  213. package/dist/visual-editor-Dg7P-vDv.js +0 -1057
  214. package/dist/visual-editor-Dh2cuwWt.js +0 -1049
  215. package/dist/visual-editor-DpetyO9o.js +0 -1049
  216. package/dist/visual-editor-Duav2tXb.js +0 -1061
  217. package/dist/visual-editor-DvYsu_s9.js +0 -221
  218. package/dist/visual-editor-DwlX3nnZ.js +0 -221
  219. package/dist/visual-editor-Dz5s66Og.js +0 -221
  220. package/dist/visual-editor-E57fPJMD.js +0 -1049
  221. package/dist/visual-editor-Fy_uEJju.js +0 -1061
  222. package/dist/visual-editor-G8e2TllW.js +0 -1049
  223. package/dist/visual-editor-HkfpXRw7.js +0 -1049
  224. package/dist/visual-editor-ZKG4e_Ey.js +0 -1049
  225. package/dist/visual-editor-rZRnDwgU.js +0 -245
@@ -0,0 +1,872 @@
1
+ import * as React from "react";
2
+ import { describe, it, expect } from "vitest";
3
+ import {
4
+ axe,
5
+ ComponentTest,
6
+ testHours,
7
+ transformTests,
8
+ } from "../../testing/componentTests.setup.ts";
9
+ import { render as reactRender } from "@testing-library/react";
10
+ import { Directory } from "./Directory.tsx";
11
+ import { migrate } from "../../../utils/migrate.ts";
12
+ import { migrationRegistry } from "../../migrations/migrationRegistry.ts";
13
+ import { SlotsCategoryComponents } from "../../testing/SlotComponents.tsx";
14
+ import { VisualEditorProvider } from "../../../utils/VisualEditorProvider.tsx";
15
+ import { Render, Config, resolveAllData } from "@puckeditor/core";
16
+ import { page } from "@vitest/browser/context";
17
+ import { MainContent } from "../../helpers/MainContent.tsx";
18
+
19
+ const rootDocument = {
20
+ locale: "en",
21
+ _site: {
22
+ name: "Example Business",
23
+ },
24
+ __: {
25
+ isPrimaryLocale: true,
26
+ },
27
+ _pageset: JSON.stringify({
28
+ config: {
29
+ urlTemplate: {
30
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
31
+ },
32
+ },
33
+ }),
34
+ name: "Location Directory",
35
+ meta: { entityType: { id: "dm_root", uid: 123 }, locale: "en" },
36
+ dm_childEntityIds: ["998877"],
37
+ dm_directoryChildren: [
38
+ {
39
+ name: "United States",
40
+ slug: "us",
41
+ dm_addressCountryDisplayName: "United States",
42
+ },
43
+ {
44
+ name: "Mexico",
45
+ slug: "mx",
46
+ dm_addressCountryDisplayName: "Mexico",
47
+ },
48
+ {
49
+ name: "Canada",
50
+ slug: "ca",
51
+ dm_addressCountryDisplayName: "Canada",
52
+ },
53
+ {
54
+ name: "France",
55
+ slug: "fr",
56
+ dm_addressCountryDisplayName: "France",
57
+ },
58
+ ],
59
+ dm_directoryManagerId: "63590-locations",
60
+ slug: "en/index.html",
61
+ };
62
+
63
+ const countryDocument = {
64
+ locale: "en",
65
+ _site: {
66
+ name: "Example Business",
67
+ },
68
+ __: {
69
+ isPrimaryLocale: true,
70
+ },
71
+ _pageset: JSON.stringify({
72
+ config: {
73
+ urlTemplate: {
74
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
75
+ },
76
+ },
77
+ }),
78
+ name: "US",
79
+ meta: { entityType: { id: "dm_country", uid: 123 }, locale: "en" },
80
+ dm_addressCountryDisplayName: "United States",
81
+ dm_childEntityIds: ["123456"],
82
+ dm_directoryChildren: [
83
+ {
84
+ name: "Virginia",
85
+ slug: "us/va",
86
+ dm_addressCountryDisplayName: "United States",
87
+ dm_addressRegionDisplayName: "Virginia",
88
+ },
89
+ {
90
+ name: "Washington DC",
91
+ slug: "us/dc",
92
+ dm_addressCountryDisplayName: "United States",
93
+ dm_addressRegionDisplayName: "Washington DC",
94
+ },
95
+ {
96
+ name: "New York",
97
+ slug: "us/ny",
98
+ dm_addressCountryDisplayName: "United States",
99
+ dm_addressRegionDisplayName: "New York",
100
+ },
101
+ {
102
+ name: "California",
103
+ slug: "us/ca",
104
+ dm_addressCountryDisplayName: "United States",
105
+ dm_addressRegionDisplayName: "California",
106
+ },
107
+ ],
108
+ dm_directoryManagerId: "63590-locations",
109
+ dm_directoryParents_63590_locations: [
110
+ {
111
+ name: "Locations Directory",
112
+ slug: "en/index.html",
113
+ dm_addressCountryDisplayName: "United States",
114
+ },
115
+ ],
116
+ slug: "us",
117
+ };
118
+
119
+ const regionDocument = {
120
+ locale: "en",
121
+ _site: {
122
+ name: "Example Business",
123
+ },
124
+ __: {
125
+ isPrimaryLocale: true,
126
+ },
127
+ _pageset: JSON.stringify({
128
+ config: {
129
+ urlTemplate: {
130
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
131
+ },
132
+ },
133
+ }),
134
+ name: "VA",
135
+ meta: { entityType: { id: "dm_region", uid: 123 }, locale: "en" },
136
+ dm_addressCountryDisplayName: "United States",
137
+ dm_addressRegionDisplayName: "Virginia",
138
+ dm_childEntityIds: ["8932945"],
139
+ dm_directoryChildren: [
140
+ {
141
+ name: "Arlington",
142
+ slug: "us/va/arlington",
143
+ dm_addressCountryDisplayName: "United States",
144
+ dm_addressRegionDisplayName: "Virginia",
145
+ },
146
+ {
147
+ name: "Fairfax",
148
+ slug: "us/va/fairfax",
149
+ dm_addressCountryDisplayName: "United States",
150
+ dm_addressRegionDisplayName: "Virginia",
151
+ },
152
+ {
153
+ name: "Alexandria",
154
+ slug: "us/va/alexandria",
155
+ dm_addressCountryDisplayName: "United States",
156
+ dm_addressRegionDisplayName: "Virginia",
157
+ },
158
+ {
159
+ name: "Falls Church",
160
+ slug: "us/va/fallschurch",
161
+ dm_addressCountryDisplayName: "United States",
162
+ dm_addressRegionDisplayName: "Virginia",
163
+ },
164
+ ],
165
+ dm_directoryManagerId: "63590-locations",
166
+ dm_directoryParents_63590_locations: [
167
+ {
168
+ name: "Locations Directory",
169
+ slug: "en/index.html",
170
+ },
171
+ {
172
+ name: "US",
173
+ slug: "en/us",
174
+ dm_addressCountryDisplayName: "United States",
175
+ },
176
+ ],
177
+ slug: "us/va",
178
+ };
179
+
180
+ const cityDocument = {
181
+ locale: "en",
182
+ _site: {
183
+ name: "Example Business",
184
+ },
185
+ __: {
186
+ isPrimaryLocale: true,
187
+ },
188
+ _pageset: JSON.stringify({
189
+ config: {
190
+ urlTemplate: {
191
+ primary: "[[address.region]]/[[address.city]]/[[address.line1]]",
192
+ },
193
+ },
194
+ }),
195
+ dm_childEntityIds: ["8725530"],
196
+ dm_directoryChildren: [
197
+ {
198
+ address: {
199
+ city: "Arlington",
200
+ countryCode: "US",
201
+ line1: "1101 Wilson Blvd",
202
+ postalCode: "22209",
203
+ region: "VA",
204
+ },
205
+ mainPhone: "+12025551010",
206
+ hours: testHours,
207
+ name: "Galaxy Grill Rosslyn",
208
+ timezone: "America/New_York",
209
+ slug: "arlington",
210
+ geomodifier: "2nd Floor",
211
+ },
212
+ {
213
+ address: {
214
+ city: "Arlington",
215
+ countryCode: "US",
216
+ line1: "4320 Fairfax Dr",
217
+ postalCode: "22201",
218
+ region: "VA",
219
+ },
220
+ mainPhone: "+12025551011",
221
+ hours: testHours,
222
+ name: "Galaxy Grill Ballston",
223
+ timezone: "America/New_York",
224
+ },
225
+ {
226
+ address: {
227
+ city: "Arlington",
228
+ countryCode: "US",
229
+ line1: "3100 Wilson Blvd",
230
+ postalCode: "22201",
231
+ region: "VA",
232
+ },
233
+ mainPhone: "+12025551012",
234
+ name: "Galaxy Grill Clarendon",
235
+ timezone: "America/New_York",
236
+ geomodifier: "Rooftop",
237
+ },
238
+ {
239
+ address: {
240
+ city: "Arlington",
241
+ countryCode: "US",
242
+ line1: "1250 S Hays St",
243
+ postalCode: "22202",
244
+ region: "VA",
245
+ },
246
+ hours: testHours,
247
+ name: "Galaxy Grill Pentagon City",
248
+ timezone: "America/New_York",
249
+ },
250
+ ],
251
+ name: "Arlington",
252
+ meta: { entityType: { id: "dm_city", uid: 456 }, locale: "en" },
253
+ dm_addressCountryDisplayName: "United States",
254
+ dm_addressRegionDisplayName: "Virginia",
255
+ dm_directoryManagerId: "63590-locations",
256
+ dm_directoryParents_63590_locations: [
257
+ { name: "Locations Directory", slug: "en/index.html" },
258
+ {
259
+ name: "US",
260
+ slug: "en/us",
261
+ dm_addressCountryDisplayName: "United States",
262
+ },
263
+ {
264
+ name: "VA",
265
+ slug: "us/va",
266
+ dm_addressCountryDisplayName: "United States",
267
+ dm_addressRegionDisplayName: "Virginia",
268
+ },
269
+ ],
270
+ slug: "us/va/arlington",
271
+ };
272
+
273
+ const version40Props = {
274
+ styles: {
275
+ backgroundColor: {
276
+ bgColor: "bg-palette-primary-dark",
277
+ textColor: "text-white",
278
+ },
279
+ },
280
+ slots: {
281
+ TitleSlot: [
282
+ {
283
+ type: "HeadingTextSlot",
284
+ props: {
285
+ data: {
286
+ text: {
287
+ constantValue: {
288
+ en: "[[name]]",
289
+ hasLocalizedValue: "true",
290
+ },
291
+ constantValueEnabled: true,
292
+ field: "",
293
+ },
294
+ },
295
+ styles: { level: 2, align: "center" },
296
+ },
297
+ },
298
+ ],
299
+ SiteNameSlot: [
300
+ {
301
+ type: "HeadingTextSlot",
302
+ props: {
303
+ data: {
304
+ text: {
305
+ constantValue: {
306
+ en: "",
307
+ hasLocalizedValue: "true",
308
+ },
309
+ constantValueEnabled: true,
310
+ field: "name",
311
+ },
312
+ },
313
+ styles: { level: 4, align: "center" },
314
+ },
315
+ },
316
+ ],
317
+ BreadcrumbsSlot: [
318
+ {
319
+ type: "BreadcrumbsSlot",
320
+ props: {
321
+ data: {
322
+ directoryRoot: {
323
+ en: "Directory Root",
324
+ hasLocalizedValue: "true",
325
+ },
326
+ },
327
+ styles: {
328
+ backgroundColor: {
329
+ bgColor: "bg-palette-secondary-dark",
330
+ textColor: "text-white",
331
+ },
332
+ },
333
+ analytics: {
334
+ scope: "directory",
335
+ },
336
+ liveVisibility: true,
337
+ },
338
+ },
339
+ ],
340
+ DirectoryGrid: [
341
+ {
342
+ type: "DirectoryGrid",
343
+ props: {
344
+ slots: {
345
+ CardSlot: [],
346
+ },
347
+ },
348
+ },
349
+ ],
350
+ },
351
+ };
352
+
353
+ const tests: ComponentTest[] = [
354
+ {
355
+ name: "default props - no document",
356
+ document: {},
357
+ props: { ...Directory.defaultProps },
358
+ version: migrationRegistry.length,
359
+ },
360
+ {
361
+ name: "default props - root - document data",
362
+ document: rootDocument,
363
+ props: { ...Directory.defaultProps },
364
+ version: migrationRegistry.length,
365
+ },
366
+ {
367
+ name: "default props - country - document data",
368
+ document: countryDocument,
369
+ props: { ...Directory.defaultProps },
370
+ version: migrationRegistry.length,
371
+ },
372
+ {
373
+ name: "default props - region - document data",
374
+ document: regionDocument,
375
+ props: { ...Directory.defaultProps },
376
+ version: migrationRegistry.length,
377
+ },
378
+ {
379
+ name: "default props - city list - document data",
380
+ document: cityDocument,
381
+ props: { ...Directory.defaultProps },
382
+ version: migrationRegistry.length,
383
+ },
384
+ {
385
+ name: "version 8 - directory list - non-default props",
386
+ document: regionDocument,
387
+ props: {
388
+ data: {
389
+ directoryRoot: "Not Default Root",
390
+ },
391
+ styles: {
392
+ backgroundColor: {
393
+ bgColor: "bg-palette-primary-light",
394
+ textColor: "text-black",
395
+ },
396
+ breadcrumbsBackgroundColor: {
397
+ bgColor: "bg-palette-primary-light",
398
+ textColor: "text-black",
399
+ },
400
+ cards: {
401
+ backgroundColor: {
402
+ bgColor: "bg-palette-primary-light",
403
+ textColor: "text-black",
404
+ },
405
+ headingLevel: 3,
406
+ },
407
+ },
408
+ liveVisibility: true,
409
+ },
410
+ version: 8,
411
+ },
412
+ {
413
+ name: "version 8 - directory card - non-default props",
414
+ document: cityDocument,
415
+ props: {
416
+ data: {
417
+ directoryRoot: "Not Default Root",
418
+ },
419
+ styles: {
420
+ backgroundColor: {
421
+ bgColor: "bg-palette-primary-light",
422
+ textColor: "text-black",
423
+ },
424
+ breadcrumbsBackgroundColor: {
425
+ bgColor: "bg-palette-primary-light",
426
+ textColor: "text-black",
427
+ },
428
+ cards: {
429
+ backgroundColor: {
430
+ bgColor: "bg-palette-primary-light",
431
+ textColor: "text-black",
432
+ },
433
+ headingLevel: 3,
434
+ },
435
+ },
436
+ liveVisibility: true,
437
+ },
438
+ version: 8,
439
+ },
440
+ {
441
+ name: "version 8 - root - default props",
442
+ document: rootDocument,
443
+ props: {
444
+ data: {
445
+ directoryRoot: "Directory Root",
446
+ },
447
+ styles: {
448
+ backgroundColor: {
449
+ bgColor: "bg-palette-primary-light",
450
+ textColor: "text-black",
451
+ },
452
+ breadcrumbsBackgroundColor: {
453
+ bgColor: "bg-palette-primary-light",
454
+ textColor: "text-black",
455
+ },
456
+ cards: {
457
+ backgroundColor: {
458
+ bgColor: "bg-palette-primary-light",
459
+ textColor: "text-black",
460
+ },
461
+ headingLevel: 3,
462
+ },
463
+ },
464
+ liveVisibility: true,
465
+ },
466
+ version: 8,
467
+ },
468
+ {
469
+ name: "version 8 - country - default props",
470
+ document: countryDocument,
471
+ props: {
472
+ data: {
473
+ directoryRoot: "Directory Root",
474
+ },
475
+ styles: {
476
+ backgroundColor: {
477
+ bgColor: "bg-palette-primary-light",
478
+ textColor: "text-black",
479
+ },
480
+ breadcrumbsBackgroundColor: {
481
+ bgColor: "bg-palette-primary-light",
482
+ textColor: "text-black",
483
+ },
484
+ cards: {
485
+ backgroundColor: {
486
+ bgColor: "bg-palette-primary-light",
487
+ textColor: "text-black",
488
+ },
489
+ headingLevel: 3,
490
+ },
491
+ },
492
+ liveVisibility: true,
493
+ },
494
+ version: 8,
495
+ },
496
+ {
497
+ name: "version 8 - region - default props",
498
+ document: regionDocument,
499
+ props: {
500
+ data: {
501
+ directoryRoot: "Directory Root",
502
+ },
503
+ styles: {
504
+ backgroundColor: {
505
+ bgColor: "bg-palette-primary-light",
506
+ textColor: "text-black",
507
+ },
508
+ breadcrumbsBackgroundColor: {
509
+ bgColor: "bg-palette-primary-light",
510
+ textColor: "text-black",
511
+ },
512
+ cards: {
513
+ backgroundColor: {
514
+ bgColor: "bg-palette-primary-light",
515
+ textColor: "text-black",
516
+ },
517
+ headingLevel: 3,
518
+ },
519
+ },
520
+ liveVisibility: true,
521
+ },
522
+ version: 8,
523
+ },
524
+ {
525
+ name: "version 8 - city - default props",
526
+ document: cityDocument,
527
+ props: {
528
+ data: {
529
+ directoryRoot: "Directory Root",
530
+ },
531
+ styles: {
532
+ backgroundColor: {
533
+ bgColor: "bg-palette-primary-light",
534
+ textColor: "text-black",
535
+ },
536
+ breadcrumbsBackgroundColor: {
537
+ bgColor: "bg-palette-primary-light",
538
+ textColor: "text-black",
539
+ },
540
+ cards: {
541
+ backgroundColor: {
542
+ bgColor: "bg-palette-primary-light",
543
+ textColor: "text-black",
544
+ },
545
+ headingLevel: 3,
546
+ },
547
+ },
548
+ liveVisibility: true,
549
+ },
550
+ version: 8,
551
+ },
552
+ {
553
+ name: "version 18 with cityDocument and siteName field",
554
+ document: cityDocument,
555
+ props: {
556
+ data: {
557
+ title: {
558
+ field: "",
559
+ constantValueEnabled: true,
560
+ constantValue: {
561
+ en: "[[name]]",
562
+ hasLocalizedValue: "true",
563
+ },
564
+ },
565
+ directoryRoot: "Directory Root",
566
+ siteName: {
567
+ field: "",
568
+ constantValueEnabled: true,
569
+ constantValue: {
570
+ en: "Example Business",
571
+ hasLocalizedValue: "true",
572
+ },
573
+ },
574
+ },
575
+ styles: {
576
+ backgroundColor: {
577
+ bgColor: "bg-palette-primary-light",
578
+ textColor: "text-black",
579
+ },
580
+ breadcrumbsBackgroundColor: {
581
+ bgColor: "bg-palette-primary-light",
582
+ textColor: "text-black",
583
+ },
584
+ cards: {
585
+ backgroundColor: {
586
+ bgColor: "bg-palette-primary-light",
587
+ textColor: "text-black",
588
+ },
589
+ headingLevel: 3,
590
+ },
591
+ hours: {
592
+ showCurrentStatus: true,
593
+ timeFormat: "12h",
594
+ showDayNames: false,
595
+ dayOfWeekFormat: "short",
596
+ },
597
+ phoneNumberFormat: "international",
598
+ phoneNumberLink: true,
599
+ },
600
+ liveVisibility: true,
601
+ },
602
+ version: 18,
603
+ },
604
+ {
605
+ name: "version 40 with cityDocument and non-default props",
606
+ document: cityDocument,
607
+ props: version40Props,
608
+ version: 40,
609
+ },
610
+ {
611
+ name: "version 40 with countryDocument and non-default props",
612
+ document: countryDocument,
613
+ props: version40Props,
614
+ version: 40,
615
+ },
616
+ {
617
+ name: "version 58 - Slotified Address with showGetDirectionsLink",
618
+ document: cityDocument,
619
+ props: {
620
+ ...version40Props,
621
+ slots: {
622
+ ...version40Props.slots,
623
+ DirectoryGrid: [
624
+ {
625
+ type: "DirectoryGrid",
626
+ props: {
627
+ slots: {
628
+ CardSlot: [
629
+ {
630
+ type: "DirectoryCard",
631
+ props: {
632
+ slots: {
633
+ AddressSlot: [
634
+ {
635
+ type: "AddressSlot",
636
+ props: {
637
+ styles: {
638
+ showGetDirectionsLink: true,
639
+ },
640
+ },
641
+ },
642
+ ],
643
+ },
644
+ },
645
+ },
646
+ ],
647
+ },
648
+ },
649
+ },
650
+ ],
651
+ },
652
+ },
653
+ version: 58,
654
+ },
655
+ {
656
+ name: "version 77 - City with custom card titles",
657
+ document: cityDocument,
658
+ props: {
659
+ ...version40Props,
660
+ slots: {
661
+ ...version40Props.slots,
662
+ DirectoryGrid: [
663
+ {
664
+ type: "DirectoryGrid",
665
+ props: {
666
+ data: {
667
+ field: "dm_directoryChildren",
668
+ constantValueEnabled: false,
669
+ constantValue: [],
670
+ mappings: {
671
+ cardTitle: {
672
+ field: "",
673
+ constantValueEnabled: true,
674
+ constantValue: {
675
+ defaultValue: "[[name]] [[geomodifier]]",
676
+ },
677
+ },
678
+ },
679
+ },
680
+ styles: {
681
+ backgroundColor: {
682
+ selectedColor: "white",
683
+ contrastingColor: "black",
684
+ },
685
+ },
686
+ slots: {
687
+ CardSlot: [
688
+ {
689
+ type: "DirectoryCard",
690
+ props: {
691
+ data: {
692
+ cardTitle: {
693
+ defaultValue: "[[name]]",
694
+ },
695
+ },
696
+ styles: {
697
+ backgroundColor: {
698
+ selectedColor: "white",
699
+ contrastingColor: "black",
700
+ },
701
+ },
702
+ slots: {
703
+ HeadingSlot: [
704
+ {
705
+ type: "HeadingTextSlot",
706
+ props: {
707
+ data: {
708
+ text: {
709
+ field: "",
710
+ constantValueEnabled: true,
711
+ constantValue: {
712
+ defaultValue: "[[name]]",
713
+ },
714
+ },
715
+ },
716
+ styles: {
717
+ level: 3,
718
+ align: "left",
719
+ },
720
+ },
721
+ },
722
+ ],
723
+ AddressSlot: [
724
+ {
725
+ type: "AddressSlot",
726
+ props: {
727
+ data: {
728
+ address: {
729
+ field: "address",
730
+ constantValue: {
731
+ line1: "",
732
+ city: "",
733
+ postalCode: "",
734
+ countryCode: "",
735
+ },
736
+ },
737
+ },
738
+ styles: {
739
+ showGetDirectionsLink: true,
740
+ showRegion: true,
741
+ showCountry: true,
742
+ ctaVariant: "link",
743
+ },
744
+ },
745
+ },
746
+ ],
747
+ PhoneSlot: [
748
+ {
749
+ type: "PhoneSlot",
750
+ props: {
751
+ data: {
752
+ number: {
753
+ constantValue: "",
754
+ field: "mainPhone",
755
+ },
756
+ label: {
757
+ constantValue: "",
758
+ hasLocalizedValue: "true",
759
+ field: "",
760
+ },
761
+ },
762
+ styles: {
763
+ phoneFormat: "domestic",
764
+ includePhoneHyperlink: true,
765
+ includeIcon: false,
766
+ },
767
+ },
768
+ },
769
+ ],
770
+ HoursSlot: [
771
+ {
772
+ type: "HoursStatusSlot",
773
+ props: {
774
+ data: {
775
+ hours: {
776
+ constantValue: {},
777
+ field: "hours",
778
+ },
779
+ },
780
+ styles: {
781
+ dayOfWeekFormat: "long",
782
+ showDayNames: true,
783
+ showCurrentStatus: true,
784
+ className:
785
+ "mb-2 font-semibold font-body-fontFamily text-body-fontSize h-full",
786
+ },
787
+ },
788
+ },
789
+ ],
790
+ },
791
+ },
792
+ },
793
+ ],
794
+ },
795
+ },
796
+ },
797
+ ],
798
+ },
799
+ },
800
+ version: 77,
801
+ },
802
+ ];
803
+
804
+ describe("Directory", async () => {
805
+ const puckConfig: Config = {
806
+ components: { Directory, MainContent, ...SlotsCategoryComponents },
807
+ root: {
808
+ render: ({ children }: { children: React.ReactNode }) => {
809
+ return <>{children}</>;
810
+ },
811
+ },
812
+ };
813
+ it.each(transformTests(tests))(
814
+ "$viewport.name $name",
815
+ async ({
816
+ document,
817
+ name,
818
+ props,
819
+ interactions,
820
+ version,
821
+ viewport: { width, height, name: viewportName },
822
+ }) => {
823
+ let data = migrate(
824
+ puckConfig,
825
+ {
826
+ root: {
827
+ props: {
828
+ version,
829
+ },
830
+ },
831
+ content: [
832
+ {
833
+ type: "Directory",
834
+ props: props,
835
+ },
836
+ ],
837
+ },
838
+ document,
839
+ migrationRegistry
840
+ );
841
+
842
+ const updatedData = await resolveAllData(data, puckConfig, {
843
+ streamDocument: document,
844
+ });
845
+
846
+ const { container } = reactRender(
847
+ <VisualEditorProvider templateProps={{ document }}>
848
+ <Render
849
+ config={puckConfig}
850
+ data={updatedData}
851
+ metadata={{ streamDocument: document }}
852
+ />
853
+ </VisualEditorProvider>
854
+ );
855
+
856
+ await page.viewport(width, height);
857
+
858
+ await expect(`Directory/[${viewportName}] ${name}`).toMatchScreenshot();
859
+ const results = await axe(container);
860
+ expect(results).toHaveNoViolations();
861
+
862
+ if (interactions) {
863
+ await interactions(page);
864
+ await expect(
865
+ `Directory/[${viewportName}] ${name} (after interactions)`
866
+ ).toMatchScreenshot();
867
+ const results = await axe(container);
868
+ expect(results).toHaveNoViolations();
869
+ }
870
+ }
871
+ );
872
+ });