@griddo/ax 11.15.7 → 11.15.8-rc.0
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 -2
- package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.atoms.test.tsx +409 -0
- package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.helpers.test.tsx +418 -0
- package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.test.tsx +776 -29
- package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +368 -11
- package/src/__tests__/modules/Users/UserList/UserList.test.tsx +6 -6
- package/src/components/Fields/IntegrationsField/IntegrationItem/atoms.tsx +14 -5
- package/src/components/Fields/IntegrationsField/IntegrationItem/index.tsx +1 -8
- package/src/components/Fields/UrlField/index.tsx +5 -4
- package/src/components/Fields/Wysiwyg/atoms.tsx +140 -0
- package/src/components/Fields/Wysiwyg/config.tsx +190 -9
- package/src/components/Fields/Wysiwyg/helpers.tsx +54 -1
- package/src/components/Fields/Wysiwyg/index.tsx +210 -61
- package/src/components/Fields/Wysiwyg/style.tsx +32 -1
- package/src/components/Fields/Wysiwyg/vendors.tsx +0 -1
- package/src/components/FieldsBehavior/index.tsx +66 -31
- package/src/components/Icon/components/Sync.js +16 -0
- package/src/components/Icon/svgs/Sync.svg +3 -0
- package/src/components/RestoreModal/index.tsx +1 -3
- package/src/components/ScheduleModal/index.tsx +3 -3
- package/src/components/TableList/index.tsx +5 -3
- package/src/containers/FileDrive/actions.tsx +5 -5
- package/src/containers/Forms/actions.tsx +40 -38
- package/src/containers/Gallery/actions.tsx +27 -27
- package/src/containers/Integrations/actions.tsx +2 -2
- package/src/containers/Navigation/Defaults/actions.tsx +1 -1
- package/src/containers/PageEditor/actions.tsx +3 -5
- package/src/containers/Redirects/actions.tsx +2 -2
- package/src/containers/Sites/actions.tsx +15 -8
- package/src/containers/StructuredData/actions.tsx +5 -5
- package/src/containers/Users/actions.tsx +2 -2
- package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +36 -43
- package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +15 -11
- package/src/modules/Categories/CategoriesList/atoms.tsx +42 -12
- package/src/modules/Categories/CategoriesList/index.tsx +8 -30
- package/src/modules/Content/PageItem/index.tsx +6 -5
- package/src/modules/Content/atoms.tsx +7 -3
- package/src/modules/Content/index.tsx +8 -16
- package/src/modules/FileDrive/FileModal/DetailPanel/index.tsx +14 -14
- package/src/modules/FileDrive/FolderItem/index.tsx +46 -54
- package/src/modules/FileDrive/GridItem/index.tsx +32 -37
- package/src/modules/FileDrive/ListItem/index.tsx +31 -37
- package/src/modules/FileDrive/atoms.tsx +59 -12
- package/src/modules/FileDrive/index.tsx +88 -98
- package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +42 -34
- package/src/modules/Forms/FormCategoriesList/atoms.tsx +17 -6
- package/src/modules/Forms/FormCategoriesList/index.tsx +30 -34
- package/src/modules/Forms/FormEditor/index.tsx +14 -6
- package/src/modules/Forms/FormList/FormItem/index.tsx +5 -1
- package/src/modules/Forms/FormList/index.tsx +15 -9
- package/src/modules/Forms/atoms.tsx +7 -4
- package/src/modules/GlobalEditor/atoms.tsx +77 -0
- package/src/modules/GlobalEditor/index.tsx +24 -7
- package/src/modules/MediaGallery/FolderItem/index.tsx +36 -52
- package/src/modules/MediaGallery/GridItem/index.tsx +27 -38
- package/src/modules/MediaGallery/ImageModal/DetailPanel/index.tsx +13 -13
- package/src/modules/MediaGallery/ImageModal/index.tsx +2 -16
- package/src/modules/MediaGallery/ListItem/index.tsx +25 -37
- package/src/modules/MediaGallery/atoms.tsx +84 -15
- package/src/modules/MediaGallery/index.tsx +62 -122
- package/src/modules/Navigation/Defaults/Item/atoms.tsx +2 -4
- package/src/modules/Navigation/Defaults/Item/index.tsx +80 -94
- package/src/modules/Navigation/Defaults/atoms.tsx +179 -7
- package/src/modules/Navigation/Defaults/index.tsx +51 -18
- package/src/modules/Navigation/Defaults/style.tsx +10 -7
- package/src/modules/Navigation/Menus/List/Table/Item/atoms.tsx +33 -19
- package/src/modules/Navigation/Menus/List/Table/Item/index.tsx +18 -19
- package/src/modules/Navigation/Menus/List/Table/index.tsx +15 -13
- package/src/modules/Navigation/Menus/List/index.tsx +1 -1
- package/src/modules/PageEditor/atoms.tsx +14 -11
- package/src/modules/PageEditor/index.tsx +11 -16
- package/src/modules/Redirects/RedirectItem/index.tsx +37 -39
- package/src/modules/Redirects/atoms.tsx +58 -12
- package/src/modules/Redirects/index.tsx +30 -58
- package/src/modules/Settings/Integrations/IntegrationItem/CopyModal/index.tsx +1 -1
- package/src/modules/Settings/Integrations/IntegrationItem/index.tsx +57 -69
- package/src/modules/Settings/Integrations/atoms.tsx +72 -8
- package/src/modules/Settings/Integrations/index.tsx +34 -48
- package/src/modules/StructuredData/Form/index.tsx +25 -8
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +26 -75
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +15 -33
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +63 -41
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/style.tsx +13 -8
- package/src/modules/StructuredData/StructuredDataList/index.tsx +11 -16
- package/src/modules/StructuredData/{StructuredDataList/atoms.tsx → atoms.tsx} +25 -28
- package/src/modules/Users/UserList/UserItem/index.tsx +18 -35
- package/src/modules/Users/UserList/atoms.tsx +61 -0
- package/src/modules/Users/UserList/index.tsx +12 -32
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPopupFunctions,
|
|
3
|
+
getLanguageMenuHtml,
|
|
4
|
+
getPopupPosition,
|
|
5
|
+
getRichTextConfig,
|
|
6
|
+
parseClassNames,
|
|
7
|
+
setLinkAttributes,
|
|
8
|
+
} from "@ax/components/Fields/Wysiwyg/helpers";
|
|
9
|
+
|
|
10
|
+
// Mock the config module
|
|
11
|
+
jest.mock("components", () => ({
|
|
12
|
+
config: {
|
|
13
|
+
schemas: {
|
|
14
|
+
config: {
|
|
15
|
+
richTextConfig: {
|
|
16
|
+
paragraphStyles: [
|
|
17
|
+
{ label: "Normal", className: "normal" },
|
|
18
|
+
{ label: "Heading", className: "heading" },
|
|
19
|
+
],
|
|
20
|
+
editorLangs: [
|
|
21
|
+
{ name: "English", iso: "en" },
|
|
22
|
+
{ name: "Spanish", iso: "es" },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
describe("Wysiwyg helpers", () => {
|
|
31
|
+
describe("getRichTextConfig", () => {
|
|
32
|
+
it("should return richTextConfig from global config", () => {
|
|
33
|
+
const config = getRichTextConfig();
|
|
34
|
+
|
|
35
|
+
expect(config).not.toBeNull();
|
|
36
|
+
expect(config?.paragraphStyles).toBeDefined();
|
|
37
|
+
expect(config?.editorLangs).toBeDefined();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should return config with correct structure", () => {
|
|
41
|
+
const config = getRichTextConfig();
|
|
42
|
+
|
|
43
|
+
expect(config?.paragraphStyles).toHaveLength(2);
|
|
44
|
+
expect(config?.paragraphStyles?.[0]).toEqual({ label: "Normal", className: "normal" });
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("parseClassNames", () => {
|
|
49
|
+
it("should convert array of styles to className map", () => {
|
|
50
|
+
const styles = [
|
|
51
|
+
{ label: "Normal", className: "normal-text" },
|
|
52
|
+
{ label: "Bold", className: "bold-text" },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const result = parseClassNames(styles);
|
|
56
|
+
|
|
57
|
+
expect(result).toEqual({
|
|
58
|
+
"normal-text": "Normal",
|
|
59
|
+
"bold-text": "Bold",
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should handle empty array", () => {
|
|
64
|
+
const result = parseClassNames([]);
|
|
65
|
+
|
|
66
|
+
expect(result).toEqual({});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should handle single style", () => {
|
|
70
|
+
const styles = [{ label: "Italic", className: "italic-text" }];
|
|
71
|
+
|
|
72
|
+
const result = parseClassNames(styles);
|
|
73
|
+
|
|
74
|
+
expect(result).toEqual({ "italic-text": "Italic" });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should use className as key and label as value", () => {
|
|
78
|
+
const styles = [{ label: "My Label", className: "my-class" }];
|
|
79
|
+
|
|
80
|
+
const result = parseClassNames(styles);
|
|
81
|
+
|
|
82
|
+
expect(result).toEqual({ "my-class": "My Label" });
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe("getLanguageMenuHtml", () => {
|
|
87
|
+
it("should generate HTML with featured languages first", () => {
|
|
88
|
+
const languages = [
|
|
89
|
+
{ name: "English", iso: "en", featured: true },
|
|
90
|
+
{ name: "Spanish", iso: "es" },
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
const html = getLanguageMenuHtml(languages);
|
|
94
|
+
|
|
95
|
+
expect(html).toContain("English");
|
|
96
|
+
expect(html).toContain("Spanish");
|
|
97
|
+
expect(html).toContain("Remove");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("should include Remove option with italic style", () => {
|
|
101
|
+
const languages = [{ name: "English", iso: "en" }];
|
|
102
|
+
|
|
103
|
+
const html = getLanguageMenuHtml(languages);
|
|
104
|
+
|
|
105
|
+
expect(html).toContain("Remove");
|
|
106
|
+
expect(html).toContain("font-style");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("should set data-param1 attribute with language iso", () => {
|
|
110
|
+
const languages = [{ name: "English", iso: "en" }];
|
|
111
|
+
|
|
112
|
+
const html = getLanguageMenuHtml(languages);
|
|
113
|
+
|
|
114
|
+
expect(html).toContain('data-param1="en"');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("should include fr-command class and lang dropdown data-cmd", () => {
|
|
118
|
+
const languages = [{ name: "English", iso: "en" }];
|
|
119
|
+
|
|
120
|
+
const html = getLanguageMenuHtml(languages);
|
|
121
|
+
|
|
122
|
+
expect(html).toContain("fr-command");
|
|
123
|
+
expect(html).toContain("data-cmd");
|
|
124
|
+
expect(html).toContain("langDropdown");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("should handle multiple featured and non-featured languages", () => {
|
|
128
|
+
const languages = [
|
|
129
|
+
{ name: "English", iso: "en", featured: true },
|
|
130
|
+
{ name: "Spanish", iso: "es", featured: true },
|
|
131
|
+
{ name: "French", iso: "fr" },
|
|
132
|
+
{ name: "German", iso: "de" },
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
const html = getLanguageMenuHtml(languages);
|
|
136
|
+
|
|
137
|
+
expect(html).toContain("English");
|
|
138
|
+
expect(html).toContain("Spanish");
|
|
139
|
+
expect(html).toContain("French");
|
|
140
|
+
expect(html).toContain("German");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe("setLinkAttributes", () => {
|
|
145
|
+
let linkElement: HTMLElement;
|
|
146
|
+
|
|
147
|
+
beforeEach(() => {
|
|
148
|
+
linkElement = document.createElement("a");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("should set href attribute", () => {
|
|
152
|
+
setLinkAttributes(linkElement, "http://example.com");
|
|
153
|
+
|
|
154
|
+
expect(linkElement.getAttribute("href")).toBe("http://example.com");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should set target attribute when newTab is true", () => {
|
|
158
|
+
setLinkAttributes(linkElement, "http://example.com", { newTab: true });
|
|
159
|
+
|
|
160
|
+
expect(linkElement.getAttribute("target")).toBe("_blank");
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("should remove target attribute when newTab is false", () => {
|
|
164
|
+
linkElement.setAttribute("target", "_blank");
|
|
165
|
+
|
|
166
|
+
setLinkAttributes(linkElement, "http://example.com", { newTab: false });
|
|
167
|
+
|
|
168
|
+
expect(linkElement.getAttribute("target")).toBeNull();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("should set rel attribute when noFollow is true", () => {
|
|
172
|
+
setLinkAttributes(linkElement, "http://example.com", { noFollow: true });
|
|
173
|
+
|
|
174
|
+
expect(linkElement.getAttribute("rel")).toBe("nofollow");
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("should remove rel attribute when noFollow is false", () => {
|
|
178
|
+
linkElement.setAttribute("rel", "nofollow");
|
|
179
|
+
|
|
180
|
+
setLinkAttributes(linkElement, "http://example.com", { noFollow: false });
|
|
181
|
+
|
|
182
|
+
expect(linkElement.getAttribute("rel")).toBeNull();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("should set data-pageId attribute when linkTo is provided", () => {
|
|
186
|
+
setLinkAttributes(linkElement, "http://example.com", { linkTo: 42 });
|
|
187
|
+
|
|
188
|
+
expect(linkElement.getAttribute("data-pageId")).toBe("42");
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("should remove data-pageId attribute when linkTo is null or undefined", () => {
|
|
192
|
+
linkElement.setAttribute("data-pageId", "42");
|
|
193
|
+
|
|
194
|
+
setLinkAttributes(linkElement, "http://example.com", { linkTo: null });
|
|
195
|
+
|
|
196
|
+
expect(linkElement.getAttribute("data-pageId")).toBeNull();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("should apply all options together", () => {
|
|
200
|
+
setLinkAttributes(linkElement, "http://example.com", {
|
|
201
|
+
newTab: true,
|
|
202
|
+
noFollow: true,
|
|
203
|
+
linkTo: 99,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
expect(linkElement.getAttribute("href")).toBe("http://example.com");
|
|
207
|
+
expect(linkElement.getAttribute("target")).toBe("_blank");
|
|
208
|
+
expect(linkElement.getAttribute("rel")).toBe("nofollow");
|
|
209
|
+
expect(linkElement.getAttribute("data-pageId")).toBe("99");
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("should handle null element gracefully", () => {
|
|
213
|
+
expect(() => {
|
|
214
|
+
setLinkAttributes(null, "http://example.com");
|
|
215
|
+
}).not.toThrow();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("should update href without changing other attributes", () => {
|
|
219
|
+
setLinkAttributes(linkElement, "http://old.com", { newTab: true, noFollow: true });
|
|
220
|
+
setLinkAttributes(linkElement, "http://new.com");
|
|
221
|
+
|
|
222
|
+
expect(linkElement.getAttribute("href")).toBe("http://new.com");
|
|
223
|
+
expect(linkElement.getAttribute("target")).toBeNull();
|
|
224
|
+
expect(linkElement.getAttribute("rel")).toBeNull();
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe("getPopupPosition", () => {
|
|
229
|
+
let editorEl: HTMLElement;
|
|
230
|
+
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
editorEl = document.createElement("div");
|
|
233
|
+
document.body.appendChild(editorEl);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
afterEach(() => {
|
|
237
|
+
document.body.removeChild(editorEl);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("should calculate position based on editor element bounds", () => {
|
|
241
|
+
// Mock getBoundingClientRect
|
|
242
|
+
editorEl.getBoundingClientRect = jest.fn(() => ({
|
|
243
|
+
left: 100,
|
|
244
|
+
top: 200,
|
|
245
|
+
width: 400,
|
|
246
|
+
height: 300,
|
|
247
|
+
right: 500,
|
|
248
|
+
bottom: 500,
|
|
249
|
+
x: 100,
|
|
250
|
+
y: 200,
|
|
251
|
+
toJSON: () => ({}),
|
|
252
|
+
}));
|
|
253
|
+
|
|
254
|
+
const pos = getPopupPosition(editorEl);
|
|
255
|
+
|
|
256
|
+
expect(pos.x).toBe(200); // 100 + 400/2 - 100
|
|
257
|
+
expect(pos.y).toBe(250); // 200 + 50
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it("should use window center when getBoundingClientRect is unavailable", () => {
|
|
261
|
+
editorEl.getBoundingClientRect = undefined as any;
|
|
262
|
+
|
|
263
|
+
const pos = getPopupPosition(editorEl);
|
|
264
|
+
|
|
265
|
+
expect(pos.x).toBe(window.innerWidth / 2 - 100);
|
|
266
|
+
expect(pos.y).toBe(50);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("should center popup horizontally in editor", () => {
|
|
270
|
+
editorEl.getBoundingClientRect = jest.fn(() => ({
|
|
271
|
+
left: 0,
|
|
272
|
+
top: 0,
|
|
273
|
+
width: 1000,
|
|
274
|
+
height: 500,
|
|
275
|
+
right: 1000,
|
|
276
|
+
bottom: 500,
|
|
277
|
+
x: 0,
|
|
278
|
+
y: 0,
|
|
279
|
+
toJSON: () => ({}),
|
|
280
|
+
}));
|
|
281
|
+
|
|
282
|
+
const pos = getPopupPosition(editorEl);
|
|
283
|
+
|
|
284
|
+
expect(pos.x).toBe(400); // 0 + 1000/2 - 100
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("should position popup 50px below editor top", () => {
|
|
288
|
+
editorEl.getBoundingClientRect = jest.fn(() => ({
|
|
289
|
+
left: 0,
|
|
290
|
+
top: 100,
|
|
291
|
+
width: 500,
|
|
292
|
+
height: 300,
|
|
293
|
+
right: 500,
|
|
294
|
+
bottom: 400,
|
|
295
|
+
x: 0,
|
|
296
|
+
y: 100,
|
|
297
|
+
toJSON: () => ({}),
|
|
298
|
+
}));
|
|
299
|
+
|
|
300
|
+
const pos = getPopupPosition(editorEl);
|
|
301
|
+
|
|
302
|
+
expect(pos.y).toBe(150); // 100 + 50
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
describe("createPopupFunctions", () => {
|
|
307
|
+
let mockEditor: any;
|
|
308
|
+
let editorEl: HTMLElement;
|
|
309
|
+
|
|
310
|
+
beforeEach(() => {
|
|
311
|
+
editorEl = document.createElement("div");
|
|
312
|
+
editorEl.getBoundingClientRect = jest.fn(() => ({
|
|
313
|
+
left: 0,
|
|
314
|
+
top: 0,
|
|
315
|
+
width: 400,
|
|
316
|
+
height: 300,
|
|
317
|
+
right: 400,
|
|
318
|
+
bottom: 300,
|
|
319
|
+
x: 0,
|
|
320
|
+
y: 0,
|
|
321
|
+
toJSON: () => ({}),
|
|
322
|
+
}));
|
|
323
|
+
|
|
324
|
+
mockEditor = {
|
|
325
|
+
popups: {
|
|
326
|
+
create: jest.fn(),
|
|
327
|
+
onHide: jest.fn(),
|
|
328
|
+
show: jest.fn(),
|
|
329
|
+
hide: jest.fn(),
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it("should return object with showPopup and showErrorPopup functions", () => {
|
|
335
|
+
const { showPopup, showErrorPopup } = createPopupFunctions(mockEditor, editorEl);
|
|
336
|
+
|
|
337
|
+
expect(typeof showPopup).toBe("function");
|
|
338
|
+
expect(typeof showErrorPopup).toBe("function");
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it("showPopup should create and show popup", () => {
|
|
342
|
+
const { showPopup } = createPopupFunctions(mockEditor, editorEl);
|
|
343
|
+
const template = { custom_layer: "<div>Test</div>" };
|
|
344
|
+
|
|
345
|
+
showPopup("test.popup", template);
|
|
346
|
+
|
|
347
|
+
expect(mockEditor.popups.create).toHaveBeenCalledWith("test.popup", template);
|
|
348
|
+
expect(mockEditor.popups.show).toHaveBeenCalled();
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("showPopup should register hide callback by default", () => {
|
|
352
|
+
const { showPopup } = createPopupFunctions(mockEditor, editorEl);
|
|
353
|
+
|
|
354
|
+
showPopup("test.popup", {});
|
|
355
|
+
|
|
356
|
+
expect(mockEditor.popups.onHide).toHaveBeenCalledWith("test.popup", expect.any(Function));
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it("showPopup should not register hide callback when keepVisible is true", () => {
|
|
360
|
+
const { showPopup } = createPopupFunctions(mockEditor, editorEl);
|
|
361
|
+
|
|
362
|
+
showPopup("test.popup", {}, true);
|
|
363
|
+
|
|
364
|
+
expect(mockEditor.popups.onHide).not.toHaveBeenCalled();
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it("showErrorPopup should show error popup with correct message", () => {
|
|
368
|
+
const { showErrorPopup } = createPopupFunctions(mockEditor, editorEl);
|
|
369
|
+
|
|
370
|
+
showErrorPopup();
|
|
371
|
+
|
|
372
|
+
expect(mockEditor.popups.create).toHaveBeenCalledWith(
|
|
373
|
+
"image.uploadError",
|
|
374
|
+
expect.objectContaining({
|
|
375
|
+
custom_layer: expect.stringContaining("Upload failed"),
|
|
376
|
+
}),
|
|
377
|
+
);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it("showErrorPopup should hide error popup after 3 seconds", (done) => {
|
|
381
|
+
jest.useFakeTimers();
|
|
382
|
+
const { showErrorPopup } = createPopupFunctions(mockEditor, editorEl);
|
|
383
|
+
|
|
384
|
+
showErrorPopup();
|
|
385
|
+
|
|
386
|
+
jest.advanceTimersByTime(3000);
|
|
387
|
+
|
|
388
|
+
expect(mockEditor.popups.hide).toHaveBeenCalledWith("image.uploadError");
|
|
389
|
+
|
|
390
|
+
jest.useRealTimers();
|
|
391
|
+
done();
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it("showPopup should pass correct position arguments to show method", () => {
|
|
395
|
+
const { showPopup } = createPopupFunctions(mockEditor, editorEl);
|
|
396
|
+
|
|
397
|
+
showPopup("test.popup", {});
|
|
398
|
+
|
|
399
|
+
const showCall = mockEditor.popups.show.mock.calls[0];
|
|
400
|
+
expect(showCall[0]).toBe("test.popup");
|
|
401
|
+
expect(typeof showCall[1]).toBe("number"); // x
|
|
402
|
+
expect(typeof showCall[2]).toBe("number"); // y
|
|
403
|
+
expect(showCall[3]).toBe(50); // z-index
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it("showErrorPopup should have correct styling", () => {
|
|
407
|
+
const { showErrorPopup } = createPopupFunctions(mockEditor, editorEl);
|
|
408
|
+
|
|
409
|
+
showErrorPopup();
|
|
410
|
+
|
|
411
|
+
const createCall = mockEditor.popups.create.mock.calls[0];
|
|
412
|
+
const template = createCall[1];
|
|
413
|
+
|
|
414
|
+
expect(template.custom_layer).toContain("color: #d32f2f");
|
|
415
|
+
expect(template.custom_layer).toContain("padding: 15px 30px");
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
});
|