@griddo/ax 1.73.29 → 1.74.1
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/griddo-config/index.js +24 -3
- package/config/webpackSchemas.config.js +3 -5
- package/package.json +3 -2
- package/scripts/griddo-sync-schemas.js +4 -3
- package/src/__mocks__/axios/SitesList.ts +84 -0
- package/src/__mocks__/store/SitesList.ts +714 -0
- package/src/__tests__/components/Avatar/Avatar.test.tsx +119 -0
- package/src/__tests__/components/Avatar/__snapshots__/Avatar.test.tsx.snap +61 -0
- package/src/__tests__/components/Fields/ReferenceField/ReferenceField.test.tsx +10 -10
- package/src/__tests__/components/LanguageMenu/LanguageMenu.test.tsx +221 -0
- package/src/__tests__/components/Loading/Loading.test.tsx +23 -0
- package/src/__tests__/components/Login/Login.test.tsx +247 -0
- package/src/__tests__/components/Login/RecoveryModal/RecoveryModal.test.tsx +185 -0
- package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +6 -6
- package/src/__tests__/modules/Sites/Sites.test.tsx +259 -0
- package/src/__tests__/modules/Sites/SitesList/ListView/BulkHeader/BulkHeader.test.tsx +51 -0
- package/src/__tests__/modules/Sites/SitesList/SitesList.test.tsx +896 -0
- package/src/api/sites.tsx +43 -4
- package/src/components/ActionMenu/index.tsx +1 -1
- package/src/components/Avatar/index.tsx +4 -4
- package/src/components/Browser/index.tsx +27 -20
- package/src/components/BrowserContent/index.tsx +6 -0
- package/src/components/Fields/AsyncSelect/style.tsx +6 -3
- package/src/components/Fields/CheckField/index.tsx +1 -0
- package/src/components/Fields/DateField/style.tsx +3 -1
- package/src/components/Fields/HeadingField/index.tsx +14 -5
- package/src/components/Fields/ImageField/index.tsx +3 -0
- package/src/components/Fields/ImageField/style.tsx +2 -2
- package/src/components/Fields/Select/style.tsx +2 -0
- package/src/components/Fields/SliderField/index.tsx +2 -1
- package/src/components/Fields/TextField/index.tsx +1 -0
- package/src/components/Icon/components/BulletList.js +16 -0
- package/src/components/Icon/components/Grid2.js +16 -0
- package/src/components/Icon/svgs/Bullet-list.svg +3 -0
- package/src/components/Icon/svgs/Grid-2.svg +3 -0
- package/src/components/IconAction/index.tsx +4 -2
- package/src/components/IconAction/style.tsx +8 -2
- package/src/components/LanguageMenu/index.tsx +13 -6
- package/src/components/Login/RecoveryModal/index.tsx +5 -4
- package/src/components/Login/index.tsx +13 -3
- package/src/components/Login/style.tsx +12 -25
- package/src/components/Pagination/style.tsx +1 -1
- package/src/components/SearchField/index.tsx +9 -1
- package/src/components/SideModal/style.tsx +8 -8
- package/src/components/TableFilters/LastAccessFilter/index.tsx +52 -0
- package/src/components/TableFilters/LastAccessFilter/style.tsx +31 -0
- package/src/components/TableFilters/LiveFilter/index.tsx +7 -5
- package/src/components/TableFilters/NameFilter/index.tsx +4 -3
- package/src/components/TableFilters/index.tsx +2 -0
- package/src/components/TableList/index.tsx +2 -1
- package/src/components/TableList/style.tsx +2 -2
- package/src/components/index.tsx +2 -0
- package/src/containers/App/actions.tsx +5 -0
- package/src/containers/App/interfaces.tsx +1 -1
- package/src/containers/App/reducer.tsx +1 -1
- package/src/containers/Navigation/Defaults/actions.tsx +3 -1
- package/src/containers/PageEditor/actions.tsx +6 -3
- package/src/containers/Sites/actions.tsx +76 -11
- package/src/containers/Sites/constants.tsx +2 -0
- package/src/containers/Sites/interfaces.tsx +12 -0
- package/src/containers/Sites/reducer.tsx +8 -0
- package/src/helpers/schemas.tsx +27 -1
- package/src/hooks/iframe.ts +56 -0
- package/src/hooks/index.tsx +3 -0
- package/src/modules/Content/index.tsx +4 -3
- package/src/modules/FramePreview/index.tsx +25 -39
- package/src/modules/GlobalEditor/Editor/index.tsx +2 -2
- package/src/modules/GlobalEditor/PageBrowser/index.tsx +16 -4
- package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/DefaultsBrowser/index.tsx +11 -7
- package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/index.tsx +4 -3
- package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/index.tsx +1 -0
- package/src/modules/PageEditor/Editor/index.tsx +2 -2
- package/src/modules/PageEditor/PageBrowser/index.tsx +16 -4
- package/src/modules/PageEditor/index.tsx +8 -7
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/Field/index.tsx +12 -11
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/index.tsx +3 -17
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/style.tsx +2 -10
- package/src/modules/Sites/SitesList/GridView/GridHeaderFilter/index.tsx +72 -0
- package/src/modules/Sites/SitesList/GridView/GridHeaderFilter/style.tsx +32 -0
- package/src/modules/Sites/SitesList/{SiteItem → GridView/GridSiteItem}/index.tsx +17 -27
- package/src/modules/Sites/SitesList/{SiteItem → GridView/GridSiteItem}/style.tsx +14 -25
- package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +64 -0
- package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/style.tsx +50 -0
- package/src/modules/Sites/SitesList/ListView/BulkHeader/index.tsx +75 -0
- package/src/modules/Sites/SitesList/ListView/BulkHeader/style.tsx +8 -0
- package/src/modules/Sites/SitesList/ListView/ListSiteItem/index.tsx +200 -0
- package/src/modules/Sites/SitesList/ListView/ListSiteItem/style.tsx +112 -0
- package/src/modules/Sites/SitesList/RecentSiteItem/index.tsx +50 -0
- package/src/modules/Sites/SitesList/RecentSiteItem/style.tsx +28 -0
- package/src/modules/Sites/SitesList/SiteModal/index.tsx +4 -3
- package/src/modules/Sites/SitesList/atoms.tsx +47 -0
- package/src/modules/Sites/SitesList/hooks.tsx +102 -0
- package/src/modules/Sites/SitesList/index.tsx +272 -19
- package/src/modules/Sites/SitesList/style.tsx +157 -4
- package/src/modules/Sites/SitesList/utils.tsx +33 -0
- package/src/modules/Sites/index.tsx +6 -11
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +1 -1
- package/src/types/index.tsx +25 -2
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { render, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
import renderer from "react-test-renderer";
|
|
6
|
+
|
|
7
|
+
import { parseTheme } from "@ax/helpers";
|
|
8
|
+
import Avatar from "@ax/components/Avatar";
|
|
9
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
10
|
+
|
|
11
|
+
afterEach(cleanup);
|
|
12
|
+
|
|
13
|
+
describe("Avatar component rendering", () => {
|
|
14
|
+
it("should render the component with name and image", () => {
|
|
15
|
+
const props = {
|
|
16
|
+
name: "Ignatius Reilly",
|
|
17
|
+
image: "https://images.dev.griddo.io/w/215/h/161/descarga-1",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
render(
|
|
21
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
22
|
+
<Avatar {...props} />
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const avatarWrapper = screen.getByTestId("avatar-wrapper");
|
|
27
|
+
const avatar = screen.queryByTestId("avatar");
|
|
28
|
+
|
|
29
|
+
expect(avatarWrapper).toBeTruthy();
|
|
30
|
+
expect(avatar).toHaveStyle(`width: 32px; height: 32px`);
|
|
31
|
+
expect(avatar).toHaveStyle(
|
|
32
|
+
`background: url("https://images.dev.griddo.io/w/215/h/161/descarga-1") center center / cover no-repeat, rgb(230, 231, 248)`
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should render the component only with name", () => {
|
|
37
|
+
const props = {
|
|
38
|
+
name: "Ignatius Reilly",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const tree = renderer
|
|
42
|
+
.create(
|
|
43
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
44
|
+
<Avatar {...props} />
|
|
45
|
+
</ThemeProvider>
|
|
46
|
+
)
|
|
47
|
+
.toJSON();
|
|
48
|
+
|
|
49
|
+
expect(tree).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should render the component with image null", () => {
|
|
53
|
+
const props = {
|
|
54
|
+
name: "Ignatius Reilly",
|
|
55
|
+
image: null,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const tree = renderer
|
|
59
|
+
.create(
|
|
60
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
61
|
+
<Avatar {...props} />
|
|
62
|
+
</ThemeProvider>
|
|
63
|
+
)
|
|
64
|
+
.toJSON();
|
|
65
|
+
|
|
66
|
+
expect(tree).toMatchSnapshot();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should render the component without name or image", () => {
|
|
70
|
+
const tree = renderer
|
|
71
|
+
.create(
|
|
72
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
73
|
+
<Avatar />
|
|
74
|
+
</ThemeProvider>
|
|
75
|
+
)
|
|
76
|
+
.toJSON();
|
|
77
|
+
|
|
78
|
+
expect(tree).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("should render the component with a wrong image url", () => {
|
|
82
|
+
const props = {
|
|
83
|
+
name: "Ignatius Reilly",
|
|
84
|
+
image: "lolololololo",
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
render(
|
|
88
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
89
|
+
<Avatar {...props} />
|
|
90
|
+
</ThemeProvider>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const avatar = screen.queryByTestId("avatar");
|
|
94
|
+
|
|
95
|
+
expect(avatar).toHaveStyle(`width: 32px; height: 32px;`);
|
|
96
|
+
|
|
97
|
+
const tree = renderer
|
|
98
|
+
.create(
|
|
99
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
100
|
+
<Avatar {...props} />
|
|
101
|
+
</ThemeProvider>
|
|
102
|
+
)
|
|
103
|
+
.toJSON();
|
|
104
|
+
|
|
105
|
+
expect(tree).toMatchSnapshot();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("should render the component with an empty string as name", () => {
|
|
109
|
+
const tree = renderer
|
|
110
|
+
.create(
|
|
111
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
112
|
+
<Avatar name="" />
|
|
113
|
+
</ThemeProvider>
|
|
114
|
+
)
|
|
115
|
+
.toJSON();
|
|
116
|
+
|
|
117
|
+
expect(tree).toMatchSnapshot();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Avatar component rendering should render the component only with name 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="sc-gSAPjG jRkXjC"
|
|
6
|
+
data-testid="avatar-wrapper"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
className="sc-lbxAil fkodDH"
|
|
10
|
+
data-testid="avatar"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`Avatar component rendering should render the component with a wrong image url 1`] = `
|
|
16
|
+
<div
|
|
17
|
+
className="sc-gSAPjG jRkXjC"
|
|
18
|
+
data-testid="avatar-wrapper"
|
|
19
|
+
>
|
|
20
|
+
<div
|
|
21
|
+
className="sc-lbxAil ejhcAS"
|
|
22
|
+
data-testid="avatar"
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`Avatar component rendering should render the component with an empty string as name 1`] = `
|
|
28
|
+
<div
|
|
29
|
+
className="sc-gSAPjG jRkXjC"
|
|
30
|
+
data-testid="avatar-wrapper"
|
|
31
|
+
>
|
|
32
|
+
<div
|
|
33
|
+
className="sc-lbxAil hilXDA"
|
|
34
|
+
data-testid="avatar"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`Avatar component rendering should render the component with image null 1`] = `
|
|
40
|
+
<div
|
|
41
|
+
className="sc-gSAPjG jRkXjC"
|
|
42
|
+
data-testid="avatar-wrapper"
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
className="sc-lbxAil jDWEnq"
|
|
46
|
+
data-testid="avatar"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
exports[`Avatar component rendering should render the component without name or image 1`] = `
|
|
52
|
+
<div
|
|
53
|
+
className="sc-gSAPjG jRkXjC"
|
|
54
|
+
data-testid="avatar-wrapper"
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
className="sc-lbxAil hilXDA"
|
|
58
|
+
data-testid="avatar"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
`;
|
|
@@ -439,19 +439,19 @@ describe("onChange events", () => {
|
|
|
439
439
|
const initialState = { ...initialStore, ...defaultProps };
|
|
440
440
|
const onChange = jest.fn();
|
|
441
441
|
|
|
442
|
-
|
|
442
|
+
// mockApiCalls();
|
|
443
443
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
444
|
+
// const Component = (
|
|
445
|
+
// <ThemeProvider theme={parseTheme(globalTheme)}>
|
|
446
|
+
// <ReferenceField {...initialState} onChange={onChange} />
|
|
447
|
+
// </ThemeProvider>
|
|
448
|
+
// );
|
|
449
449
|
|
|
450
|
-
|
|
450
|
+
// const { rerender } = render(Component, { store });
|
|
451
451
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
452
|
+
// await act(async () => {
|
|
453
|
+
// rerender(Component);
|
|
454
|
+
// });
|
|
455
455
|
|
|
456
456
|
const referenceFieldItems = screen.getAllByTestId("reference-field-item");
|
|
457
457
|
expect(referenceFieldItems[0]).toHaveTextContent("Article 02");
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { render, cleanup, screen, fireEvent } from "@testing-library/react";
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
|
|
6
|
+
import { parseTheme } from "@ax/helpers";
|
|
7
|
+
import LanguageMenu from "@ax/components/LanguageMenu";
|
|
8
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
9
|
+
|
|
10
|
+
afterEach(cleanup);
|
|
11
|
+
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
language: "en_GB",
|
|
14
|
+
availableLanguages: [
|
|
15
|
+
{
|
|
16
|
+
id: 4,
|
|
17
|
+
locale: "en_GB",
|
|
18
|
+
language: "English",
|
|
19
|
+
path: "/gonzalo-h",
|
|
20
|
+
domain: {
|
|
21
|
+
id: 1,
|
|
22
|
+
url: "//cx.dev.griddo.io/pre-griddo",
|
|
23
|
+
slug: "/pre-griddo",
|
|
24
|
+
},
|
|
25
|
+
label: "EN",
|
|
26
|
+
isDefault: true,
|
|
27
|
+
home: "//cx.dev.griddo.io/pre-griddo/gonzalo-h",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 2,
|
|
31
|
+
locale: "es_ES",
|
|
32
|
+
language: "Spanish",
|
|
33
|
+
path: "/gonzalo-h/es",
|
|
34
|
+
domain: {
|
|
35
|
+
id: 1,
|
|
36
|
+
url: "//cx.dev.griddo.io/pre-griddo",
|
|
37
|
+
slug: "/pre-griddo",
|
|
38
|
+
},
|
|
39
|
+
label: "ES",
|
|
40
|
+
isDefault: false,
|
|
41
|
+
home: "//cx.dev.griddo.io/pre-griddo/gonzalo-h/es",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
isInAppBar: true,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
describe("LanguageMenu component rendering", () => {
|
|
48
|
+
it("should render the component", () => {
|
|
49
|
+
const setLanguage = jest.fn();
|
|
50
|
+
|
|
51
|
+
render(
|
|
52
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
53
|
+
<LanguageMenu setLanguage={setLanguage} {...defaultProps} />
|
|
54
|
+
</ThemeProvider>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const languageMenu = screen.getByTestId("language-menu");
|
|
58
|
+
expect(languageMenu).toBeTruthy();
|
|
59
|
+
const languageMenuItems = screen.getAllByTestId("language-menu-item");
|
|
60
|
+
expect(languageMenuItems.length).toBe(2);
|
|
61
|
+
expect(screen.getByText(/English/i)).toBeTruthy();
|
|
62
|
+
|
|
63
|
+
// current selected language
|
|
64
|
+
expect(languageMenuItems[0].querySelector(`div[data-testid="language-icon"]`)).toBeTruthy();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("should render the component without props", () => {
|
|
68
|
+
const setLanguage = jest.fn();
|
|
69
|
+
|
|
70
|
+
render(
|
|
71
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
72
|
+
<LanguageMenu setLanguage={setLanguage} />
|
|
73
|
+
</ThemeProvider>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const languageMenu = screen.getByTestId("language-menu");
|
|
77
|
+
expect(languageMenu).toBeTruthy();
|
|
78
|
+
|
|
79
|
+
const languageMenuItem = screen.queryAllByTestId("language-menu-item");
|
|
80
|
+
expect(languageMenuItem.length).toBe(0);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should render the component with only one language", () => {
|
|
84
|
+
const setLanguage = jest.fn();
|
|
85
|
+
|
|
86
|
+
const props = {
|
|
87
|
+
language: "en_GB",
|
|
88
|
+
availableLanguages: [
|
|
89
|
+
{
|
|
90
|
+
id: 4,
|
|
91
|
+
locale: "en_GB",
|
|
92
|
+
language: "English",
|
|
93
|
+
path: "/gonzalo-h",
|
|
94
|
+
domain: {
|
|
95
|
+
id: 1,
|
|
96
|
+
url: "//cx.dev.griddo.io/pre-griddo",
|
|
97
|
+
slug: "/pre-griddo",
|
|
98
|
+
},
|
|
99
|
+
label: "EN",
|
|
100
|
+
isDefault: true,
|
|
101
|
+
home: "//cx.dev.griddo.io/pre-griddo/gonzalo-h",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
isInAppBar: true,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
render(
|
|
108
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
109
|
+
<LanguageMenu setLanguage={setLanguage} {...props} />
|
|
110
|
+
</ThemeProvider>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const languageMenu = screen.getByTestId("language-menu");
|
|
114
|
+
expect(languageMenu).toBeTruthy();
|
|
115
|
+
|
|
116
|
+
const languageMenuItem = screen.queryAllByTestId("language-menu-item");
|
|
117
|
+
expect(languageMenuItem.length).toBe(1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("should render the component showing new version language", () => {
|
|
121
|
+
const setLanguage = jest.fn();
|
|
122
|
+
|
|
123
|
+
const props = {
|
|
124
|
+
language: "en_GB",
|
|
125
|
+
availableLanguages: defaultProps.availableLanguages,
|
|
126
|
+
isInAppBar: false,
|
|
127
|
+
currentLanguages: [
|
|
128
|
+
{
|
|
129
|
+
id: 4,
|
|
130
|
+
locale: "en_GB",
|
|
131
|
+
language: "English",
|
|
132
|
+
path: "/gonzalo-h",
|
|
133
|
+
domain: {
|
|
134
|
+
id: 1,
|
|
135
|
+
url: "//cx.dev.griddo.io/pre-griddo",
|
|
136
|
+
slug: "/pre-griddo",
|
|
137
|
+
},
|
|
138
|
+
label: "EN",
|
|
139
|
+
isDefault: true,
|
|
140
|
+
home: "//cx.dev.griddo.io/pre-griddo/gonzalo-h",
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
render(
|
|
146
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
147
|
+
<LanguageMenu setLanguage={setLanguage} {...props} />
|
|
148
|
+
</ThemeProvider>
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
expect(screen.getByText(/Add new version/i)).toBeTruthy();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("should render the component showing an editable language", () => {
|
|
156
|
+
const setLanguage = jest.fn();
|
|
157
|
+
|
|
158
|
+
const props = {
|
|
159
|
+
language: "en_GB",
|
|
160
|
+
availableLanguages: defaultProps.availableLanguages,
|
|
161
|
+
isInAppBar: false,
|
|
162
|
+
currentLanguages: [
|
|
163
|
+
{
|
|
164
|
+
id: 2,
|
|
165
|
+
locale: "es_ES",
|
|
166
|
+
language: "Spanish",
|
|
167
|
+
path: "/gonzalo-h/es",
|
|
168
|
+
domain: {
|
|
169
|
+
id: 1,
|
|
170
|
+
url: "//cx.dev.griddo.io/pre-griddo",
|
|
171
|
+
slug: "/pre-griddo",
|
|
172
|
+
},
|
|
173
|
+
label: "ES",
|
|
174
|
+
isDefault: false,
|
|
175
|
+
home: "//cx.dev.griddo.io/pre-griddo/gonzalo-h/es",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: 4,
|
|
179
|
+
locale: "en_GB",
|
|
180
|
+
language: "English",
|
|
181
|
+
path: "/gonzalo-h",
|
|
182
|
+
domain: {
|
|
183
|
+
id: 1,
|
|
184
|
+
url: "//cx.dev.griddo.io/pre-griddo",
|
|
185
|
+
slug: "/pre-griddo",
|
|
186
|
+
},
|
|
187
|
+
label: "EN",
|
|
188
|
+
isDefault: true,
|
|
189
|
+
home: "//cx.dev.griddo.io/pre-griddo/gonzalo-h",
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
render(
|
|
195
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
196
|
+
<LanguageMenu setLanguage={setLanguage} {...props} />
|
|
197
|
+
</ThemeProvider>
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
expect(screen.queryByText(/Add new version/i)).toBeFalsy();
|
|
201
|
+
const languageMenuItems = screen.getAllByTestId("language-menu-item");
|
|
202
|
+
expect(languageMenuItems.length).toBe(2);
|
|
203
|
+
expect(screen.getByText(/Spanish/i)).toBeTruthy();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe("LanguageMenu component events", () => {
|
|
207
|
+
it("should call setLanguage on clicking the second language in the list", () => {
|
|
208
|
+
const setLanguage = jest.fn();
|
|
209
|
+
|
|
210
|
+
render(
|
|
211
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
212
|
+
<LanguageMenu setLanguage={setLanguage} {...defaultProps} />
|
|
213
|
+
</ThemeProvider>
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
const languageMenuItems = screen.getAllByTestId("language-menu-item");
|
|
217
|
+
fireEvent.click(languageMenuItems[1]);
|
|
218
|
+
|
|
219
|
+
expect(setLanguage).toHaveBeenLastCalledWith(defaultProps.availableLanguages[1]);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { render, cleanup, screen } from "@testing-library/react";
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
|
|
6
|
+
import { parseTheme } from "@ax/helpers";
|
|
7
|
+
import Loading from "@ax/components/Loading";
|
|
8
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
9
|
+
|
|
10
|
+
afterEach(cleanup);
|
|
11
|
+
|
|
12
|
+
describe("Loading component rendering", () => {
|
|
13
|
+
it("should render the component", () => {
|
|
14
|
+
render(
|
|
15
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
16
|
+
<Loading />
|
|
17
|
+
</ThemeProvider>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const wrapper = screen.getByTestId("loading-wrapper");
|
|
21
|
+
expect(wrapper).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ThemeProvider } from "styled-components";
|
|
3
|
+
import { render, cleanup, screen, fireEvent } from "@testing-library/react";
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
|
|
6
|
+
import { parseTheme } from "@ax/helpers";
|
|
7
|
+
import Login, { ILoginProps } from "@ax/components/Login";
|
|
8
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
9
|
+
|
|
10
|
+
afterEach(cleanup);
|
|
11
|
+
|
|
12
|
+
const settings = {
|
|
13
|
+
cloudinaryName: "cloudinary",
|
|
14
|
+
globalLogoBig: "https://images.dev.griddo.io/logothesaurusextenden-2x-jrexex_6",
|
|
15
|
+
globalLogoMini: "https://images.dev.griddo.io/logothesaurusreduced-2x-cltah3_1",
|
|
16
|
+
siteLogoBig: "https://images.dev.griddo.io/logobs_1",
|
|
17
|
+
siteLogoMini: "https://images.dev.griddo.io/logobs-mini_1",
|
|
18
|
+
welcomeText1: "Welcome back to",
|
|
19
|
+
welcomeText2: "Griddo",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe("Login component rendering", () => {
|
|
23
|
+
it("should render the component", () => {
|
|
24
|
+
const defaultProps: ILoginProps = {
|
|
25
|
+
handleSubmit: jest.fn(),
|
|
26
|
+
email: "hola@secuoyas.com",
|
|
27
|
+
handleEmail: jest.fn(),
|
|
28
|
+
password: "password",
|
|
29
|
+
handlePassword: jest.fn(),
|
|
30
|
+
isLoggingIn: false,
|
|
31
|
+
settings,
|
|
32
|
+
rememberMe: false,
|
|
33
|
+
handleRememberMe: jest.fn(),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
render(
|
|
37
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
38
|
+
<Login {...defaultProps} />
|
|
39
|
+
</ThemeProvider>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const wrapper = screen.getByTestId("login-wrapper");
|
|
43
|
+
expect(wrapper).toBeTruthy();
|
|
44
|
+
const welcomeText1 = screen.getByText("Welcome back to");
|
|
45
|
+
expect(welcomeText1).toBeTruthy();
|
|
46
|
+
const welcomeText2 = screen.getByText("Griddo");
|
|
47
|
+
expect(welcomeText2).toBeTruthy();
|
|
48
|
+
const loginButton = screen.getByText("Log in");
|
|
49
|
+
expect(loginButton).toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should render the component with log button disabled", () => {
|
|
53
|
+
const handleSubmitMock = jest.fn();
|
|
54
|
+
const defaultProps: ILoginProps = {
|
|
55
|
+
handleSubmit: handleSubmitMock,
|
|
56
|
+
email: "hola@secuoyas.com",
|
|
57
|
+
handleEmail: jest.fn(),
|
|
58
|
+
password: "password",
|
|
59
|
+
handlePassword: jest.fn(),
|
|
60
|
+
isLoggingIn: true,
|
|
61
|
+
settings,
|
|
62
|
+
rememberMe: false,
|
|
63
|
+
handleRememberMe: jest.fn(),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
render(
|
|
67
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
68
|
+
<Login {...defaultProps} />
|
|
69
|
+
</ThemeProvider>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const loginButton = screen.queryByText("Log in");
|
|
73
|
+
expect(loginButton).toBeFalsy();
|
|
74
|
+
const loginButtonSending = screen.getByText("Sending");
|
|
75
|
+
expect(loginButtonSending).toBeTruthy();
|
|
76
|
+
fireEvent.click(loginButtonSending);
|
|
77
|
+
expect(handleSubmitMock).toBeCalledTimes(0);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("Login component events", () => {
|
|
82
|
+
it("should call submit function on button click", () => {
|
|
83
|
+
const handleSubmitMock = jest.fn((e) => e.preventDefault());
|
|
84
|
+
const defaultProps: ILoginProps = {
|
|
85
|
+
handleSubmit: handleSubmitMock,
|
|
86
|
+
email: "hola@secuoyas.com",
|
|
87
|
+
handleEmail: jest.fn(),
|
|
88
|
+
password: "password",
|
|
89
|
+
handlePassword: jest.fn(),
|
|
90
|
+
isLoggingIn: false,
|
|
91
|
+
settings,
|
|
92
|
+
rememberMe: false,
|
|
93
|
+
handleRememberMe: jest.fn(),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
render(
|
|
97
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
98
|
+
<Login {...defaultProps} />
|
|
99
|
+
</ThemeProvider>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const loginButton = screen.getByText("Log in");
|
|
103
|
+
expect(loginButton).toBeTruthy();
|
|
104
|
+
fireEvent.click(loginButton);
|
|
105
|
+
expect(handleSubmitMock).toBeCalledTimes(1);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("should call handleEmail function on email change", () => {
|
|
109
|
+
const handleEmailMock = jest.fn();
|
|
110
|
+
const defaultProps: ILoginProps = {
|
|
111
|
+
handleSubmit: jest.fn((e) => e.preventDefault()),
|
|
112
|
+
email: "hola@secuoyas.com",
|
|
113
|
+
handleEmail: handleEmailMock,
|
|
114
|
+
password: "password",
|
|
115
|
+
handlePassword: jest.fn(),
|
|
116
|
+
isLoggingIn: false,
|
|
117
|
+
settings,
|
|
118
|
+
rememberMe: false,
|
|
119
|
+
handleRememberMe: jest.fn(),
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
render(
|
|
123
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
124
|
+
<Login {...defaultProps} />
|
|
125
|
+
</ThemeProvider>
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const input = screen.getByLabelText("email");
|
|
129
|
+
expect(input).toBeTruthy();
|
|
130
|
+
fireEvent.change(input, { target: { value: "prueba" } });
|
|
131
|
+
expect(handleEmailMock).toBeCalledTimes(1);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("should call handlePassword function on password change", () => {
|
|
135
|
+
const handlePasswordMock = jest.fn();
|
|
136
|
+
const defaultProps: ILoginProps = {
|
|
137
|
+
handleSubmit: jest.fn((e) => e.preventDefault()),
|
|
138
|
+
email: "hola@secuoyas.com",
|
|
139
|
+
handleEmail: jest.fn(),
|
|
140
|
+
password: "password",
|
|
141
|
+
handlePassword: handlePasswordMock,
|
|
142
|
+
isLoggingIn: false,
|
|
143
|
+
settings,
|
|
144
|
+
rememberMe: false,
|
|
145
|
+
handleRememberMe: jest.fn(),
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
render(
|
|
149
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
150
|
+
<Login {...defaultProps} />
|
|
151
|
+
</ThemeProvider>
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const input = screen.getByLabelText("password");
|
|
155
|
+
expect(input).toBeTruthy();
|
|
156
|
+
fireEvent.change(input, { target: { value: "prueba" } });
|
|
157
|
+
expect(handlePasswordMock).toBeCalledTimes(1);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("should call handleRememberMe function on input click", () => {
|
|
161
|
+
const handleRememberMeMock = jest.fn();
|
|
162
|
+
const defaultProps: ILoginProps = {
|
|
163
|
+
handleSubmit: jest.fn((e) => e.preventDefault()),
|
|
164
|
+
email: "hola@secuoyas.com",
|
|
165
|
+
handleEmail: jest.fn(),
|
|
166
|
+
password: "password",
|
|
167
|
+
handlePassword: jest.fn(),
|
|
168
|
+
isLoggingIn: false,
|
|
169
|
+
settings,
|
|
170
|
+
rememberMe: false,
|
|
171
|
+
handleRememberMe: handleRememberMeMock,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
render(
|
|
175
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
176
|
+
<Login {...defaultProps} />
|
|
177
|
+
</ThemeProvider>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const input = screen.getByLabelText("rememberMe");
|
|
181
|
+
expect(input).toBeTruthy();
|
|
182
|
+
fireEvent.click(input);
|
|
183
|
+
expect(handleRememberMeMock).toBeCalledTimes(1);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("should change input type on button click", () => {
|
|
187
|
+
const defaultProps: ILoginProps = {
|
|
188
|
+
handleSubmit: jest.fn((e) => e.preventDefault()),
|
|
189
|
+
email: "hola@secuoyas.com",
|
|
190
|
+
handleEmail: jest.fn(),
|
|
191
|
+
password: "",
|
|
192
|
+
handlePassword: jest.fn(),
|
|
193
|
+
isLoggingIn: false,
|
|
194
|
+
settings,
|
|
195
|
+
rememberMe: false,
|
|
196
|
+
handleRememberMe: jest.fn(),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
render(
|
|
200
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
201
|
+
<Login {...defaultProps} />
|
|
202
|
+
</ThemeProvider>
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const input = screen.getByLabelText("password");
|
|
206
|
+
expect(input).toBeTruthy();
|
|
207
|
+
expect(input).toHaveAttribute("type", "password");
|
|
208
|
+
|
|
209
|
+
const button = screen.getByTestId("icon-component");
|
|
210
|
+
expect(button).toBeTruthy();
|
|
211
|
+
fireEvent.click(button);
|
|
212
|
+
|
|
213
|
+
expect(input).toHaveAttribute("type", "text");
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe("Recovery Modal rendering", () => {
|
|
218
|
+
it("should render the recovery modal on button click", () => {
|
|
219
|
+
const defaultProps: ILoginProps = {
|
|
220
|
+
handleSubmit: jest.fn(),
|
|
221
|
+
email: "",
|
|
222
|
+
handleEmail: jest.fn(),
|
|
223
|
+
password: "",
|
|
224
|
+
handlePassword: jest.fn(),
|
|
225
|
+
isLoggingIn: false,
|
|
226
|
+
settings,
|
|
227
|
+
rememberMe: false,
|
|
228
|
+
handleRememberMe: jest.fn(),
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
render(
|
|
232
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
233
|
+
<Login {...defaultProps} />
|
|
234
|
+
</ThemeProvider>
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
const modalClosed = screen.queryByTestId("recovery-modal-content");
|
|
238
|
+
expect(modalClosed).toBeFalsy();
|
|
239
|
+
|
|
240
|
+
const button = screen.getByTestId("forgot-button");
|
|
241
|
+
expect(button).toBeTruthy();
|
|
242
|
+
fireEvent.click(button);
|
|
243
|
+
|
|
244
|
+
const modal = screen.getByTestId("recovery-modal-content");
|
|
245
|
+
expect(modal).toBeTruthy();
|
|
246
|
+
});
|
|
247
|
+
});
|