@griddo/ax 11.11.8-rc.1 → 11.12.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/config/jest/componentsMock.js +5 -7
- package/package.json +2 -2
- package/src/__tests__/components/Browser/Browser.test.tsx +87 -438
- package/src/__tests__/components/ConfigPanel/ConfigPanel.test.tsx +3 -1
- package/src/__tests__/components/Fields/Button/Button.test.tsx +27 -29
- package/src/__tests__/components/ResizePanel/ResizePanel.test.tsx +1 -1
- package/src/components/Browser/index.tsx +149 -294
- package/src/components/Browser/style.tsx +6 -75
- package/src/components/Button/index.tsx +1 -2
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +4 -2
- package/src/components/Fields/AsyncSelect/style.tsx +0 -13
- package/src/components/Fields/FieldGroup/index.tsx +2 -5
- package/src/components/Fields/FieldGroup/style.tsx +7 -32
- package/src/components/Fields/HeadingField/index.tsx +2 -2
- package/src/components/Fields/HiddenField/style.tsx +1 -1
- package/src/components/Fields/NumberField/index.tsx +16 -15
- package/src/components/Fields/NumberField/style.tsx +0 -2
- package/src/components/Fields/ReferenceField/index.tsx +1 -1
- package/src/components/Fields/Select/index.tsx +1 -5
- package/src/components/Fields/Select/style.tsx +0 -56
- package/src/components/Fields/SummaryButton/index.tsx +9 -18
- package/src/components/Fields/SummaryButton/style.tsx +2 -1
- package/src/components/Fields/TagsField/index.tsx +9 -8
- package/src/components/Fields/UrlField/index.tsx +27 -26
- package/src/components/Fields/index.tsx +0 -2
- package/src/components/FloatingPanel/index.tsx +2 -5
- package/src/components/FloatingPanel/style.tsx +1 -2
- package/src/components/IconAction/index.tsx +1 -1
- package/src/components/MainWrapper/AppBar/index.tsx +1 -8
- package/src/components/MainWrapper/index.tsx +1 -7
- package/src/components/Notification/index.tsx +2 -2
- package/src/components/PageFinder/index.tsx +1 -1
- package/src/components/ResizePanel/index.tsx +3 -4
- package/src/components/ResizePanel/style.tsx +1 -1
- package/src/components/SearchField/style.tsx +2 -2
- package/src/components/SideModal/index.tsx +1 -2
- package/src/components/Tabs/index.tsx +4 -13
- package/src/components/Tabs/style.tsx +8 -7
- package/src/components/Toast/index.tsx +2 -4
- package/src/components/Tooltip/index.tsx +3 -4
- package/src/components/index.tsx +0 -8
- package/src/forms/fields.tsx +68 -70
- package/src/hooks/forms.tsx +1 -22
- package/src/hooks/index.tsx +3 -13
- package/src/hooks/modals.tsx +15 -103
- package/src/hooks/users.tsx +8 -25
- package/src/modules/Forms/atoms.tsx +2 -2
- package/src/modules/FramePreview/index.tsx +16 -55
- package/src/modules/FramePreview/style.tsx +2 -34
- package/src/modules/GlobalEditor/Editor/index.tsx +3 -37
- package/src/modules/GlobalEditor/PageBrowser/index.tsx +2 -19
- package/src/modules/GlobalEditor/Preview/index.tsx +2 -0
- package/src/modules/GlobalEditor/Preview/style.tsx +1 -1
- package/src/modules/GlobalEditor/index.tsx +57 -119
- package/src/modules/PageEditor/Editor/index.tsx +2 -33
- package/src/modules/PageEditor/PageBrowser/index.tsx +2 -20
- package/src/modules/PageEditor/Preview/index.tsx +2 -0
- package/src/modules/PageEditor/Preview/style.tsx +1 -1
- package/src/modules/PageEditor/atoms.tsx +1 -1
- package/src/modules/PageEditor/index.tsx +66 -130
- package/src/modules/PublicPreview/index.tsx +2 -5
- package/src/schemas/pages/GlobalPage.ts +70 -87
- package/src/schemas/pages/Page.ts +70 -87
- package/src/types/index.tsx +0 -12
- package/src/__tests__/components/Browser/Browser.utils.test.ts +0 -55
- package/src/__tests__/components/HeadingsPreviewModal/ErrorsBanner/ErrorItem/ErrorItem.test.tsx +0 -158
- package/src/__tests__/components/HeadingsPreviewModal/ErrorsBanner/ErrorsBanner.test.tsx +0 -90
- package/src/__tests__/components/HeadingsPreviewModal/HeadingsPreviewModal.test.tsx +0 -178
- package/src/__tests__/components/HeadingsPreviewModal/HeadingsPreviewModal.utils.test.tsx +0 -150
- package/src/__tests__/components/KeywordsPreviewModal/KeywordItem/KeywordItem.test.tsx +0 -91
- package/src/__tests__/components/KeywordsPreviewModal/KeywordsPreviewModal.test.tsx +0 -122
- package/src/__tests__/components/KeywordsPreviewModal/KeywordsPreviewModal.utils.test.ts +0 -15
- package/src/__tests__/components/KeywordsPreviewModal/atoms.test.tsx +0 -101
- package/src/__tests__/modules/FramePreview/FramePreview.test.tsx +0 -318
- package/src/__tests__/modules/FramePreview/FramePreview.utils.test.ts +0 -242
- package/src/__tests__/modules/FramePreview/HeadingsOverlay/HeadingsOverlay.test.tsx +0 -185
- package/src/components/Browser/utils.tsx +0 -13
- package/src/components/Fields/SEOPreview/index.tsx +0 -36
- package/src/components/Fields/SEOPreview/style.tsx +0 -24
- package/src/components/FloatingNote/index.tsx +0 -35
- package/src/components/FloatingNote/style.tsx +0 -26
- package/src/components/HeadingsPreviewModal/ErrorsBanner/ErrorItem/index.tsx +0 -85
- package/src/components/HeadingsPreviewModal/ErrorsBanner/ErrorItem/style.tsx +0 -80
- package/src/components/HeadingsPreviewModal/ErrorsBanner/index.tsx +0 -57
- package/src/components/HeadingsPreviewModal/ErrorsBanner/style.tsx +0 -82
- package/src/components/HeadingsPreviewModal/HeadingItem/index.tsx +0 -71
- package/src/components/HeadingsPreviewModal/HeadingItem/style.tsx +0 -77
- package/src/components/HeadingsPreviewModal/index.tsx +0 -146
- package/src/components/HeadingsPreviewModal/style.tsx +0 -82
- package/src/components/HeadingsPreviewModal/utils.tsx +0 -257
- package/src/components/KeywordsPreviewModal/KeywordItem/index.tsx +0 -46
- package/src/components/KeywordsPreviewModal/KeywordItem/style.tsx +0 -64
- package/src/components/KeywordsPreviewModal/atoms.tsx +0 -96
- package/src/components/KeywordsPreviewModal/index.tsx +0 -99
- package/src/components/KeywordsPreviewModal/style.tsx +0 -87
- package/src/components/KeywordsPreviewModal/utils.tsx +0 -22
- package/src/modules/FramePreview/HeadingsOverlay/index.tsx +0 -113
- package/src/modules/FramePreview/HeadingsOverlay/style.tsx +0 -24
- package/src/modules/FramePreview/utils.tsx +0 -140
|
@@ -3,13 +3,11 @@ module.exports = {
|
|
|
3
3
|
config: {
|
|
4
4
|
schemas: {
|
|
5
5
|
config: {
|
|
6
|
-
themes:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
],
|
|
6
|
+
themes: {
|
|
7
|
+
label: "theme",
|
|
8
|
+
value: "1",
|
|
9
|
+
default: false,
|
|
10
|
+
},
|
|
13
11
|
moduleCategories: [
|
|
14
12
|
{
|
|
15
13
|
label: "Developing",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.12.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -217,5 +217,5 @@
|
|
|
217
217
|
"publishConfig": {
|
|
218
218
|
"access": "public"
|
|
219
219
|
},
|
|
220
|
-
"gitHead": "
|
|
220
|
+
"gitHead": "47dd37fe46a7bb09187b0c475c4ece29a6abc289"
|
|
221
221
|
}
|
|
@@ -1,473 +1,122 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { BrowserRouter } from "react-router-dom";
|
|
2
3
|
|
|
3
|
-
import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
-
import userEvent from "@testing-library/user-event";
|
|
5
|
-
import { mock } from "jest-mock-extended";
|
|
6
4
|
import { ThemeProvider } from "styled-components";
|
|
5
|
+
import { render, cleanup, screen, fireEvent, waitFor, act } from "@testing-library/react";
|
|
6
|
+
import { mock } from "jest-mock-extended";
|
|
7
7
|
import "@testing-library/jest-dom";
|
|
8
8
|
|
|
9
|
-
import Browser, { type IBrowserProps } from "@ax/components/Browser";
|
|
10
9
|
import { parseTheme } from "@ax/helpers";
|
|
10
|
+
import Browser, { IBrowserProps } from "@ax/components/Browser";
|
|
11
11
|
import globalTheme from "@ax/themes/theme.json";
|
|
12
12
|
|
|
13
|
-
let defaultProps: IBrowserProps;
|
|
14
|
-
|
|
15
|
-
const renderBrowser = (props: IBrowserProps) =>
|
|
16
|
-
render(
|
|
17
|
-
<MemoryRouter>
|
|
18
|
-
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
19
|
-
<Browser {...props} />
|
|
20
|
-
</ThemeProvider>
|
|
21
|
-
</MemoryRouter>,
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
global.ResizeObserver = jest.fn().mockImplementation(() => ({
|
|
26
|
-
observe: jest.fn(),
|
|
27
|
-
unobserve: jest.fn(),
|
|
28
|
-
disconnect: jest.fn(),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
defaultProps = mock<IBrowserProps>();
|
|
32
|
-
defaultProps.content = {};
|
|
33
|
-
defaultProps.browserRef = { current: null };
|
|
34
|
-
defaultProps.cloudinaryName = "thesaurus-cms";
|
|
35
|
-
defaultProps.disabled = false;
|
|
36
|
-
defaultProps.footer = {};
|
|
37
|
-
defaultProps.header = {};
|
|
38
|
-
defaultProps.isPage = true;
|
|
39
|
-
defaultProps.siteID = 108;
|
|
40
|
-
defaultProps.siteLangs = [{}];
|
|
41
|
-
defaultProps.socials = {
|
|
42
|
-
facebook: "https://www.facebook.com/SlothSanctuaryCostaRica",
|
|
43
|
-
instagram: "https://www.instagram.com/sloth.sanctuary.costa.rica/",
|
|
44
|
-
};
|
|
45
|
-
defaultProps.theme = "default-theme";
|
|
46
|
-
defaultProps.url = "/gallery-stuff";
|
|
47
|
-
});
|
|
48
|
-
|
|
49
13
|
afterEach(() => {
|
|
50
14
|
jest.resetAllMocks();
|
|
51
15
|
cleanup();
|
|
52
16
|
});
|
|
53
17
|
|
|
18
|
+
const defaultProps = mock<IBrowserProps>();
|
|
19
|
+
|
|
20
|
+
defaultProps.content = {};
|
|
21
|
+
defaultProps.browserRef = {
|
|
22
|
+
current: null,
|
|
23
|
+
};
|
|
24
|
+
defaultProps.cloudinaryName = "thesaurus-cms";
|
|
25
|
+
defaultProps.disabled = false;
|
|
26
|
+
defaultProps.footer = {};
|
|
27
|
+
defaultProps.header = {};
|
|
28
|
+
defaultProps.isPage = true;
|
|
29
|
+
defaultProps.siteID = 108;
|
|
30
|
+
defaultProps.siteLangs = [{}];
|
|
31
|
+
defaultProps.socials = {
|
|
32
|
+
facebook: "https://www.facebook.com/SlothSanctuaryCostaRica",
|
|
33
|
+
instagram: "https://www.instagram.com/sloth.sanctuary.costa.rica/",
|
|
34
|
+
};
|
|
35
|
+
defaultProps.theme = "default-theme";
|
|
36
|
+
defaultProps.url = "/gallery-stuff";
|
|
37
|
+
|
|
54
38
|
describe("Browser component rendering", () => {
|
|
55
39
|
it("should render the component", () => {
|
|
56
40
|
defaultProps.isPreview = false;
|
|
57
41
|
defaultProps.showIframe = true;
|
|
58
42
|
|
|
59
|
-
|
|
43
|
+
render(
|
|
44
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
45
|
+
<Browser {...defaultProps} />
|
|
46
|
+
</ThemeProvider>,
|
|
47
|
+
);
|
|
60
48
|
|
|
61
|
-
|
|
62
|
-
expect(
|
|
63
|
-
|
|
64
|
-
expect(
|
|
49
|
+
const navActionsWrapper = screen.queryByTestId("nav-actions-wrapper");
|
|
50
|
+
expect(navActionsWrapper).not.toBeTruthy();
|
|
51
|
+
const browserWrapper = screen.getByTestId("browser-wrapper");
|
|
52
|
+
expect(browserWrapper).toBeTruthy();
|
|
53
|
+
const showIframeWrapper = screen.queryByTestId("navbar-iframe-wrapper");
|
|
54
|
+
expect(showIframeWrapper).toBeTruthy();
|
|
55
|
+
const browserContentWrapper = screen.queryByTestId("browser-content-wrapper");
|
|
56
|
+
expect(browserContentWrapper).not.toBeTruthy();
|
|
65
57
|
});
|
|
66
58
|
|
|
67
|
-
|
|
59
|
+
it("should render the browserContent", () => {
|
|
68
60
|
defaultProps.isPreview = false;
|
|
69
61
|
defaultProps.showIframe = false;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
const deleteModuleActionMock = defaultProps.actions?.deleteModuleAction as jest.MockedFunction<
|
|
63
|
+
(editorID: number[]) => void
|
|
64
|
+
>;
|
|
65
|
+
const duplicateModuleActionMock = defaultProps.actions?.duplicateModuleAction as jest.MockedFunction<
|
|
66
|
+
(editorID: number[]) => number
|
|
67
|
+
>;
|
|
68
|
+
const setSelectedContentActionMock = defaultProps.actions?.setSelectedContentAction as jest.MockedFunction<
|
|
69
|
+
() => void
|
|
70
|
+
>;
|
|
71
|
+
|
|
72
|
+
render(
|
|
73
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
74
|
+
<Browser {...defaultProps} />
|
|
75
|
+
</ThemeProvider>,
|
|
76
|
+
);
|
|
77
|
+
const navActionsWrapper = screen.queryByTestId("nav-actions-wrapper");
|
|
78
|
+
expect(navActionsWrapper).not.toBeTruthy();
|
|
79
|
+
const showIframeWrapper = screen.queryByTestId("navbar-iframe-wrapper");
|
|
80
|
+
expect(showIframeWrapper).not.toBeTruthy();
|
|
81
|
+
const browserContentWrapper = screen.queryByTestId("browser-content-wrapper");
|
|
82
|
+
expect(browserContentWrapper).toBeTruthy();
|
|
76
83
|
});
|
|
77
84
|
|
|
78
|
-
it("should change the iFrame width when changing the
|
|
85
|
+
it("should change the iFrame width when changing the resulution", () => {
|
|
79
86
|
defaultProps.isPreview = true;
|
|
80
87
|
defaultProps.showIframe = true;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
const deleteModuleActionMock = defaultProps.actions?.deleteModuleAction as jest.MockedFunction<
|
|
89
|
+
(editorID: number[]) => void
|
|
90
|
+
>;
|
|
91
|
+
const duplicateModuleActionMock = defaultProps.actions?.duplicateModuleAction as jest.MockedFunction<
|
|
92
|
+
(editorID: number[]) => number
|
|
93
|
+
>;
|
|
94
|
+
const setSelectedContentActionMock = defaultProps.actions?.setSelectedContentAction as jest.MockedFunction<
|
|
95
|
+
() => void
|
|
96
|
+
>;
|
|
97
|
+
|
|
98
|
+
render(
|
|
99
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
100
|
+
<Browser {...defaultProps} />
|
|
101
|
+
</ThemeProvider>,
|
|
102
|
+
);
|
|
103
|
+
const navActionsWrapper = screen.queryByTestId("nav-actions-wrapper");
|
|
104
|
+
expect(navActionsWrapper).toBeTruthy();
|
|
105
|
+
const showIframeWrapper = screen.queryByTestId("navbar-iframe-wrapper");
|
|
106
|
+
expect(showIframeWrapper).toBeTruthy();
|
|
107
|
+
const browserContentWrapper = screen.queryByTestId("browser-content-wrapper");
|
|
108
|
+
expect(browserContentWrapper).not.toBeTruthy();
|
|
87
109
|
|
|
88
110
|
const iframe = document.querySelector("iframe");
|
|
89
|
-
expect(iframe).
|
|
111
|
+
expect(iframe).toBeTruthy();
|
|
90
112
|
expect(iframe?.width).toBe("100%");
|
|
91
113
|
|
|
92
|
-
|
|
114
|
+
const iconActionTablet = screen.getByTestId("icon-res-tablet");
|
|
115
|
+
fireEvent.click(iconActionTablet);
|
|
93
116
|
expect(iframe?.width).toBe("768px");
|
|
94
117
|
|
|
95
|
-
|
|
118
|
+
const iconActionPhone = screen.getByTestId("icon-res-phone");
|
|
119
|
+
fireEvent.click(iconActionPhone);
|
|
96
120
|
expect(iframe?.width).toBe("425px");
|
|
97
121
|
});
|
|
98
|
-
|
|
99
|
-
it("should display the url in the navbar", () => {
|
|
100
|
-
renderBrowser(defaultProps);
|
|
101
|
-
|
|
102
|
-
expect(screen.getByText("/gallery-stuff")).toBeInTheDocument();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("should reset localStorage selectedID to '0' on mount", () => {
|
|
106
|
-
localStorage.setItem("selectedID", "42");
|
|
107
|
-
|
|
108
|
-
renderBrowser(defaultProps);
|
|
109
|
-
|
|
110
|
-
expect(localStorage.getItem("selectedID")).toBe("0");
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("should set iframe width to the current resolution in non-preview mode", () => {
|
|
114
|
-
defaultProps.isPreview = false;
|
|
115
|
-
defaultProps.showIframe = true;
|
|
116
|
-
|
|
117
|
-
renderBrowser(defaultProps);
|
|
118
|
-
|
|
119
|
-
const iframe = document.querySelector("iframe");
|
|
120
|
-
expect(iframe?.width).toBe("1280px");
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
describe("Browser editorType variants", () => {
|
|
125
|
-
it("should not render the navbar when editorType is form", () => {
|
|
126
|
-
defaultProps.editorType = "form";
|
|
127
|
-
defaultProps.showIframe = true;
|
|
128
|
-
|
|
129
|
-
renderBrowser(defaultProps);
|
|
130
|
-
|
|
131
|
-
expect(screen.queryByTestId("nav-actions-wrapper")).not.toBeInTheDocument();
|
|
132
|
-
expect(screen.getByTestId("navbar-iframe-wrapper")).toBeInTheDocument();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("should show the headings editor banner when editorType is headings", () => {
|
|
136
|
-
defaultProps.editorType = "headings";
|
|
137
|
-
defaultProps.showIframe = true;
|
|
138
|
-
|
|
139
|
-
renderBrowser(defaultProps);
|
|
140
|
-
|
|
141
|
-
expect(screen.getByTestId("floating-note-wrapper")).toBeInTheDocument();
|
|
142
|
-
expect(screen.getByTestId("floating-note-message")).toHaveTextContent(
|
|
143
|
-
"You are viewing the Headings editor of this page",
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("should call toggleHeadingsPreview when clicking Back to Page Editor in headings mode", () => {
|
|
148
|
-
defaultProps.editorType = "headings";
|
|
149
|
-
defaultProps.showIframe = true;
|
|
150
|
-
const toggleHeadingsPreviewMock = jest.fn();
|
|
151
|
-
defaultProps.toggleHeadingsPreview = toggleHeadingsPreviewMock;
|
|
152
|
-
|
|
153
|
-
renderBrowser(defaultProps);
|
|
154
|
-
|
|
155
|
-
fireEvent.click(screen.getByRole("button", { name: "Back to Page Editor" }));
|
|
156
|
-
|
|
157
|
-
expect(toggleHeadingsPreviewMock).toHaveBeenCalledTimes(1);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("should show the keywords editor banner when editorType is keywords", () => {
|
|
161
|
-
defaultProps.editorType = "keywords";
|
|
162
|
-
defaultProps.showIframe = true;
|
|
163
|
-
|
|
164
|
-
renderBrowser(defaultProps);
|
|
165
|
-
|
|
166
|
-
expect(screen.getByTestId("floating-note-wrapper")).toBeInTheDocument();
|
|
167
|
-
expect(screen.getByTestId("floating-note-message")).toHaveTextContent(
|
|
168
|
-
"You are viewing the Keywords editor of this page",
|
|
169
|
-
);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("should call toggleKeywordsPreview when clicking Back to Page Editor in keywords mode", () => {
|
|
173
|
-
defaultProps.editorType = "keywords";
|
|
174
|
-
defaultProps.showIframe = true;
|
|
175
|
-
const toggleKeywordsPreviewMock = jest.fn();
|
|
176
|
-
defaultProps.toggleKeywordsPreview = toggleKeywordsPreviewMock;
|
|
177
|
-
|
|
178
|
-
renderBrowser(defaultProps);
|
|
179
|
-
|
|
180
|
-
fireEvent.click(screen.getByRole("button", { name: "Back to Page Editor" }));
|
|
181
|
-
|
|
182
|
-
expect(toggleKeywordsPreviewMock).toHaveBeenCalledTimes(1);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it("should render nav-actions-wrapper for headings editor", () => {
|
|
186
|
-
defaultProps.editorType = "headings";
|
|
187
|
-
defaultProps.showIframe = true;
|
|
188
|
-
|
|
189
|
-
renderBrowser(defaultProps);
|
|
190
|
-
|
|
191
|
-
expect(screen.getByTestId("nav-actions-wrapper")).toBeInTheDocument();
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it("should render nav-actions-wrapper for keywords editor", () => {
|
|
195
|
-
defaultProps.editorType = "keywords";
|
|
196
|
-
defaultProps.showIframe = true;
|
|
197
|
-
|
|
198
|
-
renderBrowser(defaultProps);
|
|
199
|
-
|
|
200
|
-
expect(screen.getByTestId("nav-actions-wrapper")).toBeInTheDocument();
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it("should display the url in the headings editor navbar", () => {
|
|
204
|
-
defaultProps.editorType = "headings";
|
|
205
|
-
|
|
206
|
-
renderBrowser(defaultProps);
|
|
207
|
-
|
|
208
|
-
expect(screen.getByText("/gallery-stuff")).toBeInTheDocument();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("should display the url in the keywords editor navbar", () => {
|
|
212
|
-
defaultProps.editorType = "keywords";
|
|
213
|
-
|
|
214
|
-
renderBrowser(defaultProps);
|
|
215
|
-
|
|
216
|
-
expect(screen.getByText("/gallery-stuff")).toBeInTheDocument();
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it("should not show floating note for form editor", () => {
|
|
220
|
-
defaultProps.editorType = "form";
|
|
221
|
-
defaultProps.showIframe = true;
|
|
222
|
-
|
|
223
|
-
renderBrowser(defaultProps);
|
|
224
|
-
|
|
225
|
-
expect(screen.queryByTestId("floating-note-wrapper")).not.toBeInTheDocument();
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
describe("Browser iframe URL construction", () => {
|
|
230
|
-
it("should build the correct iframe src URL", () => {
|
|
231
|
-
defaultProps.isPreview = false;
|
|
232
|
-
defaultProps.showIframe = true;
|
|
233
|
-
|
|
234
|
-
renderBrowser(defaultProps);
|
|
235
|
-
|
|
236
|
-
const iframe = document.querySelector("iframe");
|
|
237
|
-
expect(iframe?.src).toBe("http://localhost/editor/page-preview?preview=false&disabled=false&type=page");
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it("should include headingFilter param in the URL when a specific filter is set", () => {
|
|
241
|
-
defaultProps.editorType = "headings";
|
|
242
|
-
defaultProps.headingFilter = "h2";
|
|
243
|
-
defaultProps.showIframe = true;
|
|
244
|
-
|
|
245
|
-
renderBrowser(defaultProps);
|
|
246
|
-
|
|
247
|
-
const iframe = document.querySelector("iframe");
|
|
248
|
-
expect(iframe?.src).toContain("headingFilter=h2");
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("should not include headingFilter param in the URL when headingFilter is 'all'", () => {
|
|
252
|
-
defaultProps.editorType = "headings";
|
|
253
|
-
defaultProps.headingFilter = "all";
|
|
254
|
-
defaultProps.showIframe = true;
|
|
255
|
-
|
|
256
|
-
renderBrowser(defaultProps);
|
|
257
|
-
|
|
258
|
-
const iframe = document.querySelector("iframe");
|
|
259
|
-
expect(iframe?.src).not.toContain("headingFilter");
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it("should include keywordFilter param in the URL when keywordsFilter has values", () => {
|
|
263
|
-
defaultProps.editorType = "keywords";
|
|
264
|
-
defaultProps.keywordsFilter = ["seo"];
|
|
265
|
-
defaultProps.showIframe = true;
|
|
266
|
-
|
|
267
|
-
renderBrowser(defaultProps);
|
|
268
|
-
|
|
269
|
-
const iframe = document.querySelector("iframe");
|
|
270
|
-
expect(iframe?.src).toContain("keywordFilter=seo");
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it("should not include keywordFilter param in the URL when keywordsFilter is empty", () => {
|
|
274
|
-
defaultProps.editorType = "keywords";
|
|
275
|
-
defaultProps.keywordsFilter = [];
|
|
276
|
-
defaultProps.showIframe = true;
|
|
277
|
-
|
|
278
|
-
renderBrowser(defaultProps);
|
|
279
|
-
|
|
280
|
-
const iframe = document.querySelector("iframe");
|
|
281
|
-
expect(iframe?.src).not.toContain("keywordFilter");
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it("should include all keywords in the URL when keywordsFilter has multiple values", () => {
|
|
285
|
-
defaultProps.editorType = "keywords";
|
|
286
|
-
defaultProps.keywordsFilter = ["seo", "cms"];
|
|
287
|
-
defaultProps.showIframe = true;
|
|
288
|
-
|
|
289
|
-
renderBrowser(defaultProps);
|
|
290
|
-
|
|
291
|
-
const iframe = document.querySelector("iframe");
|
|
292
|
-
expect(iframe?.src).toContain("keywordFilter=seo,cms");
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
describe("Browser ResizeObserver lifecycle", () => {
|
|
297
|
-
it("should update dimensions based on containerWidth when ResizeObserver fires", () => {
|
|
298
|
-
global.ResizeObserver = jest.fn().mockImplementation((callback: ResizeObserverCallback) => ({
|
|
299
|
-
observe: jest.fn(() =>
|
|
300
|
-
callback([{ contentRect: { width: 1024 } }] as ResizeObserverEntry[], {} as ResizeObserver),
|
|
301
|
-
),
|
|
302
|
-
unobserve: jest.fn(),
|
|
303
|
-
disconnect: jest.fn(),
|
|
304
|
-
}));
|
|
305
|
-
|
|
306
|
-
defaultProps.isPreview = false;
|
|
307
|
-
defaultProps.showIframe = true;
|
|
308
|
-
|
|
309
|
-
renderBrowser(defaultProps);
|
|
310
|
-
|
|
311
|
-
// calcDefaultResolution(1024, options) → "1024px"; calcAutoZoom(1024, "1024px") → "100"
|
|
312
|
-
expect(screen.getByText("1024px")).toBeInTheDocument();
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it("should disconnect ResizeObserver on unmount", () => {
|
|
316
|
-
const disconnectMock = jest.fn();
|
|
317
|
-
global.ResizeObserver = jest.fn().mockImplementation(() => ({
|
|
318
|
-
observe: jest.fn(),
|
|
319
|
-
unobserve: jest.fn(),
|
|
320
|
-
disconnect: disconnectMock,
|
|
321
|
-
}));
|
|
322
|
-
|
|
323
|
-
defaultProps.showIframe = true;
|
|
324
|
-
|
|
325
|
-
const { unmount } = renderBrowser(defaultProps);
|
|
326
|
-
unmount();
|
|
327
|
-
|
|
328
|
-
expect(disconnectMock).toHaveBeenCalledTimes(1);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it("should not update dimensions when ResizeObserver fires with zero width", () => {
|
|
332
|
-
global.ResizeObserver = jest.fn().mockImplementation((callback: ResizeObserverCallback) => ({
|
|
333
|
-
observe: jest.fn(() => callback([{ contentRect: { width: 0 } }] as ResizeObserverEntry[], {} as ResizeObserver)),
|
|
334
|
-
unobserve: jest.fn(),
|
|
335
|
-
disconnect: jest.fn(),
|
|
336
|
-
}));
|
|
337
|
-
|
|
338
|
-
defaultProps.isPreview = false;
|
|
339
|
-
defaultProps.showIframe = true;
|
|
340
|
-
|
|
341
|
-
renderBrowser(defaultProps);
|
|
342
|
-
|
|
343
|
-
// default resolution remains "1280px" since width=0 is ignored
|
|
344
|
-
expect(screen.getByText("1280px")).toBeInTheDocument();
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
describe("Browser compact mode", () => {
|
|
349
|
-
beforeEach(() => {
|
|
350
|
-
global.ResizeObserver = jest.fn().mockImplementation((callback: ResizeObserverCallback) => ({
|
|
351
|
-
observe: jest.fn(() =>
|
|
352
|
-
callback([{ contentRect: { width: 300 } }] as ResizeObserverEntry[], {} as ResizeObserver),
|
|
353
|
-
),
|
|
354
|
-
unobserve: jest.fn(),
|
|
355
|
-
disconnect: jest.fn(),
|
|
356
|
-
}));
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
it("should show 'Back' button and omit 'of this page' in headings mode when compact", () => {
|
|
360
|
-
defaultProps.editorType = "headings";
|
|
361
|
-
defaultProps.showIframe = true;
|
|
362
|
-
|
|
363
|
-
renderBrowser(defaultProps);
|
|
364
|
-
|
|
365
|
-
expect(screen.getByRole("button", { name: "Back" })).toBeInTheDocument();
|
|
366
|
-
expect(screen.getByTestId("floating-note-message")).not.toHaveTextContent("of this page");
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
it("should show 'Back' button in keywords mode when compact", () => {
|
|
370
|
-
defaultProps.editorType = "keywords";
|
|
371
|
-
defaultProps.showIframe = true;
|
|
372
|
-
|
|
373
|
-
renderBrowser(defaultProps);
|
|
374
|
-
|
|
375
|
-
expect(screen.getByRole("button", { name: "Back" })).toBeInTheDocument();
|
|
376
|
-
expect(screen.getByTestId("floating-note-message")).not.toHaveTextContent("of this page");
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
describe("Browser resolution and zoom selectors", () => {
|
|
381
|
-
it("should render both resolution and zoom select components in non-preview mode", () => {
|
|
382
|
-
defaultProps.isPreview = false;
|
|
383
|
-
defaultProps.showIframe = true;
|
|
384
|
-
|
|
385
|
-
const { container } = renderBrowser(defaultProps);
|
|
386
|
-
|
|
387
|
-
expect(container.querySelectorAll('[data-testid="select-component"]')).toHaveLength(2);
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
it("should display the default resolution '1280px' in the resolution select", () => {
|
|
391
|
-
defaultProps.isPreview = false;
|
|
392
|
-
defaultProps.showIframe = true;
|
|
393
|
-
|
|
394
|
-
renderBrowser(defaultProps);
|
|
395
|
-
|
|
396
|
-
expect(screen.getByText("1280px")).toBeInTheDocument();
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
it("should display the default zoom '100%' in the zoom select", () => {
|
|
400
|
-
defaultProps.isPreview = false;
|
|
401
|
-
defaultProps.showIframe = true;
|
|
402
|
-
|
|
403
|
-
renderBrowser(defaultProps);
|
|
404
|
-
|
|
405
|
-
expect(screen.getByText("100%")).toBeInTheDocument();
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
it("should update the displayed resolution when a new option is selected", async () => {
|
|
409
|
-
defaultProps.isPreview = false;
|
|
410
|
-
defaultProps.showIframe = true;
|
|
411
|
-
|
|
412
|
-
renderBrowser(defaultProps);
|
|
413
|
-
|
|
414
|
-
await act(async () => userEvent.click(screen.getByLabelText("resolution")));
|
|
415
|
-
await act(async () => userEvent.click(screen.getByText("1024px")));
|
|
416
|
-
|
|
417
|
-
expect(screen.getByText("1024px")).toBeInTheDocument();
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it("should update the displayed zoom when a new option is selected", async () => {
|
|
421
|
-
defaultProps.isPreview = false;
|
|
422
|
-
defaultProps.showIframe = true;
|
|
423
|
-
|
|
424
|
-
renderBrowser(defaultProps);
|
|
425
|
-
|
|
426
|
-
await act(async () => userEvent.click(screen.getByLabelText("zoom")));
|
|
427
|
-
await act(async () => userEvent.click(screen.getByText("75%")));
|
|
428
|
-
|
|
429
|
-
expect(screen.getByText("75%")).toBeInTheDocument();
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
it("should display a custom auto-zoom percentage when it is not a standard zoom option", () => {
|
|
433
|
-
global.ResizeObserver = jest.fn().mockImplementation((callback: ResizeObserverCallback) => ({
|
|
434
|
-
observe: jest.fn(() =>
|
|
435
|
-
callback([{ contentRect: { width: 300 } }] as ResizeObserverEntry[], {} as ResizeObserver),
|
|
436
|
-
),
|
|
437
|
-
unobserve: jest.fn(),
|
|
438
|
-
disconnect: jest.fn(),
|
|
439
|
-
}));
|
|
440
|
-
|
|
441
|
-
defaultProps.isPreview = false;
|
|
442
|
-
defaultProps.showIframe = true;
|
|
443
|
-
|
|
444
|
-
renderBrowser(defaultProps);
|
|
445
|
-
|
|
446
|
-
// calcDefaultResolution(300, options) → "360px"; calcAutoZoom(300, "360px") = floor(83.33) = "83"
|
|
447
|
-
expect(screen.getByText("83%")).toBeInTheDocument();
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
it("should restore auto-zoom when Reset is selected", async () => {
|
|
451
|
-
global.ResizeObserver = jest.fn().mockImplementation((callback: ResizeObserverCallback) => ({
|
|
452
|
-
observe: jest.fn(() =>
|
|
453
|
-
callback([{ contentRect: { width: 300 } }] as ResizeObserverEntry[], {} as ResizeObserver),
|
|
454
|
-
),
|
|
455
|
-
unobserve: jest.fn(),
|
|
456
|
-
disconnect: jest.fn(),
|
|
457
|
-
}));
|
|
458
|
-
|
|
459
|
-
defaultProps.isPreview = false;
|
|
460
|
-
defaultProps.showIframe = true;
|
|
461
|
-
|
|
462
|
-
renderBrowser(defaultProps);
|
|
463
|
-
|
|
464
|
-
expect(screen.getByText("83%")).toBeInTheDocument();
|
|
465
|
-
|
|
466
|
-
// Reset is enabled because "83" is not in the standard zoom options
|
|
467
|
-
await act(async () => userEvent.click(screen.getByLabelText("zoom")));
|
|
468
|
-
await act(async () => userEvent.click(screen.getByText("Reset")));
|
|
469
|
-
|
|
470
|
-
// After reset: calcAutoZoom(clientWidth=0, "360px") = "100" → zoom select shows "100%"
|
|
471
|
-
expect(screen.getByText("100%")).toBeInTheDocument();
|
|
472
|
-
});
|
|
473
122
|
});
|
|
@@ -137,7 +137,9 @@ defaultProps.schema = {
|
|
|
137
137
|
},
|
|
138
138
|
],
|
|
139
139
|
};
|
|
140
|
-
defaultProps.setSelectedTab.mockImplementation(
|
|
140
|
+
defaultProps.setSelectedTab.mockImplementation((tab) => {
|
|
141
|
+
console.log("Tab seleccionada:", tab);
|
|
142
|
+
});
|
|
141
143
|
defaultProps.actions = { deleteModule: jest.fn() };
|
|
142
144
|
defaultProps.breadcrumb = [
|
|
143
145
|
{
|