@yext/visual-editor 1.4.11 → 2.0.0-beta.1
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.
- package/dist/SectionLibraryVisualEditorProvider-67ng4X9e.js +108670 -0
- package/dist/SectionLibraryVisualEditorProvider.css +1 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/Address.tsx +251 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HeadingText.tsx +147 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursStatus.tsx +157 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/HoursTable.tsx +164 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/MapboxStaticMap.tsx +205 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/Phone.tsx +155 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/EmptyImageState.tsx +168 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/Image.tsx +275 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/image/styling.ts +66 -0
- package/dist/cli/assets/directory-locator-source/components/contentBlocks/index.ts +13 -0
- package/dist/cli/assets/directory-locator-source/components/sections/Breadcrumbs.tsx +298 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.test.tsx +872 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/Directory.tsx +260 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryCard.tsx +507 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/DirectoryWrapper.tsx +491 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.test.tsx +226 -0
- package/dist/cli/assets/directory-locator-source/components/sections/directory/directoryChildReference.tsx +98 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.test.tsx +147 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Filters.tsx +691 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.test.tsx +1551 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Locator.tsx +541 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorFields.test.ts +43 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorResultCard.tsx +1594 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/LocatorWrapper.tsx +1157 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Map.tsx +304 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/MapPinIcon.tsx +160 -0
- package/dist/cli/assets/directory-locator-source/components/sections/locator/Results.tsx +267 -0
- package/dist/cli/assets/directory-locator-source/sectionLibrarySupport.ts +245 -0
- package/dist/cli/yextve.js +16888 -0
- package/dist/index.d.ts +542 -6311
- package/dist/locales/page/cs/visual-editor.json +85 -0
- package/dist/locales/page/da/visual-editor.json +73 -0
- package/dist/locales/page/de/visual-editor.json +73 -0
- package/dist/locales/page/en/visual-editor.json +73 -0
- package/dist/locales/page/en-GB/visual-editor.json +73 -0
- package/dist/locales/page/es/visual-editor.json +79 -0
- package/dist/locales/page/et/visual-editor.json +73 -0
- package/dist/locales/page/fi/visual-editor.json +73 -0
- package/dist/locales/page/fr/visual-editor.json +79 -0
- package/dist/locales/page/hr/visual-editor.json +79 -0
- package/dist/locales/page/hu/visual-editor.json +73 -0
- package/dist/locales/page/it/visual-editor.json +79 -0
- package/dist/locales/page/ja/visual-editor.json +73 -0
- package/dist/locales/page/lt/visual-editor.json +85 -0
- package/dist/locales/page/lv/visual-editor.json +77 -0
- package/dist/locales/page/nb/visual-editor.json +73 -0
- package/dist/locales/page/nl/visual-editor.json +73 -0
- package/dist/locales/page/pl/visual-editor.json +85 -0
- package/dist/locales/page/pt/visual-editor.json +79 -0
- package/dist/locales/page/ro/visual-editor.json +79 -0
- package/dist/locales/page/sk/visual-editor.json +85 -0
- package/dist/locales/page/sv/visual-editor.json +73 -0
- package/dist/locales/page/tr/visual-editor.json +73 -0
- package/dist/locales/page/zh/visual-editor.json +73 -0
- package/dist/locales/page/zh-TW/visual-editor.json +73 -0
- package/dist/locales/platform/cs/visual-editor.json +531 -0
- package/dist/locales/platform/da/visual-editor.json +519 -0
- package/dist/locales/platform/de/visual-editor.json +519 -0
- package/dist/locales/platform/en/visual-editor.json +519 -0
- package/dist/locales/platform/en-GB/visual-editor.json +519 -0
- package/dist/locales/platform/es/visual-editor.json +525 -0
- package/dist/locales/platform/et/visual-editor.json +519 -0
- package/dist/locales/platform/fi/visual-editor.json +519 -0
- package/dist/locales/platform/fr/visual-editor.json +525 -0
- package/dist/locales/platform/hr/visual-editor.json +525 -0
- package/dist/locales/platform/hu/visual-editor.json +519 -0
- package/dist/locales/platform/it/visual-editor.json +525 -0
- package/dist/locales/platform/ja/visual-editor.json +519 -0
- package/dist/locales/platform/lt/visual-editor.json +531 -0
- package/dist/locales/platform/lv/visual-editor.json +523 -0
- package/dist/locales/platform/nb/visual-editor.json +519 -0
- package/dist/locales/platform/nl/visual-editor.json +519 -0
- package/dist/locales/platform/pl/visual-editor.json +531 -0
- package/dist/locales/platform/pt/visual-editor.json +525 -0
- package/dist/locales/platform/ro/visual-editor.json +525 -0
- package/dist/locales/platform/sk/visual-editor.json +531 -0
- package/dist/locales/platform/sv/visual-editor.json +519 -0
- package/dist/locales/platform/tr/visual-editor.json +519 -0
- package/dist/locales/platform/zh/visual-editor.json +519 -0
- package/dist/locales/platform/zh-TW/visual-editor.json +519 -0
- package/dist/locatorEntityTypes-s4dmT9l5.d.ts +1850 -0
- package/dist/plugin/internal/sectionLibraryValidation/builtInTranslationResources.d.ts +3 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/api/api.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/api/libraryMetadata.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/importRules.d.ts +13 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/validateCode.d.ts +10 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/code/xssRules.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/stages/structure/structure.d.ts +7 -0
- package/dist/plugin/internal/sectionLibraryValidation/types.d.ts +48 -0
- package/dist/plugin/internal/sectionLibraryValidation/validateSectionLibrary.d.ts +8 -0
- package/dist/plugin/internal/sectionLibraryValidation/validationError.d.ts +6 -0
- package/dist/plugin/plugin.js +2233 -5786
- package/dist/plugin/types/entityFields.d.ts +21 -0
- package/dist/plugin/types/images.d.ts +62 -0
- package/dist/plugin/types/sectionLibrary.d.ts +94 -0
- package/dist/plugin/types/types.d.ts +204 -0
- package/dist/plugin/types/videos.d.ts +24 -0
- package/dist/plugin/utils/i18n/locales.d.ts +5 -0
- package/dist/plugin/utils/i18n/translationResources.d.ts +41 -0
- package/dist/plugin/utils/normalizeLocale.d.ts +8 -0
- package/dist/plugin/utils/plainText.d.ts +6 -0
- package/dist/plugin/vite-plugin/index.d.ts +2 -0
- package/dist/plugin/vite-plugin/local-editor/artifacts.d.ts +18 -0
- package/dist/plugin/vite-plugin/local-editor/config.d.ts +11 -0
- package/dist/plugin/vite-plugin/local-editor/data.d.ts +10 -0
- package/dist/plugin/vite-plugin/local-editor/entityFields.d.ts +13 -0
- package/dist/plugin/vite-plugin/local-editor/fixtureData.d.ts +12 -0
- package/dist/plugin/vite-plugin/local-editor/generatedFiles.d.ts +34 -0
- package/dist/plugin/vite-plugin/local-editor/server.d.ts +18 -0
- package/dist/plugin/vite-plugin/local-editor/types.d.ts +109 -0
- package/dist/plugin/vite-plugin/local-editor/utils.d.ts +16 -0
- package/dist/plugin/vite-plugin/plugin.d.ts +8 -0
- package/dist/plugin/vite-plugin/section-library/migrationRegistry.d.ts +6 -0
- package/dist/plugin/vite-plugin/section-library/sectionFrontmatter.d.ts +3 -0
- package/dist/plugin/vite-plugin/section-library/sectionLibraryGenerator.d.ts +21 -0
- package/dist/plugin/vite-plugin/section-library/sharedComponentRegistry.d.ts +16 -0
- package/dist/section-library-support.js +158 -0
- package/dist/sectionLibrarySupport.d.ts +282 -0
- package/dist/style.css +1 -1
- package/dist/visual-editor-9bLkRo2X.js +702 -0
- package/dist/visual-editor-B5f3AZF6.js +706 -0
- package/dist/visual-editor-BGZbJkMp.js +694 -0
- package/dist/visual-editor-BPVqHHz5.js +706 -0
- package/dist/visual-editor-BPvDMSb8.js +706 -0
- package/dist/visual-editor-BTT9n9b6.js +718 -0
- package/dist/visual-editor-BXSlgf31.js +694 -0
- package/dist/visual-editor-BXYlpe7B.js +145 -0
- package/dist/visual-editor-Bez9GftS.js +694 -0
- package/dist/visual-editor-Bk5QJccl.js +718 -0
- package/dist/visual-editor-BqtG2m0y.js +694 -0
- package/dist/visual-editor-Bxy81Ezy.js +145 -0
- package/dist/visual-editor-C00efXqJ.js +706 -0
- package/dist/visual-editor-C0vq2BRM.js +145 -0
- package/dist/visual-editor-CCgmYV5S.js +169 -0
- package/dist/visual-editor-CERViyTJ.js +145 -0
- package/dist/visual-editor-CZdmgAn0.js +706 -0
- package/dist/visual-editor-CcOCcCUQ.js +694 -0
- package/dist/visual-editor-CjORnP1D.js +169 -0
- package/dist/visual-editor-CmomGJB8.js +157 -0
- package/dist/visual-editor-Cymg8ID2.js +169 -0
- package/dist/visual-editor-D2Hk1nhM.js +145 -0
- package/dist/visual-editor-D2_8u6ZI.js +694 -0
- package/dist/visual-editor-D4vaqoBN.js +694 -0
- package/dist/visual-editor-D6n8EP_O.js +694 -0
- package/dist/visual-editor-D8MRFn5x.js +157 -0
- package/dist/visual-editor-DKG_E7X4.js +694 -0
- package/dist/visual-editor-DOXtCqRv.js +145 -0
- package/dist/visual-editor-DQEd3xwY.js +145 -0
- package/dist/visual-editor-DQq0_rUn.js +706 -0
- package/dist/visual-editor-DRXezaoB.js +694 -0
- package/dist/visual-editor-DUngIOnE.js +157 -0
- package/dist/visual-editor-DbgFzBNV.js +718 -0
- package/dist/visual-editor-DeZVZYfd.js +169 -0
- package/dist/visual-editor-DfJMZpiP.js +145 -0
- package/dist/visual-editor-DgAsQK9D.js +145 -0
- package/dist/visual-editor-Dhi__-7_.js +145 -0
- package/dist/visual-editor-DiLdoISr.js +718 -0
- package/dist/visual-editor-DjdqpJU-.js +145 -0
- package/dist/visual-editor-DnTPMRV4.js +694 -0
- package/dist/visual-editor-DvuH3jyL.js +157 -0
- package/dist/visual-editor-E0hASBXn.js +694 -0
- package/dist/visual-editor-TfVDfO5_.js +145 -0
- package/dist/visual-editor-W1OHU94y.js +694 -0
- package/dist/visual-editor-W_ZDmMFn.js +145 -0
- package/dist/visual-editor-b7ALusk8.js +145 -0
- package/dist/visual-editor-bauJ9beX.js +694 -0
- package/dist/visual-editor-erGXf3kS.js +157 -0
- package/dist/visual-editor-xnDHZFuO.js +153 -0
- package/dist/visual-editor-yiWZqIH0.js +157 -0
- package/dist/visual-editor.css +1 -0
- package/dist/visual-editor.js +15074 -137463
- package/package.json +46 -25
- package/dist/editor.css +0 -1
- package/dist/visual-editor-1QC8zZX_.js +0 -221
- package/dist/visual-editor-5C5XV5rL.js +0 -221
- package/dist/visual-editor-B8-FoFxc.js +0 -1049
- package/dist/visual-editor-BJgCpnYV.js +0 -1073
- package/dist/visual-editor-BKLiin5z.js +0 -1049
- package/dist/visual-editor-BWbqw_QE.js +0 -233
- package/dist/visual-editor-Bb6upvTE.js +0 -221
- package/dist/visual-editor-BcZCBLFh.js +0 -1049
- package/dist/visual-editor-BecDYKH8.js +0 -1049
- package/dist/visual-editor-BllAUu_T.js +0 -1073
- package/dist/visual-editor-BmaYFuCe.js +0 -233
- package/dist/visual-editor-BnPFkJlo.js +0 -221
- package/dist/visual-editor-BoIXa-xl.js +0 -245
- package/dist/visual-editor-BtDJICJp.js +0 -1073
- package/dist/visual-editor-BwxWyr_L.js +0 -221
- package/dist/visual-editor-Bz7BlR_j.js +0 -221
- package/dist/visual-editor-CC0RAmib.js +0 -1049
- package/dist/visual-editor-CDY9slY9.js +0 -1061
- package/dist/visual-editor-CFebs6R8.js +0 -1049
- package/dist/visual-editor-CNL0HyVh.js +0 -1049
- package/dist/visual-editor-CYnzwNwX.js +0 -229
- package/dist/visual-editor-CZH605TK.js +0 -233
- package/dist/visual-editor-Cada46ZF.js +0 -1049
- package/dist/visual-editor-CheComxC.js +0 -1061
- package/dist/visual-editor-CuA8h_Xv.js +0 -221
- package/dist/visual-editor-CuRmgs-p.js +0 -245
- package/dist/visual-editor-D9_YWQQY.js +0 -1073
- package/dist/visual-editor-D9w4wRG8.js +0 -245
- package/dist/visual-editor-D9xTiOC0.js +0 -221
- package/dist/visual-editor-DA7CixSl.js +0 -1061
- package/dist/visual-editor-DAnBQ9H_.js +0 -221
- package/dist/visual-editor-DF8RsMvq.js +0 -233
- package/dist/visual-editor-DLrKYx7j.js +0 -1061
- package/dist/visual-editor-DQJc_Xok.js +0 -233
- package/dist/visual-editor-DTZFGKm7.js +0 -221
- package/dist/visual-editor-DXebihTA.js +0 -233
- package/dist/visual-editor-DZ4U1fk-.js +0 -221
- package/dist/visual-editor-Dg7P-vDv.js +0 -1057
- package/dist/visual-editor-Dh2cuwWt.js +0 -1049
- package/dist/visual-editor-DpetyO9o.js +0 -1049
- package/dist/visual-editor-Duav2tXb.js +0 -1061
- package/dist/visual-editor-DvYsu_s9.js +0 -221
- package/dist/visual-editor-DwlX3nnZ.js +0 -221
- package/dist/visual-editor-Dz5s66Og.js +0 -221
- package/dist/visual-editor-E57fPJMD.js +0 -1049
- package/dist/visual-editor-Fy_uEJju.js +0 -1061
- package/dist/visual-editor-G8e2TllW.js +0 -1049
- package/dist/visual-editor-HkfpXRw7.js +0 -1049
- package/dist/visual-editor-ZKG4e_Ey.js +0 -1049
- package/dist/visual-editor-rZRnDwgU.js +0 -245
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
isDirectoryGrid,
|
|
4
|
+
sortAlphabetically,
|
|
5
|
+
} from "../../../utils/directory/utils.ts";
|
|
6
|
+
|
|
7
|
+
export type DirectoryChildReference = {
|
|
8
|
+
childIndex: number;
|
|
9
|
+
childId?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type DirectoryChild = {
|
|
13
|
+
id?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const DirectoryChildrenContext = React.createContext<DirectoryChild[]>([]);
|
|
19
|
+
|
|
20
|
+
export const DirectoryChildrenProvider = ({
|
|
21
|
+
children,
|
|
22
|
+
directoryChildren,
|
|
23
|
+
}: {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
directoryChildren: DirectoryChild[];
|
|
26
|
+
}) => (
|
|
27
|
+
<DirectoryChildrenContext.Provider value={directoryChildren}>
|
|
28
|
+
{children}
|
|
29
|
+
</DirectoryChildrenContext.Provider>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const useDirectoryChildren = (): DirectoryChild[] =>
|
|
33
|
+
React.useContext(DirectoryChildrenContext);
|
|
34
|
+
|
|
35
|
+
export const getSortedDirectoryChildren = (
|
|
36
|
+
directoryChildren: unknown
|
|
37
|
+
): DirectoryChild[] => {
|
|
38
|
+
if (
|
|
39
|
+
!Array.isArray(directoryChildren) ||
|
|
40
|
+
!isDirectoryGrid(directoryChildren)
|
|
41
|
+
) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return sortAlphabetically([...directoryChildren], "name");
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const createDirectoryChildReference = (
|
|
49
|
+
child: DirectoryChild | undefined,
|
|
50
|
+
childIndex: number
|
|
51
|
+
): DirectoryChildReference => ({
|
|
52
|
+
childIndex,
|
|
53
|
+
...(typeof child?.id === "string" ? { childId: child.id } : {}),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const matchesDirectoryChildReference = (
|
|
57
|
+
childReference: DirectoryChildReference | undefined,
|
|
58
|
+
child: DirectoryChild | undefined,
|
|
59
|
+
childIndex: number
|
|
60
|
+
): boolean => {
|
|
61
|
+
if (!childReference || childReference.childIndex !== childIndex) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (childReference.childId && childReference.childId !== child?.id) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return true;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const resolveDirectoryChildFromReference = (
|
|
73
|
+
directoryChildren: DirectoryChild[],
|
|
74
|
+
childReference: DirectoryChildReference | undefined
|
|
75
|
+
): DirectoryChild | undefined => {
|
|
76
|
+
if (!childReference) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const childAtIndex = directoryChildren[childReference.childIndex];
|
|
81
|
+
if (
|
|
82
|
+
matchesDirectoryChildReference(
|
|
83
|
+
childReference,
|
|
84
|
+
childAtIndex,
|
|
85
|
+
childReference.childIndex
|
|
86
|
+
)
|
|
87
|
+
) {
|
|
88
|
+
return childAtIndex;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (childReference.childId) {
|
|
92
|
+
return directoryChildren.find(
|
|
93
|
+
(child) => child?.id === childReference.childId
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return childAtIndex;
|
|
98
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { FilterModal } from "./Filters.tsx";
|
|
5
|
+
|
|
6
|
+
vi.mock("react-i18next", async () => {
|
|
7
|
+
const actual = await vi.importActual("react-i18next");
|
|
8
|
+
return {
|
|
9
|
+
...actual,
|
|
10
|
+
useTranslation: () => ({
|
|
11
|
+
t: (_key: string, defaultValue: string) => defaultValue,
|
|
12
|
+
i18n: { language: "fr" },
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
vi.mock("@yext/search-headless-react", async () => {
|
|
18
|
+
const actual = await vi.importActual<
|
|
19
|
+
typeof import("@yext/search-headless-react")
|
|
20
|
+
>("@yext/search-headless-react");
|
|
21
|
+
return {
|
|
22
|
+
...actual,
|
|
23
|
+
useSearchState: (selector: (state: any) => unknown) =>
|
|
24
|
+
selector({
|
|
25
|
+
filters: {
|
|
26
|
+
facets: [
|
|
27
|
+
{
|
|
28
|
+
fieldId: "keywords",
|
|
29
|
+
options: [{ matcher: actual.Matcher.Equals, value: "retail" }],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
fieldId: "services",
|
|
33
|
+
options: [{ matcher: actual.Matcher.Equals, value: "delivery" }],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
fieldId: "languages",
|
|
37
|
+
options: [{ matcher: actual.Matcher.Equals, value: "French" }],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
fieldId: "yearsOfExperience",
|
|
41
|
+
options: [
|
|
42
|
+
{
|
|
43
|
+
matcher: actual.Matcher.Between,
|
|
44
|
+
value: {
|
|
45
|
+
start: {
|
|
46
|
+
matcher: actual.Matcher.GreaterThanOrEqualTo,
|
|
47
|
+
value: 5,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
vi.mock("@yext/search-ui-react", async () => {
|
|
60
|
+
const actual = await vi.importActual<typeof import("@yext/search-ui-react")>(
|
|
61
|
+
"@yext/search-ui-react"
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
...actual,
|
|
66
|
+
AppliedFilters: () => null,
|
|
67
|
+
Facets: ({ children }: React.PropsWithChildren) => <div>{children}</div>,
|
|
68
|
+
StandardFacet: ({
|
|
69
|
+
fieldId,
|
|
70
|
+
label,
|
|
71
|
+
}: {
|
|
72
|
+
fieldId: string;
|
|
73
|
+
label?: string;
|
|
74
|
+
}) => (
|
|
75
|
+
<div
|
|
76
|
+
data-testid={`facet-${fieldId}`}
|
|
77
|
+
data-label={label}
|
|
78
|
+
data-type="standard"
|
|
79
|
+
/>
|
|
80
|
+
),
|
|
81
|
+
NumericalFacet: ({
|
|
82
|
+
fieldId,
|
|
83
|
+
label,
|
|
84
|
+
}: {
|
|
85
|
+
fieldId: string;
|
|
86
|
+
label?: string;
|
|
87
|
+
}) => (
|
|
88
|
+
<div
|
|
89
|
+
data-testid={`facet-${fieldId}`}
|
|
90
|
+
data-label={label}
|
|
91
|
+
data-type="numerical"
|
|
92
|
+
/>
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const renderFilterModal = (
|
|
98
|
+
keywordsDisplayName?: React.ComponentProps<
|
|
99
|
+
typeof FilterModal
|
|
100
|
+
>["keywordsDisplayName"]
|
|
101
|
+
) =>
|
|
102
|
+
render(
|
|
103
|
+
<FilterModal
|
|
104
|
+
showFilterModal={true}
|
|
105
|
+
showOpenNowOption={false}
|
|
106
|
+
isOpenNowSelected={false}
|
|
107
|
+
showDistanceOptions={false}
|
|
108
|
+
selectedDistanceOption={null}
|
|
109
|
+
handleCloseModalClick={vi.fn()}
|
|
110
|
+
handleOpenNowClick={vi.fn()}
|
|
111
|
+
handleDistanceClick={vi.fn()}
|
|
112
|
+
handleClearFiltersClick={vi.fn()}
|
|
113
|
+
accentColorCssValue="#000"
|
|
114
|
+
closeButtonRef={React.createRef<HTMLButtonElement>()}
|
|
115
|
+
keywordsDisplayName={keywordsDisplayName}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
describe("FilterModal", () => {
|
|
120
|
+
it("uses the current-locale display name only for the Keywords facet", () => {
|
|
121
|
+
renderFilterModal({
|
|
122
|
+
en: "Store Type",
|
|
123
|
+
fr: "Type de magasin",
|
|
124
|
+
hasLocalizedValue: "true",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
expect(screen.getByTestId("facet-keywords").dataset.label).toBe(
|
|
128
|
+
"Type de magasin"
|
|
129
|
+
);
|
|
130
|
+
expect(screen.getByTestId("facet-services").dataset.label).toBeUndefined();
|
|
131
|
+
expect(screen.getByTestId("facet-languages").dataset.label).toBeUndefined();
|
|
132
|
+
expect(screen.getByTestId("facet-yearsOfExperience").dataset).toMatchObject(
|
|
133
|
+
{
|
|
134
|
+
type: "numerical",
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("leaves the Keywords label undefined when the current locale is missing", () => {
|
|
140
|
+
renderFilterModal({
|
|
141
|
+
en: "Store Type",
|
|
142
|
+
hasLocalizedValue: "true",
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
expect(screen.getByTestId("facet-keywords").dataset.label).toBeUndefined();
|
|
146
|
+
});
|
|
147
|
+
});
|