@griddo/ax 1.75.111 → 1.75.113
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/config/jest/componentsMock.js +122 -1
- package/package.json +2 -2
- package/src/__tests__/components/Avatar/__snapshots__/Avatar.test.tsx.snap +10 -10
- package/src/__tests__/components/ConfigPanel/ConfigPanel.test.tsx +252 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/ConnectedField.test.tsx +177 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/NavConnectedField/NavConnectedField.test.tsx +161 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/Field.test.tsx +115 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/PageConnectedField.test.tsx +518 -0
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/TemplateManager.test.tsx +144 -0
- package/src/__tests__/components/ConfigPanel/Form/Form.test.tsx +235 -0
- package/src/__tests__/components/ConfigPanel/GlobalPageForm/GlobalPageForm.test.tsx +196 -0
- package/src/__tests__/components/ConfigPanel/Header/Header.test.tsx +152 -0
- package/src/__tests__/components/ConfigPanel/NavigationForm/Field/Field.test.tsx +106 -0
- package/src/__tests__/components/ConfigPanel/NavigationForm/NavigationForm.test.tsx +93 -0
- package/src/__tests__/components/ConfigPanel/PreviewForm/PreviewForm.test.tsx +93 -0
- package/src/__tests__/components/Fields/FieldGroup/FieldGroup.test.tsx +5 -5
- package/src/__tests__/components/Fields/NoteField/NoteField.test.tsx +3 -3
- package/src/__tests__/components/Fields/SliderField/SliderField.test.tsx +4 -4
- package/src/__tests__/components/Fields/TagField/TagField.test.tsx +10 -10
- package/src/__tests__/components/Fields/TextArea/TextArea.test.tsx +3 -3
- package/src/__tests__/components/Fields/TextField/TextField.test.tsx +8 -8
- package/src/__tests__/components/Fields/UrlField/UrlField.test.tsx +2 -2
- package/src/__tests__/components/Gallery/Gallery.test.tsx +613 -0
- package/src/__tests__/components/Gallery/GalleryFilters/Orientation/Orientation.test.tsx +51 -0
- package/src/__tests__/components/Gallery/GalleryFilters/SortBy/SortBy.test.tsx +117 -0
- package/src/__tests__/components/Gallery/GalleryFilters/Type/Type.test.tsx +51 -0
- package/src/__tests__/components/Gallery/GalleryPanel/DetailPanel/DetailPanel.test.tsx +853 -0
- package/src/__tests__/components/Gallery/GalleryPanel/GalleryDragAndDrop/GalleryDragAndDrop.test.tsx +252 -0
- package/src/__tests__/components/Gallery/GalleryPanel/GalleryPanel.test.tsx +56 -0
- package/src/__tests__/components/Image/Image.test.tsx +5 -5
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +3 -4
- package/src/components/ConfigPanel/Form/index.tsx +13 -5
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +5 -5
- package/src/components/ConfigPanel/Header/index.tsx +3 -3
- package/src/components/ConfigPanel/NavigationForm/Field/index.tsx +5 -3
- package/src/components/ConfigPanel/NavigationForm/index.tsx +2 -2
- package/src/components/ConfigPanel/PreviewForm/index.tsx +3 -3
- package/src/components/ConfigPanel/index.tsx +2 -3
- package/src/components/Fields/FieldGroup/index.tsx +3 -3
- package/src/components/Fields/NoteField/index.tsx +2 -2
- package/src/components/Fields/SliderField/index.tsx +10 -3
- package/src/components/Fields/TagField/index.tsx +2 -2
- package/src/components/Fields/TextArea/index.tsx +1 -1
- package/src/components/Fields/TextField/index.tsx +3 -3
- package/src/components/Gallery/GalleryFilters/Orientation/index.tsx +14 -6
- package/src/components/Gallery/GalleryFilters/SortBy/index.tsx +2 -2
- package/src/components/Gallery/GalleryFilters/Type/index.tsx +2 -2
- package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +4 -4
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/index.tsx +5 -4
- package/src/components/Gallery/GalleryPanel/index.tsx +3 -11
- package/src/components/Gallery/index.tsx +6 -5
- package/src/containers/PageEditor/actions.tsx +1 -2
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import axios, { AxiosResponse } from "axios";
|
|
4
|
+
import { ThemeProvider } from "styled-components";
|
|
5
|
+
import { render, cleanup, screen, fireEvent, act, waitFor } from "../../../../config/jest/test-utils";
|
|
6
|
+
import { mock } from "jest-mock-extended";
|
|
7
|
+
import configureStore from "redux-mock-store";
|
|
8
|
+
import thunk from "redux-thunk";
|
|
9
|
+
import "@testing-library/jest-dom";
|
|
10
|
+
|
|
11
|
+
import { parseTheme } from "@ax/helpers";
|
|
12
|
+
import Gallery, { IGalleryProps, IDispatchProps } from "@ax/components/Gallery";
|
|
13
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
14
|
+
import { IGetSiteImages, ISite } from "@ax/types";
|
|
15
|
+
import * as galleryUtils from "@ax/components/Gallery/utils";
|
|
16
|
+
import * as galleryHooks from "@ax/components/Gallery/hooks";
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
cleanup();
|
|
20
|
+
jest.resetAllMocks();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
jest.mock("axios");
|
|
24
|
+
const mockedAxios = axios as jest.MockedFunction<typeof axios>;
|
|
25
|
+
|
|
26
|
+
const defaultSiteProps = mock<ISite>();
|
|
27
|
+
const defaultDataProps = {
|
|
28
|
+
items: [
|
|
29
|
+
{
|
|
30
|
+
id: 1001,
|
|
31
|
+
name: "Imagen_Interior_fullstack.png",
|
|
32
|
+
title: "",
|
|
33
|
+
description: "",
|
|
34
|
+
alt: "",
|
|
35
|
+
tags: [],
|
|
36
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
37
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
38
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
39
|
+
damId: "imagen-interior-fullstack",
|
|
40
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
41
|
+
size: 55286,
|
|
42
|
+
width: 680,
|
|
43
|
+
height: 353,
|
|
44
|
+
orientation: "L",
|
|
45
|
+
site: "Global",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 1002,
|
|
49
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
50
|
+
title: "",
|
|
51
|
+
description: "",
|
|
52
|
+
alt: "",
|
|
53
|
+
tags: [],
|
|
54
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
55
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
56
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
57
|
+
damId: "imagen-interior-fullstack",
|
|
58
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
59
|
+
size: 55286,
|
|
60
|
+
width: 680,
|
|
61
|
+
height: 353,
|
|
62
|
+
orientation: "L",
|
|
63
|
+
site: "Global",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
isImageSelected: true,
|
|
67
|
+
imageSelected: {
|
|
68
|
+
alt: "",
|
|
69
|
+
damId: "imagen-interior-fullstack_2",
|
|
70
|
+
description: "",
|
|
71
|
+
height: 353,
|
|
72
|
+
id: 1002,
|
|
73
|
+
name: "Imagen_Interior_fullstack.png",
|
|
74
|
+
orientation: "L",
|
|
75
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
76
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
77
|
+
site: "Global",
|
|
78
|
+
size: 55286,
|
|
79
|
+
tags: [],
|
|
80
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
81
|
+
title: "",
|
|
82
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
83
|
+
width: 680,
|
|
84
|
+
},
|
|
85
|
+
page: 1,
|
|
86
|
+
isFinished: false,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const initialStore = {
|
|
90
|
+
gallery: {
|
|
91
|
+
isLoading: {
|
|
92
|
+
init: false,
|
|
93
|
+
more: false,
|
|
94
|
+
},
|
|
95
|
+
isSaving: {
|
|
96
|
+
save: false,
|
|
97
|
+
saveAdd: false,
|
|
98
|
+
delete: false,
|
|
99
|
+
},
|
|
100
|
+
data: defaultDataProps,
|
|
101
|
+
isUploading: false,
|
|
102
|
+
isSuccess: false,
|
|
103
|
+
isError: false,
|
|
104
|
+
errorMsg: "error",
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const middlewares: any = [thunk];
|
|
109
|
+
const mockStore = configureStore(middlewares);
|
|
110
|
+
|
|
111
|
+
const store = mockStore(initialStore);
|
|
112
|
+
|
|
113
|
+
describe("Gallery component rendering", () => {
|
|
114
|
+
it("should render the component", () => {
|
|
115
|
+
const defaultGalleryProps = mock<IGalleryProps>();
|
|
116
|
+
const defaultDispatchProps = mock<IDispatchProps>();
|
|
117
|
+
|
|
118
|
+
const responsePromise = Promise.resolve({
|
|
119
|
+
status: 200,
|
|
120
|
+
statusText: "ok",
|
|
121
|
+
data: {
|
|
122
|
+
items: [],
|
|
123
|
+
},
|
|
124
|
+
} as AxiosResponse);
|
|
125
|
+
|
|
126
|
+
mockedAxios.mockResolvedValue(responsePromise);
|
|
127
|
+
|
|
128
|
+
defaultGalleryProps.data = defaultDataProps;
|
|
129
|
+
defaultGalleryProps.site = defaultSiteProps;
|
|
130
|
+
defaultGalleryProps.isLoading = {
|
|
131
|
+
init: false,
|
|
132
|
+
more: false,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const defaultProps = {
|
|
136
|
+
...defaultGalleryProps,
|
|
137
|
+
...defaultDispatchProps,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
render(
|
|
141
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
142
|
+
<Gallery {...defaultProps} />
|
|
143
|
+
</ThemeProvider>,
|
|
144
|
+
{ store }
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
expect(screen.getByTestId("gallery-wrapper")).toBeTruthy();
|
|
148
|
+
expect(screen.getByTestId("grid-wrapper")).toBeTruthy();
|
|
149
|
+
expect(screen.queryAllByTestId("grid-item")).toHaveLength(2);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("should activate the handleClick with an image", () => {
|
|
153
|
+
const defaultGalleryProps = mock<IGalleryProps>();
|
|
154
|
+
const defaultDispatchProps = mock<IDispatchProps>();
|
|
155
|
+
|
|
156
|
+
const dataProps = {
|
|
157
|
+
items: [
|
|
158
|
+
{
|
|
159
|
+
id: 1001,
|
|
160
|
+
name: "Imagen_Interior_fullstack.png",
|
|
161
|
+
title: "",
|
|
162
|
+
description: "",
|
|
163
|
+
alt: "",
|
|
164
|
+
tags: [],
|
|
165
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
166
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
167
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
168
|
+
damId: "imagen-interior-fullstack",
|
|
169
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
170
|
+
size: 55286,
|
|
171
|
+
width: 680,
|
|
172
|
+
height: 353,
|
|
173
|
+
orientation: "L",
|
|
174
|
+
site: "Global",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: 1002,
|
|
178
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
179
|
+
title: "",
|
|
180
|
+
description: "",
|
|
181
|
+
alt: "",
|
|
182
|
+
tags: [],
|
|
183
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
184
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
185
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
186
|
+
damId: "imagen-interior-fullstack",
|
|
187
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
188
|
+
size: 55286,
|
|
189
|
+
width: 680,
|
|
190
|
+
height: 353,
|
|
191
|
+
orientation: "L",
|
|
192
|
+
site: "Global",
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
isImageSelected: true,
|
|
196
|
+
imageSelected: {
|
|
197
|
+
id: 1001,
|
|
198
|
+
name: "Imagen_Interior_fullstack.png",
|
|
199
|
+
title: "",
|
|
200
|
+
description: "",
|
|
201
|
+
alt: "",
|
|
202
|
+
tags: [],
|
|
203
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
204
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
205
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
206
|
+
damId: "imagen-interior-fullstack",
|
|
207
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
208
|
+
size: 55286,
|
|
209
|
+
width: 680,
|
|
210
|
+
height: 353,
|
|
211
|
+
orientation: "L",
|
|
212
|
+
site: "Global",
|
|
213
|
+
},
|
|
214
|
+
page: 1,
|
|
215
|
+
isFinished: false,
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const responsePromise = Promise.resolve({
|
|
219
|
+
status: 200,
|
|
220
|
+
statusText: "ok",
|
|
221
|
+
data: {
|
|
222
|
+
items: [],
|
|
223
|
+
},
|
|
224
|
+
} as AxiosResponse);
|
|
225
|
+
|
|
226
|
+
mockedAxios.mockResolvedValue(responsePromise);
|
|
227
|
+
|
|
228
|
+
defaultGalleryProps.data = defaultDataProps;
|
|
229
|
+
defaultGalleryProps.site = defaultSiteProps;
|
|
230
|
+
defaultGalleryProps.isLoading = {
|
|
231
|
+
init: false,
|
|
232
|
+
more: false,
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const defaultProps = {
|
|
236
|
+
...defaultGalleryProps,
|
|
237
|
+
...defaultDispatchProps,
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
render(
|
|
241
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
242
|
+
<Gallery {...defaultProps} />
|
|
243
|
+
</ThemeProvider>,
|
|
244
|
+
{ store }
|
|
245
|
+
);
|
|
246
|
+
store.clearActions();
|
|
247
|
+
|
|
248
|
+
const images = screen.queryAllByTestId("image-item");
|
|
249
|
+
expect(screen.queryAllByTestId("image-item")).toHaveLength(2);
|
|
250
|
+
|
|
251
|
+
act(() => {
|
|
252
|
+
fireEvent.click(images[0]);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
expect(store.getActions()).toContainEqual({
|
|
256
|
+
payload: { data: dataProps },
|
|
257
|
+
type: "gallery/SET_DATA",
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it("should activate the setImage action", async () => {
|
|
262
|
+
const defaultGalleryProps = mock<IGalleryProps>();
|
|
263
|
+
const defaultDispatchProps = mock<IDispatchProps>();
|
|
264
|
+
|
|
265
|
+
const responsePromise = Promise.resolve({
|
|
266
|
+
status: 200,
|
|
267
|
+
statusText: "ok",
|
|
268
|
+
data: {
|
|
269
|
+
items: [],
|
|
270
|
+
},
|
|
271
|
+
} as AxiosResponse);
|
|
272
|
+
|
|
273
|
+
mockedAxios.mockResolvedValue(responsePromise);
|
|
274
|
+
|
|
275
|
+
const getImageSelectedMocked = defaultGalleryProps.getImageSelected as jest.MockedFunction<(img: null) => void>;
|
|
276
|
+
const toggleModalMock = defaultGalleryProps.toggleModal as jest.MockedFunction<() => void>;
|
|
277
|
+
|
|
278
|
+
const defaultDataProps = {
|
|
279
|
+
items: [
|
|
280
|
+
{
|
|
281
|
+
id: 1002,
|
|
282
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
283
|
+
title: "",
|
|
284
|
+
description: "",
|
|
285
|
+
alt: "",
|
|
286
|
+
tags: [],
|
|
287
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
288
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
289
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
290
|
+
damId: "imagen-interior-fullstack",
|
|
291
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
292
|
+
size: 55286,
|
|
293
|
+
width: 680,
|
|
294
|
+
height: 353,
|
|
295
|
+
orientation: "L",
|
|
296
|
+
site: "Global",
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
isImageSelected: true,
|
|
300
|
+
imageSelected: {
|
|
301
|
+
id: 1002,
|
|
302
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
303
|
+
title: "",
|
|
304
|
+
description: "",
|
|
305
|
+
alt: "",
|
|
306
|
+
tags: [],
|
|
307
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
308
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
309
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
310
|
+
damId: "imagen-interior-fullstack",
|
|
311
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
312
|
+
size: 55286,
|
|
313
|
+
width: 680,
|
|
314
|
+
height: 353,
|
|
315
|
+
orientation: "L",
|
|
316
|
+
site: "Global",
|
|
317
|
+
},
|
|
318
|
+
page: 1,
|
|
319
|
+
isFinished: false,
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const initialStore = {
|
|
323
|
+
gallery: {
|
|
324
|
+
isLoading: {
|
|
325
|
+
init: false,
|
|
326
|
+
more: false,
|
|
327
|
+
},
|
|
328
|
+
isSaving: {
|
|
329
|
+
save: false,
|
|
330
|
+
saveAdd: false,
|
|
331
|
+
delete: false,
|
|
332
|
+
},
|
|
333
|
+
data: defaultDataProps,
|
|
334
|
+
isUploading: false,
|
|
335
|
+
isSuccess: false,
|
|
336
|
+
isError: false,
|
|
337
|
+
errorMsg: "error",
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
defaultGalleryProps.data = defaultDataProps;
|
|
342
|
+
defaultGalleryProps.site = defaultSiteProps;
|
|
343
|
+
defaultGalleryProps.isLoading = {
|
|
344
|
+
init: false,
|
|
345
|
+
more: false,
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const store = mockStore(initialStore);
|
|
349
|
+
|
|
350
|
+
const defaultProps = {
|
|
351
|
+
...defaultGalleryProps,
|
|
352
|
+
...defaultDispatchProps,
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
render(
|
|
356
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
357
|
+
<Gallery {...defaultProps} />
|
|
358
|
+
</ThemeProvider>,
|
|
359
|
+
{ store }
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const buttonDetailPanel = screen.getByTestId("button-default");
|
|
363
|
+
|
|
364
|
+
act(() => {
|
|
365
|
+
fireEvent.click(buttonDetailPanel);
|
|
366
|
+
});
|
|
367
|
+
await waitFor(() => expect(getImageSelectedMocked).toBeCalled());
|
|
368
|
+
expect(toggleModalMock).toBeCalled();
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it("should activate the refreshImages action", async () => {
|
|
372
|
+
const defaultGalleryProps = mock<IGalleryProps>();
|
|
373
|
+
const defaultDispatchProps = mock<IDispatchProps>();
|
|
374
|
+
|
|
375
|
+
const responsePromise = Promise.resolve({
|
|
376
|
+
status: 200,
|
|
377
|
+
statusText: "ok",
|
|
378
|
+
data: {
|
|
379
|
+
items: [
|
|
380
|
+
{
|
|
381
|
+
id: 1002,
|
|
382
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
383
|
+
title: "",
|
|
384
|
+
description: "",
|
|
385
|
+
alt: "",
|
|
386
|
+
tags: [],
|
|
387
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
388
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
389
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
390
|
+
damId: "imagen-interior-fullstack",
|
|
391
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
392
|
+
size: 55286,
|
|
393
|
+
width: 680,
|
|
394
|
+
height: 353,
|
|
395
|
+
orientation: "L",
|
|
396
|
+
site: "Global",
|
|
397
|
+
},
|
|
398
|
+
],
|
|
399
|
+
},
|
|
400
|
+
} as AxiosResponse);
|
|
401
|
+
|
|
402
|
+
mockedAxios.mockResolvedValue(responsePromise);
|
|
403
|
+
|
|
404
|
+
const getSiteImagesMock = defaultDispatchProps.getSiteImages as jest.MockedFunction<
|
|
405
|
+
(params: IGetSiteImages) => Promise<void>
|
|
406
|
+
>;
|
|
407
|
+
|
|
408
|
+
const defaultDataProps = {
|
|
409
|
+
items: [
|
|
410
|
+
{
|
|
411
|
+
id: 1002,
|
|
412
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
413
|
+
title: "",
|
|
414
|
+
description: "",
|
|
415
|
+
alt: "",
|
|
416
|
+
tags: [],
|
|
417
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
418
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
419
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
420
|
+
damId: "imagen-interior-fullstack",
|
|
421
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
422
|
+
size: 55286,
|
|
423
|
+
width: 680,
|
|
424
|
+
height: 353,
|
|
425
|
+
orientation: "L",
|
|
426
|
+
site: "Global",
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
isImageSelected: true,
|
|
430
|
+
imageSelected: {
|
|
431
|
+
id: 1002,
|
|
432
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
433
|
+
title: "",
|
|
434
|
+
description: "",
|
|
435
|
+
alt: "",
|
|
436
|
+
tags: [],
|
|
437
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
438
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
439
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
440
|
+
damId: "imagen-interior-fullstack",
|
|
441
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
442
|
+
size: 55286,
|
|
443
|
+
width: 680,
|
|
444
|
+
height: 353,
|
|
445
|
+
orientation: "L",
|
|
446
|
+
site: "Global",
|
|
447
|
+
},
|
|
448
|
+
page: 2,
|
|
449
|
+
isFinished: false,
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const initialStore = {
|
|
453
|
+
gallery: {
|
|
454
|
+
isLoading: {
|
|
455
|
+
init: false,
|
|
456
|
+
more: false,
|
|
457
|
+
},
|
|
458
|
+
isSaving: {
|
|
459
|
+
save: false,
|
|
460
|
+
saveAdd: false,
|
|
461
|
+
delete: false,
|
|
462
|
+
},
|
|
463
|
+
data: defaultDataProps,
|
|
464
|
+
isUploading: true,
|
|
465
|
+
isSuccess: false,
|
|
466
|
+
isError: false,
|
|
467
|
+
errorMsg: "error",
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
const dataProps = {
|
|
472
|
+
imageSelected: {
|
|
473
|
+
alt: "",
|
|
474
|
+
damId: "imagen-interior-fullstack",
|
|
475
|
+
description: "",
|
|
476
|
+
height: 353,
|
|
477
|
+
id: 1002,
|
|
478
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
479
|
+
orientation: "L",
|
|
480
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
481
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
482
|
+
site: "Global",
|
|
483
|
+
size: 55286,
|
|
484
|
+
tags: [],
|
|
485
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
486
|
+
title: "",
|
|
487
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
488
|
+
width: 680,
|
|
489
|
+
},
|
|
490
|
+
isFinished: true,
|
|
491
|
+
isImageSelected: true,
|
|
492
|
+
items: [
|
|
493
|
+
{
|
|
494
|
+
alt: "",
|
|
495
|
+
damId: "imagen-interior-fullstack",
|
|
496
|
+
description: "",
|
|
497
|
+
height: 353,
|
|
498
|
+
id: 1002,
|
|
499
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
500
|
+
orientation: "L",
|
|
501
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
502
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
503
|
+
site: "Global",
|
|
504
|
+
size: 55286,
|
|
505
|
+
tags: [],
|
|
506
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
507
|
+
title: "",
|
|
508
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
509
|
+
width: 680,
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
alt: "",
|
|
513
|
+
damId: "imagen-interior-fullstack",
|
|
514
|
+
description: "",
|
|
515
|
+
height: 353,
|
|
516
|
+
id: 1002,
|
|
517
|
+
name: "Imagen_Interior_fullstack_2.png",
|
|
518
|
+
orientation: "L",
|
|
519
|
+
publicId: "thesaurus-dev/Imagen_Interior_fullstack_6c908d9f-b493-4c93-b4d2-a0439bc00820",
|
|
520
|
+
published: new Date("2022-06-30T07:06:54.352Z"),
|
|
521
|
+
site: "Global",
|
|
522
|
+
size: 55286,
|
|
523
|
+
tags: [],
|
|
524
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/imagen-interior-fullstack",
|
|
525
|
+
title: "",
|
|
526
|
+
url: "https://images.dev.griddo.io/imagen-interior-fullstack",
|
|
527
|
+
width: 680,
|
|
528
|
+
},
|
|
529
|
+
],
|
|
530
|
+
page: 2,
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
defaultGalleryProps.data = defaultDataProps;
|
|
534
|
+
defaultGalleryProps.site = defaultSiteProps;
|
|
535
|
+
defaultGalleryProps.isLoading = {
|
|
536
|
+
init: false,
|
|
537
|
+
more: false,
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
const store = mockStore(initialStore);
|
|
541
|
+
|
|
542
|
+
const defaultProps = {
|
|
543
|
+
...defaultGalleryProps,
|
|
544
|
+
...defaultDispatchProps,
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
render(
|
|
548
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
549
|
+
<Gallery {...defaultProps} />
|
|
550
|
+
</ThemeProvider>,
|
|
551
|
+
{ store }
|
|
552
|
+
);
|
|
553
|
+
|
|
554
|
+
const buttonDetailPanel = screen.getAllByTestId("button-line-inverse");
|
|
555
|
+
|
|
556
|
+
await act(() => {
|
|
557
|
+
fireEvent.click(buttonDetailPanel[2]);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
expect(store.getActions()).toContainEqual({
|
|
561
|
+
payload: { data: dataProps },
|
|
562
|
+
type: "gallery/SET_DATA",
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
it("should call the sortBy actions", () => {
|
|
567
|
+
const defaultGalleryProps = mock<IGalleryProps>();
|
|
568
|
+
const defaultDispatchProps = mock<IDispatchProps>();
|
|
569
|
+
|
|
570
|
+
const responsePromise = Promise.resolve({
|
|
571
|
+
status: 200,
|
|
572
|
+
statusText: "ok",
|
|
573
|
+
data: {
|
|
574
|
+
items: [],
|
|
575
|
+
},
|
|
576
|
+
} as AxiosResponse);
|
|
577
|
+
|
|
578
|
+
mockedAxios.mockResolvedValue(responsePromise);
|
|
579
|
+
|
|
580
|
+
defaultGalleryProps.data = defaultDataProps;
|
|
581
|
+
defaultGalleryProps.site = defaultSiteProps;
|
|
582
|
+
defaultGalleryProps.isLoading = {
|
|
583
|
+
init: false,
|
|
584
|
+
more: false,
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
const defaultProps = {
|
|
588
|
+
...defaultGalleryProps,
|
|
589
|
+
...defaultDispatchProps,
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
const getSortedListStatusMock = jest.spyOn(galleryUtils, "getSortedListStatus");
|
|
593
|
+
const useFilterQueryMock = jest.spyOn(galleryHooks, "useFilterQuery");
|
|
594
|
+
|
|
595
|
+
render(
|
|
596
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
597
|
+
<Gallery {...defaultProps} />
|
|
598
|
+
</ThemeProvider>,
|
|
599
|
+
{ store }
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
const orientationWrapper = screen.getByTestId("sortby-wrapper");
|
|
603
|
+
expect(orientationWrapper).toBeTruthy();
|
|
604
|
+
fireEvent.click(orientationWrapper);
|
|
605
|
+
|
|
606
|
+
const listItem = screen.getAllByTestId("list-item");
|
|
607
|
+
expect(listItem).toHaveLength(6);
|
|
608
|
+
fireEvent.click(listItem[0]);
|
|
609
|
+
|
|
610
|
+
expect(getSortedListStatusMock).toBeCalled();
|
|
611
|
+
expect(useFilterQueryMock).toBeCalled();
|
|
612
|
+
});
|
|
613
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { render, cleanup, screen, fireEvent } from "@testing-library/react";
|
|
4
|
+
import { mock } from "jest-mock-extended";
|
|
5
|
+
import "@testing-library/jest-dom";
|
|
6
|
+
|
|
7
|
+
import { parseTheme } from "@ax/helpers";
|
|
8
|
+
import Orientation, { IOrientationProps } from "@ax/components/Gallery/GalleryFilters/Orientation";
|
|
9
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
cleanup();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const defaultProps = mock<IOrientationProps>();
|
|
16
|
+
const filterItemsMock = defaultProps.filterItems as jest.MockedFunction<(pointer: string, filter: string) => void>;
|
|
17
|
+
|
|
18
|
+
describe("OrderBy filter component rendering", () => {
|
|
19
|
+
it("should render the component", () => {
|
|
20
|
+
render(
|
|
21
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
22
|
+
<Orientation {...defaultProps} />
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const orientationWrapper = screen.getByTestId("orientation-wrapper");
|
|
27
|
+
expect(orientationWrapper).toBeTruthy();
|
|
28
|
+
fireEvent.click(orientationWrapper);
|
|
29
|
+
|
|
30
|
+
const listItem = screen.getAllByTestId("list-item");
|
|
31
|
+
expect(listItem).toHaveLength(4);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should call the list item", () => {
|
|
35
|
+
render(
|
|
36
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
37
|
+
<Orientation {...defaultProps} />
|
|
38
|
+
</ThemeProvider>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const orientationWrapper = screen.getByTestId("orientation-wrapper");
|
|
42
|
+
expect(orientationWrapper).toBeTruthy();
|
|
43
|
+
fireEvent.click(orientationWrapper);
|
|
44
|
+
|
|
45
|
+
const listItem = screen.getAllByTestId("list-item");
|
|
46
|
+
expect(listItem).toHaveLength(4);
|
|
47
|
+
fireEvent.click(listItem[1]);
|
|
48
|
+
|
|
49
|
+
expect(filterItemsMock).toBeCalledWith("orientation", "landscape");
|
|
50
|
+
});
|
|
51
|
+
});
|