@griddo/ax 1.75.35 → 1.75.37

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "1.75.35",
4
+ "version": "1.75.37",
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": "b07f3c7a091191e2bcc82ff31bb034456d68f4d0"
233
+ "gitHead": "41e8c3e94e959bdf33b22b44523533673d1a59f2"
234
234
  }
@@ -3,6 +3,36 @@ import { structuredDataMock } from "./../store/SitesList";
3
3
  export const sitesResponse = {
4
4
  data: {
5
5
  totalItems: 22,
6
+ items: [
7
+ {
8
+ "id": 4,
9
+ "locale": "en_GB",
10
+ "language": "English",
11
+ "path": "/gonzalo-h",
12
+ "domain": {
13
+ "id": 1,
14
+ "url": "//cx.dev.griddo.io/pre-griddo",
15
+ "slug": "/pre-griddo"
16
+ },
17
+ "label": "EN",
18
+ "isDefault": true,
19
+ "home": "//cx.dev.griddo.io/pre-griddo/gonzalo-h"
20
+ },
21
+ {
22
+ "id": 2,
23
+ "locale": "es_ES",
24
+ "language": "Spanish",
25
+ "path": "/gonzalo-h/es",
26
+ "domain": {
27
+ "id": 1,
28
+ "url": "//cx.dev.griddo.io/pre-griddo",
29
+ "slug": "/pre-griddo"
30
+ },
31
+ "label": "ES",
32
+ "isDefault": false,
33
+ "home": "//cx.dev.griddo.io/pre-griddo/gonzalo-h/es"
34
+ }
35
+ ],
6
36
  page: "1",
7
37
  recentSites: [
8
38
  { siteId: 1, lastAccess: "2022-09-12T13:28:31.000Z" },
@@ -0,0 +1,29 @@
1
+ import { structuredDataMock } from "../store/SitesList";
2
+
3
+ export const sitesResponseCategories = {
4
+ data: [
5
+ {
6
+ "id": "Accordion",
7
+ "title": "Accordion",
8
+ "category": "interactive",
9
+ "thumbnails": {
10
+ "default-theme": {},
11
+ "griddo-alt-theme": {}
12
+ },
13
+ "dataPacks": null,
14
+ "type": {}
15
+ }
16
+ ],
17
+ status: 200,
18
+ statusText: "Ok",
19
+ headers: {},
20
+ config: {},
21
+ };
22
+
23
+ export const structuredDataResponse = {
24
+ data: structuredDataMock,
25
+ status: 200,
26
+ statusText: "Ok",
27
+ headers: {},
28
+ config: {},
29
+ };
@@ -0,0 +1,175 @@
1
+ import { structuredDataMock } from "../store/SitesList";
2
+
3
+ export const sitesResponseDataPack = {
4
+ data: {
5
+ totalItems: 1,
6
+ items: [
7
+ {
8
+ "id": "ARTICLES",
9
+ "title": "Articles",
10
+ "category": {
11
+ "id": "ARTICLES",
12
+ "label": "Articles"
13
+ },
14
+ "description": "Allows you to hightlight articles",
15
+ "image": "https://res.cloudinary.com/thesaurus-cms/image/upload/griddo-components/data-packs-thumbnails/articles.png",
16
+ "templates": [
17
+ {
18
+ "id": "ArticlesList",
19
+ "title": "Articles List",
20
+ "thumbnails": {
21
+ "1x": "https://res.cloudinary.com/thesaurus-cms/image/upload/griddo-components/thumbnails/ArticlesList",
22
+ "2x": "https://res.cloudinary.com/thesaurus-cms/image/upload/griddo-components/thumbnails/ArticlesList@2x"
23
+ },
24
+ "dataPacks": [
25
+ "ARTICLES"
26
+ ],
27
+ "type": {
28
+ "label": "Articles",
29
+ "value": "articles",
30
+ "mode": "list"
31
+ }
32
+ }
33
+ ],
34
+ "modules": [
35
+ {
36
+ "id": "ArticlesDistributor",
37
+ "title": "Articles Distributor",
38
+ "category": "articlesAndEvents",
39
+ "thumbnails": {
40
+ "1x": "https://res.cloudinary.com/thesaurus-cms/image/upload/griddo-components/thumbnails/ArticlesDistributor",
41
+ "2x": "https://res.cloudinary.com/thesaurus-cms/image/upload/griddo-components/thumbnails/ArticlesDistributor@2x"
42
+ },
43
+ "dataPacks": [
44
+ "ARTICLES"
45
+ ],
46
+ "type": {},
47
+ "sectionList": {
48
+ "BasicTemplate": [
49
+ "mainContent"
50
+ ],
51
+ "NewsDetail": [
52
+ "closureContent"
53
+ ],
54
+ "NewsList": [
55
+ "relatedContent"
56
+ ],
57
+ "SitemapTemplate": [
58
+ "relatedContent",
59
+ "closureContent"
60
+ ],
61
+ "StoryDetail": [
62
+ "mainContent",
63
+ "relatedContent"
64
+ ]
65
+ }
66
+ }
67
+ ],
68
+ "categories": [
69
+ {
70
+ "id": "STORY_TYPE",
71
+ "title": "Story Type",
72
+ "dataPacks": ["STORIES"],
73
+ "local": false,
74
+ "taxonomy": true,
75
+ "fromPage": false,
76
+ "translate": true,
77
+ "schema": null,
78
+ "clone": null,
79
+ "defaults": null,
80
+ "editable": true,
81
+ },
82
+ ],
83
+ "structuredData": [
84
+ {
85
+ "id": "ARTICLES",
86
+ "title": "Articles",
87
+ "dataPacks": [
88
+ "ARTICLES"
89
+ ],
90
+ "local": false,
91
+ "fromPage": false,
92
+ "relatedCategories": []
93
+ }
94
+ ],
95
+ "activated": true,
96
+ "config": {
97
+ "defaultParent": null,
98
+ "indexDefault": true,
99
+ "modifiableOnPage": false,
100
+ "templates": {
101
+ "ArticlesList": {
102
+ "defaultHeader": 178,
103
+ "defaultFooter": 78,
104
+ "integrations": [
105
+ {
106
+ "id": 91,
107
+ "name": "Script",
108
+ "description": "Super script",
109
+ "site": null,
110
+ "contentHead": "<script>alert(\"hola\")</script>",
111
+ "contentBody": "",
112
+ "contentBodyPosition": "start",
113
+ "contentPresence": {
114
+ "presenceType": "page-specific",
115
+ "relatedPages": [
116
+ 4111,
117
+ 4111
118
+ ]
119
+ },
120
+ "active": true,
121
+ "variables": [
122
+ {
123
+ "id": 93,
124
+ "variableName": "v1",
125
+ "variableKey": "key",
126
+ "isMultilanguage": true,
127
+ "defaultValue": "",
128
+ "multilanguage": [
129
+ {
130
+ "id": 54,
131
+ "languageId": 4,
132
+ "value": null
133
+ },
134
+ {
135
+ "id": 55,
136
+ "languageId": 2,
137
+ "value": null
138
+ }
139
+ ]
140
+ }
141
+ ]
142
+ },
143
+ {
144
+ "name": "codigoCustom",
145
+ "contentHead": "",
146
+ "contentBody": "",
147
+ "contentBodyPosition": null,
148
+ "contentPresence": {
149
+ "presenceType": "page-manual",
150
+ "relatedPages": null
151
+ }
152
+ }
153
+ ]
154
+ }
155
+ },
156
+ "defaultHeader": null,
157
+ "defaultFooter": null
158
+ }
159
+ }
160
+ ],
161
+ page: "1",
162
+ },
163
+ status: 200,
164
+ statusText: "Ok",
165
+ headers: {},
166
+ config: {},
167
+ };
168
+
169
+ export const structuredDataResponse = {
170
+ data: structuredDataMock,
171
+ status: 200,
172
+ statusText: "Ok",
173
+ headers: {},
174
+ config: {},
175
+ };
@@ -0,0 +1,22 @@
1
+ import { structuredDataMock } from "../store/SitesList";
2
+
3
+ export const sitesOptions = {
4
+ data: [
5
+ {
6
+ "value": 80,
7
+ "label": "DEMO SITE"
8
+ }
9
+ ],
10
+ status: 200,
11
+ statusText: "Ok",
12
+ headers: {},
13
+ config: {},
14
+ };
15
+
16
+ export const structuredDataResponse = {
17
+ data: structuredDataMock,
18
+ status: 200,
19
+ statusText: "Ok",
20
+ headers: {},
21
+ config: {},
22
+ };
@@ -0,0 +1,90 @@
1
+ import * as React from "react";
2
+
3
+ import { ThemeProvider } from "styled-components";
4
+ import { render, cleanup, screen, fireEvent } from "@testing-library/react";
5
+ import { mock } from "jest-mock-extended";
6
+ import "@testing-library/jest-dom";
7
+
8
+ import { parseTheme } from "@ax/helpers";
9
+ import DragAndDrop, { IDragAndDropProps } from "@ax/components/DragAndDrop";
10
+ import globalTheme from "@ax/themes/theme.json";
11
+
12
+ afterEach(cleanup);
13
+
14
+ const defaultProps = mock<IDragAndDropProps>();
15
+ const onDropMock = defaultProps.onDrop as jest.MockedFunction<(e: React.DragEvent<HTMLDivElement>) => void>;
16
+ const onDragOverMock = defaultProps.onDragOver as jest.MockedFunction<(e: React.DragEvent<HTMLDivElement>) => void>;
17
+ const onDragEnterMock = defaultProps.onDragEnter as jest.MockedFunction<(e: React.DragEvent<HTMLDivElement>) => void>;
18
+ const onDragLeaveMock = defaultProps.onDragLeave as jest.MockedFunction<(e: React.DragEvent<HTMLDivElement>) => void>;
19
+ defaultProps.children = React.createElement("button", null, "back button");
20
+
21
+ describe("ErrorCenter component rendering", () => {
22
+ it("should render the component", () => {
23
+ render(
24
+ <ThemeProvider theme={parseTheme(globalTheme)}>
25
+ <DragAndDrop {...defaultProps} />
26
+ </ThemeProvider>
27
+ );
28
+
29
+ expect(screen.getByTestId("drag-drop-wrapper")).toBeTruthy();
30
+ });
31
+
32
+ it("should call the onDrop", () => {
33
+ render(
34
+ <ThemeProvider theme={parseTheme(globalTheme)}>
35
+ <DragAndDrop {...defaultProps} />
36
+ </ThemeProvider>
37
+ );
38
+
39
+ const dragDropWrapper = screen.getByTestId("drag-drop-wrapper");
40
+ fireEvent.drop(dragDropWrapper);
41
+ expect(onDropMock).toBeCalled();
42
+ });
43
+
44
+ it("should call the onDragOver", () => {
45
+ render(
46
+ <ThemeProvider theme={parseTheme(globalTheme)}>
47
+ <DragAndDrop {...defaultProps} />
48
+ </ThemeProvider>
49
+ );
50
+
51
+ const dragDropWrapper = screen.getByTestId("drag-drop-wrapper");
52
+ fireEvent.dragOver(dragDropWrapper);
53
+ expect(onDragOverMock).toBeCalled();
54
+ });
55
+
56
+ it("should call the onDragEnter", () => {
57
+ render(
58
+ <ThemeProvider theme={parseTheme(globalTheme)}>
59
+ <DragAndDrop {...defaultProps} />
60
+ </ThemeProvider>
61
+ );
62
+
63
+ const dragDropWrapper = screen.getByTestId("drag-drop-wrapper");
64
+ fireEvent.dragEnter(dragDropWrapper);
65
+ expect(onDragEnterMock).toBeCalled();
66
+ });
67
+
68
+ it("should call the onDragLeave", () => {
69
+ render(
70
+ <ThemeProvider theme={parseTheme(globalTheme)}>
71
+ <DragAndDrop {...defaultProps} />
72
+ </ThemeProvider>
73
+ );
74
+
75
+ const dragDropWrapper = screen.getByTestId("drag-drop-wrapper");
76
+ fireEvent.dragLeave(dragDropWrapper);
77
+ expect(onDragLeaveMock).toBeCalled();
78
+ });
79
+
80
+ it("should render the children", () => {
81
+ render(
82
+ <ThemeProvider theme={parseTheme(globalTheme)}>
83
+ <DragAndDrop {...defaultProps} />
84
+ </ThemeProvider>
85
+ );
86
+
87
+ const buttonText = screen.getByText("back button");
88
+ expect(buttonText).toBeInTheDocument();
89
+ });
90
+ });
@@ -0,0 +1,117 @@
1
+ import React from "react";
2
+
3
+ import { ThemeProvider } from "styled-components";
4
+ import { mock } from "jest-mock-extended";
5
+ import { render, screen, cleanup, fireEvent } from "@testing-library/react";
6
+ import "@testing-library/jest-dom";
7
+
8
+ import Button, { IButtonProps } from "@ax/components/Button";
9
+ import { parseTheme } from "@ax/helpers";
10
+ import globalTheme from "@ax/themes/theme.json";
11
+
12
+ afterEach(cleanup);
13
+
14
+ const defaultProps = mock<IButtonProps>();
15
+
16
+ describe("Button component rendering", () => {
17
+ it("should render the component with the default button and no icon", () => {
18
+ render(
19
+ <ThemeProvider theme={parseTheme(globalTheme)}>
20
+ <Button {...defaultProps} />
21
+ </ThemeProvider>
22
+ );
23
+
24
+ const buttonElement = screen.getByTestId("button-default");
25
+ expect(buttonElement).toBeTruthy();
26
+ const iconElement = screen.queryByTestId("icon-component");
27
+ expect(iconElement).not.toBeTruthy();
28
+ });
29
+
30
+ it("should render the component with the text button and an icon", () => {
31
+ defaultProps.buttonStyle = "text";
32
+ defaultProps.icon = "delete";
33
+
34
+ render(
35
+ <ThemeProvider theme={parseTheme(globalTheme)}>
36
+ <Button {...defaultProps} />
37
+ </ThemeProvider>
38
+ );
39
+
40
+ const buttonElement = screen.getByTestId("button-text");
41
+ expect(buttonElement).toBeTruthy();
42
+ const iconElement = screen.getByTestId("icon-component");
43
+ expect(iconElement).toBeTruthy();
44
+ });
45
+
46
+ it("should render the component with the line button", () => {
47
+ defaultProps.buttonStyle = "line";
48
+ render(
49
+ <ThemeProvider theme={parseTheme(globalTheme)}>
50
+ <Button {...defaultProps} />
51
+ </ThemeProvider>
52
+ );
53
+
54
+ const buttonElement = screen.getByTestId("button-line-inverse");
55
+ expect(buttonElement).toBeTruthy();
56
+ });
57
+
58
+ it("should render the component with a className", () => {
59
+ defaultProps.className = "my-class";
60
+ render(
61
+ <ThemeProvider theme={parseTheme(globalTheme)}>
62
+ <Button {...defaultProps} />
63
+ </ThemeProvider>
64
+ );
65
+
66
+ const buttonElement = screen.getByTestId("button-line-inverse");
67
+ expect(buttonElement).toBeTruthy();
68
+ expect(buttonElement).toHaveClass("my-class");
69
+ });
70
+
71
+ it("should render the children", () => {
72
+ defaultProps.children = "el texto";
73
+ render(
74
+ <ThemeProvider theme={parseTheme(globalTheme)}>
75
+ <Button {...defaultProps} />
76
+ </ThemeProvider>
77
+ );
78
+
79
+ expect(screen.getByText<HTMLElement>("el texto")).toBeInTheDocument();
80
+ });
81
+
82
+ it("should trigger the onClick action", () => {
83
+ defaultProps.buttonStyle = "lineInverse";
84
+ const handleOnClickMock = defaultProps.onClick as jest.MockedFunction<
85
+ (e: React.MouseEvent<HTMLButtonElement>) => void
86
+ >;
87
+ render(
88
+ <ThemeProvider theme={parseTheme(globalTheme)}>
89
+ <Button {...defaultProps} />
90
+ </ThemeProvider>
91
+ );
92
+
93
+ const buttonElement = screen.getByTestId("button-line-inverse");
94
+ expect(buttonElement).toBeTruthy();
95
+ fireEvent.click(buttonElement);
96
+ expect(handleOnClickMock).toHaveBeenCalled();
97
+ });
98
+
99
+ it("should not trigger the onClick action if the button is disabled", () => {
100
+ defaultProps.buttonStyle = "lineInverse";
101
+ defaultProps.disabled = true;
102
+ const handleOnClickMock = defaultProps.onClick as jest.MockedFunction<
103
+ (e: React.MouseEvent<HTMLButtonElement>) => void
104
+ >;
105
+ render(
106
+ <ThemeProvider theme={parseTheme(globalTheme)}>
107
+ <Button {...defaultProps} />
108
+ </ThemeProvider>
109
+ );
110
+
111
+ const buttonElement = screen.getByTestId("button-line-inverse");
112
+ expect(buttonElement).toBeTruthy();
113
+ expect(buttonElement).toBeDisabled();
114
+ fireEvent.click(buttonElement);
115
+ expect(handleOnClickMock).not.toHaveBeenCalled();
116
+ });
117
+ });
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import PasteModuleButton, {
3
- IProps,
3
+ IPasteModuleProps,
4
4
  } from "@ax/components/Fields/ComponentArray/MixableComponentArray/PasteModuleButton";
5
5
  import { ThemeProvider } from "styled-components";
6
6
  import { parseTheme } from "@ax/helpers";
@@ -12,10 +12,17 @@ import { mock } from "jest-mock-extended";
12
12
 
13
13
  afterEach(cleanup);
14
14
 
15
- const defaultProps = mock<IProps>();
15
+ jest.mock("react-router-dom", () => ({
16
+ ...jest.requireActual("react-router-dom"),
17
+ useLocation: () => ({
18
+ pathname: "localhost:3000/example/path",
19
+ }),
20
+ }));
21
+
22
+ const defaultProps = mock<IPasteModuleProps>();
16
23
 
17
24
  const mockedFunction = defaultProps.pasteModule as jest.MockedFunction<
18
- (value: number) => Promise<{ error?: INotification }>
25
+ (editorID: number, key: string) => Promise<{ error?: INotification }>
19
26
  >;
20
27
  const mockedNotification = defaultProps.setNotification as jest.MockedFunction<(notification: INotification) => void>;
21
28
  defaultProps.editorID = 1;
@@ -26,7 +33,7 @@ describe("ComponentArraySelector component rendering", () => {
26
33
  defaultProps.setHistoryPush = jest.fn();
27
34
  render(
28
35
  <ThemeProvider theme={parseTheme(globalTheme)}>
29
- <PasteModuleButton arrayKey={""} {...defaultProps} />
36
+ <PasteModuleButton {...defaultProps} />
30
37
  </ThemeProvider>
31
38
  );
32
39
  const iconButton = screen.getByTestId("icon-action-component");
@@ -50,7 +57,7 @@ describe("ComponentArraySelector trigger events", () => {
50
57
 
51
58
  render(
52
59
  <ThemeProvider theme={parseTheme(globalTheme)}>
53
- <PasteModuleButton arrayKey={""} {...defaultProps} />
60
+ <PasteModuleButton {...defaultProps} />
54
61
  </ThemeProvider>
55
62
  );
56
63
  const iconButton = screen.getByTestId("icon-action-component");
@@ -59,7 +66,7 @@ describe("ComponentArraySelector trigger events", () => {
59
66
  fireEvent.click(iconButton);
60
67
  });
61
68
  await expect(mockedFunction).toHaveBeenCalled();
62
- await expect(mockedFunction(1)).resolves.toEqual({
69
+ await expect(mockedFunction(1, "")).resolves.toEqual({
63
70
  error: {
64
71
  type: "warning",
65
72
  text: "This is a warning",
@@ -75,7 +82,7 @@ describe("ComponentArraySelector trigger events", () => {
75
82
 
76
83
  render(
77
84
  <ThemeProvider theme={parseTheme(globalTheme)}>
78
- <PasteModuleButton arrayKey={""} {...defaultProps} />
85
+ <PasteModuleButton {...defaultProps} />
79
86
  </ThemeProvider>
80
87
  );
81
88
  const iconButton = screen.getByTestId("icon-action-component");
@@ -84,7 +91,7 @@ describe("ComponentArraySelector trigger events", () => {
84
91
  fireEvent.click(iconButton);
85
92
  });
86
93
  await expect(mockedFunction).toHaveBeenCalled();
87
- await expect(mockedFunction(1)).resolves.toEqual({});
94
+ await expect(mockedFunction(1, "")).resolves.toEqual({});
88
95
  expect(screen.getByTestId("toast-message")).toHaveTextContent("Module pasted from clipboard");
89
96
  });
90
97
 
@@ -94,7 +101,7 @@ describe("ComponentArraySelector trigger events", () => {
94
101
 
95
102
  render(
96
103
  <ThemeProvider theme={parseTheme(globalTheme)}>
97
- <PasteModuleButton arrayKey={""} {...defaultProps} />
104
+ <PasteModuleButton {...defaultProps} />
98
105
  </ThemeProvider>
99
106
  );
100
107
  const iconButton = screen.getByTestId("icon-action-component");
@@ -103,7 +110,7 @@ describe("ComponentArraySelector trigger events", () => {
103
110
  fireEvent.click(iconButton);
104
111
  });
105
112
  await expect(mockedFunction).toHaveBeenCalled();
106
- await expect(mockedFunction(1)).resolves.toEqual({ error: undefined });
113
+ await expect(mockedFunction(1, "")).resolves.toEqual({ error: undefined });
107
114
  expect(screen.getByTestId("toast-message")).toHaveTextContent("Module pasted from clipboard");
108
115
  });
109
116
  });
@@ -21,6 +21,7 @@ const defaultProps = {
21
21
  },
22
22
  ],
23
23
  showAdvanced: false,
24
+ default: {},
24
25
  };
25
26
 
26
27
  describe("HeadingField component rendering", () => {
@@ -50,6 +51,7 @@ describe("HeadingField component rendering", () => {
50
51
  },
51
52
  ],
52
53
  showAdvanced: true,
54
+ default: {},
53
55
  };
54
56
 
55
57
  render(
@@ -12,10 +12,13 @@ import { history } from "@ax/routes";
12
12
  import globalTheme from "@ax/themes/theme.json";
13
13
  import { IGetSitesParams, ISettingsForm } from "@ax/types";
14
14
 
15
- import { render, cleanup, screen, fireEvent, act } from "./../../../../../config/jest/test-utils";
15
+ import { render, cleanup, screen, fireEvent, act, waitFor } from "./../../../../../config/jest/test-utils";
16
16
 
17
17
  import { sitesDataMock, sitesDataNoThumbnailMock, userDataMock } from "./../../../../__mocks__/store/SitesList";
18
18
  import { sitesResponse } from "./../../../../__mocks__/axios/SitesList";
19
+ import { sitesResponseDataPack } from "./../../../../__mocks__/axios/SitesListDataPack";
20
+ import { sitesResponseCategories } from "./../../../../__mocks__/axios/SitesListCategories";
21
+ import { sitesOptions } from "./../../../../__mocks__/axios/SitesListOptions";
19
22
  import SitesList, { ISitesListProps } from "./../../../../modules/Sites/SitesList";
20
23
 
21
24
  afterEach(cleanup);
@@ -35,7 +38,10 @@ const initialStore = {
35
38
  },
36
39
  users: userDataMock,
37
40
  sites: sitesDataMock,
38
- structuredData: { global: [], sites: [] },
41
+ structuredData: {
42
+ structuredData: { global: [], sites: [] },
43
+ categories: { global: [], sites: [] },
44
+ },
39
45
  };
40
46
 
41
47
  describe("Sites module rendering", () => {
@@ -402,7 +408,24 @@ describe("Sites module events", () => {
402
408
  [path: string, isEditor?: boolean | undefined]
403
409
  >;
404
410
  const initialState = { ...initialStore, ...defaultProps };
405
- mockedAxios.mockResolvedValue(sitesResponse);
411
+ mockedAxios.mockImplementation((request: any) => {
412
+ switch (request.url) {
413
+ case "undefined/site/3/languages":
414
+ case "undefined/site/global/metrics":
415
+ case "undefined/site/3/metrics":
416
+ case "undefined/site/3/socials":
417
+ case "undefined/site/undefined/templates":
418
+ case "undefined/site/3/structured_data":
419
+ return Promise.resolve(sitesResponse);
420
+ case "undefined/sites?recentSitesNumber=7&pagination=true&page=1&itemsPerPage=30&order=lastAccess-desc":
421
+ case "undefined/site/3/data_pack/?status=activated":
422
+ return Promise.resolve(sitesResponseDataPack);
423
+ case "undefined/site/undefined/modules":
424
+ return Promise.resolve(sitesResponseCategories);
425
+ default:
426
+ return Promise.reject({ status: 500 });
427
+ }
428
+ });
406
429
 
407
430
  const Component = (
408
431
  <Router history={history}>
@@ -448,7 +471,9 @@ describe("Sites module events", () => {
448
471
  const listIconAction = screen.getByTestId("icon-action-BulletList");
449
472
  expect(gridIconAction).toBeTruthy();
450
473
  expect(listIconAction).toBeTruthy();
451
- fireEvent.click(listIconAction);
474
+ await act(async () => {
475
+ fireEvent.click(listIconAction);
476
+ });
452
477
  const listSitesItems = screen.getAllByTestId("list-site-item");
453
478
  expect(listSitesItems.length).toEqual(2);
454
479
  });
@@ -481,13 +506,14 @@ describe("Sites module events", () => {
481
506
  const listIconAction = screen.getByTestId("icon-action-BulletList");
482
507
  expect(gridIconAction).toBeTruthy();
483
508
  expect(listIconAction).toBeTruthy();
484
- fireEvent.click(listIconAction);
509
+ await act(async () => {
510
+ fireEvent.click(listIconAction);
511
+ });
485
512
  const listSitesItems = screen.getAllByTestId("list-site-item");
486
513
  expect(listSitesItems.length).toEqual(2);
487
514
 
488
515
  fireEvent.click(listSitesItems[0]);
489
-
490
- expect(history.location.pathname).toEqual("/sites/pages");
516
+ waitFor(() => expect(history.location.pathname).toEqual("/sites/pages"));
491
517
  });
492
518
 
493
519
  it("should display grid view on click grid option button", async () => {
@@ -533,7 +559,25 @@ describe("Sites module events", () => {
533
559
  >;
534
560
  const initialState = { ...initialStore, ...defaultProps };
535
561
 
536
- mockedAxios.mockResolvedValue(sitesResponse);
562
+ // mockedAxios.mockResolvedValue(sitesResponse);
563
+ mockedAxios.mockImplementation((request: any) => {
564
+ switch (request.url) {
565
+ case "undefined/site/1/languages":
566
+ case "undefined/site/1/socials":
567
+ case "undefined/site/undefined/templates":
568
+ case "undefined/site/global/metrics":
569
+ case "undefined/site/1/metrics":
570
+ return Promise.resolve(sitesResponse);
571
+ case "undefined/sites?recentSitesNumber=7&pagination=true&page=1&itemsPerPage=30&order=lastAccess-desc":
572
+ case "undefined/site/1/data_pack/?status=activated":
573
+ case "undefined/site/1/structured_data":
574
+ return Promise.resolve(sitesResponseDataPack);
575
+ case "undefined/site/undefined/modules":
576
+ return Promise.resolve(sitesResponseCategories);
577
+ default:
578
+ return Promise.reject(new Error("not found"));
579
+ }
580
+ });
537
581
  const Component = (
538
582
  <Router history={history}>
539
583
  <ThemeProvider theme={parseTheme(globalTheme)}>
@@ -561,7 +605,7 @@ describe("Sites module events", () => {
561
605
  const store = mockStore(initialStore);
562
606
 
563
607
  const initialState = { ...initialStore, ...defaultProps };
564
- mockedAxios.mockResolvedValue(sitesResponse);
608
+ mockedAxios.mockResolvedValue(sitesOptions);
565
609
 
566
610
  const Component = (
567
611
  <Router history={history}>
@@ -577,7 +621,9 @@ describe("Sites module events", () => {
577
621
 
578
622
  const newButton = screen.getByTestId("button-default");
579
623
  expect(newButton.textContent).toEqual("New");
580
- fireEvent.click(newButton);
624
+ await act(async () => {
625
+ fireEvent.click(newButton);
626
+ });
581
627
  const siteModalForm = screen.getByTestId("site-modal-form");
582
628
  expect(siteModalForm).toBeTruthy();
583
629
  });
@@ -811,7 +857,9 @@ describe("Sites module events", () => {
811
857
 
812
858
  const listIconAction = screen.getByTestId("icon-action-BulletList");
813
859
  expect(listIconAction).toBeTruthy();
814
- fireEvent.click(listIconAction);
860
+ await act(async () => {
861
+ fireEvent.click(listIconAction);
862
+ });
815
863
  const listItems = screen.getAllByTestId("list-site-item");
816
864
  const moreInfoButton = screen.getAllByTestId("more-info-button");
817
865
 
@@ -880,7 +928,9 @@ describe("Sites module events", () => {
880
928
 
881
929
  const listIconAction = screen.getByTestId("icon-action-BulletList");
882
930
  expect(listIconAction).toBeTruthy();
883
- fireEvent.click(listIconAction);
931
+ await act(async () => {
932
+ fireEvent.click(listIconAction);
933
+ });
884
934
  const listItems = screen.getAllByTestId("list-site-item");
885
935
  const moreInfoButton = screen.getAllByTestId("more-info-button");
886
936
 
@@ -74,7 +74,7 @@ const Button = ({ children, type, disabled, icon, buttonStyle, onClick, classNam
74
74
  }
75
75
  };
76
76
 
77
- interface IButtonProps {
77
+ export interface IButtonProps {
78
78
  children: JSX.Element | string;
79
79
  type: "button" | "submit" | "reset" | undefined;
80
80
  onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import styled from "styled-components";
2
3
 
3
4
  export const Button = styled.button`
@@ -6,7 +7,7 @@ export const Button = styled.button`
6
7
  border-radius: 4px;
7
8
  z-index: 0;
8
9
  border: none;
9
- color: ${p => p.theme.colors.uiBackground02};
10
+ color: ${(p) => p.theme.colors.uiBackground02};
10
11
  min-height: calc(${(p) => p.theme.spacing.s} * 2);
11
12
  padding: ${(p) => p.theme.spacing.xs} ${(p) => p.theme.spacing.s};
12
13
  vertical-align: middle;
@@ -59,7 +60,7 @@ export const Button = styled.button`
59
60
  }
60
61
  `;
61
62
 
62
- export const TextButton = styled(Button)`
63
+ export const TextButton = styled((props) => <Button {...props} />)`
63
64
  background-color: transparent;
64
65
  color: ${(p) => p.theme.color.interactive01};
65
66
  padding: 0 ${(p) => p.theme.spacing.xs};
@@ -88,18 +89,19 @@ export const TextButton = styled(Button)`
88
89
  }
89
90
  `;
90
91
 
91
- export const LineButton = styled(Button)<{ isInverse: boolean | undefined }>`
92
- background-color: ${(p) => p.isInverse ? p.theme.color.uiMainMenuBackground : p.theme.color.interactiveBackground};
93
- border: 1px solid ${(p) => p.isInverse ? "#fff" : p.theme.color.interactive01};
94
- color: ${(p) => p.isInverse ? "#fff" : p.theme.color.interactive01};
92
+ export const LineButton = styled((props) => <Button {...props} />)<{ isInverse: boolean | undefined }>`
93
+ background-color: ${(p) => (p.isInverse ? p.theme.color.uiMainMenuBackground : p.theme.color.interactiveBackground)};
94
+ border: 1px solid ${(p) => (p.isInverse ? "#fff" : p.theme.color.interactive01)};
95
+ color: ${(p) => (p.isInverse ? "#fff" : p.theme.color.interactive01)};
95
96
  :hover:before {
96
- background-color: ${(p) =>p.isInverse ? p.theme.color.uiMainMenuBackground : p.theme.color.overlayHoverPrimary};
97
+ background-color: ${(p) => (p.isInverse ? p.theme.color.uiMainMenuBackground : p.theme.color.overlayHoverPrimary)};
97
98
  }
98
99
  :focus:before {
99
- background-color: ${(p) => p.isInverse ? p.theme.color.uiMainMenuBackground : p.theme.color.overlayFocusPrimary};
100
+ background-color: ${(p) => (p.isInverse ? p.theme.color.uiMainMenuBackground : p.theme.color.overlayFocusPrimary)};
100
101
  }
101
102
  :active:before {
102
- background-color: ${(p) => p.isInverse ? p.theme.color.uiMainMenuBackground : p.theme.color.overlayPressedPrimary};
103
+ background-color: ${(p) =>
104
+ p.isInverse ? p.theme.color.uiMainMenuBackground : p.theme.color.overlayPressedPrimary};
103
105
  }
104
106
  :disabled {
105
107
  background-color: transparent;
@@ -1,4 +1,5 @@
1
1
  import { Button } from "@ax/components";
2
+ import React from "react";
2
3
  import styled from "styled-components";
3
4
 
4
5
  const NoteWrapper = styled.div`
@@ -29,7 +30,7 @@ const DataTitle = styled.div`
29
30
  margin-left: ${(p) => p.theme.spacing.xs};
30
31
  `;
31
32
 
32
- const StyledButton = styled(Button)`
33
+ const StyledButton = styled((props) => <Button {...props} />)`
33
34
  margin-left: auto;
34
35
  `;
35
36
 
@@ -1,4 +1,5 @@
1
1
  import { Button } from "@ax/components";
2
+ import React from "react";
2
3
  import styled from "styled-components";
3
4
 
4
5
  const FieldWrapper = styled.div`
@@ -29,7 +30,7 @@ const DataTitle = styled.div`
29
30
  margin-left: ${(p) => p.theme.spacing.xs};
30
31
  `;
31
32
 
32
- const StyledButton = styled(Button)`
33
+ const StyledButton = styled((props) => <Button {...props} />)`
33
34
  margin-left: auto;
34
35
  `;
35
36
 
@@ -29,13 +29,19 @@ const DragAndDrop = (props: any) => {
29
29
  };
30
30
 
31
31
  return (
32
- <S.DragDropWrapper onDrop={_handleDrop} onDragOver={_handleDragOver} onDragEnter={_handleDragEnter} onDragLeave={_handleDragLeave}>
32
+ <S.DragDropWrapper
33
+ data-testid="drag-drop-wrapper"
34
+ onDrop={_handleDrop}
35
+ onDragOver={_handleDragOver}
36
+ onDragEnter={_handleDragEnter}
37
+ onDragLeave={_handleDragLeave}
38
+ >
33
39
  {children}
34
40
  </S.DragDropWrapper>
35
41
  );
36
42
  };
37
43
 
38
- interface IDragAndDropProps {
44
+ export interface IDragAndDropProps {
39
45
  children: JSX.Element | JSX.Element[];
40
46
  onDrop: (e: React.DragEvent<HTMLDivElement>) => void;
41
47
  onDragOver: (e: React.DragEvent<HTMLDivElement>) => void;
@@ -4,7 +4,7 @@ import { useToast } from "@ax/hooks";
4
4
  import { Tooltip, IconAction, Toast } from "@ax/components";
5
5
  import { INotification } from "@ax/types";
6
6
 
7
- const PasteModuleButton = (props: IProps): JSX.Element => {
7
+ const PasteModuleButton = (props: IPasteModuleProps): JSX.Element => {
8
8
  const { pasteModule, setNotification, setHistoryPush, editorID, isModuleCopyUnavailable, arrayKey } = props;
9
9
 
10
10
  const { isVisible, toggleToast, setIsVisible } = useToast();
@@ -39,7 +39,7 @@ const PasteModuleButton = (props: IProps): JSX.Element => {
39
39
  );
40
40
  };
41
41
 
42
- interface IProps {
42
+ export interface IPasteModuleProps {
43
43
  pasteModule: (editorID: number, key: string) => Promise<{ error?: INotification }>;
44
44
  setNotification?: (notification: INotification) => void;
45
45
  setHistoryPush?: (path: string, isEditor: boolean) => void;
@@ -156,7 +156,7 @@ export const ErrorMsg = styled.div`
156
156
  margin-top: ${(p) => p.theme.spacing.xxs};
157
157
  `;
158
158
 
159
- export const StyledButton = styled(Button)`
159
+ export const StyledButton = styled((props) => <Button {...props} />)`
160
160
  margin-top: ${(p) => p.theme.spacing.s};
161
161
  `;
162
162