@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,235 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { render, cleanup, screen, fireEvent } from "../../../../../config/jest/test-utils";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
import configureStore from "redux-mock-store";
|
|
7
|
+
import "@testing-library/jest-dom";
|
|
8
|
+
|
|
9
|
+
import { parseTheme } from "@ax/helpers";
|
|
10
|
+
import Form, { IFormProps } from "@ax/components/ConfigPanel/Form";
|
|
11
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
cleanup();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const middlewares: any = [];
|
|
18
|
+
const mockStore = configureStore(middlewares);
|
|
19
|
+
const initialStore = {
|
|
20
|
+
navigation: {
|
|
21
|
+
currentDefaultsContent: [
|
|
22
|
+
{
|
|
23
|
+
component: "Header",
|
|
24
|
+
type: "header",
|
|
25
|
+
title: "Header name",
|
|
26
|
+
note01: {
|
|
27
|
+
title: "",
|
|
28
|
+
text: "To configure social links go to settings/general/social. To activate search feature go to settings/actionables",
|
|
29
|
+
},
|
|
30
|
+
showTopNavigation: true,
|
|
31
|
+
topNavigationContent: ["showSocialMedia", "showSearchFeature"],
|
|
32
|
+
school: "GRIDDO_BIG",
|
|
33
|
+
primaryLink: {
|
|
34
|
+
component: "Link",
|
|
35
|
+
parentEditorID: 0,
|
|
36
|
+
},
|
|
37
|
+
secondaryLink: {
|
|
38
|
+
component: "Link",
|
|
39
|
+
parentEditorID: 0,
|
|
40
|
+
},
|
|
41
|
+
setAsDefault: false,
|
|
42
|
+
topMenu: null,
|
|
43
|
+
mainMenu: null,
|
|
44
|
+
sticky: true,
|
|
45
|
+
navigationBannerIcon: null,
|
|
46
|
+
navigationBanner: false,
|
|
47
|
+
navigationBannerText: "lorem ipsum",
|
|
48
|
+
navigationBannerLink: {
|
|
49
|
+
component: "Link",
|
|
50
|
+
parentEditorID: 0,
|
|
51
|
+
},
|
|
52
|
+
navigationBannerBGColor: "#50ABFF",
|
|
53
|
+
parentEditorID: null,
|
|
54
|
+
id: 181,
|
|
55
|
+
thumbnail: {
|
|
56
|
+
id: 1005,
|
|
57
|
+
name: "navigation-thumbnail.png",
|
|
58
|
+
title: "Thumbnail for Header name",
|
|
59
|
+
description: "",
|
|
60
|
+
alt: "",
|
|
61
|
+
tags: [],
|
|
62
|
+
url: "https://images.dev.griddo.io/navigation-thumbnail_71",
|
|
63
|
+
thumb: "https://images.dev.griddo.io/w/215/h/161/navigation-thumbnail_71",
|
|
64
|
+
publicId: "thesaurus-dev/navigation-thumbnail_f8d25cc6-daa0-4ea9-b08a-d68670a50a41",
|
|
65
|
+
damId: "navigation-thumbnail_71",
|
|
66
|
+
published: "2022-07-06T14:27:23.553Z",
|
|
67
|
+
size: 4236,
|
|
68
|
+
width: 773,
|
|
69
|
+
height: 92,
|
|
70
|
+
orientation: "L",
|
|
71
|
+
site: 85,
|
|
72
|
+
},
|
|
73
|
+
isDefault: false,
|
|
74
|
+
navigationLanguages: [
|
|
75
|
+
{
|
|
76
|
+
navigationId: 181,
|
|
77
|
+
languageId: 4,
|
|
78
|
+
locale: "en_GB",
|
|
79
|
+
language: "English",
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
site: 85,
|
|
83
|
+
language: 4,
|
|
84
|
+
entity: "73c91b2f-caca-4732-be7e-56fc1b640774",
|
|
85
|
+
deleted: false,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
pageEditor: {
|
|
90
|
+
selectedContent: { component: "Page" },
|
|
91
|
+
errors: [{}],
|
|
92
|
+
},
|
|
93
|
+
sites: {
|
|
94
|
+
currentSitePages: [
|
|
95
|
+
{
|
|
96
|
+
editorID: 1,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
app: {
|
|
101
|
+
lang: { locale: "es-ES", id: 0 },
|
|
102
|
+
},
|
|
103
|
+
dataPacks: {
|
|
104
|
+
templates: [],
|
|
105
|
+
},
|
|
106
|
+
menu: {
|
|
107
|
+
savedMenus: null,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
const store = mockStore(initialStore);
|
|
111
|
+
|
|
112
|
+
const defaultProps = mock<IFormProps>();
|
|
113
|
+
|
|
114
|
+
defaultProps.schema = {
|
|
115
|
+
title: "Header",
|
|
116
|
+
component: "Header",
|
|
117
|
+
type: "header",
|
|
118
|
+
configTabs: [
|
|
119
|
+
{
|
|
120
|
+
title: "content",
|
|
121
|
+
fields: [
|
|
122
|
+
{
|
|
123
|
+
title: "Name",
|
|
124
|
+
key: "title",
|
|
125
|
+
type: "TextField",
|
|
126
|
+
mandatory: true,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
schemaType: "module",
|
|
132
|
+
};
|
|
133
|
+
const restorePageNavigationActionMock = jest.fn();
|
|
134
|
+
defaultProps.actions = {
|
|
135
|
+
restorePageNavigationAction: restorePageNavigationActionMock,
|
|
136
|
+
};
|
|
137
|
+
const setSelectedContentMock = defaultProps.setSelectedContent as jest.MockedFunction<(editorID: number) => void>;
|
|
138
|
+
const setSelectedTabMocked = defaultProps.setSelectedTab as jest.MockedFunction<(tab: string) => void>;
|
|
139
|
+
const setHistoryPushMocked = defaultProps.setHistoryPush as jest.MockedFunction<
|
|
140
|
+
(path: string, isEditor: boolean) => void
|
|
141
|
+
>;
|
|
142
|
+
defaultProps.selectedTab = "content";
|
|
143
|
+
defaultProps.isPage = false;
|
|
144
|
+
defaultProps.isGlobal = false;
|
|
145
|
+
defaultProps.theme = "default-theme";
|
|
146
|
+
|
|
147
|
+
describe("Form component rendering", () => {
|
|
148
|
+
it("should render the component", () => {
|
|
149
|
+
defaultProps.isPage = true;
|
|
150
|
+
defaultProps.isGlobal = true;
|
|
151
|
+
|
|
152
|
+
render(
|
|
153
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
154
|
+
<Form {...defaultProps} />
|
|
155
|
+
</ThemeProvider>,
|
|
156
|
+
{ store }
|
|
157
|
+
);
|
|
158
|
+
expect(screen.getByTestId("form-section")).toBeTruthy();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("should render the component with no header warning text", () => {
|
|
162
|
+
defaultProps.isPage = false;
|
|
163
|
+
defaultProps.isGlobal = false;
|
|
164
|
+
defaultProps.header = 0;
|
|
165
|
+
|
|
166
|
+
render(
|
|
167
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
168
|
+
<Form {...defaultProps} />
|
|
169
|
+
</ThemeProvider>,
|
|
170
|
+
{ store }
|
|
171
|
+
);
|
|
172
|
+
expect(screen.getByText(/This page doesn\'t have a header. Click/i)).toBeInTheDocument();
|
|
173
|
+
expect(screen.getByTestId("form-section")).toBeTruthy();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("should call the function to restore the header", () => {
|
|
177
|
+
defaultProps.header = 0;
|
|
178
|
+
|
|
179
|
+
render(
|
|
180
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
181
|
+
<Form {...defaultProps} />
|
|
182
|
+
</ThemeProvider>,
|
|
183
|
+
{ store }
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
expect(screen.getByText(/This page doesn\'t have a header. Click/i)).toBeInTheDocument();
|
|
187
|
+
const headerLink = screen.getByTestId("header-link");
|
|
188
|
+
fireEvent.click(headerLink);
|
|
189
|
+
expect(restorePageNavigationActionMock).toBeCalled();
|
|
190
|
+
expect(restorePageNavigationActionMock).toBeCalledWith("header");
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("should render the component with no footer warning text", () => {
|
|
194
|
+
defaultProps.footer = 0;
|
|
195
|
+
|
|
196
|
+
render(
|
|
197
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
198
|
+
<Form {...defaultProps} />
|
|
199
|
+
</ThemeProvider>,
|
|
200
|
+
{ store }
|
|
201
|
+
);
|
|
202
|
+
expect(screen.getByText(/This page doesn\'t have a footer. Click/i)).toBeInTheDocument();
|
|
203
|
+
expect(screen.getByTestId("form-section")).toBeTruthy();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("should call the function to restore the header", () => {
|
|
207
|
+
defaultProps.header = 0;
|
|
208
|
+
|
|
209
|
+
render(
|
|
210
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
211
|
+
<Form {...defaultProps} />
|
|
212
|
+
</ThemeProvider>,
|
|
213
|
+
{ store }
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
expect(screen.getByText(/This page doesn\'t have a header. Click/i)).toBeInTheDocument();
|
|
217
|
+
const footerLink = screen.getByTestId("footer-link");
|
|
218
|
+
fireEvent.click(footerLink);
|
|
219
|
+
expect(restorePageNavigationActionMock).toBeCalled();
|
|
220
|
+
expect(restorePageNavigationActionMock).toBeCalledWith("footer");
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("should render the tabs", () => {
|
|
224
|
+
defaultProps.isPage = true;
|
|
225
|
+
defaultProps.isGlobal = true;
|
|
226
|
+
|
|
227
|
+
render(
|
|
228
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
229
|
+
<Form {...defaultProps} />
|
|
230
|
+
</ThemeProvider>,
|
|
231
|
+
{ store }
|
|
232
|
+
);
|
|
233
|
+
expect(screen.getByTestId("form-section")).toBeTruthy();
|
|
234
|
+
});
|
|
235
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { render, cleanup, screen, fireEvent } from "../../../../../config/jest/test-utils";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
import configureStore from "redux-mock-store";
|
|
7
|
+
import "@testing-library/jest-dom";
|
|
8
|
+
|
|
9
|
+
import { parseTheme } from "@ax/helpers";
|
|
10
|
+
import GlobalPageForm, { IGlobalPageFormProps } from "@ax/components/ConfigPanel/GlobalPageForm";
|
|
11
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
cleanup();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const middlewares: any = [];
|
|
18
|
+
const mockStore = configureStore(middlewares);
|
|
19
|
+
const updateEditorContentMock = jest.fn();
|
|
20
|
+
const initialStore = {
|
|
21
|
+
pageEditor: {
|
|
22
|
+
selectedContent: {
|
|
23
|
+
title: {
|
|
24
|
+
component: "Page",
|
|
25
|
+
templateType: "default",
|
|
26
|
+
},
|
|
27
|
+
template: {
|
|
28
|
+
type: "template",
|
|
29
|
+
templateType: "BasicTemplate",
|
|
30
|
+
heroSection: {
|
|
31
|
+
component: "Section",
|
|
32
|
+
name: "Hero Section",
|
|
33
|
+
modules: [],
|
|
34
|
+
sectionPosition: 1,
|
|
35
|
+
editorID: 2,
|
|
36
|
+
parentEditorID: 1,
|
|
37
|
+
key: "heroSection",
|
|
38
|
+
},
|
|
39
|
+
editorID: 1,
|
|
40
|
+
parentEditorID: 0,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
errors: [{}],
|
|
44
|
+
},
|
|
45
|
+
sites: {
|
|
46
|
+
currentSitePages: [
|
|
47
|
+
{
|
|
48
|
+
editorID: 1,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
app: {
|
|
53
|
+
lang: { locale: "es-ES", id: 0 },
|
|
54
|
+
},
|
|
55
|
+
dataPacks: {
|
|
56
|
+
templates: [{ id: "default" }, { id: "BasicTemplate" }],
|
|
57
|
+
activated: [],
|
|
58
|
+
},
|
|
59
|
+
menu: {
|
|
60
|
+
savedMenus: null,
|
|
61
|
+
},
|
|
62
|
+
navigationActions: {
|
|
63
|
+
updateEditorContent: updateEditorContentMock,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const store = mockStore(initialStore);
|
|
68
|
+
|
|
69
|
+
const defaultProps = mock<IGlobalPageFormProps>();
|
|
70
|
+
|
|
71
|
+
describe("GlobalPageForm component rendering", () => {
|
|
72
|
+
it("should render PageConnectedField", () => {
|
|
73
|
+
render(
|
|
74
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
75
|
+
<GlobalPageForm {...defaultProps} />
|
|
76
|
+
</ThemeProvider>,
|
|
77
|
+
{ store }
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const globalPageSection = screen.getByTestId("global-page-section");
|
|
81
|
+
expect(globalPageSection).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should call the function to restore the header", () => {
|
|
85
|
+
defaultProps.selectedTab = "content";
|
|
86
|
+
defaultProps.header = 0;
|
|
87
|
+
|
|
88
|
+
render(
|
|
89
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
90
|
+
<GlobalPageForm {...defaultProps} />
|
|
91
|
+
</ThemeProvider>,
|
|
92
|
+
{ store }
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
expect(screen.getByText(/This page doesn\'t have a header. Click/i)).toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("should render the component with no footer warning text", () => {
|
|
99
|
+
defaultProps.selectedTab = "content";
|
|
100
|
+
defaultProps.footer = 0;
|
|
101
|
+
|
|
102
|
+
render(
|
|
103
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
104
|
+
<GlobalPageForm {...defaultProps} />
|
|
105
|
+
</ThemeProvider>,
|
|
106
|
+
{ store }
|
|
107
|
+
);
|
|
108
|
+
expect(screen.getByText(/This page doesn\'t have a footer. Click/i)).toBeInTheDocument();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("should render the connectedField component", () => {
|
|
112
|
+
defaultProps.selectedTab = "config";
|
|
113
|
+
defaultProps.schema = {
|
|
114
|
+
schemaType: "module",
|
|
115
|
+
type: "Header",
|
|
116
|
+
title: "Header",
|
|
117
|
+
component: "header",
|
|
118
|
+
configTabs: [],
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
render(
|
|
122
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
123
|
+
<GlobalPageForm {...defaultProps} />
|
|
124
|
+
</ThemeProvider>,
|
|
125
|
+
{ store }
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const fieldsBehaviorWrapper = screen.getByTestId("fields-behavior-wrapper");
|
|
129
|
+
expect(fieldsBehaviorWrapper).toBeTruthy();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe("GlobalPageForm component rendering", () => {
|
|
134
|
+
it("should trigger handleClick", () => {
|
|
135
|
+
defaultProps.selectedTab = "content";
|
|
136
|
+
const getGlobalFromLocalPageActionMock = jest.fn();
|
|
137
|
+
const saveCurrentSiteInfoActionMock = jest.fn();
|
|
138
|
+
defaultProps.actions.saveCurrentSiteInfoAction = saveCurrentSiteInfoActionMock;
|
|
139
|
+
defaultProps.actions.getGlobalFromLocalPageAction = getGlobalFromLocalPageActionMock;
|
|
140
|
+
|
|
141
|
+
render(
|
|
142
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
143
|
+
<GlobalPageForm {...defaultProps} />
|
|
144
|
+
</ThemeProvider>,
|
|
145
|
+
{ store }
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const globalPageSection = screen.getByTestId("global-page-section");
|
|
149
|
+
expect(globalPageSection).toBeTruthy();
|
|
150
|
+
const editButton = screen.getByText<HTMLButtonElement>("Edit");
|
|
151
|
+
expect(editButton).toBeTruthy();
|
|
152
|
+
fireEvent.click(editButton);
|
|
153
|
+
expect(getGlobalFromLocalPageActionMock).toBeCalled();
|
|
154
|
+
expect(saveCurrentSiteInfoActionMock).toBeCalled();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should trigger handleRestoreHeader", () => {
|
|
158
|
+
defaultProps.selectedTab = "content";
|
|
159
|
+
defaultProps.header = 0;
|
|
160
|
+
const restorePageNavigationActionMock = jest.fn();
|
|
161
|
+
defaultProps.actions.restorePageNavigationAction = restorePageNavigationActionMock;
|
|
162
|
+
|
|
163
|
+
render(
|
|
164
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
165
|
+
<GlobalPageForm {...defaultProps} />
|
|
166
|
+
</ThemeProvider>,
|
|
167
|
+
{ store }
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
expect(screen.getByText(/This page doesn\'t have a header. Click/i)).toBeInTheDocument();
|
|
171
|
+
const headerLink = screen.getByTestId("header-link");
|
|
172
|
+
expect(headerLink).toBeTruthy();
|
|
173
|
+
fireEvent.click(headerLink);
|
|
174
|
+
expect(restorePageNavigationActionMock).toBeCalled();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("should trigger handleRestoreFooter", () => {
|
|
178
|
+
defaultProps.selectedTab = "content";
|
|
179
|
+
defaultProps.footer = 0;
|
|
180
|
+
const restorePageNavigationActionMock = jest.fn();
|
|
181
|
+
defaultProps.actions.restorePageNavigationAction = restorePageNavigationActionMock;
|
|
182
|
+
|
|
183
|
+
render(
|
|
184
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
185
|
+
<GlobalPageForm {...defaultProps} />
|
|
186
|
+
</ThemeProvider>,
|
|
187
|
+
{ store }
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
expect(screen.getByText(/This page doesn\'t have a footer. Click/i)).toBeInTheDocument();
|
|
191
|
+
const footerLink = screen.getByTestId("footer-link");
|
|
192
|
+
expect(footerLink).toBeTruthy();
|
|
193
|
+
fireEvent.click(footerLink);
|
|
194
|
+
expect(restorePageNavigationActionMock).toBeCalled();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { render, cleanup, screen, fireEvent } from "../../../../../config/jest/test-utils";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
import configureStore from "redux-mock-store";
|
|
7
|
+
import "@testing-library/jest-dom";
|
|
8
|
+
|
|
9
|
+
import { parseTheme } from "@ax/helpers";
|
|
10
|
+
import Header, { IHeaderProps } from "@ax/components/ConfigPanel/Header";
|
|
11
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
cleanup();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const middlewares: any = [];
|
|
18
|
+
const mockStore = configureStore(middlewares);
|
|
19
|
+
const updateEditorContentMock = jest.fn();
|
|
20
|
+
const initialStore = {
|
|
21
|
+
pageEditor: {
|
|
22
|
+
selectedContent: {
|
|
23
|
+
title: {
|
|
24
|
+
component: "Page",
|
|
25
|
+
templateType: "default",
|
|
26
|
+
},
|
|
27
|
+
template: {
|
|
28
|
+
type: "template",
|
|
29
|
+
templateType: "BasicTemplate",
|
|
30
|
+
heroSection: {
|
|
31
|
+
component: "Section",
|
|
32
|
+
name: "Hero Section",
|
|
33
|
+
modules: [],
|
|
34
|
+
sectionPosition: 1,
|
|
35
|
+
editorID: 2,
|
|
36
|
+
parentEditorID: 1,
|
|
37
|
+
key: "heroSection",
|
|
38
|
+
},
|
|
39
|
+
editorID: 1,
|
|
40
|
+
parentEditorID: 0,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
errors: [{}],
|
|
44
|
+
},
|
|
45
|
+
sites: {
|
|
46
|
+
currentSitePages: [
|
|
47
|
+
{
|
|
48
|
+
editorID: 1,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
app: {
|
|
53
|
+
lang: { locale: "es-ES", id: 0 },
|
|
54
|
+
},
|
|
55
|
+
dataPacks: {
|
|
56
|
+
templates: [{ id: "default" }, { id: "BasicTemplate" }],
|
|
57
|
+
activated: [],
|
|
58
|
+
},
|
|
59
|
+
menu: {
|
|
60
|
+
savedMenus: null,
|
|
61
|
+
},
|
|
62
|
+
navigationActions: {
|
|
63
|
+
updateEditorContent: updateEditorContentMock,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const store = mockStore(initialStore);
|
|
68
|
+
|
|
69
|
+
const defaultProps = mock<IHeaderProps>();
|
|
70
|
+
defaultProps.actions = {
|
|
71
|
+
duplicateModuleAction: jest.fn(),
|
|
72
|
+
deleteModuleAction: jest.fn(),
|
|
73
|
+
copyModuleAction: jest.fn(),
|
|
74
|
+
};
|
|
75
|
+
const setSelectedContentMock = defaultProps.setSelectedContent as jest.MockedFunction<(editorID: number) => void>;
|
|
76
|
+
|
|
77
|
+
defaultProps.schema = {
|
|
78
|
+
title: "Header",
|
|
79
|
+
component: "Header",
|
|
80
|
+
type: "header",
|
|
81
|
+
configTabs: [
|
|
82
|
+
{
|
|
83
|
+
title: "content",
|
|
84
|
+
fields: [
|
|
85
|
+
{
|
|
86
|
+
title: "Name",
|
|
87
|
+
key: "title",
|
|
88
|
+
type: "TextField",
|
|
89
|
+
mandatory: true,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
schemaType: "module",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
defaultProps.breadcrumb = [
|
|
98
|
+
{
|
|
99
|
+
editorID: 0,
|
|
100
|
+
component: "TextField",
|
|
101
|
+
displayName: "Texto",
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
defaultProps.activatedModules = ["TextField"];
|
|
106
|
+
|
|
107
|
+
describe("Header component rendering", () => {
|
|
108
|
+
it("should render component", () => {
|
|
109
|
+
render(
|
|
110
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
111
|
+
<Header {...defaultProps} />
|
|
112
|
+
</ThemeProvider>,
|
|
113
|
+
{ store }
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const headerConfigWrapper = screen.getByTestId("header-config-wrapper");
|
|
117
|
+
expect(headerConfigWrapper).toBeTruthy();
|
|
118
|
+
expect(screen.getByText(/Texto/i)).toBeInTheDocument();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("should render the actions menu when clicking the more info button", () => {
|
|
122
|
+
defaultProps.selectedParent = [];
|
|
123
|
+
|
|
124
|
+
render(
|
|
125
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
126
|
+
<Header {...defaultProps} />
|
|
127
|
+
</ThemeProvider>,
|
|
128
|
+
{ store }
|
|
129
|
+
);
|
|
130
|
+
expect(screen.getByTestId("action-menu-wrapper")).toBeTruthy();
|
|
131
|
+
const moreInfo = screen.getByTestId("more-info-button");
|
|
132
|
+
fireEvent.click(moreInfo);
|
|
133
|
+
const listItem = screen.getAllByTestId("action-menu-item");
|
|
134
|
+
expect(listItem).toHaveLength(3);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("should trigger the duplicate action", () => {
|
|
138
|
+
render(
|
|
139
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
140
|
+
<Header {...defaultProps} />
|
|
141
|
+
</ThemeProvider>,
|
|
142
|
+
{ store }
|
|
143
|
+
);
|
|
144
|
+
expect(screen.getByTestId("action-menu-wrapper")).toBeTruthy();
|
|
145
|
+
const moreInfo = screen.getByTestId("more-info-button");
|
|
146
|
+
fireEvent.click(moreInfo);
|
|
147
|
+
const listItem = screen.getAllByTestId("action-menu-item");
|
|
148
|
+
expect(listItem).toHaveLength(3);
|
|
149
|
+
fireEvent.click(listItem[0]);
|
|
150
|
+
expect(setSelectedContentMock).toBeCalled();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import { render, cleanup, screen, fireEvent } from "../../../../../../config/jest/test-utils";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
import configureStore from "redux-mock-store";
|
|
7
|
+
import "@testing-library/jest-dom";
|
|
8
|
+
import thunk from "redux-thunk";
|
|
9
|
+
|
|
10
|
+
import { parseTheme } from "@ax/helpers";
|
|
11
|
+
import Field, { IField, IStateProps, IDispatchProps } from "@ax/components/ConfigPanel/NavigationForm/Field";
|
|
12
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
cleanup();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const middlewares: any = [thunk];
|
|
19
|
+
const mockStore = configureStore(middlewares);
|
|
20
|
+
|
|
21
|
+
const initialStore = {
|
|
22
|
+
pageEditor: {
|
|
23
|
+
selectedContent: {
|
|
24
|
+
editorID: 0,
|
|
25
|
+
title: "selected content field",
|
|
26
|
+
id: 1,
|
|
27
|
+
component: "module",
|
|
28
|
+
},
|
|
29
|
+
editorContent: {
|
|
30
|
+
module: 0,
|
|
31
|
+
editorID: 0,
|
|
32
|
+
parentEditorID: null,
|
|
33
|
+
setAsHome: false,
|
|
34
|
+
headerConfig: "{}",
|
|
35
|
+
footerConfig: "{}",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
navigation: {
|
|
39
|
+
currentDefaultsContent: [
|
|
40
|
+
{
|
|
41
|
+
type: "module",
|
|
42
|
+
id: 2,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const store = mockStore(initialStore);
|
|
49
|
+
|
|
50
|
+
const defaultFieldProps = mock<IField>();
|
|
51
|
+
const defaultStateProps = mock<IStateProps>();
|
|
52
|
+
const defaultDispatchProps = mock<IDispatchProps>();
|
|
53
|
+
|
|
54
|
+
defaultFieldProps.type = "module";
|
|
55
|
+
|
|
56
|
+
const defaultProps = { ...defaultFieldProps, ...defaultStateProps, ...defaultDispatchProps };
|
|
57
|
+
|
|
58
|
+
describe("Field component rendering", () => {
|
|
59
|
+
it("should render component", () => {
|
|
60
|
+
render(
|
|
61
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
62
|
+
<Field {...defaultProps} />
|
|
63
|
+
</ThemeProvider>,
|
|
64
|
+
{ store }
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const componentWrapper = screen.getByText(/selected content field/i);
|
|
68
|
+
expect(componentWrapper).toBeInTheDocument();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should render SideModal because has multiple options", () => {
|
|
72
|
+
render(
|
|
73
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
74
|
+
<Field {...defaultProps} />
|
|
75
|
+
</ThemeProvider>,
|
|
76
|
+
{ store }
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const moreInfo = screen.getByTestId("more-info-button");
|
|
80
|
+
fireEvent.click(moreInfo);
|
|
81
|
+
const listItem = screen.getAllByTestId("action-menu-item");
|
|
82
|
+
expect(listItem).toHaveLength(2);
|
|
83
|
+
fireEvent.click(listItem[0]);
|
|
84
|
+
const sideModalWrapper = screen.getByTestId("side-modal");
|
|
85
|
+
expect(sideModalWrapper).toBeTruthy();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should trigger the handleRemove action", () => {
|
|
89
|
+
render(
|
|
90
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
91
|
+
<Field {...defaultProps} />
|
|
92
|
+
</ThemeProvider>,
|
|
93
|
+
{ store }
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const moreInfo = screen.getByTestId("more-info-button");
|
|
97
|
+
fireEvent.click(moreInfo);
|
|
98
|
+
const listItem = screen.getAllByTestId("action-menu-item");
|
|
99
|
+
expect(listItem).toHaveLength(2);
|
|
100
|
+
fireEvent.click(listItem[1]);
|
|
101
|
+
expect(store.getActions()).toContainEqual({
|
|
102
|
+
payload: { editorContent: initialStore.pageEditor.editorContent },
|
|
103
|
+
type: "pageEditor/SET_EDITOR_CONTENT",
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|