@griddo/ax 1.75.257 → 10.1.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/GlobalStore.tsx +3 -0
- package/src/__tests__/components/ConfigPanel/GlobalPageForm/GlobalPageForm.test.tsx +10 -1
- package/src/__tests__/components/Fields/IntegrationsField/IntegrationsField.test.tsx +391 -0
- package/src/__tests__/modules/Settings/Integrations/Integrations.test.tsx +167 -0
- package/src/api/index.tsx +3 -1
- package/src/api/integrations.tsx +153 -0
- package/src/api/sites.tsx +4 -2
- package/src/components/ActionMenu/index.tsx +3 -1
- package/src/components/ActionMenu/style.tsx +1 -0
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +4 -1
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +3 -0
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +11 -2
- package/src/components/FieldContainer/index.tsx +2 -1
- package/src/components/Fields/IntegrationsField/IntegrationItem/CustomPanel/index.tsx +101 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/CustomPanel/style.tsx +23 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/helpers.ts +31 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/index.tsx +120 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/style.tsx +23 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/atoms.tsx +27 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/index.tsx +132 -0
- package/src/components/Fields/IntegrationsField/IntegrationItem/style.tsx +63 -0
- package/src/components/Fields/IntegrationsField/PasteIntegrationButton/index.tsx +30 -0
- package/src/components/Fields/IntegrationsField/SideModal/SideModalOption/index.tsx +52 -0
- package/src/components/Fields/IntegrationsField/SideModal/SideModalOption/style.tsx +54 -0
- package/src/components/Fields/IntegrationsField/SideModal/index.tsx +57 -0
- package/src/components/Fields/IntegrationsField/SideModal/style.tsx +50 -0
- package/src/components/Fields/IntegrationsField/index.tsx +145 -0
- package/src/components/Fields/IntegrationsField/style.tsx +29 -0
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +11 -2
- package/src/components/Fields/TextArea/index.tsx +1 -1
- package/src/components/Fields/ToggleField/index.tsx +5 -3
- package/src/components/Fields/UrlField/index.tsx +8 -8
- package/src/components/Fields/index.tsx +2 -0
- package/src/components/Icon/components/Deactivate.js +14 -0
- package/src/components/Icon/components/Lock.js +15 -0
- package/src/components/Icon/svgs/Deactivate.svg +8 -0
- package/src/components/Icon/svgs/Lock.svg +6 -0
- package/src/components/PageFinder/SelectionListItem/index.tsx +46 -0
- package/src/components/PageFinder/SelectionListItem/style.tsx +46 -0
- package/src/components/{Fields/UrlField/PageFinder → PageFinder}/index.tsx +99 -21
- package/src/components/{Fields/UrlField/PageFinder → PageFinder}/style.tsx +14 -1
- package/src/components/TableFilters/CheckGroupFilter/index.tsx +83 -0
- package/src/components/TableFilters/CheckGroupFilter/style.tsx +40 -0
- package/src/components/TableFilters/StateFilter/index.tsx +66 -0
- package/src/components/TableFilters/StateFilter/style.tsx +30 -0
- package/src/components/TableFilters/index.tsx +4 -0
- package/src/components/index.tsx +9 -1
- package/src/containers/Integrations/actions.tsx +190 -0
- package/src/containers/Integrations/constants.tsx +14 -0
- package/src/containers/Integrations/index.tsx +4 -0
- package/src/containers/Integrations/interfaces.tsx +24 -0
- package/src/containers/Integrations/reducer.tsx +31 -0
- package/src/containers/PageEditor/actions.tsx +11 -1
- package/src/containers/PageEditor/utils.tsx +30 -2
- package/src/hooks/content.tsx +46 -2
- package/src/hooks/index.tsx +2 -1
- package/src/hooks/modals.tsx +4 -2
- package/src/modules/App/Routing/NavMenu/NavItem/style.tsx +13 -12
- package/src/modules/Content/index.tsx +5 -0
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/IntegrationsField/index.tsx +47 -0
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/IntegrationsField/style.tsx +7 -0
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/{Field → NavigationField}/index.tsx +2 -2
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/index.tsx +7 -7
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/index.tsx +1 -1
- package/src/modules/Settings/Integrations/BulkHeader/TableHeader/index.tsx +81 -0
- package/src/modules/Settings/Integrations/BulkHeader/TableHeader/style.tsx +35 -0
- package/src/modules/Settings/Integrations/BulkHeader/index.tsx +69 -0
- package/src/modules/Settings/Integrations/IntegrationForm/VariableItem/index.tsx +95 -0
- package/src/modules/Settings/Integrations/IntegrationForm/VariableItem/style.tsx +62 -0
- package/src/modules/Settings/Integrations/IntegrationForm/VariablePanel/index.tsx +138 -0
- package/src/modules/Settings/Integrations/IntegrationForm/VariablePanel/style.tsx +28 -0
- package/src/modules/Settings/Integrations/IntegrationForm/index.tsx +319 -0
- package/src/modules/Settings/Integrations/IntegrationForm/style.tsx +77 -0
- package/src/modules/Settings/Integrations/IntegrationItem/CopyModal/index.tsx +44 -0
- package/src/modules/Settings/Integrations/IntegrationItem/CopyModal/style.tsx +13 -0
- package/src/modules/Settings/Integrations/IntegrationItem/index.tsx +197 -0
- package/src/modules/Settings/Integrations/IntegrationItem/style.tsx +81 -0
- package/src/modules/Settings/Integrations/atoms.tsx +49 -0
- package/src/modules/Settings/Integrations/hooks.tsx +72 -0
- package/src/modules/Settings/Integrations/index.tsx +299 -0
- package/src/modules/Settings/Integrations/style.tsx +48 -0
- package/src/modules/Settings/Integrations/utils.tsx +39 -0
- package/src/routes/site.tsx +19 -0
- package/src/schemas/pages/Page.tsx +5 -0
- package/src/types/index.tsx +35 -0
- package/tsconfig.paths.json +2 -0
- package/src/components/Fields/UrlField/PageFinder/SelectionListItem/index.tsx +0 -34
- package/src/components/Fields/UrlField/PageFinder/SelectionListItem/style.tsx +0 -35
- /package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/{Field → NavigationField}/style.tsx +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "10.1.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -230,5 +230,5 @@
|
|
|
230
230
|
"publishConfig": {
|
|
231
231
|
"access": "public"
|
|
232
232
|
},
|
|
233
|
-
"gitHead": "
|
|
233
|
+
"gitHead": "9c3c0cf154929716b3f9782fb4d7b3b88d2988a2"
|
|
234
234
|
}
|
package/src/GlobalStore.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import { galleryReducer, galleryInitialState } from "./containers/Gallery/reduce
|
|
|
19
19
|
import { domainsReducer, domainsInitialState } from "./containers/Domains/reducer";
|
|
20
20
|
import { redirectsReducer, redirectsInitialState } from "./containers/Redirects/reducer";
|
|
21
21
|
import { analyticsReducer, analyticsInitialState } from "./containers/Analytics/reducer";
|
|
22
|
+
import { integrationsReducer, integrationsInitialState } from "./containers/Integrations/reducer";
|
|
22
23
|
import { LOGOUT } from "./containers/App/constants";
|
|
23
24
|
|
|
24
25
|
import { IRootState } from "@ax/types";
|
|
@@ -52,6 +53,7 @@ export class GlobalStore {
|
|
|
52
53
|
domains: domainsReducer as Reducer<any, Action<any>>,
|
|
53
54
|
redirects: redirectsReducer as Reducer<any, Action<any>>,
|
|
54
55
|
analytics: analyticsReducer as Reducer<any, Action<any>>,
|
|
56
|
+
integrations: integrationsReducer as Reducer<any, Action<any>>,
|
|
55
57
|
});
|
|
56
58
|
|
|
57
59
|
const rootReducer = (state: IRootState | undefined, action: any) => {
|
|
@@ -72,6 +74,7 @@ export class GlobalStore {
|
|
|
72
74
|
domains: domainsInitialState,
|
|
73
75
|
redirects: redirectsInitialState,
|
|
74
76
|
analytics: analyticsInitialState,
|
|
77
|
+
integrations: integrationsInitialState,
|
|
75
78
|
};
|
|
76
79
|
}
|
|
77
80
|
|
|
@@ -5,6 +5,7 @@ import { render, cleanup, screen, fireEvent } from "../../../../../config/jest/t
|
|
|
5
5
|
import { mock } from "jest-mock-extended";
|
|
6
6
|
import configureStore from "redux-mock-store";
|
|
7
7
|
import "@testing-library/jest-dom";
|
|
8
|
+
import thunk from "redux-thunk";
|
|
8
9
|
|
|
9
10
|
import { parseTheme } from "@ax/helpers";
|
|
10
11
|
import GlobalPageForm, { IGlobalPageFormProps } from "@ax/components/ConfigPanel/GlobalPageForm";
|
|
@@ -14,7 +15,7 @@ beforeEach(() => {
|
|
|
14
15
|
cleanup();
|
|
15
16
|
});
|
|
16
17
|
|
|
17
|
-
const middlewares: any = [];
|
|
18
|
+
const middlewares: any = [thunk];
|
|
18
19
|
const mockStore = configureStore(middlewares);
|
|
19
20
|
const updateEditorContentMock = jest.fn();
|
|
20
21
|
const initialStore = {
|
|
@@ -48,6 +49,9 @@ const initialStore = {
|
|
|
48
49
|
editorID: 1,
|
|
49
50
|
},
|
|
50
51
|
],
|
|
52
|
+
currentSiteInfo: {
|
|
53
|
+
id: 1,
|
|
54
|
+
},
|
|
51
55
|
},
|
|
52
56
|
app: {
|
|
53
57
|
lang: { locale: "es-ES", id: 0 },
|
|
@@ -62,6 +66,11 @@ const initialStore = {
|
|
|
62
66
|
navigationActions: {
|
|
63
67
|
updateEditorContent: updateEditorContentMock,
|
|
64
68
|
},
|
|
69
|
+
integrations: {
|
|
70
|
+
integrations: [],
|
|
71
|
+
totalItems: 0,
|
|
72
|
+
integrationCopy: null,
|
|
73
|
+
},
|
|
65
74
|
};
|
|
66
75
|
|
|
67
76
|
const store = mockStore(initialStore);
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "@testing-library/jest-dom";
|
|
3
|
+
import configureStore from "redux-mock-store";
|
|
4
|
+
import { ThemeProvider } from "styled-components";
|
|
5
|
+
import { mock } from "jest-mock-extended";
|
|
6
|
+
import axios from "axios";
|
|
7
|
+
import thunk from "redux-thunk";
|
|
8
|
+
import { Router } from "react-router-dom";
|
|
9
|
+
import { history } from "@ax/routes";
|
|
10
|
+
|
|
11
|
+
import { render, cleanup, act, screen, fireEvent } from "../../../../../config/jest/test-utils";
|
|
12
|
+
|
|
13
|
+
import IntegrationsField, { IIntegrationsFieldProps } from "@ax/components/Fields/IntegrationsField";
|
|
14
|
+
import { parseTheme } from "@ax/helpers";
|
|
15
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
16
|
+
|
|
17
|
+
afterEach(cleanup);
|
|
18
|
+
|
|
19
|
+
const middlewares: any = [thunk];
|
|
20
|
+
const mockStore = configureStore(middlewares);
|
|
21
|
+
|
|
22
|
+
jest.mock("axios");
|
|
23
|
+
const mockedAxios = axios as jest.MockedFunction<typeof axios>;
|
|
24
|
+
|
|
25
|
+
const defaultProps = mock<IIntegrationsFieldProps>();
|
|
26
|
+
defaultProps.site.id = 86;
|
|
27
|
+
|
|
28
|
+
const initialStore = {
|
|
29
|
+
dataPacks: { activated: [] },
|
|
30
|
+
pageEditor: { template: "" },
|
|
31
|
+
app: {
|
|
32
|
+
globalLangs: [
|
|
33
|
+
{
|
|
34
|
+
id: 4,
|
|
35
|
+
locale: "en_GB",
|
|
36
|
+
language: "English",
|
|
37
|
+
label: "EN",
|
|
38
|
+
isDefault: true,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 2,
|
|
42
|
+
locale: "es_ES",
|
|
43
|
+
language: "Spanish",
|
|
44
|
+
label: "ES",
|
|
45
|
+
isDefault: false,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
sites: {
|
|
50
|
+
currentSiteInfo: { id: 86 },
|
|
51
|
+
},
|
|
52
|
+
integrations: {
|
|
53
|
+
integrations: [
|
|
54
|
+
{
|
|
55
|
+
id: 22,
|
|
56
|
+
name: "Customer Support",
|
|
57
|
+
description: "This is the integration for Customer Support",
|
|
58
|
+
site: 86,
|
|
59
|
+
contentHead: "<script>console.log('Hello')</script>",
|
|
60
|
+
contentBody: "",
|
|
61
|
+
contentBodyPosition: "start",
|
|
62
|
+
contentPresence: {
|
|
63
|
+
presenceType: null,
|
|
64
|
+
relatedPages: null,
|
|
65
|
+
},
|
|
66
|
+
active: true,
|
|
67
|
+
relatedPages: [],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: 5,
|
|
71
|
+
name: "Reproductor",
|
|
72
|
+
description: "This is the integration for layers",
|
|
73
|
+
site: 86,
|
|
74
|
+
contentHead: "",
|
|
75
|
+
contentBody: "<script>console.log('Hello')</script>",
|
|
76
|
+
contentBodyPosition: "start",
|
|
77
|
+
contentPresence: {
|
|
78
|
+
presenceType: "all",
|
|
79
|
+
relatedPages: null,
|
|
80
|
+
},
|
|
81
|
+
active: true,
|
|
82
|
+
variables: [
|
|
83
|
+
{
|
|
84
|
+
id: 9,
|
|
85
|
+
variableName: "Pointer",
|
|
86
|
+
variableKey: "color",
|
|
87
|
+
defaultValue: "#FFFFF",
|
|
88
|
+
value: "#123456",
|
|
89
|
+
multilanguage: [],
|
|
90
|
+
isMultilanguage: false,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
relatedPages: [],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 4,
|
|
97
|
+
name: "Cupmaker",
|
|
98
|
+
description: "This is the integration for Cupmaker",
|
|
99
|
+
site: 86,
|
|
100
|
+
contentHead: "",
|
|
101
|
+
contentBody: "<script>console.log('Hello')</script>",
|
|
102
|
+
contentBodyPosition: "start",
|
|
103
|
+
contentPresence: {
|
|
104
|
+
presenceType: "page-specific",
|
|
105
|
+
relatedPages: null,
|
|
106
|
+
},
|
|
107
|
+
active: true,
|
|
108
|
+
variables: [
|
|
109
|
+
{
|
|
110
|
+
id: 3,
|
|
111
|
+
variableName: "Background",
|
|
112
|
+
variableKey: "color",
|
|
113
|
+
defaultValue: "#FFFFF",
|
|
114
|
+
value: "#111222",
|
|
115
|
+
multilanguage: [],
|
|
116
|
+
isMultilanguage: false,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 10,
|
|
120
|
+
variableName: "ColorCup",
|
|
121
|
+
variableKey: "color",
|
|
122
|
+
defaultValue: "#FFFFF",
|
|
123
|
+
value: "#000000",
|
|
124
|
+
multilanguage: [],
|
|
125
|
+
isMultilanguage: false,
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
relatedPages: [],
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
totalItems: 3,
|
|
132
|
+
integrationCopy: null,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
describe("IntegrationsField component rendering", () => {
|
|
137
|
+
test("should render the component IntegrationsField", async () => {
|
|
138
|
+
const initialState = { ...defaultProps };
|
|
139
|
+
defaultProps.value = [];
|
|
140
|
+
const store = mockStore(initialStore);
|
|
141
|
+
|
|
142
|
+
const data = {
|
|
143
|
+
data: { ...initialStore.integrations },
|
|
144
|
+
status: 200,
|
|
145
|
+
statusText: "Ok",
|
|
146
|
+
headers: {},
|
|
147
|
+
config: {},
|
|
148
|
+
};
|
|
149
|
+
mockedAxios.mockResolvedValue(data);
|
|
150
|
+
|
|
151
|
+
await act(async () => {
|
|
152
|
+
render(
|
|
153
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
154
|
+
<IntegrationsField {...{ ...initialState, ...defaultProps }} />
|
|
155
|
+
</ThemeProvider>,
|
|
156
|
+
{ store }
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
expect(screen.getByText("Third-Party Integration")).toBeTruthy();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("should render the component IntegrationsField with integrations", async () => {
|
|
164
|
+
const initialState = { ...defaultProps };
|
|
165
|
+
defaultProps.value = [...initialStore.integrations.integrations];
|
|
166
|
+
const store = mockStore(initialStore);
|
|
167
|
+
|
|
168
|
+
const data = {
|
|
169
|
+
data: { ...initialStore.integrations },
|
|
170
|
+
status: 200,
|
|
171
|
+
statusText: "Ok",
|
|
172
|
+
headers: {},
|
|
173
|
+
config: {},
|
|
174
|
+
};
|
|
175
|
+
mockedAxios.mockResolvedValue(data);
|
|
176
|
+
|
|
177
|
+
await act(async () => {
|
|
178
|
+
render(
|
|
179
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
180
|
+
<IntegrationsField {...{ ...initialState, ...defaultProps }} />
|
|
181
|
+
</ThemeProvider>,
|
|
182
|
+
{ store }
|
|
183
|
+
);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
expect(screen.getAllByTestId("integration-item").length).toBe(3);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test("should render the component IntegrationsField with custom code integration", async () => {
|
|
190
|
+
const initialState = { ...defaultProps };
|
|
191
|
+
|
|
192
|
+
const customOption = {
|
|
193
|
+
name: "",
|
|
194
|
+
contentHead: "",
|
|
195
|
+
contentBody: "",
|
|
196
|
+
contentBodyPosition: null,
|
|
197
|
+
contentPresence: { presenceType: "page-manual", relatedPages: null },
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
defaultProps.value = [...initialStore.integrations.integrations, customOption];
|
|
201
|
+
const store = mockStore(initialStore);
|
|
202
|
+
|
|
203
|
+
const data = {
|
|
204
|
+
data: { ...initialStore.integrations },
|
|
205
|
+
status: 200,
|
|
206
|
+
statusText: "Ok",
|
|
207
|
+
headers: {},
|
|
208
|
+
config: {},
|
|
209
|
+
};
|
|
210
|
+
mockedAxios.mockResolvedValue(data);
|
|
211
|
+
|
|
212
|
+
await act(async () => {
|
|
213
|
+
render(
|
|
214
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
215
|
+
<IntegrationsField {...{ ...initialState, ...defaultProps }} />
|
|
216
|
+
</ThemeProvider>,
|
|
217
|
+
{ store }
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
expect(screen.getAllByTestId("integration-item").length).toBe(4);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe("Events", () => {
|
|
226
|
+
test("should delete a integration", async () => {
|
|
227
|
+
const initialState = { ...defaultProps };
|
|
228
|
+
defaultProps.value = [...initialStore.integrations.integrations];
|
|
229
|
+
const store = mockStore(initialStore);
|
|
230
|
+
const onChange = jest.fn();
|
|
231
|
+
|
|
232
|
+
const data = {
|
|
233
|
+
data: { ...initialStore.integrations },
|
|
234
|
+
status: 200,
|
|
235
|
+
statusText: "Ok",
|
|
236
|
+
headers: {},
|
|
237
|
+
config: {},
|
|
238
|
+
};
|
|
239
|
+
mockedAxios.mockResolvedValue(data);
|
|
240
|
+
|
|
241
|
+
await act(async () => {
|
|
242
|
+
render(
|
|
243
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
244
|
+
<IntegrationsField {...{ ...initialState, ...defaultProps }} onChange={onChange} />
|
|
245
|
+
</ThemeProvider>,
|
|
246
|
+
{ store }
|
|
247
|
+
);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
expect(screen.getAllByTestId("integration-item").length).toBe(3);
|
|
251
|
+
|
|
252
|
+
const floatingMenuButtons = screen.getAllByTestId("floating-menu-button");
|
|
253
|
+
fireEvent.click(floatingMenuButtons[1]);
|
|
254
|
+
const actionMenu = screen.getByTestId("action-menu-item");
|
|
255
|
+
fireEvent.click(actionMenu);
|
|
256
|
+
|
|
257
|
+
const buttonsDefault = screen.getAllByTestId("button-default");
|
|
258
|
+
fireEvent.click(buttonsDefault[3]);
|
|
259
|
+
|
|
260
|
+
const integrationsWithDeletion = initialStore.integrations.integrations.slice(0, 2);
|
|
261
|
+
|
|
262
|
+
expect(onChange).toHaveBeenLastCalledWith(integrationsWithDeletion);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("should add an integration", async () => {
|
|
266
|
+
const initialState = { ...defaultProps };
|
|
267
|
+
defaultProps.value = [];
|
|
268
|
+
const store = mockStore(initialStore);
|
|
269
|
+
const onChange = jest.fn();
|
|
270
|
+
|
|
271
|
+
const data = {
|
|
272
|
+
data: { ...initialStore.integrations },
|
|
273
|
+
status: 200,
|
|
274
|
+
statusText: "Ok",
|
|
275
|
+
headers: {},
|
|
276
|
+
config: {},
|
|
277
|
+
};
|
|
278
|
+
mockedAxios.mockResolvedValue(data);
|
|
279
|
+
|
|
280
|
+
await act(async () => {
|
|
281
|
+
render(
|
|
282
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
283
|
+
<IntegrationsField {...{ ...initialState, ...defaultProps }} onChange={onChange} />
|
|
284
|
+
</ThemeProvider>,
|
|
285
|
+
{ store }
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
const iconActionComponent = screen.getByTestId("icon-action-component");
|
|
290
|
+
fireEvent.click(iconActionComponent);
|
|
291
|
+
|
|
292
|
+
const integrationSideModalOption = screen.getAllByTestId("integration-side-modal-option");
|
|
293
|
+
fireEvent.click(integrationSideModalOption[0]);
|
|
294
|
+
|
|
295
|
+
const integrationAdded = initialStore.integrations.integrations.slice(0, 1);
|
|
296
|
+
|
|
297
|
+
expect(onChange).toHaveBeenLastCalledWith(integrationAdded);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test("should add an custom code integration", async () => {
|
|
301
|
+
const initialState = { ...defaultProps };
|
|
302
|
+
defaultProps.value = [];
|
|
303
|
+
const store = mockStore(initialStore);
|
|
304
|
+
const onChange = jest.fn();
|
|
305
|
+
|
|
306
|
+
const data = {
|
|
307
|
+
data: { ...initialStore.integrations },
|
|
308
|
+
status: 200,
|
|
309
|
+
statusText: "Ok",
|
|
310
|
+
headers: {},
|
|
311
|
+
config: {},
|
|
312
|
+
};
|
|
313
|
+
mockedAxios.mockResolvedValue(data);
|
|
314
|
+
|
|
315
|
+
await act(async () => {
|
|
316
|
+
render(
|
|
317
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
318
|
+
<IntegrationsField {...{ ...initialState, ...defaultProps }} onChange={onChange} />
|
|
319
|
+
</ThemeProvider>,
|
|
320
|
+
{ store }
|
|
321
|
+
);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
const iconActionComponent = screen.getByTestId("icon-action-component");
|
|
325
|
+
fireEvent.click(iconActionComponent);
|
|
326
|
+
|
|
327
|
+
const integrationSideModalOption = screen.getAllByTestId("integration-side-modal-option");
|
|
328
|
+
fireEvent.click(integrationSideModalOption[1]);
|
|
329
|
+
|
|
330
|
+
const customOption = {
|
|
331
|
+
active: true,
|
|
332
|
+
name: "",
|
|
333
|
+
contentHead: "",
|
|
334
|
+
contentBody: "",
|
|
335
|
+
contentBodyPosition: null,
|
|
336
|
+
contentPresence: { presenceType: "page-custom", relatedPages: null },
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
expect(onChange).toHaveBeenLastCalledWith([customOption]);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
test("should paste a custom code integration", async () => {
|
|
343
|
+
const initialState = { ...defaultProps };
|
|
344
|
+
defaultProps.value = [];
|
|
345
|
+
const _initialStore: any = { ...initialStore };
|
|
346
|
+
_initialStore.integrations.integrationCopy = {
|
|
347
|
+
date: new Date(),
|
|
348
|
+
integration: {
|
|
349
|
+
id: 29,
|
|
350
|
+
name: "My custom integration",
|
|
351
|
+
description: "This is a custom integration",
|
|
352
|
+
site: 86,
|
|
353
|
+
contentHead: "<script>console.log('Hello, world!')</script>",
|
|
354
|
+
contentBody: "",
|
|
355
|
+
contentBodyPosition: "start",
|
|
356
|
+
contentPresence: {
|
|
357
|
+
presenceType: "page-custom",
|
|
358
|
+
relatedPages: null,
|
|
359
|
+
},
|
|
360
|
+
active: true,
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
const store = mockStore(initialStore);
|
|
364
|
+
const onChange = jest.fn();
|
|
365
|
+
|
|
366
|
+
const data = {
|
|
367
|
+
data: { ...initialStore.integrations },
|
|
368
|
+
status: 200,
|
|
369
|
+
statusText: "Ok",
|
|
370
|
+
headers: {},
|
|
371
|
+
config: {},
|
|
372
|
+
};
|
|
373
|
+
mockedAxios.mockResolvedValue(data);
|
|
374
|
+
|
|
375
|
+
await act(async () => {
|
|
376
|
+
render(
|
|
377
|
+
<Router history={history}>
|
|
378
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
379
|
+
<IntegrationsField {...{ ...initialState, ...defaultProps }} onChange={onChange} />
|
|
380
|
+
</ThemeProvider>
|
|
381
|
+
</Router>,
|
|
382
|
+
{ store }
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
const iconActionComponents = screen.getAllByTestId("icon-action-component");
|
|
387
|
+
fireEvent.click(iconActionComponents[0]);
|
|
388
|
+
|
|
389
|
+
expect(onChange).toHaveBeenLastCalledWith([_initialStore.integrations.integrationCopy.integration]);
|
|
390
|
+
});
|
|
391
|
+
});
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { parseTheme } from "@ax/helpers";
|
|
4
|
+
import { mock } from "jest-mock-extended";
|
|
5
|
+
import configureStore from "redux-mock-store";
|
|
6
|
+
import thunk from "redux-thunk";
|
|
7
|
+
import { Router } from "react-router-dom";
|
|
8
|
+
|
|
9
|
+
import history from "@ax/routes/history";
|
|
10
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
11
|
+
import Integrations, { IIntegrationsProps } from "@ax/modules/Settings/Integrations";
|
|
12
|
+
import { render, cleanup, screen, act } from "../../../../../config/jest/test-utils";
|
|
13
|
+
|
|
14
|
+
afterEach(cleanup);
|
|
15
|
+
|
|
16
|
+
const defaultProps = mock<IIntegrationsProps>();
|
|
17
|
+
|
|
18
|
+
describe("Component rendering", () => {
|
|
19
|
+
it("should render the component with integrations list empty", async () => {
|
|
20
|
+
const initialStore = {
|
|
21
|
+
integrations: {
|
|
22
|
+
integrations: [],
|
|
23
|
+
totalItems: 0,
|
|
24
|
+
},
|
|
25
|
+
app: { isLoading: false },
|
|
26
|
+
sites: { currentSiteInfo: { id: 85 } },
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const middlewares: any = [thunk];
|
|
30
|
+
const mockStore = configureStore(middlewares);
|
|
31
|
+
const store = mockStore(initialStore);
|
|
32
|
+
|
|
33
|
+
const initialState = { ...initialStore, ...defaultProps };
|
|
34
|
+
|
|
35
|
+
await act(async () => {
|
|
36
|
+
render(
|
|
37
|
+
<Router history={history}>
|
|
38
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
39
|
+
<Integrations {...initialState} />
|
|
40
|
+
</ThemeProvider>
|
|
41
|
+
</Router>,
|
|
42
|
+
{ store }
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const integrationsMainWrapper = screen.getByTestId("integrations-main-wrapper");
|
|
47
|
+
|
|
48
|
+
expect(integrationsMainWrapper).toBeTruthy();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should render the component with items in the list", async () => {
|
|
52
|
+
const initialStore = {
|
|
53
|
+
integrations: {
|
|
54
|
+
integrations: [
|
|
55
|
+
{
|
|
56
|
+
id: 28,
|
|
57
|
+
name: "Chatbot",
|
|
58
|
+
description: "This is the integration for cookies",
|
|
59
|
+
site: 85,
|
|
60
|
+
contentHead: null,
|
|
61
|
+
contentBody: "<script>console.log('Hello')</script>",
|
|
62
|
+
contentBodyPosition: "start",
|
|
63
|
+
contentPresence: {
|
|
64
|
+
presenceType: null,
|
|
65
|
+
relatedPages: null,
|
|
66
|
+
},
|
|
67
|
+
active: false,
|
|
68
|
+
variables: [
|
|
69
|
+
{
|
|
70
|
+
id: 38,
|
|
71
|
+
variableName: "Nuevo1",
|
|
72
|
+
variableKey: "color",
|
|
73
|
+
defaultValue: "#FFFFF",
|
|
74
|
+
multilanguage: null,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 39,
|
|
78
|
+
variableName: "Nuevo3",
|
|
79
|
+
variableKey: "color",
|
|
80
|
+
defaultValue: "#FFFFF",
|
|
81
|
+
multilanguage: null,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 19,
|
|
87
|
+
name: "Service 1",
|
|
88
|
+
description: "This is the integration for Service",
|
|
89
|
+
site: 85,
|
|
90
|
+
contentHead: null,
|
|
91
|
+
contentBody: "<script>console.log('Hello')</script>",
|
|
92
|
+
contentBodyPosition: "start",
|
|
93
|
+
contentPresence: {
|
|
94
|
+
presenceType: "page-specific",
|
|
95
|
+
relatedPages: [3347],
|
|
96
|
+
},
|
|
97
|
+
active: false,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 20,
|
|
101
|
+
name: "Service 2",
|
|
102
|
+
description: "This is the integration for Service",
|
|
103
|
+
site: 85,
|
|
104
|
+
contentHead: null,
|
|
105
|
+
contentBody: "<script>console.log('Hello')</script>",
|
|
106
|
+
contentBodyPosition: "start",
|
|
107
|
+
contentPresence: {
|
|
108
|
+
presenceType: "all",
|
|
109
|
+
relatedPages: null,
|
|
110
|
+
},
|
|
111
|
+
active: false,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: 21,
|
|
115
|
+
name: "Service 3",
|
|
116
|
+
description: "This is the integration for Service",
|
|
117
|
+
site: 85,
|
|
118
|
+
contentHead: null,
|
|
119
|
+
contentBody: "<script>console.log('Hello')</script>",
|
|
120
|
+
contentBodyPosition: "start",
|
|
121
|
+
contentPresence: {
|
|
122
|
+
presenceType: "page-specific",
|
|
123
|
+
relatedPages: null,
|
|
124
|
+
},
|
|
125
|
+
active: true,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: 22,
|
|
129
|
+
name: "Service 4",
|
|
130
|
+
description: "This is the integration for Service",
|
|
131
|
+
site: 85,
|
|
132
|
+
contentHead: null,
|
|
133
|
+
contentBody: "<script>console.log('Hello')</script>",
|
|
134
|
+
contentBodyPosition: "start",
|
|
135
|
+
contentPresence: {
|
|
136
|
+
presenceType: undefined,
|
|
137
|
+
relatedPages: undefined,
|
|
138
|
+
},
|
|
139
|
+
active: true,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
totalItems: 5,
|
|
143
|
+
},
|
|
144
|
+
app: { isLoading: false },
|
|
145
|
+
sites: { currentSiteInfo: { id: 85 } },
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const middlewares: any = [thunk];
|
|
149
|
+
const mockStore = configureStore(middlewares);
|
|
150
|
+
const store = mockStore(initialStore);
|
|
151
|
+
|
|
152
|
+
const initialState = { ...initialStore, ...defaultProps };
|
|
153
|
+
|
|
154
|
+
const Component = (
|
|
155
|
+
<Router history={history}>
|
|
156
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
157
|
+
<Integrations {...initialState} />
|
|
158
|
+
</ThemeProvider>
|
|
159
|
+
</Router>
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
render(Component, { store });
|
|
163
|
+
|
|
164
|
+
expect(await screen.findByText("Chatbot")).toBeTruthy();
|
|
165
|
+
expect(screen.getAllByTestId("integration-item-row").length).toBe(5);
|
|
166
|
+
});
|
|
167
|
+
});
|
package/src/api/index.tsx
CHANGED
|
@@ -16,6 +16,7 @@ import users from "./users";
|
|
|
16
16
|
import domains from "./domains";
|
|
17
17
|
import redirects from "./redirects";
|
|
18
18
|
import analytics from "./analytics";
|
|
19
|
+
import integrations from "./integrations";
|
|
19
20
|
|
|
20
21
|
export {
|
|
21
22
|
sites,
|
|
@@ -35,5 +36,6 @@ export {
|
|
|
35
36
|
users,
|
|
36
37
|
domains,
|
|
37
38
|
redirects,
|
|
38
|
-
analytics
|
|
39
|
+
analytics,
|
|
40
|
+
integrations,
|
|
39
41
|
};
|