@salesforcedevs/dx-components 0.16.2 → 0.18.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/lwc.config.json +1 -0
- package/package.json +3 -3
- package/src/assets/svg/sidebar-loading.svg +34 -0
- package/src/modules/dx/dropdown/dropdown.html +2 -0
- package/src/modules/dx/dropdown/dropdown.ts +4 -2
- package/src/modules/dx/dropdownOption/__tests__/dropdownOption.test.ts +32 -2
- package/src/modules/dx/dropdownOption/dropdownOption.ts +9 -6
- package/src/modules/dx/footer/footer.ts +13 -1
- package/src/modules/dx/header/__tests__/header.test.ts +15 -21
- package/src/modules/dx/header/__tests__/mockProps.ts +7 -1
- package/src/modules/dx/headerNav/headerNav.html +1 -0
- package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +24 -39
- package/src/modules/dx/headerSearch/__tests__/mockProps.ts +2 -7
- package/src/modules/dx/headerSearch/headerSearch.ts +13 -19
- package/src/modules/dx/lazy/lazy.ts +0 -7
- package/src/modules/dx/newsletterForm/newsletterForm.ts +20 -11
- package/src/modules/dx/sidebar/__tests__/mockSearchChangeEmptyEvent.ts +6 -0
- package/src/modules/dx/sidebar/__tests__/mockSearchChangeEvent.ts +527 -0
- package/src/modules/dx/sidebar/__tests__/sidebar.test.ts +210 -247
- package/src/modules/dx/sidebar/sidebar.css +68 -34
- package/src/modules/dx/sidebar/sidebar.html +58 -34
- package/src/modules/dx/sidebar/sidebar.stories.ts +50 -4
- package/src/modules/dx/sidebar/sidebar.ts +141 -73
- package/src/modules/dx/sidebarOld/__tests__/mockProps.ts +178 -0
- package/src/modules/dx/sidebarOld/__tests__/sidebarOld.test.ts +574 -0
- package/src/modules/dx/sidebarOld/sidebarOld.css +160 -0
- package/src/modules/dx/sidebarOld/sidebarOld.html +70 -0
- package/src/modules/dx/sidebarOld/sidebarOld.stories.ts +139 -0
- package/src/modules/dx/sidebarOld/sidebarOld.ts +187 -0
- package/src/modules/dx/sidebarSearch/__tests__/mockPreloadedState.ts +8843 -0
- package/src/modules/dx/sidebarSearch/__tests__/sidebarSearch.test.ts +113 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.css +3 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.html +26 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +421 -0
- package/src/modules/dx/sidebarSearchResult/__tests__/sidebarSearchResult.test.ts +55 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.css +36 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.html +14 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.ts +56 -0
- package/src/modules/dx/treeTile/__tests__/treeTile.test.ts +27 -38
- package/src/modules/dx/treeTile/treeTile.css +3 -19
- package/src/modules/dx/treeTile/treeTile.html +4 -1
- package/src/modules/dx/treeTile/treeTile.ts +2 -2
- package/src/modules/helpers/sidebar/sidebar.css +21 -0
- package/src/modules/utils/coveo/coveo.ts +69 -0
- package/src/modules/utils/headerBase/headerBase.ts +10 -2
- package/src/modules/utils/highlight/__tests__/highlight.test.ts +108 -0
- package/src/modules/utils/highlight/__tests__/mockProps.ts +45 -0
- package/src/modules/utils/highlight/highlight.ts +2 -1
- package/src/modules/utils/jest/jest.ts +35 -0
- package/src/modules/utils/recentSearches/__tests__/recentSearches.test.ts +79 -0
- package/src/modules/utils/recentSearches/recentSearches.ts +57 -0
- package/src/modules/utils/tests/tests.ts +18 -11
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@coveo/headless": "
|
|
17
|
+
"@coveo/headless": "^1.32.0",
|
|
18
18
|
"@popperjs/core": "2.9.1",
|
|
19
19
|
"@sfdocs-internal/wires": "^0.6.3",
|
|
20
20
|
"classnames": "^2.2.6",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"@types/debounce": "^1.2.0",
|
|
30
30
|
"@types/lodash.get": "^4.4.6"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "582d4e57d2fa40c37540bbbe3f41c01159897832"
|
|
33
33
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
<svg width="100%" height="374px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<g id="Scoped-Search" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
4
|
+
<g id="Docs-–-Search-Results-Loading" transform="translate(-52.000000, -240.000000)" fill="#DAD8D7">
|
|
5
|
+
<g id="Group-12" transform="translate(52.000000, 240.000000)">
|
|
6
|
+
<g id="Group-5">
|
|
7
|
+
<rect id="Rectangle" x="0" y="0" width="90%" height="10" rx="5"></rect>
|
|
8
|
+
<rect id="Rectangle" x="0" y="26" width="80%" height="10" rx="5"></rect>
|
|
9
|
+
<rect id="Rectangle" x="0" y="52" width="70%" height="10" rx="5"></rect>
|
|
10
|
+
</g>
|
|
11
|
+
<g id="Group-5" opacity="0.8" transform="translate(0.000000, 78.000000)">
|
|
12
|
+
<rect id="Rectangle" x="0" y="0" width="90%" height="10" rx="5"></rect>
|
|
13
|
+
<rect id="Rectangle" x="0" y="26" width="80%" height="10" rx="5"></rect>
|
|
14
|
+
<rect id="Rectangle" x="0" y="52" width="70%" height="10" rx="5"></rect>
|
|
15
|
+
</g>
|
|
16
|
+
<g id="Group-5" opacity="0.6" transform="translate(0.000000, 156.000000)">
|
|
17
|
+
<rect id="Rectangle" x="0" y="0" width="90%" height="10" rx="5"></rect>
|
|
18
|
+
<rect id="Rectangle" x="0" y="26" width="80%" height="10" rx="5"></rect>
|
|
19
|
+
<rect id="Rectangle" x="0" y="52" width="70%" height="10" rx="5"></rect>
|
|
20
|
+
</g>
|
|
21
|
+
<g id="Group-5" opacity="0.4" transform="translate(0.000000, 234.000000)">
|
|
22
|
+
<rect id="Rectangle" x="0" y="0" width="90%" height="10" rx="5"></rect>
|
|
23
|
+
<rect id="Rectangle" x="0" y="26" width="80%" height="10" rx="5"></rect>
|
|
24
|
+
<rect id="Rectangle" x="0" y="52" width="70%" height="10" rx="5"></rect>
|
|
25
|
+
</g>
|
|
26
|
+
<g id="Group-5" opacity="0.197206577" transform="translate(0.000000, 312.000000)">
|
|
27
|
+
<rect id="Rectangle" x="0" y="0" width="90%" height="10" rx="5"></rect>
|
|
28
|
+
<rect id="Rectangle" x="0" y="26" width="80%" height="10" rx="5"></rect>
|
|
29
|
+
<rect id="Rectangle" x="0" y="52" width="70%" height="10" rx="5"></rect>
|
|
30
|
+
</g>
|
|
31
|
+
</g>
|
|
32
|
+
</g>
|
|
33
|
+
</g>
|
|
34
|
+
</svg>
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
>
|
|
22
22
|
<template for:each={options} for:item="option">
|
|
23
23
|
<dx-dropdown-option
|
|
24
|
+
analytics-event={analyticsEvent}
|
|
24
25
|
active={option.active}
|
|
25
26
|
key-value={option.keyValue}
|
|
26
27
|
if:false={option.options}
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
<span class="menu_heading">{option.label}</span>
|
|
40
41
|
<template for:each={option.options} for:item="suboption">
|
|
41
42
|
<dx-dropdown-option
|
|
43
|
+
analytics-event={analyticsEvent}
|
|
42
44
|
active={suboption.active}
|
|
43
45
|
key={suboption.id}
|
|
44
46
|
key-value={suboption.keyValue}
|
|
@@ -29,8 +29,10 @@ export default class Dropdown extends LightningElement {
|
|
|
29
29
|
@api small?: boolean = false;
|
|
30
30
|
@api openOnHover?: boolean = false; // dropdown opens/closes with hover
|
|
31
31
|
@api width?: string | null = null;
|
|
32
|
-
@api fullWidth?: boolean | null;
|
|
33
|
-
|
|
32
|
+
@api fullWidth?: boolean | null; @api navItemLabel: string | null = null;
|
|
33
|
+
|
|
34
|
+
// props forwarded to dropdown option
|
|
35
|
+
@api analyticsEvent: string | null = null
|
|
34
36
|
|
|
35
37
|
@api
|
|
36
38
|
get options() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import DropdownOption from "dx/dropdownOption";
|
|
2
2
|
import { createRenderComponent } from "utils/tests";
|
|
3
3
|
import { MOCK_BUTTON_PROPS, MOCK_LINK_PROPS } from "./mockProps";
|
|
4
|
+
import * as instrumentation from "dx/instrumentation";
|
|
4
5
|
|
|
5
6
|
const TAG = "dx-dropdown-option";
|
|
6
7
|
const render = createRenderComponent(TAG, DropdownOption);
|
|
@@ -13,6 +14,10 @@ const appendToMenu = (element: HTMLElement) => {
|
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
describe(TAG, () => {
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
jest.clearAllMocks();
|
|
19
|
+
});
|
|
20
|
+
|
|
16
21
|
it("renders a button by default", () => {
|
|
17
22
|
const component = render(MOCK_BUTTON_PROPS);
|
|
18
23
|
expect(component.shadowRoot.querySelector("button")).not.toBeNull();
|
|
@@ -23,8 +28,8 @@ describe(TAG, () => {
|
|
|
23
28
|
|
|
24
29
|
it("renders the correct label, description, and img", () => {
|
|
25
30
|
const component = render(MOCK_BUTTON_PROPS);
|
|
26
|
-
const label =
|
|
27
|
-
.textContent;
|
|
31
|
+
const label =
|
|
32
|
+
component.shadowRoot.querySelector(".option_label").textContent;
|
|
28
33
|
expect(label).toEqual(MOCK_BUTTON_PROPS.option.label);
|
|
29
34
|
|
|
30
35
|
const description = component.shadowRoot.querySelector(
|
|
@@ -79,4 +84,29 @@ describe(TAG, () => {
|
|
|
79
84
|
|
|
80
85
|
expect(onClickMock).toBeCalled();
|
|
81
86
|
});
|
|
87
|
+
|
|
88
|
+
it("fires analytics when given an analytics event", () => {
|
|
89
|
+
const track = jest.spyOn(instrumentation, "track");
|
|
90
|
+
|
|
91
|
+
const component = render({
|
|
92
|
+
...MOCK_BUTTON_PROPS,
|
|
93
|
+
analyticsEvent: "mock"
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const option = component.shadowRoot.querySelector(".option");
|
|
97
|
+
option.click();
|
|
98
|
+
|
|
99
|
+
expect(track).toHaveBeenCalledTimes(1);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("doesn't fire analytics when not given an analytics event", () => {
|
|
103
|
+
const track = jest.spyOn(instrumentation, "track");
|
|
104
|
+
|
|
105
|
+
const component = render(MOCK_BUTTON_PROPS);
|
|
106
|
+
|
|
107
|
+
const option = component.shadowRoot.querySelector(".option");
|
|
108
|
+
option.click();
|
|
109
|
+
|
|
110
|
+
expect(track).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
82
112
|
});
|
|
@@ -8,6 +8,7 @@ export default class DropdownOption extends LightningElement {
|
|
|
8
8
|
@api keyValue!: string;
|
|
9
9
|
@api active: boolean = false;
|
|
10
10
|
@api navItemLabel: String | null = null;
|
|
11
|
+
@api analyticsEvent: string | null = null;
|
|
11
12
|
|
|
12
13
|
@api focus() {
|
|
13
14
|
const option = this.template.querySelector(".option");
|
|
@@ -26,11 +27,13 @@ export default class DropdownOption extends LightningElement {
|
|
|
26
27
|
new CustomEvent("select", { detail: this.keyValue })
|
|
27
28
|
);
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
if (this.analyticsEvent && e.currentTarget) {
|
|
31
|
+
track(e.currentTarget, this.analyticsEvent, {
|
|
32
|
+
navHeading: this.navItemLabel || undefined,
|
|
33
|
+
navSubHeading: this.option.label || undefined,
|
|
34
|
+
clickText: this.keyValue || undefined,
|
|
35
|
+
pageLocation: window.location.pathname || undefined
|
|
36
|
+
});
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -14,6 +14,12 @@ import { track } from "dx/instrumentation";
|
|
|
14
14
|
const createNewsletterSignupHref = (email: string): string =>
|
|
15
15
|
`/newsletter?subscriberEmail=${email}`;
|
|
16
16
|
|
|
17
|
+
const ANALYTICS_INFO = {
|
|
18
|
+
itemTitle: "Newsletter Sign Up Footer",
|
|
19
|
+
elementType: "button",
|
|
20
|
+
destinationType: "internal",
|
|
21
|
+
ctaClick: true
|
|
22
|
+
};
|
|
17
23
|
export default class Footer extends LightningElement {
|
|
18
24
|
@api locale: string | null = null;
|
|
19
25
|
@api
|
|
@@ -85,7 +91,13 @@ export default class Footer extends LightningElement {
|
|
|
85
91
|
|
|
86
92
|
private onSubmitEmail = async (e: CustomEvent) => {
|
|
87
93
|
const href = createNewsletterSignupHref(e.detail);
|
|
88
|
-
|
|
94
|
+
|
|
95
|
+
track(e.currentTarget, "custEv_ctaButtonClick", {
|
|
96
|
+
...ANALYTICS_INFO,
|
|
97
|
+
clickText: e.detail,
|
|
98
|
+
clickUrl: href,
|
|
99
|
+
});
|
|
100
|
+
|
|
89
101
|
window.location.assign(href);
|
|
90
102
|
};
|
|
91
103
|
|
|
@@ -9,23 +9,20 @@ import {
|
|
|
9
9
|
mockPropsNoNavigation
|
|
10
10
|
} from "./mockProps";
|
|
11
11
|
import { track } from "dx/instrumentation";
|
|
12
|
+
import { ANALYTICS_INFO } from "utils/headerBase";
|
|
12
13
|
|
|
13
14
|
const TAG = "dx-header";
|
|
14
15
|
const render = createRenderComponent(TAG, Header);
|
|
15
16
|
|
|
16
17
|
jest.mock("dx/instrumentation");
|
|
17
18
|
|
|
18
|
-
const GTM_EVENT_NAME = "custEv_signupStart";
|
|
19
|
-
const SIGN_UP_LABEL = "Sign Up";
|
|
20
|
-
|
|
21
19
|
describe("dx-header", () => {
|
|
22
20
|
it("renders", () => {
|
|
23
21
|
const subtitle = "testsubtitle";
|
|
24
22
|
const element = render({ ...mockPropsDevelopers, subtitle });
|
|
25
23
|
const subtitleEl = element.shadowRoot.querySelector(".subtitle");
|
|
26
|
-
const buttons: Array<HTMLElement> =
|
|
27
|
-
"dx-button"
|
|
28
|
-
);
|
|
24
|
+
const buttons: Array<HTMLElement> =
|
|
25
|
+
element.shadowRoot.querySelectorAll("dx-button");
|
|
29
26
|
const dropdown = element.shadowRoot.querySelector("dx-dropdown");
|
|
30
27
|
const headerEl = element.shadowRoot.querySelector("dx-header-nav");
|
|
31
28
|
|
|
@@ -88,9 +85,8 @@ describe("dx-header", () => {
|
|
|
88
85
|
...mockPropsDevelopers,
|
|
89
86
|
versions: JSON.stringify([version])
|
|
90
87
|
});
|
|
91
|
-
const dropdown: Dropdown =
|
|
92
|
-
"dx-dropdown"
|
|
93
|
-
);
|
|
88
|
+
const dropdown: Dropdown =
|
|
89
|
+
element.shadowRoot.querySelector("dx-dropdown");
|
|
94
90
|
expect(dropdown).not.toBeNull();
|
|
95
91
|
expect(dropdown.options).toHaveLength(1);
|
|
96
92
|
|
|
@@ -180,9 +176,8 @@ describe("dx-header", () => {
|
|
|
180
176
|
bailLabel: "test",
|
|
181
177
|
signupLink: "/"
|
|
182
178
|
});
|
|
183
|
-
const buttons: Array<Button> =
|
|
184
|
-
"dx-button"
|
|
185
|
-
);
|
|
179
|
+
const buttons: Array<Button> =
|
|
180
|
+
element.shadowRoot.querySelectorAll("dx-button");
|
|
186
181
|
|
|
187
182
|
expect(buttons[0].href).toEqual("/");
|
|
188
183
|
expect(buttons[2].href).toEqual("test");
|
|
@@ -194,26 +189,25 @@ describe("dx-header", () => {
|
|
|
194
189
|
subtitle: mockPropsDevelopers.subtitle,
|
|
195
190
|
navItems: mockPropsDevelopers.navItems
|
|
196
191
|
});
|
|
197
|
-
const headerSearch =
|
|
198
|
-
"dx-header-search"
|
|
199
|
-
);
|
|
192
|
+
const headerSearch =
|
|
193
|
+
element.shadowRoot.querySelector("dx-header-search");
|
|
200
194
|
|
|
201
195
|
expect(headerSearch).toBeNull();
|
|
202
196
|
return expect(element).toBeAccessible();
|
|
203
197
|
});
|
|
204
198
|
|
|
205
|
-
it("signup button track is
|
|
199
|
+
it("signup button track is being called", () => {
|
|
206
200
|
const element = render(mockPropsDevelopers);
|
|
207
201
|
|
|
208
|
-
const button: HTMLElement =
|
|
209
|
-
"dx-button"
|
|
210
|
-
);
|
|
202
|
+
const button: HTMLElement =
|
|
203
|
+
element.shadowRoot.querySelector("dx-button");
|
|
211
204
|
|
|
212
205
|
button.click();
|
|
213
206
|
|
|
214
207
|
expect(track).toBeCalledTimes(1);
|
|
215
|
-
expect(track).toBeCalledWith(button,
|
|
216
|
-
|
|
208
|
+
expect(track).toBeCalledWith(button, "custEv_signupStart", {
|
|
209
|
+
...ANALYTICS_INFO,
|
|
210
|
+
clickUrl: "/sign-up"
|
|
217
211
|
});
|
|
218
212
|
});
|
|
219
213
|
|
|
@@ -13,7 +13,13 @@ import {
|
|
|
13
13
|
mockNavAnalytics
|
|
14
14
|
} from "./mockNavs";
|
|
15
15
|
import mockNavDevelopers from "./mockNavDevelopers";
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
export const coveoConfig = {
|
|
18
|
+
coveoOrganizationId: "coveosalesforcetestakshatha",
|
|
19
|
+
coveoPublicAccessToken: "xx114e9d50-bc6b-40f1-b25b-fa5a06c7e168",
|
|
20
|
+
coveoSearchPipeline: "salesforcedevdoc",
|
|
21
|
+
coveoSearchHub: "salesforcedevdoc2"
|
|
22
|
+
};
|
|
17
23
|
|
|
18
24
|
const versions = JSON.stringify([
|
|
19
25
|
{
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HeadlessEngine,
|
|
3
|
-
buildStandaloneSearchBox,
|
|
4
|
-
searchAppReducers
|
|
5
|
-
} from "@coveo/headless";
|
|
1
|
+
import { buildSearchEngine, buildStandaloneSearchBox } from "@coveo/headless";
|
|
6
2
|
import Input from "dx/input";
|
|
7
3
|
import Button from "dx/button";
|
|
8
4
|
import Dropdown from "dx/dropdown";
|
|
9
5
|
import HeaderSearch from "dx/headerSearch";
|
|
10
6
|
import { PopoverRequestCloseType } from "typings/custom";
|
|
11
7
|
import { createRenderComponent } from "utils/tests";
|
|
8
|
+
import { coveoHeaderConfig } from "utils/coveo";
|
|
12
9
|
import { MOCK_SUGGESTIONS } from "./mockData";
|
|
13
|
-
import mockProps
|
|
10
|
+
import mockProps from "./mockProps";
|
|
14
11
|
|
|
15
12
|
const COVEO_CONFIG = {
|
|
16
13
|
configuration: {
|
|
17
|
-
organizationId:
|
|
18
|
-
accessToken:
|
|
14
|
+
organizationId: coveoHeaderConfig.coveoOrganizationId,
|
|
15
|
+
accessToken: coveoHeaderConfig.coveoPublicAccessToken,
|
|
19
16
|
search: {
|
|
20
|
-
pipeline:
|
|
21
|
-
searchHub:
|
|
17
|
+
pipeline: coveoHeaderConfig.coveoSearchPipeline,
|
|
18
|
+
searchHub: coveoHeaderConfig.coveoSearchHub
|
|
22
19
|
}
|
|
23
|
-
}
|
|
24
|
-
reducers: searchAppReducers
|
|
20
|
+
}
|
|
25
21
|
};
|
|
26
22
|
|
|
27
23
|
const REDIRECT_URL = "https://developer.salesforce.com";
|
|
@@ -37,9 +33,8 @@ const mockUpdateText = jest.fn();
|
|
|
37
33
|
|
|
38
34
|
jest.mock("@coveo/headless", () => {
|
|
39
35
|
return {
|
|
40
|
-
|
|
41
|
-
buildStandaloneSearchBox: jest.fn()
|
|
42
|
-
searchAppReducers: jest.fn()
|
|
36
|
+
buildSearchEngine: jest.fn(),
|
|
37
|
+
buildStandaloneSearchBox: jest.fn()
|
|
43
38
|
};
|
|
44
39
|
});
|
|
45
40
|
|
|
@@ -68,14 +63,11 @@ const expectMobileToDefaultRender = ({
|
|
|
68
63
|
};
|
|
69
64
|
|
|
70
65
|
const expectSearchToInit = () => {
|
|
71
|
-
expect(
|
|
72
|
-
expect(
|
|
66
|
+
expect(buildSearchEngine).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(buildSearchEngine).toHaveBeenCalledWith(COVEO_CONFIG);
|
|
73
68
|
expect(buildStandaloneSearchBox).toHaveBeenCalledTimes(1);
|
|
74
|
-
const [
|
|
75
|
-
|
|
76
|
-
options
|
|
77
|
-
] = (buildStandaloneSearchBox as jest.Mock).mock.calls[0];
|
|
78
|
-
expect(engine).toBeInstanceOf(HeadlessEngine);
|
|
69
|
+
const options = (buildStandaloneSearchBox as jest.Mock).mock.calls[0][1];
|
|
70
|
+
|
|
79
71
|
expect(options).toEqual({
|
|
80
72
|
options: {
|
|
81
73
|
numberOfSuggestions: 3,
|
|
@@ -85,8 +77,6 @@ const expectSearchToInit = () => {
|
|
|
85
77
|
expect(mockSubscribe).toHaveBeenCalledTimes(1);
|
|
86
78
|
expect(subscribeCallback).not.toBeNull();
|
|
87
79
|
expect(subscribeCallback).toBeInstanceOf(Function);
|
|
88
|
-
expect(mockUpdateText).toHaveBeenCalledTimes(1);
|
|
89
|
-
expect(mockUpdateText).toHaveBeenCalledWith("");
|
|
90
80
|
};
|
|
91
81
|
|
|
92
82
|
describe(TAG, () => {
|
|
@@ -113,9 +103,8 @@ describe(TAG, () => {
|
|
|
113
103
|
expect(container).not.toBeNull();
|
|
114
104
|
expect(container.classList).toContain("desktop_search-container");
|
|
115
105
|
|
|
116
|
-
const suggestionsDropdown: Dropdown =
|
|
117
|
-
"dx-dropdown"
|
|
118
|
-
);
|
|
106
|
+
const suggestionsDropdown: Dropdown =
|
|
107
|
+
element.shadowRoot.querySelector("dx-dropdown");
|
|
119
108
|
expect(suggestionsDropdown.options).toHaveLength(0);
|
|
120
109
|
expect(suggestionsDropdown.open).toBe(false);
|
|
121
110
|
|
|
@@ -132,21 +121,18 @@ describe(TAG, () => {
|
|
|
132
121
|
|
|
133
122
|
it("renders as mobile view", () => {
|
|
134
123
|
const element = render({ ...mockProps, mobile: true });
|
|
135
|
-
const container: HTMLElement =
|
|
136
|
-
"div"
|
|
137
|
-
);
|
|
124
|
+
const container: HTMLElement =
|
|
125
|
+
element.shadowRoot.querySelector("div");
|
|
138
126
|
expect(container).not.toBeNull();
|
|
139
127
|
expect(container.classList).toHaveLength(0);
|
|
140
128
|
|
|
141
|
-
const dropdowns: Dropdown[] =
|
|
142
|
-
"dx-dropdown"
|
|
143
|
-
);
|
|
129
|
+
const dropdowns: Dropdown[] =
|
|
130
|
+
element.shadowRoot.querySelectorAll("dx-dropdown");
|
|
144
131
|
expect(dropdowns).toHaveLength(1);
|
|
145
132
|
const [dropdown] = dropdowns;
|
|
146
133
|
const input: Input = element.shadowRoot.querySelector("dx-input");
|
|
147
|
-
const button: Button =
|
|
148
|
-
"dx-button"
|
|
149
|
-
);
|
|
134
|
+
const button: Button =
|
|
135
|
+
element.shadowRoot.querySelector("dx-button");
|
|
150
136
|
expectMobileToDefaultRender({
|
|
151
137
|
input,
|
|
152
138
|
dropdown,
|
|
@@ -165,9 +151,8 @@ describe(TAG, () => {
|
|
|
165
151
|
const element = render({ ...mockProps, mobile: true });
|
|
166
152
|
|
|
167
153
|
const input: Input = element.shadowRoot.querySelector("dx-input");
|
|
168
|
-
const dropdown: Dropdown =
|
|
169
|
-
"dx-dropdown"
|
|
170
|
-
);
|
|
154
|
+
const dropdown: Dropdown =
|
|
155
|
+
element.shadowRoot.querySelector("dx-dropdown");
|
|
171
156
|
const button = element.shadowRoot.querySelector("dx-button");
|
|
172
157
|
button.click();
|
|
173
158
|
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
coveoOrganizationId: "coveosalesforcetestakshatha",
|
|
3
|
-
coveoPublicAccessToken: "xx8d9c92ef-1018-4d92-a3c7-647dff01c21c",
|
|
4
|
-
coveoSearchPipeline: "salesforcedevdoc",
|
|
5
|
-
coveoSearchHub: "salesforcedevdoc"
|
|
6
|
-
};
|
|
1
|
+
import { coveoHeaderConfig } from "utils/coveo";
|
|
7
2
|
|
|
8
3
|
export default {
|
|
9
4
|
mobile: false,
|
|
10
|
-
...
|
|
5
|
+
...coveoHeaderConfig
|
|
11
6
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import { PopoverRequestCloseType, Option } from "typings/custom";
|
|
4
|
+
import { buildSearchEngine } from "utils/coveo";
|
|
4
5
|
import {
|
|
5
|
-
HeadlessEngine,
|
|
6
6
|
StandaloneSearchBox as StandaloneSearchBoxType,
|
|
7
|
-
StandaloneSearchBoxOptions,
|
|
8
7
|
StandaloneSearchBoxState,
|
|
9
8
|
buildStandaloneSearchBox,
|
|
10
|
-
|
|
9
|
+
StandaloneSearchBoxOptions
|
|
11
10
|
} from "@coveo/headless";
|
|
12
11
|
|
|
13
12
|
const baseSearchHref = `/search`;
|
|
@@ -32,11 +31,11 @@ export default class HeaderSearch extends LightningElement {
|
|
|
32
31
|
private get suggestions(): Option[] {
|
|
33
32
|
if (this.searchState) {
|
|
34
33
|
return this.searchState.suggestions.map(
|
|
35
|
-
({
|
|
36
|
-
id:
|
|
37
|
-
label:
|
|
34
|
+
({ highlightedValue }: { highlightedValue: string }) => ({
|
|
35
|
+
id: highlightedValue,
|
|
36
|
+
label: highlightedValue,
|
|
38
37
|
link: {
|
|
39
|
-
href: this.createSearchHref(
|
|
38
|
+
href: this.createSearchHref(highlightedValue),
|
|
40
39
|
target: null
|
|
41
40
|
}
|
|
42
41
|
})
|
|
@@ -83,25 +82,20 @@ export default class HeaderSearch extends LightningElement {
|
|
|
83
82
|
redirectionUrl: "https://developer.salesforce.com"
|
|
84
83
|
};
|
|
85
84
|
|
|
86
|
-
const engine =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
pipeline: this.coveoSearchPipeline,
|
|
92
|
-
searchHub: this.coveoSearchHub
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
reducers: searchAppReducers
|
|
85
|
+
const engine = buildSearchEngine({
|
|
86
|
+
organizationId: this.coveoOrganizationId,
|
|
87
|
+
publicAccessToken: this.coveoPublicAccessToken,
|
|
88
|
+
searchPipeline: this.coveoSearchPipeline,
|
|
89
|
+
searchHub: this.coveoSearchHub
|
|
96
90
|
});
|
|
97
91
|
|
|
98
92
|
this.searchBox = buildStandaloneSearchBox(engine, { options });
|
|
99
|
-
|
|
93
|
+
|
|
94
|
+
this.searchBox?.subscribe(() => {
|
|
100
95
|
if (this.searchBox) {
|
|
101
96
|
this.searchState = this.searchBox.state;
|
|
102
97
|
}
|
|
103
98
|
});
|
|
104
|
-
this.searchBox.updateText("");
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
private createSearchHref = (value: string | null = "") => {
|
|
@@ -2,13 +2,6 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
|
|
3
3
|
import { LazyMode } from "typings/custom";
|
|
4
4
|
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
requestIdleCallback: any;
|
|
8
|
-
cancelIdleCallback: any;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
5
|
/**
|
|
13
6
|
* Defines a fallback for BackgroundTasksAPI for browsers that doesn't support it.
|
|
14
7
|
* Currently BackgroundTasksAPI is supported by all major browsers
|
|
@@ -2,6 +2,18 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
import { track } from "dx/instrumentation";
|
|
3
3
|
import { CountryOptions, CheckboxTextSet } from "typings/custom";
|
|
4
4
|
|
|
5
|
+
const ANALYTICS_INFO = {
|
|
6
|
+
itemTitle: "newsletter sign up submit",
|
|
7
|
+
formName: "newsletter",
|
|
8
|
+
formType: "newsletter",
|
|
9
|
+
method: "email",
|
|
10
|
+
destinationType: "internal",
|
|
11
|
+
clickText: "Subscribe Now",
|
|
12
|
+
clickUrl: "/newsletter/success",
|
|
13
|
+
elementType: "button",
|
|
14
|
+
ctaClick: true
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
export default class Form extends LightningElement {
|
|
6
18
|
@api checkboxTextSet: string = "";
|
|
7
19
|
@api countries: string = "";
|
|
@@ -134,16 +146,13 @@ export default class Form extends LightningElement {
|
|
|
134
146
|
submitButtonEl.textContent = "...Processing request";
|
|
135
147
|
|
|
136
148
|
try {
|
|
137
|
-
const res = await fetch(
|
|
138
|
-
"
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
body: JSON.stringify(formData)
|
|
145
|
-
}
|
|
146
|
-
);
|
|
149
|
+
const res = await fetch("/pages/pardot/footer_optin", {
|
|
150
|
+
method: "POST",
|
|
151
|
+
headers: {
|
|
152
|
+
"Content-Type": "application/json"
|
|
153
|
+
},
|
|
154
|
+
body: JSON.stringify(formData)
|
|
155
|
+
});
|
|
147
156
|
|
|
148
157
|
if (!res.ok) {
|
|
149
158
|
throw new Error(errorMsg);
|
|
@@ -156,7 +165,7 @@ export default class Form extends LightningElement {
|
|
|
156
165
|
}
|
|
157
166
|
|
|
158
167
|
// GTM event
|
|
159
|
-
track(submitButtonEl, "
|
|
168
|
+
track(submitButtonEl, "custEv_formCompletion", ANALYTICS_INFO);
|
|
160
169
|
|
|
161
170
|
window.location.assign("/newsletter/success");
|
|
162
171
|
} catch (error) {
|