@salesforcedevs/docs-components 0.26.0 → 0.26.3
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/package.json +2 -6
- package/src/modules/doc/header/header.ts +1 -1
- package/src/modules/doc/content/__tests__/content.test.ts +0 -312
- package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -348
- package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/content/__tests__/mockSidebar.ts +0 -81
- package/src/modules/doc/content/content.stories.ts +0 -148
- package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
- package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
- package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
- package/src/modules/doc/contentMedia/__tests__/contentMedia.test.ts +0 -93
- package/src/modules/doc/contentMedia/contentMedia.stories.ts +0 -113
- package/src/modules/doc/header/__tests__/coveoConfig.ts +0 -6
- package/src/modules/doc/header/__tests__/header.test.ts +0 -437
- package/src/modules/doc/header/__tests__/mockNavDevelopers.ts +0 -427
- package/src/modules/doc/header/__tests__/mockNavs.ts +0 -115
- package/src/modules/doc/header/__tests__/mockProps.ts +0 -152
- package/src/modules/doc/header/header.stories.ts +0 -190
- package/src/modules/doc/headingAnchor/__tests__/headingAnchor.test.ts +0 -110
- package/src/modules/doc/headingAnchor/headingAnchor.stories.ts +0 -33
- package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/nav/__tests__/nav.test.ts +0 -57
- package/src/modules/doc/phase/__tests__/mockProps.ts +0 -13
- package/src/modules/doc/phase/__tests__/phase.test.ts +0 -58
- package/src/modules/doc/phase/phase.stories.ts +0 -12
- package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
- package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
package/package.json
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.3",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">= 14.x"
|
|
9
9
|
},
|
|
10
|
-
"files": [
|
|
11
|
-
"src/modules",
|
|
12
|
-
"lwc.config.json"
|
|
13
|
-
],
|
|
14
10
|
"publishConfig": {
|
|
15
11
|
"access": "public"
|
|
16
12
|
},
|
|
17
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "9c94c66a063751c3ada92ae0dbbded0b999feb98"
|
|
18
14
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import type { Option } from "typings/custom";
|
|
4
|
-
import { HeaderBase } from "
|
|
4
|
+
import { HeaderBase } from "base-elements/headerBase";
|
|
5
5
|
import { toJson } from "utils/normalizers";
|
|
6
6
|
import get from "lodash.get";
|
|
7
7
|
|
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import CodeBlock from "dx/codeBlock";
|
|
2
|
-
import { createRenderComponent } from "utils-internal/tests";
|
|
3
|
-
import Content from "../content";
|
|
4
|
-
import * as mockContent from "./mockDocContent";
|
|
5
|
-
import mockPageReference from "./mockPageReference";
|
|
6
|
-
|
|
7
|
-
const TAG = "doc-content";
|
|
8
|
-
const render = createRenderComponent(TAG, Content);
|
|
9
|
-
|
|
10
|
-
describe("doc-content", () => {
|
|
11
|
-
it("renders the content", () => {
|
|
12
|
-
const component = render({
|
|
13
|
-
docsData: mockContent.content,
|
|
14
|
-
pageReference: mockPageReference,
|
|
15
|
-
_isStorybook: false
|
|
16
|
-
});
|
|
17
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
18
|
-
'[data-name="content"]'
|
|
19
|
-
);
|
|
20
|
-
expect(contentEl).not.toBeNull();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("renders both with and wothout pagination buttons", () => {
|
|
24
|
-
const c_buttons = render({
|
|
25
|
-
docsData: mockContent.withButtons,
|
|
26
|
-
pageReference: mockPageReference,
|
|
27
|
-
showPaginationButtons: true,
|
|
28
|
-
_isStorybook: false
|
|
29
|
-
});
|
|
30
|
-
const dx_buttons = c_buttons.shadowRoot.querySelectorAll("dx-button");
|
|
31
|
-
expect(dx_buttons.length).toEqual(2);
|
|
32
|
-
|
|
33
|
-
const c_no_buttons = render({
|
|
34
|
-
docsData: mockContent.withButtons,
|
|
35
|
-
pageReference: mockPageReference,
|
|
36
|
-
_isStorybook: false
|
|
37
|
-
});
|
|
38
|
-
const empty_dx_buttons =
|
|
39
|
-
c_no_buttons.shadowRoot.querySelectorAll("dx-button");
|
|
40
|
-
expect(empty_dx_buttons.length).toEqual(0);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("swaps out images", () => {
|
|
44
|
-
const component = render({
|
|
45
|
-
docsData: mockContent.withImages,
|
|
46
|
-
pageReference: mockPageReference,
|
|
47
|
-
_isStorybook: false
|
|
48
|
-
});
|
|
49
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
50
|
-
'[data-name="content"]'
|
|
51
|
-
);
|
|
52
|
-
expect(contentEl).not.toBeNull();
|
|
53
|
-
const images = component.shadowRoot.querySelectorAll("img");
|
|
54
|
-
expect(images.length).toEqual(3);
|
|
55
|
-
const contentMediaEls =
|
|
56
|
-
component.shadowRoot.querySelectorAll("doc-content-media");
|
|
57
|
-
expect(contentMediaEls.length).toEqual(0);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("swaps out iframes", () => {
|
|
61
|
-
const component = render({
|
|
62
|
-
docsData: mockContent.withVideos,
|
|
63
|
-
pageReference: mockPageReference,
|
|
64
|
-
_isStorybook: false
|
|
65
|
-
});
|
|
66
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
67
|
-
'[data-name="content"]'
|
|
68
|
-
);
|
|
69
|
-
expect(contentEl).not.toBeNull();
|
|
70
|
-
const images = component.shadowRoot.querySelectorAll("iframe");
|
|
71
|
-
expect(images.length).toEqual(0);
|
|
72
|
-
const contentMediaEls =
|
|
73
|
-
component.shadowRoot.querySelectorAll("doc-content-media");
|
|
74
|
-
expect(contentMediaEls.length).toEqual(2);
|
|
75
|
-
contentMediaEls.forEach((contentMedia) => {
|
|
76
|
-
expect(contentMedia.contentType).toEqual("iframe");
|
|
77
|
-
expect(contentMedia.mediaTitle).not.toBeUndefined();
|
|
78
|
-
expect(contentMedia.contentSrc).toMatch(
|
|
79
|
-
"https://play.vidyard.com/"
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("swaps out notes", () => {
|
|
85
|
-
const component = render({
|
|
86
|
-
docsData: mockContent.withNotes,
|
|
87
|
-
pageReference: mockPageReference,
|
|
88
|
-
_isStorybook: false
|
|
89
|
-
});
|
|
90
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
91
|
-
'[data-name="content"]'
|
|
92
|
-
);
|
|
93
|
-
expect(contentEl).not.toBeNull();
|
|
94
|
-
const notes = component.shadowRoot.querySelectorAll(".message");
|
|
95
|
-
expect(notes).toHaveLength(4);
|
|
96
|
-
notes.forEach((note) => {
|
|
97
|
-
const noteHeader = note.querySelector("doc-content-callout");
|
|
98
|
-
expect(noteHeader).not.toBeNull();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("includes tables, lists, and code blocks in notes", () => {
|
|
103
|
-
const component = render({
|
|
104
|
-
docsData: mockContent.withNotes,
|
|
105
|
-
pageReference: mockPageReference,
|
|
106
|
-
_isStorybook: false
|
|
107
|
-
});
|
|
108
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
109
|
-
'[data-name="content"]'
|
|
110
|
-
);
|
|
111
|
-
expect(contentEl).not.toBeNull();
|
|
112
|
-
const notes = component.shadowRoot.querySelectorAll(".message");
|
|
113
|
-
expect(notes[0].querySelector("table")).not.toBeNull();
|
|
114
|
-
expect(notes[1].querySelector("ul")).not.toBeNull();
|
|
115
|
-
expect(notes[2].querySelector("ol")).not.toBeNull();
|
|
116
|
-
expect(notes[3].querySelector("dx-code-block")).not.toBeNull();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("highlights text that matches search criteria", () => {
|
|
120
|
-
const component = render({
|
|
121
|
-
docsData: mockContent.content,
|
|
122
|
-
pageReference: mockPageReference,
|
|
123
|
-
isStorybook: true
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
127
|
-
'[data-name="content"]'
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
expect(contentEl.querySelectorAll("mark")).toHaveLength(0);
|
|
131
|
-
|
|
132
|
-
contentEl.dispatchEvent(
|
|
133
|
-
new CustomEvent("highlightedtermchange", {
|
|
134
|
-
detail: "apex",
|
|
135
|
-
composed: true,
|
|
136
|
-
bubbles: true
|
|
137
|
-
})
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
expect(contentEl.querySelectorAll("mark")).toHaveLength(14);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("doesn't highlight elements that contains dx/docs components", () => {
|
|
144
|
-
const searchTerm = "customreport";
|
|
145
|
-
|
|
146
|
-
const component = render({
|
|
147
|
-
docsData: mockContent.sampleCodeBlockAndNote,
|
|
148
|
-
pageReference: mockPageReference,
|
|
149
|
-
isStorybook: true
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
153
|
-
'[data-name="content"]'
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
expect(contentEl.querySelectorAll("mark")).toHaveLength(0);
|
|
157
|
-
|
|
158
|
-
contentEl.dispatchEvent(
|
|
159
|
-
new CustomEvent("highlightedtermchange", {
|
|
160
|
-
detail: searchTerm,
|
|
161
|
-
composed: true,
|
|
162
|
-
bubbles: true
|
|
163
|
-
})
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const marks: Array<HTMLElement> = contentEl.querySelectorAll("mark");
|
|
167
|
-
|
|
168
|
-
expect(marks).toHaveLength(0);
|
|
169
|
-
|
|
170
|
-
const code: CodeBlock = contentEl.querySelector("dx-code-block");
|
|
171
|
-
expect(code).not.toBeNull();
|
|
172
|
-
expect(code.codeBlock).toBeTruthy();
|
|
173
|
-
expect(contentEl.querySelector("doc-content-callout")).not.toBeNull();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("doesn't highlight terms separated by html tags", () => {
|
|
177
|
-
const searchTerm = "loadData within";
|
|
178
|
-
|
|
179
|
-
const component = render({
|
|
180
|
-
docsData: mockContent.sampleCodeBlockAndNote,
|
|
181
|
-
pageReference: mockPageReference,
|
|
182
|
-
isStorybook: true
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
186
|
-
'[data-name="content"]'
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
contentEl.dispatchEvent(
|
|
190
|
-
new CustomEvent("highlightedtermchange", {
|
|
191
|
-
detail: searchTerm,
|
|
192
|
-
composed: true,
|
|
193
|
-
bubbles: true
|
|
194
|
-
})
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
const marks: Array<HTMLElement> =
|
|
198
|
-
component.shadowRoot.querySelectorAll("mark");
|
|
199
|
-
expect(marks).toHaveLength(0);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it("escapes regex especial characters", () => {
|
|
203
|
-
const searchTerm = "used.+";
|
|
204
|
-
|
|
205
|
-
const component = render({
|
|
206
|
-
docsData: mockContent.sampleCodeBlockAndNote,
|
|
207
|
-
pageReference: mockPageReference,
|
|
208
|
-
isStorybook: true
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
212
|
-
'[data-name="content"]'
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
contentEl.dispatchEvent(
|
|
216
|
-
new CustomEvent("highlightedtermchange", {
|
|
217
|
-
detail: searchTerm,
|
|
218
|
-
composed: true,
|
|
219
|
-
bubbles: true
|
|
220
|
-
})
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
const marks: Array<HTMLElement> =
|
|
224
|
-
component.shadowRoot.querySelectorAll("mark");
|
|
225
|
-
expect(marks).toHaveLength(0);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it("cleans previous search result before searching for a new term", () => {
|
|
229
|
-
const firstSearch = "verify";
|
|
230
|
-
const secondSearch = "sObject";
|
|
231
|
-
|
|
232
|
-
const component = render({
|
|
233
|
-
docsData: mockContent.sampleCodeBlockAndNote,
|
|
234
|
-
pageReference: mockPageReference,
|
|
235
|
-
isStorybook: true
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
239
|
-
'[data-name="content"]'
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
contentEl.dispatchEvent(
|
|
243
|
-
new CustomEvent("highlightedtermchange", {
|
|
244
|
-
detail: firstSearch,
|
|
245
|
-
composed: true,
|
|
246
|
-
bubbles: true
|
|
247
|
-
})
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
const firstMarks: Array<HTMLElement> =
|
|
251
|
-
component.shadowRoot.querySelectorAll("mark");
|
|
252
|
-
expect(firstMarks).toHaveLength(2);
|
|
253
|
-
firstMarks.forEach(({ textContent }) =>
|
|
254
|
-
expect(textContent).toBe(firstSearch)
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
contentEl.dispatchEvent(
|
|
258
|
-
new CustomEvent("highlightedtermchange", {
|
|
259
|
-
detail: secondSearch,
|
|
260
|
-
composed: true,
|
|
261
|
-
bubbles: true
|
|
262
|
-
})
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
const secondMarks: Array<HTMLElement> =
|
|
266
|
-
component.shadowRoot.querySelectorAll("mark");
|
|
267
|
-
expect(secondMarks).toHaveLength(1);
|
|
268
|
-
secondMarks.forEach(({ textContent }) =>
|
|
269
|
-
expect(textContent).toBe(secondSearch)
|
|
270
|
-
);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it("cleans all marks if the search term is empty string", () => {
|
|
274
|
-
const firstSearch = "verify";
|
|
275
|
-
const secondSearch = "";
|
|
276
|
-
|
|
277
|
-
const component = render({
|
|
278
|
-
docsData: mockContent.sampleCodeBlockAndNote,
|
|
279
|
-
pageReference: mockPageReference,
|
|
280
|
-
isStorybook: true
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
284
|
-
'[data-name="content"]'
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
contentEl.dispatchEvent(
|
|
288
|
-
new CustomEvent("highlightedtermchange", {
|
|
289
|
-
detail: firstSearch,
|
|
290
|
-
composed: true,
|
|
291
|
-
bubbles: true
|
|
292
|
-
})
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
const firstMarks: Array<HTMLElement> =
|
|
296
|
-
component.shadowRoot.querySelectorAll("mark");
|
|
297
|
-
expect(firstMarks).toHaveLength(2);
|
|
298
|
-
firstMarks.forEach(({ textContent }) =>
|
|
299
|
-
expect(textContent).toBe(firstSearch)
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
contentEl.dispatchEvent(
|
|
303
|
-
new CustomEvent("highlightedtermchange", {
|
|
304
|
-
detail: secondSearch,
|
|
305
|
-
composed: true,
|
|
306
|
-
bubbles: true
|
|
307
|
-
})
|
|
308
|
-
);
|
|
309
|
-
|
|
310
|
-
expect(component.shadowRoot.querySelectorAll("mark")).toHaveLength(0);
|
|
311
|
-
});
|
|
312
|
-
});
|