@griddo/ax 1.75.33 → 1.75.35

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.
@@ -1,4 +1,5 @@
1
1
  module.exports = {
2
+ SiteProvider: jest.fn(),
2
3
  schemas: {
3
4
  key: "schema definition",
4
5
  all: {
@@ -1501,4 +1502,4 @@ module.exports = {
1501
1502
  },
1502
1503
  },
1503
1504
  },
1504
- };
1505
+ };
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.33",
4
+ "version": "1.75.35",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -183,7 +183,8 @@
183
183
  "react-test-render": "1.1.2",
184
184
  "react-test-renderer": "^18.2.0",
185
185
  "redux-mock-store": "^1.5.4",
186
- "ts-jest": "^27.1.4"
186
+ "ts-jest": "^27.1.4",
187
+ "ts-node": "^10.9.1"
187
188
  },
188
189
  "resolutions": {
189
190
  "react-error-overlay": "6.0.9"
@@ -229,5 +230,5 @@
229
230
  "publishConfig": {
230
231
  "access": "public"
231
232
  },
232
- "gitHead": "8fd3e9c38978faee9d3860c4f2613423bc59e117"
233
+ "gitHead": "b07f3c7a091191e2bcc82ff31bb034456d68f4d0"
233
234
  }
@@ -2,11 +2,11 @@
2
2
 
3
3
  exports[`Avatar component rendering should render the component only with name 1`] = `
4
4
  <div
5
- className="sc-gSAPjG jRkXjC"
5
+ className="sc-gScZFl gCBoym"
6
6
  data-testid="avatar-wrapper"
7
7
  >
8
8
  <div
9
- className="sc-lbxAil fkodDH"
9
+ className="sc-lbVpMG hOAqbs"
10
10
  data-testid="avatar"
11
11
  />
12
12
  </div>
@@ -14,11 +14,11 @@ exports[`Avatar component rendering should render the component only with name 1
14
14
 
15
15
  exports[`Avatar component rendering should render the component with a wrong image url 1`] = `
16
16
  <div
17
- className="sc-gSAPjG jRkXjC"
17
+ className="sc-gScZFl gCBoym"
18
18
  data-testid="avatar-wrapper"
19
19
  >
20
20
  <div
21
- className="sc-lbxAil ejhcAS"
21
+ className="sc-lbVpMG kLnTvZ"
22
22
  data-testid="avatar"
23
23
  />
24
24
  </div>
@@ -26,11 +26,11 @@ exports[`Avatar component rendering should render the component with a wrong ima
26
26
 
27
27
  exports[`Avatar component rendering should render the component with an empty string as name 1`] = `
28
28
  <div
29
- className="sc-gSAPjG jRkXjC"
29
+ className="sc-gScZFl gCBoym"
30
30
  data-testid="avatar-wrapper"
31
31
  >
32
32
  <div
33
- className="sc-lbxAil hilXDA"
33
+ className="sc-lbVpMG dbQJiT"
34
34
  data-testid="avatar"
35
35
  />
36
36
  </div>
@@ -38,11 +38,11 @@ exports[`Avatar component rendering should render the component with an empty st
38
38
 
39
39
  exports[`Avatar component rendering should render the component with image null 1`] = `
40
40
  <div
41
- className="sc-gSAPjG jRkXjC"
41
+ className="sc-gScZFl gCBoym"
42
42
  data-testid="avatar-wrapper"
43
43
  >
44
44
  <div
45
- className="sc-lbxAil jDWEnq"
45
+ className="sc-lbVpMG jpmXvZ"
46
46
  data-testid="avatar"
47
47
  />
48
48
  </div>
@@ -50,11 +50,11 @@ exports[`Avatar component rendering should render the component with image null
50
50
 
51
51
  exports[`Avatar component rendering should render the component without name or image 1`] = `
52
52
  <div
53
- className="sc-gSAPjG jRkXjC"
53
+ className="sc-gScZFl gCBoym"
54
54
  data-testid="avatar-wrapper"
55
55
  >
56
56
  <div
57
- className="sc-lbxAil hilXDA"
57
+ className="sc-lbVpMG dbQJiT"
58
58
  data-testid="avatar"
59
59
  />
60
60
  </div>
@@ -0,0 +1,201 @@
1
+ import * as React from "react";
2
+
3
+ import { ThemeProvider } from "styled-components";
4
+ import { render, cleanup, screen, fireEvent, waitFor, act } 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 Browser, { IBrowserProps } from "@ax/components/Browser";
10
+ import globalTheme from "@ax/themes/theme.json";
11
+
12
+ afterEach(() => {
13
+ jest.resetAllMocks();
14
+ cleanup();
15
+ });
16
+
17
+ const defaultProps = mock<IBrowserProps>();
18
+
19
+ defaultProps.content = {};
20
+ defaultProps.browserRef = {
21
+ current: "",
22
+ };
23
+ defaultProps.cloudinaryName = "thesaurus-cms";
24
+ defaultProps.disabled = false;
25
+ defaultProps.footer = {};
26
+ defaultProps.header = {};
27
+ defaultProps.isPage = true;
28
+ defaultProps.siteID = 108;
29
+ defaultProps.siteLangs = [{}];
30
+ defaultProps.socials = {
31
+ facebook: "https://www.facebook.com/SlothSanctuaryCostaRica",
32
+ instagram: "https://www.instagram.com/sloth.sanctuary.costa.rica/",
33
+ };
34
+ defaultProps.theme = "default-theme";
35
+ defaultProps.url = "/gallery-stuff";
36
+
37
+ describe("Browser component rendering", () => {
38
+ it("should render the component", () => {
39
+ defaultProps.isPreview = false;
40
+ defaultProps.showIframe = true;
41
+
42
+ render(
43
+ <ThemeProvider theme={parseTheme(globalTheme)}>
44
+ <Browser {...defaultProps} />
45
+ </ThemeProvider>
46
+ );
47
+
48
+ const navActionsWrapper = screen.queryByTestId("nav-actions-wrapper");
49
+ expect(navActionsWrapper).not.toBeTruthy();
50
+ const browserWrapper = screen.getByTestId("browser-wrapper");
51
+ expect(browserWrapper).toBeTruthy();
52
+ const showIframeWrapper = screen.queryByTestId("navbar-iframe-wrapper");
53
+ expect(showIframeWrapper).toBeTruthy();
54
+ const browserContentWrapper = screen.queryByTestId("browser-content-wrapper");
55
+ expect(browserContentWrapper).not.toBeTruthy();
56
+ });
57
+
58
+ it("should do the copyUrl action and return console error", () => {
59
+ defaultProps.isPreview = true;
60
+ defaultProps.showIframe = true;
61
+
62
+ document.execCommand = jest.fn();
63
+ console.log = jest.fn();
64
+
65
+ render(
66
+ <ThemeProvider theme={parseTheme(globalTheme)}>
67
+ <Browser {...defaultProps} />
68
+ </ThemeProvider>
69
+ );
70
+
71
+ const navActionsWrapper = screen.queryByTestId("nav-actions-wrapper");
72
+ expect(navActionsWrapper).toBeTruthy();
73
+ const browserWrapper = screen.getByTestId("browser-wrapper");
74
+ expect(browserWrapper).toBeTruthy();
75
+
76
+ const iconWrapperBrowser = screen.getAllByTestId("icon-wrapper-browser");
77
+
78
+ fireEvent.click(iconWrapperBrowser[0]);
79
+ waitFor(() => expect(console.log).toHaveBeenCalledWith("Could not copy text:"));
80
+ });
81
+
82
+ it("should do the copyUrl action and return document.execCommand call", () => {
83
+ defaultProps.isPreview = true;
84
+ defaultProps.showIframe = true;
85
+
86
+ Object.assign(document, {
87
+ execCommand: jest.fn().mockImplementation(() => Promise.resolve()),
88
+ });
89
+
90
+ render(
91
+ <ThemeProvider theme={parseTheme(globalTheme)}>
92
+ <Browser {...defaultProps} />
93
+ </ThemeProvider>
94
+ );
95
+ const browserWrapper = screen.getByTestId("browser-wrapper");
96
+ expect(browserWrapper).toBeTruthy();
97
+
98
+ const iconWrapperBrowser = screen.getAllByTestId("icon-wrapper-browser");
99
+
100
+ fireEvent.click(iconWrapperBrowser[0]);
101
+ waitFor(() => expect(screen.getByText(/URL Copied/i)).toBeInTheDocument());
102
+ });
103
+
104
+ it("should do the copyUrl action and return clipboard call", () => {
105
+ defaultProps.isPreview = true;
106
+ defaultProps.showIframe = true;
107
+
108
+ Object.assign(navigator, {
109
+ clipboard: {
110
+ writeText: jest.fn().mockImplementation(() => Promise.resolve()),
111
+ },
112
+ });
113
+
114
+ Object.assign(window, {
115
+ isSecureContext: {},
116
+ });
117
+
118
+ jest.spyOn(navigator.clipboard, "writeText");
119
+
120
+ render(
121
+ <ThemeProvider theme={parseTheme(globalTheme)}>
122
+ <Browser {...defaultProps} />
123
+ </ThemeProvider>
124
+ );
125
+
126
+ const browserWrapper = screen.getByTestId("browser-wrapper");
127
+ expect(browserWrapper).toBeTruthy();
128
+
129
+ const iconWrapperBrowser = screen.getAllByTestId("icon-wrapper-browser");
130
+ fireEvent.click(iconWrapperBrowser[0]);
131
+ waitFor(() =>
132
+ expect(navigator.clipboard.writeText).toBeCalledWith(
133
+ "http://localhost/page-preview/4390/c221db88-41bf-423b-8e40-d5f7837db627"
134
+ )
135
+ );
136
+ });
137
+
138
+ it("should render the browserContent", () => {
139
+ defaultProps.isPreview = false;
140
+ defaultProps.showIframe = false;
141
+ const deleteModuleActionMock = defaultProps.actions?.deleteModuleAction as jest.MockedFunction<
142
+ (editorID: number) => void
143
+ >;
144
+ const duplicateModuleActionMock = defaultProps.actions?.duplicateModuleAction as jest.MockedFunction<
145
+ (editorID: number) => Promise<number>
146
+ >;
147
+ const setSelectedContentActionMock = defaultProps.actions?.setSelectedContentAction as jest.MockedFunction<
148
+ () => void
149
+ >;
150
+
151
+ render(
152
+ <ThemeProvider theme={parseTheme(globalTheme)}>
153
+ <Browser {...defaultProps} />
154
+ </ThemeProvider>
155
+ );
156
+ const navActionsWrapper = screen.queryByTestId("nav-actions-wrapper");
157
+ expect(navActionsWrapper).not.toBeTruthy();
158
+ const showIframeWrapper = screen.queryByTestId("navbar-iframe-wrapper");
159
+ expect(showIframeWrapper).not.toBeTruthy();
160
+ const browserContentWrapper = screen.queryByTestId("browser-content-wrapper");
161
+ expect(browserContentWrapper).toBeTruthy();
162
+ });
163
+
164
+ it("should change the iFrame width when changing the resulution", () => {
165
+ defaultProps.isPreview = true;
166
+ defaultProps.showIframe = true;
167
+ const deleteModuleActionMock = defaultProps.actions?.deleteModuleAction as jest.MockedFunction<
168
+ (editorID: number) => void
169
+ >;
170
+ const duplicateModuleActionMock = defaultProps.actions?.duplicateModuleAction as jest.MockedFunction<
171
+ (editorID: number) => Promise<number>
172
+ >;
173
+ const setSelectedContentActionMock = defaultProps.actions?.setSelectedContentAction as jest.MockedFunction<
174
+ () => void
175
+ >;
176
+
177
+ render(
178
+ <ThemeProvider theme={parseTheme(globalTheme)}>
179
+ <Browser {...defaultProps} />
180
+ </ThemeProvider>
181
+ );
182
+ const navActionsWrapper = screen.queryByTestId("nav-actions-wrapper");
183
+ expect(navActionsWrapper).toBeTruthy();
184
+ const showIframeWrapper = screen.queryByTestId("navbar-iframe-wrapper");
185
+ expect(showIframeWrapper).toBeTruthy();
186
+ const browserContentWrapper = screen.queryByTestId("browser-content-wrapper");
187
+ expect(browserContentWrapper).not.toBeTruthy();
188
+
189
+ const iframe = document.querySelector("iframe");
190
+ expect(iframe).toBeTruthy();
191
+ expect(iframe?.width).toBe("100%");
192
+
193
+ const iconActionTablet = screen.getByTestId("icon-res-tablet");
194
+ fireEvent.click(iconActionTablet);
195
+ expect(iframe?.width).toBe("768px");
196
+
197
+ const iconActionPhone = screen.getByTestId("icon-res-phone");
198
+ fireEvent.click(iconActionPhone);
199
+ expect(iframe?.width).toBe("425px");
200
+ });
201
+ });
@@ -0,0 +1,167 @@
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 "@testing-library/jest-dom";
6
+ import userEvent from "@testing-library/user-event";
7
+
8
+ import { parseTheme } from "@ax/helpers";
9
+ import BulkSelectionOptions from "@ax/components/BulkSelectionOptions";
10
+ import globalTheme from "@ax/themes/theme.json";
11
+
12
+ afterEach(() => {
13
+ jest.resetAllMocks();
14
+ cleanup();
15
+ });
16
+ const propActionMock = jest.fn();
17
+ const selectItemsMock = jest.fn();
18
+ const defaultProps = {
19
+ isScrolling: false,
20
+ checkState: { isAllSelected: false, indeterminate: false },
21
+ actions: [
22
+ {
23
+ icon: "delete",
24
+ text: "delete",
25
+ action: propActionMock,
26
+ },
27
+ ],
28
+ selectItems: selectItemsMock,
29
+ totalItems: 1234,
30
+ };
31
+
32
+ describe("Browser component rendering", () => {
33
+ it("should render the component", () => {
34
+ render(
35
+ <ThemeProvider theme={parseTheme(globalTheme)}>
36
+ <BulkSelectionOptions {...defaultProps} />
37
+ </ThemeProvider>
38
+ );
39
+
40
+ const bulkHeaderWrapper = screen.getByTestId("bulk-header-wrapper");
41
+ expect(bulkHeaderWrapper).toBeTruthy();
42
+
43
+ const tableCounter = screen.getByTestId("table-counter");
44
+ expect(tableCounter).toBeTruthy();
45
+ expect(screen.getByText("1234 results")).toBeInTheDocument();
46
+ });
47
+
48
+ it("should call the action on onclick", () => {
49
+ render(
50
+ <ThemeProvider theme={parseTheme(globalTheme)}>
51
+ <BulkSelectionOptions {...defaultProps} />
52
+ </ThemeProvider>
53
+ );
54
+
55
+ const bulkHeaderWrapper = screen.getByTestId("bulk-header-wrapper");
56
+ expect(bulkHeaderWrapper).toBeTruthy();
57
+ const buttonText = screen.getByTestId("button-text");
58
+ expect(buttonText).toBeTruthy();
59
+ fireEvent.click(buttonText);
60
+ expect(propActionMock).toHaveBeenCalled();
61
+ });
62
+
63
+ it("should call the action on onchange", async () => {
64
+ const user = userEvent.setup();
65
+ render(
66
+ <ThemeProvider theme={parseTheme(globalTheme)}>
67
+ <BulkSelectionOptions {...defaultProps} />
68
+ </ThemeProvider>
69
+ );
70
+
71
+ const bulkHeaderWrapper = screen.getByTestId("bulk-header-wrapper");
72
+ expect(bulkHeaderWrapper).toBeTruthy();
73
+ const checkFieldInput = screen.getByTestId<HTMLInputElement>("check-field-input");
74
+ expect(checkFieldInput).toBeTruthy();
75
+ await user.click(checkFieldInput);
76
+ expect(selectItemsMock).toHaveBeenCalled();
77
+ });
78
+
79
+ it("should mark the check if isAllSelected", () => {
80
+ const defaultPropsCheck = {
81
+ isScrolling: false,
82
+ checkState: { isAllSelected: true, indeterminate: false },
83
+ actions: [
84
+ {
85
+ icon: "delete",
86
+ text: "delete",
87
+ action: propActionMock,
88
+ },
89
+ ],
90
+ selectItems: selectItemsMock,
91
+ totalItems: 10,
92
+ };
93
+
94
+ render(
95
+ <ThemeProvider theme={parseTheme(globalTheme)}>
96
+ <BulkSelectionOptions {...defaultPropsCheck} />
97
+ </ThemeProvider>
98
+ );
99
+
100
+ const bulkHeaderWrapper = screen.getByTestId("bulk-header-wrapper");
101
+ expect(bulkHeaderWrapper).toBeTruthy();
102
+
103
+ const checkFieldCheckMark = screen.getAllByTestId<HTMLInputElement>("check-field-check-mark");
104
+ checkFieldCheckMark.map((item) => {
105
+ expect(item.checked).toBe(true);
106
+ });
107
+ });
108
+
109
+ it("should change the style if indeterminate is true", () => {
110
+ const defaultPropsCheck = {
111
+ isScrolling: false,
112
+ checkState: { isAllSelected: false, indeterminate: true },
113
+ actions: [
114
+ {
115
+ icon: "delete",
116
+ text: "delete",
117
+ action: propActionMock,
118
+ },
119
+ ],
120
+ selectItems: selectItemsMock,
121
+ totalItems: 10,
122
+ };
123
+
124
+ render(
125
+ <ThemeProvider theme={parseTheme(globalTheme)}>
126
+ <BulkSelectionOptions {...defaultPropsCheck} />
127
+ </ThemeProvider>
128
+ );
129
+
130
+ const bulkHeaderWrapper = screen.getByTestId("bulk-header-wrapper");
131
+ expect(bulkHeaderWrapper).toBeTruthy();
132
+ const theme = parseTheme(globalTheme);
133
+ expect(bulkHeaderWrapper).not.toHaveStyle(`border-bottom: 1px solid ${theme.color.uiLine}`);
134
+
135
+ const checkFieldCheckMark = screen.getAllByTestId<HTMLInputElement>("check-field-check-mark");
136
+ checkFieldCheckMark.map((item) => {
137
+ expect(item.checked).toBe(false);
138
+ expect(item).toHaveStyle("border: 2px solid #5057FF");
139
+ });
140
+ });
141
+
142
+ it("should show the borderBottom whe isScrolling is true", () => {
143
+ const defaultPropsCheck = {
144
+ isScrolling: true,
145
+ checkState: { isAllSelected: true, indeterminate: false },
146
+ actions: [
147
+ {
148
+ icon: "delete",
149
+ text: "delete",
150
+ action: propActionMock,
151
+ },
152
+ ],
153
+ selectItems: selectItemsMock,
154
+ totalItems: 10,
155
+ };
156
+
157
+ render(
158
+ <ThemeProvider theme={parseTheme(globalTheme)}>
159
+ <BulkSelectionOptions {...defaultPropsCheck} />
160
+ </ThemeProvider>
161
+ );
162
+ const theme = parseTheme(globalTheme);
163
+ const bulkHeaderWrapper = screen.getByTestId("bulk-header-wrapper");
164
+ expect(bulkHeaderWrapper).toBeTruthy();
165
+ expect(bulkHeaderWrapper).toHaveStyle(`border-bottom: 1px solid ${theme.color.uiLine}`);
166
+ });
167
+ });
@@ -0,0 +1,66 @@
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 CategoryCell, { ICategoryCellProps } from "@ax/components/CategoryCell";
10
+ import globalTheme from "@ax/themes/theme.json";
11
+
12
+ afterEach(cleanup);
13
+
14
+ const defaultProps = mock<ICategoryCellProps>();
15
+ const addCategoryColorsMock = defaultProps.addCategoryColors as jest.MockedFunction<(cats: string[]) => void>;
16
+
17
+ describe("CategoryCell component rendering", () => {
18
+ it("should render the component with no elements", () => {
19
+ defaultProps.categoryColors = {};
20
+ defaultProps.categories = false;
21
+
22
+ render(
23
+ <ThemeProvider theme={parseTheme(globalTheme)}>
24
+ <CategoryCell {...defaultProps} />
25
+ </ThemeProvider>
26
+ );
27
+
28
+ expect(screen.queryByTestId("elements-wrapper")).not.toBeTruthy();
29
+ });
30
+
31
+ it("should render the component with one element and no remaining element", () => {
32
+ defaultProps.categoryColors = {
33
+ Hogwarts: "#FFE695",
34
+ };
35
+ defaultProps.categories = ["Hogwarts"];
36
+
37
+ render(
38
+ <ThemeProvider theme={parseTheme(globalTheme)}>
39
+ <CategoryCell {...defaultProps} />
40
+ </ThemeProvider>
41
+ );
42
+
43
+ expect(addCategoryColorsMock).toBeCalled();
44
+ expect(screen.getByTestId("elements-wrapper")).toBeTruthy();
45
+ expect(screen.queryByTestId("remaining-element")).not.toBeTruthy();
46
+ });
47
+
48
+ it("should render the component with two remaining elements", () => {
49
+ defaultProps.categoryColors = {
50
+ Hogwarts: "#FFE695",
51
+ Test: "#FFE695",
52
+ };
53
+ defaultProps.categories = ["Hogwarts", "Test"];
54
+
55
+ render(
56
+ <ThemeProvider theme={parseTheme(globalTheme)}>
57
+ <CategoryCell {...defaultProps} />
58
+ </ThemeProvider>
59
+ );
60
+
61
+ expect(addCategoryColorsMock).toBeCalled();
62
+ expect(screen.getByTestId("elements-wrapper")).toBeTruthy();
63
+ expect(screen.getByTestId("remaining-element")).toBeTruthy();
64
+ expect(screen.getAllByTestId("div-element")).toHaveLength(2);
65
+ });
66
+ });
@@ -1,9 +1,12 @@
1
1
  import React from "react";
2
- import CheckField from "@ax/components/Fields/CheckField";
2
+
3
3
  import { ThemeProvider } from "styled-components";
4
+ import "@testing-library/jest-dom";
5
+ import { render, screen, cleanup, fireEvent } from "@testing-library/react";
6
+
7
+ import CheckField from "@ax/components/Fields/CheckField";
4
8
  import { parseTheme } from "@ax/helpers";
5
9
  import globalTheme from "@ax/themes/theme.json";
6
- import { render, screen, cleanup, fireEvent } from "@testing-library/react";
7
10
 
8
11
  afterEach(cleanup);
9
12
 
@@ -29,11 +32,71 @@ describe("CheckField component rendering", () => {
29
32
 
30
33
  const checkFieldLabel = screen.getByTestId("check-field-label");
31
34
  const checkFieldInput = screen.getByTestId("check-field-input");
32
- const checkFieldCheckMark = screen.getByTestId("checkFieldCheckMark");
35
+ const checkFieldCheckMark = screen.getByTestId("check-field-check-mark");
36
+
37
+ expect(checkFieldLabel).toBeTruthy();
38
+ expect(checkFieldInput).toBeTruthy();
39
+ expect(checkFieldCheckMark).toBeTruthy();
40
+ });
41
+
42
+ it("should been checked", () => {
43
+ const newProps = {
44
+ name: "",
45
+ title: "",
46
+ value: "",
47
+ checked: true,
48
+ error: false,
49
+ disabled: false,
50
+ indeterminate: false,
51
+ onChange: jest.fn(),
52
+ icon: "",
53
+ };
54
+
55
+ render(
56
+ <ThemeProvider theme={parseTheme(globalTheme)}>
57
+ <CheckField {...newProps} />
58
+ </ThemeProvider>
59
+ );
60
+
61
+ const checkFieldLabel = screen.getByTestId("check-field-label");
62
+ const checkFieldInput = screen.getByTestId("check-field-input");
63
+ const checkFieldCheckMark = screen.getByTestId<HTMLInputElement>("check-field-check-mark");
64
+
65
+ expect(checkFieldLabel).toBeTruthy();
66
+ expect(checkFieldInput).toBeTruthy();
67
+ expect(checkFieldCheckMark).toBeTruthy();
68
+ expect(checkFieldCheckMark.checked).toBe(true);
69
+ });
70
+
71
+ it("should change the style if indeterminate is true", () => {
72
+ const newProps = {
73
+ name: "",
74
+ title: "",
75
+ value: "",
76
+ checked: false,
77
+ error: false,
78
+ disabled: false,
79
+ indeterminate: true,
80
+ onChange: jest.fn(),
81
+ icon: "",
82
+ };
83
+
84
+ render(
85
+ <ThemeProvider theme={parseTheme(globalTheme)}>
86
+ <CheckField {...newProps} />
87
+ </ThemeProvider>
88
+ );
89
+
90
+ const checkFieldLabel = screen.getByTestId("check-field-label");
91
+ const checkFieldInput = screen.getByTestId("check-field-input");
92
+ const checkFieldCheckMark = screen.getByTestId<HTMLInputElement>("check-field-check-mark");
33
93
 
34
94
  expect(checkFieldLabel).toBeTruthy();
35
95
  expect(checkFieldInput).toBeTruthy();
36
96
  expect(checkFieldCheckMark).toBeTruthy();
97
+ expect(checkFieldCheckMark.checked).toBe(false);
98
+ const theme = parseTheme(globalTheme);
99
+ expect(checkFieldCheckMark).toHaveStyle(`border: 2px solid ${theme.colors.interactive01}`);
37
100
  });
38
101
 
39
102
  it("should render the component with icon", () => {
@@ -105,12 +105,12 @@ const Browser = (props: IBrowserProps): JSX.Element => {
105
105
  };
106
106
 
107
107
  return (
108
- <S.BrowserWrapper ref={browserRef}>
108
+ <S.BrowserWrapper data-testid="browser-wrapper" ref={browserRef}>
109
109
  <S.NavBar>
110
110
  <S.NavUrl>{url}</S.NavUrl>
111
111
  {isPreview && (
112
- <S.NavActions>
113
- <S.IconWrapper onClick={copyUrl}>
112
+ <S.NavActions data-testid="nav-actions-wrapper">
113
+ <S.IconWrapper data-testid="icon-wrapper-browser" onClick={copyUrl}>
114
114
  <Tooltip content="Copy url to share draft" bottom>
115
115
  <Icon name="share" size="24" />
116
116
  </Tooltip>
@@ -120,12 +120,20 @@ const Browser = (props: IBrowserProps): JSX.Element => {
120
120
  <Icon name="desktop" size="24" />
121
121
  </Tooltip>
122
122
  </S.IconWrapper>
123
- <S.IconWrapper active={resolution === "tablet"} onClick={() => setResolution("tablet")}>
123
+ <S.IconWrapper
124
+ data-testid="icon-res-tablet"
125
+ active={resolution === "tablet"}
126
+ onClick={() => setResolution("tablet")}
127
+ >
124
128
  <Tooltip content="Tablet" bottom>
125
129
  <Icon name="tablet" size="24" />
126
130
  </Tooltip>
127
131
  </S.IconWrapper>
128
- <S.IconWrapper active={resolution === "phone"} onClick={() => setResolution("phone")}>
132
+ <S.IconWrapper
133
+ data-testid="icon-res-phone"
134
+ active={resolution === "phone"}
135
+ onClick={() => setResolution("phone")}
136
+ >
129
137
  <Tooltip content="Mobile" bottom>
130
138
  <Icon name="phone" size="24" />
131
139
  </Tooltip>
@@ -134,11 +142,15 @@ const Browser = (props: IBrowserProps): JSX.Element => {
134
142
  )}
135
143
  </S.NavBar>
136
144
  {showIframe ? (
137
- <S.FrameWrapper>
145
+ <S.FrameWrapper data-testid="navbar-iframe-wrapper">
138
146
  <iframe title="Preview" width={getWidth(resolution)} height="100%" src={urlPreview} loading="lazy" />
139
147
  </S.FrameWrapper>
140
148
  ) : (
141
- <S.Wrapper ref={(ref: any) => ((window as any).browserRef = ref)} className="browser-content">
149
+ <S.Wrapper
150
+ data-testid="browser-content-wrapper"
151
+ ref={(ref: any) => ((window as any).browserRef = ref)}
152
+ className="browser-content"
153
+ >
142
154
  <BrowserContent
143
155
  cloudinaryName={cloudinaryName}
144
156
  theme={theme}
@@ -162,7 +174,7 @@ const Browser = (props: IBrowserProps): JSX.Element => {
162
174
  );
163
175
  };
164
176
 
165
- interface IBrowserProps {
177
+ export interface IBrowserProps {
166
178
  content: any;
167
179
  header?: any;
168
180
  footer?: any;
@@ -4,11 +4,11 @@ import { Button, CheckField, TableCounter } from "@ax/components";
4
4
 
5
5
  import * as S from "./style";
6
6
 
7
- const BulkSelectionOptions = (props: any) => {
7
+ const BulkSelectionOptions = (props: IBulkSelectionProps) => {
8
8
  const { isScrolling, checkState, actions, selectItems, totalItems } = props;
9
9
 
10
10
  return (
11
- <S.BulkHeader isScrolling={isScrolling}>
11
+ <S.BulkHeader data-testid="bulk-header-wrapper" isScrolling={isScrolling}>
12
12
  <S.BulkActionsWrapper>
13
13
  <S.SelectAllCheckField>
14
14
  <CheckField
@@ -24,14 +24,9 @@ const BulkSelectionOptions = (props: any) => {
24
24
  </S.SelectAllCheckField>
25
25
  <S.BulkActions>
26
26
  {actions.map((item: any) => (
27
- <Button
28
- key={item.text}
29
- type="button"
30
- buttonStyle="text"
31
- icon={item.icon}
32
- children={item.text}
33
- onClick={item.action}
34
- />
27
+ <Button key={item.text} type="button" buttonStyle="text" icon={item.icon} onClick={item.action}>
28
+ {item.text}
29
+ </Button>
35
30
  ))}
36
31
  </S.BulkActions>
37
32
  <S.Counter>
@@ -42,4 +37,16 @@ const BulkSelectionOptions = (props: any) => {
42
37
  );
43
38
  };
44
39
 
40
+ interface IBulkSelectionProps {
41
+ checkState: any;
42
+ actions: {
43
+ icon: string;
44
+ text: string;
45
+ action: () => void;
46
+ }[];
47
+ selectItems: () => void;
48
+ totalItems: number;
49
+ isScrolling?: boolean;
50
+ }
51
+
45
52
  export default BulkSelectionOptions;
@@ -1,8 +1,8 @@
1
1
  import React, { useEffect } from "react";
2
2
  import { ElementsTooltip } from "@ax/components";
3
- import * as S from "./style"
3
+ import * as S from "./style";
4
4
 
5
- const CategoryCell = (props: IProps): JSX.Element => {
5
+ const CategoryCell = (props: ICategoryCellProps): JSX.Element => {
6
6
  const { categories, categoryColors, addCategoryColors } = props;
7
7
 
8
8
  useEffect(() => {
@@ -17,7 +17,7 @@ const CategoryCell = (props: IProps): JSX.Element => {
17
17
  );
18
18
  };
19
19
 
20
- interface IProps {
20
+ export interface ICategoryCellProps {
21
21
  categories: any;
22
22
  categoryColors: any;
23
23
  addCategoryColors(cats: string[]): void;
@@ -46,7 +46,7 @@ const CheckField = ({
46
46
  aria-label={`${name}`}
47
47
  />
48
48
  <S.CheckMark
49
- data-testid={"checkFieldCheckMark"}
49
+ data-testid="check-field-check-mark"
50
50
  checked={checked}
51
51
  error={error}
52
52
  indeterminate={indeterminate}
@@ -41,9 +41,9 @@ const BulkHeader = (props: IProps): JSX.Element => {
41
41
  filterItems={filterItems}
42
42
  filterValues={filterValues}
43
43
  isSiteItem={isSiteItem}
44
- sortItems={sortItems}
45
- sortedListStatus={sortedListStatus}
46
- />
44
+ sortItems={sortItems}
45
+ sortedListStatus={sortedListStatus}
46
+ />
47
47
  );
48
48
  };
49
49