@salesforcedevs/dx-components 0.10.1-alpha.147 → 0.10.1-alpha.148
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 -1
- package/package.json +1 -1
- package/src/modules/dx/banner/__tests__/banner.test.ts +31 -0
- package/src/modules/dx/{feedbackBanner/feedbackBanner.css → banner/banner.css} +6 -6
- package/src/modules/dx/banner/banner.html +13 -0
- package/src/modules/dx/banner/banner.ts +14 -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/emptyState/emptyState.css +2 -1
- package/src/modules/dx/footer/footer.ts +13 -1
- package/src/modules/dx/header/__tests__/header.test.ts +38 -21
- package/src/modules/dx/header/__tests__/mockProps.ts +22 -36
- package/src/modules/dx/header/header.html +4 -1
- package/src/modules/dx/header/header.stories.ts +30 -0
- package/src/modules/dx/header/header.ts +4 -1
- package/src/modules/dx/headerNav/headerNav.html +1 -0
- package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +18 -34
- package/src/modules/dx/headerSearch/__tests__/mockProps.ts +12 -0
- 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 +112 -4
- package/src/modules/dx/sidebar/sidebar.ts +17 -9
- package/src/modules/dx/sidebarSearch/__tests__/sidebarSearch.test.ts +24 -30
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +10 -8
- package/src/modules/utils/headerBase/headerBase.ts +13 -2
- package/src/modules/dx/feedbackBanner/__tests__/feedbackBanner.test.ts +0 -19
- package/src/modules/dx/feedbackBanner/feedbackBanner.html +0 -13
- package/src/modules/dx/feedbackBanner/feedbackBanner.ts +0 -3
- package/src/modules/dx/sidebar/__tests__/mockSearchResults.ts +0 -0
- package/src/modules/dx/sidebarSearch/utils.ts +0 -2
- package/src/modules/dx/tooltip/tippy.css +0 -1
|
@@ -1,8 +1,4 @@
|
|
|
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";
|
|
@@ -20,8 +16,7 @@ const COVEO_CONFIG = {
|
|
|
20
16
|
pipeline: coveoConfig.coveoSearchPipeline,
|
|
21
17
|
searchHub: coveoConfig.coveoSearchHub
|
|
22
18
|
}
|
|
23
|
-
}
|
|
24
|
-
reducers: searchAppReducers
|
|
19
|
+
}
|
|
25
20
|
};
|
|
26
21
|
|
|
27
22
|
const REDIRECT_URL = "https://developer.salesforce.com";
|
|
@@ -37,9 +32,8 @@ const mockUpdateText = jest.fn();
|
|
|
37
32
|
|
|
38
33
|
jest.mock("@coveo/headless", () => {
|
|
39
34
|
return {
|
|
40
|
-
|
|
41
|
-
buildStandaloneSearchBox: jest.fn()
|
|
42
|
-
searchAppReducers: jest.fn()
|
|
35
|
+
buildSearchEngine: jest.fn(),
|
|
36
|
+
buildStandaloneSearchBox: jest.fn()
|
|
43
37
|
};
|
|
44
38
|
});
|
|
45
39
|
|
|
@@ -68,14 +62,11 @@ const expectMobileToDefaultRender = ({
|
|
|
68
62
|
};
|
|
69
63
|
|
|
70
64
|
const expectSearchToInit = () => {
|
|
71
|
-
expect(
|
|
72
|
-
expect(
|
|
65
|
+
expect(buildSearchEngine).toHaveBeenCalledTimes(1);
|
|
66
|
+
expect(buildSearchEngine).toHaveBeenCalledWith(COVEO_CONFIG);
|
|
73
67
|
expect(buildStandaloneSearchBox).toHaveBeenCalledTimes(1);
|
|
74
|
-
const [
|
|
75
|
-
|
|
76
|
-
options
|
|
77
|
-
] = (buildStandaloneSearchBox as jest.Mock).mock.calls[0];
|
|
78
|
-
expect(engine).toBeInstanceOf(HeadlessEngine);
|
|
68
|
+
const options = (buildStandaloneSearchBox as jest.Mock).mock.calls[0][1];
|
|
69
|
+
|
|
79
70
|
expect(options).toEqual({
|
|
80
71
|
options: {
|
|
81
72
|
numberOfSuggestions: 3,
|
|
@@ -85,8 +76,6 @@ const expectSearchToInit = () => {
|
|
|
85
76
|
expect(mockSubscribe).toHaveBeenCalledTimes(1);
|
|
86
77
|
expect(subscribeCallback).not.toBeNull();
|
|
87
78
|
expect(subscribeCallback).toBeInstanceOf(Function);
|
|
88
|
-
expect(mockUpdateText).toHaveBeenCalledTimes(1);
|
|
89
|
-
expect(mockUpdateText).toHaveBeenCalledWith("");
|
|
90
79
|
};
|
|
91
80
|
|
|
92
81
|
describe(TAG, () => {
|
|
@@ -113,9 +102,8 @@ describe(TAG, () => {
|
|
|
113
102
|
expect(container).not.toBeNull();
|
|
114
103
|
expect(container.classList).toContain("desktop_search-container");
|
|
115
104
|
|
|
116
|
-
const suggestionsDropdown: Dropdown =
|
|
117
|
-
"dx-dropdown"
|
|
118
|
-
);
|
|
105
|
+
const suggestionsDropdown: Dropdown =
|
|
106
|
+
element.shadowRoot.querySelector("dx-dropdown");
|
|
119
107
|
expect(suggestionsDropdown.options).toHaveLength(0);
|
|
120
108
|
expect(suggestionsDropdown.open).toBe(false);
|
|
121
109
|
|
|
@@ -132,21 +120,18 @@ describe(TAG, () => {
|
|
|
132
120
|
|
|
133
121
|
it("renders as mobile view", () => {
|
|
134
122
|
const element = render({ ...mockProps, mobile: true });
|
|
135
|
-
const container: HTMLElement =
|
|
136
|
-
"div"
|
|
137
|
-
);
|
|
123
|
+
const container: HTMLElement =
|
|
124
|
+
element.shadowRoot.querySelector("div");
|
|
138
125
|
expect(container).not.toBeNull();
|
|
139
126
|
expect(container.classList).toHaveLength(0);
|
|
140
127
|
|
|
141
|
-
const dropdowns: Dropdown[] =
|
|
142
|
-
"dx-dropdown"
|
|
143
|
-
);
|
|
128
|
+
const dropdowns: Dropdown[] =
|
|
129
|
+
element.shadowRoot.querySelectorAll("dx-dropdown");
|
|
144
130
|
expect(dropdowns).toHaveLength(1);
|
|
145
131
|
const [dropdown] = dropdowns;
|
|
146
132
|
const input: Input = element.shadowRoot.querySelector("dx-input");
|
|
147
|
-
const button: Button =
|
|
148
|
-
"dx-button"
|
|
149
|
-
);
|
|
133
|
+
const button: Button =
|
|
134
|
+
element.shadowRoot.querySelector("dx-button");
|
|
150
135
|
expectMobileToDefaultRender({
|
|
151
136
|
input,
|
|
152
137
|
dropdown,
|
|
@@ -165,9 +150,8 @@ describe(TAG, () => {
|
|
|
165
150
|
const element = render({ ...mockProps, mobile: true });
|
|
166
151
|
|
|
167
152
|
const input: Input = element.shadowRoot.querySelector("dx-input");
|
|
168
|
-
const dropdown: Dropdown =
|
|
169
|
-
"dx-dropdown"
|
|
170
|
-
);
|
|
153
|
+
const dropdown: Dropdown =
|
|
154
|
+
element.shadowRoot.querySelector("dx-dropdown");
|
|
171
155
|
const button = element.shadowRoot.querySelector("dx-button");
|
|
172
156
|
button.click();
|
|
173
157
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// TODO: Move coveoConfig to a specific module to share it.
|
|
2
|
+
export const coveoConfig = {
|
|
3
|
+
coveoOrganizationId: "coveosalesforcetestakshatha",
|
|
4
|
+
coveoPublicAccessToken: "xx8d9c92ef-1018-4d92-a3c7-647dff01c21c",
|
|
5
|
+
coveoSearchPipeline: "salesforcedevdoc",
|
|
6
|
+
coveoSearchHub: "salesforcedevdoc"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
mobile: false,
|
|
11
|
+
...coveoConfig
|
|
12
|
+
};
|
|
@@ -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) {
|