@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.
Files changed (52) hide show
  1. package/config/jest/componentsMock.js +122 -1
  2. package/package.json +2 -2
  3. package/src/__tests__/components/Avatar/__snapshots__/Avatar.test.tsx.snap +10 -10
  4. package/src/__tests__/components/ConfigPanel/ConfigPanel.test.tsx +252 -0
  5. package/src/__tests__/components/ConfigPanel/Form/ConnectedField/ConnectedField.test.tsx +177 -0
  6. package/src/__tests__/components/ConfigPanel/Form/ConnectedField/NavConnectedField/NavConnectedField.test.tsx +161 -0
  7. package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/Field.test.tsx +115 -0
  8. package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/PageConnectedField.test.tsx +518 -0
  9. package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/TemplateManager.test.tsx +144 -0
  10. package/src/__tests__/components/ConfigPanel/Form/Form.test.tsx +235 -0
  11. package/src/__tests__/components/ConfigPanel/GlobalPageForm/GlobalPageForm.test.tsx +196 -0
  12. package/src/__tests__/components/ConfigPanel/Header/Header.test.tsx +152 -0
  13. package/src/__tests__/components/ConfigPanel/NavigationForm/Field/Field.test.tsx +106 -0
  14. package/src/__tests__/components/ConfigPanel/NavigationForm/NavigationForm.test.tsx +93 -0
  15. package/src/__tests__/components/ConfigPanel/PreviewForm/PreviewForm.test.tsx +93 -0
  16. package/src/__tests__/components/Fields/FieldGroup/FieldGroup.test.tsx +5 -5
  17. package/src/__tests__/components/Fields/NoteField/NoteField.test.tsx +3 -3
  18. package/src/__tests__/components/Fields/SliderField/SliderField.test.tsx +4 -4
  19. package/src/__tests__/components/Fields/TagField/TagField.test.tsx +10 -10
  20. package/src/__tests__/components/Fields/TextArea/TextArea.test.tsx +3 -3
  21. package/src/__tests__/components/Fields/TextField/TextField.test.tsx +8 -8
  22. package/src/__tests__/components/Fields/UrlField/UrlField.test.tsx +2 -2
  23. package/src/__tests__/components/Gallery/Gallery.test.tsx +613 -0
  24. package/src/__tests__/components/Gallery/GalleryFilters/Orientation/Orientation.test.tsx +51 -0
  25. package/src/__tests__/components/Gallery/GalleryFilters/SortBy/SortBy.test.tsx +117 -0
  26. package/src/__tests__/components/Gallery/GalleryFilters/Type/Type.test.tsx +51 -0
  27. package/src/__tests__/components/Gallery/GalleryPanel/DetailPanel/DetailPanel.test.tsx +853 -0
  28. package/src/__tests__/components/Gallery/GalleryPanel/GalleryDragAndDrop/GalleryDragAndDrop.test.tsx +252 -0
  29. package/src/__tests__/components/Gallery/GalleryPanel/GalleryPanel.test.tsx +56 -0
  30. package/src/__tests__/components/Image/Image.test.tsx +5 -5
  31. package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +3 -4
  32. package/src/components/ConfigPanel/Form/index.tsx +13 -5
  33. package/src/components/ConfigPanel/GlobalPageForm/index.tsx +5 -5
  34. package/src/components/ConfigPanel/Header/index.tsx +3 -3
  35. package/src/components/ConfigPanel/NavigationForm/Field/index.tsx +5 -3
  36. package/src/components/ConfigPanel/NavigationForm/index.tsx +2 -2
  37. package/src/components/ConfigPanel/PreviewForm/index.tsx +3 -3
  38. package/src/components/ConfigPanel/index.tsx +2 -3
  39. package/src/components/Fields/FieldGroup/index.tsx +3 -3
  40. package/src/components/Fields/NoteField/index.tsx +2 -2
  41. package/src/components/Fields/SliderField/index.tsx +10 -3
  42. package/src/components/Fields/TagField/index.tsx +2 -2
  43. package/src/components/Fields/TextArea/index.tsx +1 -1
  44. package/src/components/Fields/TextField/index.tsx +3 -3
  45. package/src/components/Gallery/GalleryFilters/Orientation/index.tsx +14 -6
  46. package/src/components/Gallery/GalleryFilters/SortBy/index.tsx +2 -2
  47. package/src/components/Gallery/GalleryFilters/Type/index.tsx +2 -2
  48. package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +4 -4
  49. package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/index.tsx +5 -4
  50. package/src/components/Gallery/GalleryPanel/index.tsx +3 -11
  51. package/src/components/Gallery/index.tsx +6 -5
  52. package/src/containers/PageEditor/actions.tsx +1 -2
@@ -0,0 +1,93 @@
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 NavigationForm, { INavigationFormProps } from "@ax/components/ConfigPanel/NavigationForm";
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 defaultProps = mock<INavigationFormProps>();
51
+
52
+ defaultProps.schema = {
53
+ schemaType: "module",
54
+ displayName: "Header",
55
+ component: "Header",
56
+ type: "header",
57
+ defaultNavigation: true,
58
+ category: "header",
59
+ dataPacks: null,
60
+ configTabs: [
61
+ {
62
+ title: "content",
63
+ fields: [
64
+ {
65
+ title: "Name",
66
+ key: "title",
67
+ type: "TextField",
68
+ mandatory: true,
69
+ },
70
+ ],
71
+ },
72
+ ],
73
+ };
74
+ defaultProps.theme = "default-theme";
75
+
76
+ describe("NavigationForm component rendering", () => {
77
+ it("should render component", () => {
78
+ render(
79
+ <ThemeProvider theme={parseTheme(globalTheme)}>
80
+ <NavigationForm {...defaultProps} />
81
+ </ThemeProvider>,
82
+ { store }
83
+ );
84
+
85
+ // the text is loading in the header
86
+ const componentWrapper = screen.getByText(/selected content field/i);
87
+ expect(componentWrapper).toBeInTheDocument();
88
+
89
+ // the text is loading in the noteField
90
+ const noteText = screen.getByText(/go to Navigation/i);
91
+ expect(noteText).toBeInTheDocument();
92
+ });
93
+ });
@@ -0,0 +1,93 @@
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 PreviewForm, { IPreviewFormProps } from "@ax/components/ConfigPanel/PreviewForm";
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 defaultProps = mock<IPreviewFormProps>();
51
+
52
+ defaultProps.selectedTab = "content";
53
+ const setSelectedTabMock = defaultProps.setSelectedTab as jest.MockedFunction<(tab: string) => void>;
54
+
55
+ describe("PreviewForm component rendering", () => {
56
+ it("should render component", () => {
57
+ render(
58
+ <ThemeProvider theme={parseTheme(globalTheme)}>
59
+ <PreviewForm {...defaultProps} />
60
+ </ThemeProvider>,
61
+ { store }
62
+ );
63
+
64
+ const previewFormWrapper = screen.getByTestId("preview-form-wrapper");
65
+ expect(previewFormWrapper).toBeTruthy();
66
+
67
+ const noteFieldTitle = screen.getByText("This page is currently being edited");
68
+ expect(noteFieldTitle).toBeTruthy();
69
+ });
70
+
71
+ it("should render component with user name", () => {
72
+ defaultProps.userEditing = {
73
+ id: 0,
74
+ name: "User 1",
75
+ username: "user1",
76
+ };
77
+
78
+ render(
79
+ <ThemeProvider theme={parseTheme(globalTheme)}>
80
+ <PreviewForm {...defaultProps} />
81
+ </ThemeProvider>,
82
+ { store }
83
+ );
84
+
85
+ const previewFormWrapper = screen.getByTestId("preview-form-wrapper");
86
+ expect(previewFormWrapper).toBeTruthy();
87
+
88
+ const noteFieldTitle = screen.getByText(/User 1/i);
89
+ expect(noteFieldTitle).toBeTruthy();
90
+
91
+ expect(setSelectedTabMock).toBeCalled();
92
+ });
93
+ });
@@ -24,9 +24,9 @@ describe("FieldGroup component rendering", () => {
24
24
  </ThemeProvider>
25
25
  );
26
26
 
27
- const fieldGroupWrapper = screen.getByTestId("fieldGroupWrapper");
28
- const fieldGroupLabel = screen.getByTestId("fieldGroupLabel");
29
- const fieldGroupContent = screen.getByTestId("fieldGroupContent");
27
+ const fieldGroupWrapper = screen.getByTestId("field-group-wrapper");
28
+ const fieldGroupLabel = screen.getByTestId("field-group-label");
29
+ const fieldGroupContent = screen.getByTestId("field-group-content");
30
30
 
31
31
  expect(fieldGroupWrapper).toBeTruthy();
32
32
  expect(fieldGroupLabel).toBeTruthy();
@@ -52,8 +52,8 @@ describe("FieldGroup component rendering", () => {
52
52
  </ThemeProvider>
53
53
  );
54
54
 
55
- const fieldGroupLabel = screen.getByTestId("fieldGroupLabel");
56
- const fieldGroupContent = screen.getByTestId("fieldGroupContent");
55
+ const fieldGroupLabel = screen.getByTestId("field-group-label");
56
+ const fieldGroupContent = screen.getByTestId("field-group-content");
57
57
  expect(fieldGroupLabel).toBeTruthy();
58
58
  expect(fieldGroupContent).toBeTruthy();
59
59
  expect(fieldGroupContent).toHaveTextContent("blablabla");
@@ -19,7 +19,7 @@ describe("NoteField component rendering", () => {
19
19
  </ThemeProvider>
20
20
  );
21
21
 
22
- const noteFieldWrapper = screen.getByTestId("noteFieldWrapper");
22
+ const noteFieldWrapper = screen.getByTestId("note-field-wrapper");
23
23
 
24
24
  expect(noteFieldWrapper).toBeTruthy();
25
25
  });
@@ -41,7 +41,7 @@ describe("NoteField component rendering", () => {
41
41
  </ThemeProvider>
42
42
  );
43
43
 
44
- const title = screen.queryByTestId("title");
44
+ const title = screen.queryByTestId("note-field-title");
45
45
 
46
46
  expect(title).toBeNull();
47
47
  });
@@ -55,7 +55,7 @@ describe("NoteField component rendering", () => {
55
55
  </ThemeProvider>
56
56
  );
57
57
 
58
- const title = screen.queryByTestId("title");
58
+ const title = screen.queryByTestId("note-field-title");
59
59
 
60
60
  expect(title).toBeTruthy();
61
61
  });
@@ -23,9 +23,9 @@ describe("Select component rendering", () => {
23
23
  </ThemeProvider>
24
24
  );
25
25
 
26
- expect(screen.getByTestId("sliderComponent")).toBeTruthy();
27
- expect(screen.getByTestId("bubbleComponent")).toBeTruthy();
28
- expect(screen.getByTestId("inputComponent")).toBeTruthy();
26
+ expect(screen.getByTestId("slider-component")).toBeTruthy();
27
+ expect(screen.getByTestId("bubble-component")).toBeTruthy();
28
+ expect(screen.getByTestId("input-slider-component")).toBeTruthy();
29
29
  });
30
30
 
31
31
  test("should render the component with prefix and suffix", () => {
@@ -62,7 +62,7 @@ describe("Select component events trigger", () => {
62
62
  </ThemeProvider>
63
63
  );
64
64
 
65
- const input = screen.getByTestId("inputComponent");
65
+ const input = screen.getByTestId("input-slider-component");
66
66
  fireEvent.change(input, { target: { value: "20" } });
67
67
  expect(onChangeMock).toBeCalledWith(20);
68
68
  });
@@ -20,11 +20,11 @@ describe("TagField component", () => {
20
20
  </ThemeProvider>
21
21
  );
22
22
 
23
- const tagFieldWrapper = screen.getAllByTestId("tagFieldWrapper");
23
+ const tagFieldWrapper = screen.getAllByTestId("tag-field-wrapper");
24
24
  expect(tagFieldWrapper).toBeTruthy();
25
25
  expect(tagFieldWrapper).toHaveLength(1);
26
26
 
27
- const tagFieldInput = screen.getAllByTestId("tagFieldInput");
27
+ const tagFieldInput = screen.getAllByTestId("tag-field-input");
28
28
  expect(tagFieldInput).toBeTruthy();
29
29
  expect(tagFieldInput).toHaveLength(1);
30
30
  });
@@ -41,16 +41,16 @@ describe("TagField component", () => {
41
41
  </ThemeProvider>
42
42
  );
43
43
 
44
- const tagFieldWrapper = screen.getByTestId("tagFieldWrapper");
44
+ const tagFieldWrapper = screen.getByTestId("tag-field-wrapper");
45
45
  expect(tagFieldWrapper).toBeTruthy();
46
46
 
47
- const tagFieldInput = screen.getByTestId("tagFieldInput");
47
+ const tagFieldInput = screen.getByTestId("tag-field-input");
48
48
  expect(tagFieldInput).toBeTruthy();
49
49
 
50
50
  const tagRendered = within(tagFieldWrapper).getAllByTestId("delete-icon-wrapper");
51
51
  expect(tagRendered).toHaveLength(2);
52
52
 
53
- const tagComponent = screen.getByTestId("tagFieldWrapper");
53
+ const tagComponent = screen.getByTestId("tag-field-wrapper");
54
54
  expect(tagComponent.textContent).toBe("onetwo");
55
55
  });
56
56
  });
@@ -62,7 +62,7 @@ describe("TagField events", () => {
62
62
  <TagField {...props} />
63
63
  </ThemeProvider>
64
64
  );
65
- const tagFieldInput = screen.getByTestId<HTMLInputElement>("tagFieldInput");
65
+ const tagFieldInput = screen.getByTestId<HTMLInputElement>("tag-field-input");
66
66
 
67
67
  fireEvent.change(tagFieldInput, { target: { value: "test" } });
68
68
  expect(tagFieldInput.value).toBe("test");
@@ -80,7 +80,7 @@ describe("TagField events", () => {
80
80
  </ThemeProvider>
81
81
  );
82
82
 
83
- const tagFieldInput = screen.getByTestId<HTMLInputElement>("tagFieldInput");
83
+ const tagFieldInput = screen.getByTestId<HTMLInputElement>("tag-field-input");
84
84
  fireEvent.input(tagFieldInput, { target: { value: "test" } });
85
85
  fireEvent.keyDown(tagFieldInput, { key: "Enter", code: "Enter", charCode: 13 });
86
86
  expect(onChange).toHaveBeenCalledWith(["test"]);
@@ -97,7 +97,7 @@ describe("TagField events", () => {
97
97
  </ThemeProvider>
98
98
  );
99
99
 
100
- const tagFieldInput = screen.getByTestId<HTMLInputElement>("tagFieldInput");
100
+ const tagFieldInput = screen.getByTestId<HTMLInputElement>("tag-field-input");
101
101
  fireEvent.input(tagFieldInput, { target: { value: "test" } });
102
102
  fireEvent.keyDown(tagFieldInput, { key: "Enter", code: "Enter", charCode: 13 });
103
103
  expect(onChange).toBeCalledTimes(0);
@@ -115,7 +115,7 @@ describe("TagField events", () => {
115
115
  </ThemeProvider>
116
116
  );
117
117
 
118
- const tagFieldWrapper = screen.getByTestId("tagFieldWrapper");
118
+ const tagFieldWrapper = screen.getByTestId("tag-field-wrapper");
119
119
  const tagRendered = within(tagFieldWrapper).getAllByTestId("delete-icon-wrapper");
120
120
  expect(tagRendered).toHaveLength(2);
121
121
  fireEvent.click(tagRendered[0], 0);
@@ -129,7 +129,7 @@ describe("TagField events", () => {
129
129
  <TagField {...props} />
130
130
  </ThemeProvider>
131
131
  );
132
- const tagFieldWrapper = screen.getByTestId("tagFieldWrapper");
132
+ const tagFieldWrapper = screen.getByTestId("tag-field-wrapper");
133
133
  fireEvent.click(tagFieldWrapper);
134
134
  expect(useRefSpy).toBeCalledTimes(1);
135
135
  });
@@ -21,7 +21,7 @@ describe("TextArea component rendering", () => {
21
21
  </ThemeProvider>
22
22
  );
23
23
 
24
- const textAreaComponent = screen.getAllByTestId("textAreaComponent");
24
+ const textAreaComponent = screen.getAllByTestId("text-area-component");
25
25
  expect(textAreaComponent).toHaveLength(1);
26
26
  });
27
27
  });
@@ -38,7 +38,7 @@ describe("TextArea events", () => {
38
38
  </ThemeProvider>
39
39
  );
40
40
 
41
- const textAreaComponent = screen.getByTestId("textAreaComponent");
41
+ const textAreaComponent = screen.getByTestId("text-area-component");
42
42
  expect(textAreaComponent).toBeTruthy();
43
43
  fireEvent.change(textAreaComponent, { target: { value: "test" } });
44
44
  expect(setStateMock).toHaveBeenCalledWith("test");
@@ -59,7 +59,7 @@ describe("TextArea events", () => {
59
59
  </ThemeProvider>
60
60
  );
61
61
 
62
- const textAreaComponent = screen.getByTestId("textAreaComponent");
62
+ const textAreaComponent = screen.getByTestId("text-area-component");
63
63
 
64
64
  expect(textAreaComponent).toBeTruthy();
65
65
  fireEvent.blur(textAreaComponent, { target: { value: "name" } });
@@ -21,7 +21,7 @@ describe("TextField component rendering", () => {
21
21
  );
22
22
 
23
23
  const textFieldContainer = screen.getByTestId("text-field-container");
24
- const inputComponent = screen.getByTestId("inputComponent");
24
+ const inputComponent = screen.getByTestId("input-component");
25
25
 
26
26
  expect(textFieldContainer).toBeTruthy();
27
27
  expect(inputComponent).toBeTruthy();
@@ -41,7 +41,7 @@ describe("TextField component rendering", () => {
41
41
  );
42
42
 
43
43
  const textFieldContainer = screen.getByTestId("text-field-container");
44
- const inputComponent = screen.getByTestId("inputComponent");
44
+ const inputComponent = screen.getByTestId("input-component");
45
45
  const prefix = screen.getByTestId("prefix");
46
46
  expect(textFieldContainer).toBeTruthy();
47
47
  expect(inputComponent).toBeTruthy();
@@ -62,8 +62,8 @@ describe("TextField component rendering", () => {
62
62
  );
63
63
 
64
64
  const textFieldContainer = screen.getByTestId("text-field-container");
65
- const inputComponent = screen.getByTestId("inputComponent");
66
- const backgroundIconComponent = screen.getByTestId("backgroundIconComponent");
65
+ const inputComponent = screen.getByTestId("input-component");
66
+ const backgroundIconComponent = screen.getByTestId("background-icon-component");
67
67
 
68
68
  expect(textFieldContainer).toBeTruthy();
69
69
  expect(inputComponent).toBeTruthy();
@@ -84,8 +84,8 @@ describe("TextField component rendering", () => {
84
84
  );
85
85
 
86
86
  const textFieldContainer = screen.getByTestId("text-field-container");
87
- const inputComponent = screen.getByTestId("inputComponent");
88
- const iconWrapperComponent = screen.getByTestId("iconWrapperComponent");
87
+ const inputComponent = screen.getByTestId("input-component");
88
+ const iconWrapperComponent = screen.getByTestId("icon-wrapper-component");
89
89
 
90
90
  expect(textFieldContainer).toBeTruthy();
91
91
  expect(inputComponent).toBeTruthy();
@@ -110,7 +110,7 @@ describe("onClick from buttons", () => {
110
110
  </ThemeProvider>
111
111
  );
112
112
 
113
- const backgroundIconComponent = screen.getByTestId("backgroundIconComponent");
113
+ const backgroundIconComponent = screen.getByTestId("background-icon-component");
114
114
  expect(backgroundIconComponent).toBeTruthy();
115
115
 
116
116
  fireEvent.click(backgroundIconComponent);
@@ -133,7 +133,7 @@ describe("onClick from buttons", () => {
133
133
  </ThemeProvider>
134
134
  );
135
135
 
136
- const iconWrapperComponent = screen.getByTestId("iconWrapperComponent");
136
+ const iconWrapperComponent = screen.getByTestId("icon-wrapper-component");
137
137
  expect(iconWrapperComponent).toBeTruthy();
138
138
  const iconActionComponent = within(iconWrapperComponent).getByTestId("icon-action-component");
139
139
  expect(iconActionComponent).toBeTruthy();
@@ -337,7 +337,7 @@ describe("onChange events", () => {
337
337
  );
338
338
  });
339
339
 
340
- const inputComponents = screen.getAllByTestId("inputComponent");
340
+ const inputComponents = screen.getAllByTestId("input-component");
341
341
 
342
342
  await act(async () => {
343
343
  fireEvent.change(inputComponents[0], { target: { value: "eooo" } });
@@ -388,7 +388,7 @@ describe("onClick events", () => {
388
388
  const selectionListItem = screen.getAllByTestId("selection-list-item");
389
389
  selectionListItem[0].click();
390
390
 
391
- const inputComponents = screen.getAllByTestId("inputComponent");
391
+ const inputComponents = screen.getAllByTestId("input-component");
392
392
  fireEvent.change(inputComponents[0], { value: "foo" });
393
393
  });
394
394