@griddo/ax 11.14.2-rc.0 → 11.14.2
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/reactEasyCropMock.js +15 -0
- package/config/jest/reactTimezoneMock.js +13 -0
- package/package.json +221 -219
- package/public/img/welcome.svg +127 -0
- package/src/__tests__/components/Browser/Browser.test.tsx +27 -51
- package/src/__tests__/components/CategoryCell/CategoryCell.test.tsx +10 -5
- package/src/__tests__/components/ElementsTooltip/ElementsTooltip.test.tsx +27 -14
- package/src/__tests__/components/HeadingsPreviewModal/ErrorsBanner/ErrorItem/ErrorItem.test.tsx +2 -0
- package/src/__tests__/components/HeadingsPreviewModal/HeadingsPreviewModal.utils.test.tsx +138 -1
- package/src/__tests__/components/ImageDragAndDrop/CropStep/CropStep.test.tsx +84 -0
- package/src/__tests__/components/ImageDragAndDrop/ImageDragAndDrop.test.tsx +173 -0
- package/src/__tests__/components/KeywordsPreviewModal/KeywordsPreviewModal.test.tsx +3 -4
- package/src/__tests__/components/ProfileImage/ProfileImage.test.tsx +120 -0
- package/src/__tests__/components/ResizePanel/ResizePanel.test.tsx +8 -0
- package/src/__tests__/components/UserRolesAndSites/RoleItem/RoleItem.test.tsx +190 -0
- package/src/__tests__/components/UserRolesAndSites/UserRolesAndSites.test.tsx +471 -0
- package/src/__tests__/modules/FramePreview/HeadingsOverlay/HeadingsOverlay.test.tsx +15 -2
- package/src/__tests__/modules/Sites/Sites.test.tsx +68 -224
- package/src/__tests__/modules/Sites/SitesList/ListView/BulkHeader/BulkHeader.test.tsx +21 -17
- package/src/__tests__/modules/Sites/SitesList/SitesList.test.tsx +65 -565
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/DataStep/DataStep.test.tsx +109 -0
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/FinalStep/FinalStep.test.tsx +157 -0
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/ImageStep/CropView/CropView.test.tsx +51 -0
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/ImageStep/ImageStep.test.tsx +70 -0
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/ImageStep/UploadView/UploadView.test.tsx +92 -0
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/TimezoneStep/TimezoneStep.test.tsx +94 -0
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/WelcomeModal.test.tsx +78 -0
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/WelcomeStep/WelcomeStep.test.tsx +39 -0
- package/src/__tests__/modules/Sites/SitesList/WelcomeModal/utils.test.ts +55 -0
- package/src/api/sites.tsx +4 -4
- package/src/components/Avatar/index.tsx +26 -5
- package/src/components/Avatar/style.tsx +20 -10
- package/src/components/Browser/index.tsx +7 -1
- package/src/components/ConfigPanel/index.tsx +11 -7
- package/src/components/ElementsTooltip/index.tsx +96 -34
- package/src/components/ElementsTooltip/style.tsx +12 -1
- package/src/components/Fields/FileField/index.tsx +16 -18
- package/src/components/Fields/HeadingField/index.tsx +1 -1
- package/src/components/Fields/ImageField/index.tsx +9 -38
- package/src/components/Fields/ImageField/style.tsx +12 -1
- package/src/components/Fields/ToggleField/index.tsx +1 -1
- package/src/components/Fields/Wysiwyg/index.tsx +25 -20
- package/src/components/FileGallery/GalleryPanel/index.tsx +15 -7
- package/src/components/FileGallery/index.tsx +33 -28
- package/src/components/Gallery/GalleryPanel/index.tsx +5 -16
- package/src/components/Gallery/index.tsx +0 -2
- package/src/components/HeadingsPreviewModal/ErrorsBanner/ErrorItem/index.tsx +11 -2
- package/src/components/HeadingsPreviewModal/ErrorsBanner/index.tsx +21 -3
- package/src/components/HeadingsPreviewModal/ErrorsBanner/style.tsx +2 -2
- package/src/components/HeadingsPreviewModal/index.tsx +13 -3
- package/src/components/HeadingsPreviewModal/style.tsx +18 -0
- package/src/components/HeadingsPreviewModal/utils.tsx +31 -3
- package/src/components/Image/index.tsx +2 -2
- package/src/components/ImageDragAndDrop/CropStep/index.tsx +95 -0
- package/src/components/ImageDragAndDrop/CropStep/style.tsx +101 -0
- package/src/{modules/MediaGallery → components}/ImageDragAndDrop/index.tsx +103 -40
- package/src/{modules/MediaGallery → components}/ImageDragAndDrop/style.tsx +14 -2
- package/src/components/KeywordsPreviewModal/atoms.tsx +2 -2
- package/src/components/KeywordsPreviewModal/index.tsx +6 -6
- package/src/components/KeywordsPreviewModal/utils.tsx +2 -2
- package/src/components/ProfileImage/index.tsx +55 -0
- package/src/components/ProfileImage/style.tsx +58 -0
- package/src/components/ResizePanel/ResizeHandle/index.tsx +44 -6
- package/src/components/ResizePanel/ResizeHandle/style.tsx +7 -0
- package/src/components/ResizePanel/index.tsx +25 -4
- package/src/components/Tabs/style.tsx +1 -1
- package/src/components/Tag/index.tsx +0 -1
- package/src/components/UserRolesAndSites/RoleItem/index.tsx +42 -0
- package/src/components/UserRolesAndSites/RoleItem/style.tsx +29 -0
- package/src/components/UserRolesAndSites/index.tsx +102 -0
- package/src/components/UserRolesAndSites/style.tsx +67 -0
- package/src/components/index.tsx +6 -0
- package/src/constants/index.ts +13 -1
- package/src/containers/App/actions.tsx +8 -1
- package/src/containers/Sites/actions.tsx +26 -0
- package/src/containers/Sites/constants.tsx +1 -0
- package/src/containers/Sites/interfaces.tsx +6 -0
- package/src/containers/Sites/reducer.tsx +5 -1
- package/src/containers/Users/reducer.tsx +6 -5
- package/src/guards/routeLeaving/index.tsx +9 -11
- package/src/helpers/images.tsx +50 -3
- package/src/helpers/index.tsx +2 -1
- package/src/hooks/forms.tsx +45 -48
- package/src/hooks/index.tsx +2 -1
- package/src/hooks/modals.tsx +4 -3
- package/src/hooks/window.ts +50 -2
- package/src/modules/ActivityLog/ItemLogUser/UserItem/index.tsx +1 -1
- package/src/modules/App/Routing/Logout/index.tsx +3 -5
- package/src/modules/App/Routing/NavMenu/NavItem/index.tsx +73 -52
- package/src/modules/App/Routing/NavMenu/NavItem/style.tsx +21 -7
- package/src/modules/App/Routing/NavMenu/index.tsx +59 -54
- package/src/modules/App/Routing/NavMenu/style.tsx +13 -11
- package/src/modules/CreatePass/index.tsx +1 -1
- package/src/modules/FileDrive/FileDragAndDrop/index.tsx +11 -8
- package/src/modules/FileDrive/FileModal/index.tsx +8 -9
- package/src/modules/FileDrive/index.tsx +1 -18
- package/src/modules/Forms/FormEditor/index.tsx +1 -1
- package/src/modules/FramePreview/HeadingsOverlay/index.tsx +22 -11
- package/src/modules/FramePreview/HeadingsOverlay/style.tsx +1 -1
- package/src/modules/MediaGallery/ImageModal/index.tsx +1 -5
- package/src/modules/MediaGallery/index.tsx +1 -3
- package/src/modules/Settings/Globals/constants.tsx +942 -106
- package/src/modules/Sites/SitesList/AllSitesHeader/index.tsx +33 -0
- package/src/modules/Sites/SitesList/AllSitesHeader/style.tsx +35 -0
- package/src/modules/Sites/SitesList/GridView/GridHeaderFilter/index.tsx +5 -5
- package/src/modules/Sites/SitesList/GridView/GridSiteItem/index.tsx +23 -119
- package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +4 -4
- package/src/modules/Sites/SitesList/ListView/BulkHeader/index.tsx +4 -3
- package/src/modules/Sites/SitesList/ListView/ListSiteItem/index.tsx +23 -120
- package/src/modules/Sites/SitesList/{RecentSiteItem → RecentSites/RecentSiteItem}/index.tsx +4 -5
- package/src/modules/Sites/SitesList/RecentSites/index.tsx +49 -0
- package/src/modules/Sites/SitesList/RecentSites/style.tsx +92 -0
- package/src/modules/Sites/SitesList/SiteModal/index.tsx +8 -7
- package/src/modules/Sites/SitesList/WelcomeModal/DataStep/index.tsx +72 -0
- package/src/modules/Sites/SitesList/WelcomeModal/DataStep/style.tsx +59 -0
- package/src/modules/Sites/SitesList/WelcomeModal/FinalStep/constants.tsx +78 -0
- package/src/modules/Sites/SitesList/WelcomeModal/FinalStep/index.tsx +78 -0
- package/src/modules/Sites/SitesList/WelcomeModal/FinalStep/style.tsx +141 -0
- package/src/modules/Sites/SitesList/WelcomeModal/ImageStep/CropView/index.tsx +93 -0
- package/src/modules/Sites/SitesList/WelcomeModal/ImageStep/CropView/style.tsx +77 -0
- package/src/modules/Sites/SitesList/WelcomeModal/ImageStep/UploadView/index.tsx +100 -0
- package/src/modules/Sites/SitesList/WelcomeModal/ImageStep/UploadView/style.tsx +94 -0
- package/src/modules/Sites/SitesList/WelcomeModal/ImageStep/index.tsx +44 -0
- package/src/modules/Sites/SitesList/WelcomeModal/ImageStep/style.tsx +31 -0
- package/src/modules/Sites/SitesList/WelcomeModal/TimezoneStep/index.tsx +51 -0
- package/src/modules/Sites/SitesList/WelcomeModal/TimezoneStep/style.tsx +52 -0
- package/src/modules/Sites/SitesList/WelcomeModal/WelcomeStep/index.tsx +40 -0
- package/src/modules/Sites/SitesList/WelcomeModal/WelcomeStep/style.tsx +53 -0
- package/src/modules/Sites/SitesList/WelcomeModal/index.tsx +215 -0
- package/src/modules/Sites/SitesList/WelcomeModal/style.tsx +12 -0
- package/src/modules/Sites/SitesList/WelcomeModal/utils.ts +26 -0
- package/src/modules/Sites/SitesList/atoms.tsx +4 -4
- package/src/modules/Sites/SitesList/hooks.tsx +149 -16
- package/src/modules/Sites/SitesList/index.tsx +127 -125
- package/src/modules/Sites/SitesList/style.tsx +1 -117
- package/src/modules/Sites/SitesList/utils.tsx +9 -2
- package/src/modules/Sites/index.tsx +19 -8
- package/src/modules/Users/Profile/index.tsx +169 -31
- package/src/modules/Users/Profile/style.tsx +81 -1
- package/src/modules/Users/Roles/RoleItem/index.tsx +2 -2
- package/src/modules/Users/UserCreate/SiteItem/index.tsx +11 -14
- package/src/modules/Users/UserForm/atoms.tsx +3 -3
- package/src/modules/Users/UserForm/index.tsx +25 -29
- package/src/modules/Users/UserForm/style.tsx +15 -2
- package/src/modules/Users/UserList/UserItem/index.tsx +4 -4
- package/src/routes/index.tsx +1 -0
- package/src/types/index.tsx +2 -0
- /package/src/modules/Sites/SitesList/{RecentSiteItem → RecentSites/RecentSiteItem}/style.tsx +0 -0
|
@@ -1,263 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
import axios from "axios";
|
|
1
|
+
import { Router } from "react-router-dom";
|
|
3
2
|
|
|
4
|
-
import { ThemeProvider } from "styled-components";
|
|
5
3
|
import { parseTheme } from "@ax/helpers";
|
|
4
|
+
import Sites, { type ISitesProps } from "@ax/modules/Sites";
|
|
5
|
+
import { history } from "@ax/routes";
|
|
6
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
7
|
+
|
|
8
|
+
import axios from "axios";
|
|
6
9
|
import { mock } from "jest-mock-extended";
|
|
7
10
|
import configureStore from "redux-mock-store";
|
|
8
11
|
import thunk from "redux-thunk";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import { history } from "@ax/routes";
|
|
12
|
-
import globalTheme from "@ax/themes/theme.json";
|
|
13
|
-
import Sites, { ISitesProps } from "@ax/modules/Sites";
|
|
12
|
+
import { ThemeProvider } from "styled-components";
|
|
14
13
|
|
|
15
|
-
import {
|
|
14
|
+
import { act, cleanup, render, screen } from "../../../../config/jest/test-utils";
|
|
15
|
+
import { structuredDataResponse } from "./../../../__mocks__/axios/SitesList";
|
|
16
16
|
import { sitesDataMock, userDataMock } from "./../../../__mocks__/store/SitesList";
|
|
17
|
-
import { sitesResponse, structuredDataResponse } from "./../../../__mocks__/axios/SitesList";
|
|
18
17
|
|
|
19
18
|
afterEach(cleanup);
|
|
20
19
|
jest.mock("axios");
|
|
21
20
|
const mockedAxios = axios as jest.MockedFunction<typeof axios>;
|
|
22
21
|
|
|
22
|
+
const mockStore = configureStore([thunk]);
|
|
23
23
|
const defaultProps = mock<ISitesProps>();
|
|
24
|
-
describe("Sites module rendering", () => {
|
|
25
|
-
it("should render loading component when is loading", async () => {
|
|
26
|
-
mockedAxios.mockResolvedValue(sitesResponse);
|
|
27
|
-
mockedAxios.mockResolvedValue(structuredDataResponse);
|
|
28
|
-
|
|
29
|
-
const initialStore = {
|
|
30
|
-
app: {
|
|
31
|
-
isLoading: true,
|
|
32
|
-
globalLangs: [
|
|
33
|
-
{ id: 4, locale: "en_GB", language: "English", label: "EN", isDefault: true },
|
|
34
|
-
{ id: 2, locale: "es_ES", language: "Spanish", label: "ES", isDefault: false },
|
|
35
|
-
],
|
|
36
|
-
token: "eyJhbGciOiJIUzI",
|
|
37
|
-
},
|
|
38
|
-
users: userDataMock,
|
|
39
|
-
sites: {
|
|
40
|
-
totalItems: 0,
|
|
41
|
-
sites: [],
|
|
42
|
-
recentSites: [],
|
|
43
|
-
config: sitesDataMock.config,
|
|
44
|
-
},
|
|
45
|
-
structuredData: { global: [], sites: [] },
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const middlewares: any = [thunk];
|
|
49
|
-
const mockStore = configureStore(middlewares);
|
|
50
|
-
const store = mockStore(initialStore);
|
|
51
|
-
|
|
52
|
-
const initialState = { ...initialStore, ...defaultProps };
|
|
53
24
|
|
|
54
|
-
|
|
25
|
+
const baseStore = {
|
|
26
|
+
app: {
|
|
27
|
+
isLoading: false,
|
|
28
|
+
globalLangs: [
|
|
29
|
+
{ id: 4, locale: "en_GB", language: "English", label: "EN", isDefault: true },
|
|
30
|
+
{ id: 2, locale: "es_ES", language: "Spanish", label: "ES", isDefault: false },
|
|
31
|
+
],
|
|
32
|
+
token: "eyJhbGciOiJIUzI",
|
|
33
|
+
},
|
|
34
|
+
users: userDataMock,
|
|
35
|
+
sites: sitesDataMock,
|
|
36
|
+
structuredData: { global: [], sites: [] },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const renderSites = async (storeData = baseStore) => {
|
|
40
|
+
const store = mockStore(storeData);
|
|
41
|
+
await act(async () => {
|
|
42
|
+
render(
|
|
55
43
|
<Router history={history}>
|
|
56
44
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
57
|
-
<Sites {...
|
|
45
|
+
<Sites {...{ ...storeData, ...defaultProps }} />
|
|
58
46
|
</ThemeProvider>
|
|
59
|
-
</Router
|
|
47
|
+
</Router>,
|
|
48
|
+
{ store },
|
|
60
49
|
);
|
|
61
|
-
|
|
62
|
-
await act(async () => {
|
|
63
|
-
render(Component, { store });
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const loadingComponent = screen.getByTestId("loading-wrapper");
|
|
67
|
-
|
|
68
|
-
expect(loadingComponent).toBeTruthy();
|
|
69
50
|
});
|
|
51
|
+
};
|
|
70
52
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const initialStore = {
|
|
76
|
-
app: {
|
|
77
|
-
isLoading: false,
|
|
78
|
-
globalLangs: [
|
|
79
|
-
{ id: 4, locale: "en_GB", language: "English", label: "EN", isDefault: true },
|
|
80
|
-
{ id: 2, locale: "es_ES", language: "Spanish", label: "ES", isDefault: false },
|
|
81
|
-
],
|
|
82
|
-
token: "eyJhbGciOiJIUzI",
|
|
83
|
-
},
|
|
84
|
-
users: userDataMock,
|
|
85
|
-
sites: sitesDataMock,
|
|
86
|
-
structuredData: { global: [], sites: [] },
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const middlewares: any = [thunk];
|
|
90
|
-
const mockStore = configureStore(middlewares);
|
|
91
|
-
const store = mockStore(initialStore);
|
|
92
|
-
|
|
93
|
-
const initialState = { ...initialStore, ...defaultProps };
|
|
94
|
-
|
|
95
|
-
const Component = (
|
|
96
|
-
<Router history={history}>
|
|
97
|
-
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
98
|
-
<Sites {...initialState} />
|
|
99
|
-
</ThemeProvider>
|
|
100
|
-
</Router>
|
|
101
|
-
);
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
mockedAxios.mockResolvedValue(structuredDataResponse);
|
|
55
|
+
});
|
|
102
56
|
|
|
103
|
-
|
|
104
|
-
|
|
57
|
+
describe("Sites module rendering", () => {
|
|
58
|
+
it("should render loading component when is loading", async () => {
|
|
59
|
+
await renderSites({
|
|
60
|
+
...baseStore,
|
|
61
|
+
app: { ...baseStore.app, isLoading: true },
|
|
62
|
+
sites: { totalItems: 0, sites: [], recentSites: [], config: sitesDataMock.config },
|
|
105
63
|
});
|
|
106
64
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const title = screen.getByTestId("recent-sites-title");
|
|
110
|
-
const recentSitesItemsWrapper = screen.getByTestId("recent-sites-items-wrapper");
|
|
111
|
-
const collapseButton = screen.getByTestId("recent-sites-collapse-button");
|
|
112
|
-
const hideLabel = screen.getByTestId("recent-sites-hide-label");
|
|
65
|
+
expect(screen.getByTestId("loading-wrapper")).toBeTruthy();
|
|
66
|
+
});
|
|
113
67
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
expect(
|
|
118
|
-
expect(
|
|
119
|
-
expect(
|
|
68
|
+
it("should render recent sites list when there are recent sites", async () => {
|
|
69
|
+
await renderSites();
|
|
70
|
+
|
|
71
|
+
expect(screen.getByTestId("recent-sites-list")).toBeTruthy();
|
|
72
|
+
expect(screen.getByTestId("recent-sites-header")).toBeTruthy();
|
|
73
|
+
expect(screen.getByTestId("recent-sites-title")).toBeTruthy();
|
|
74
|
+
expect(screen.getByTestId("recent-sites-items-wrapper")).toBeTruthy();
|
|
75
|
+
expect(screen.getByTestId("recent-sites-collapse-button")).toBeTruthy();
|
|
76
|
+
expect(screen.getByTestId("recent-sites-hide-label")).toBeTruthy();
|
|
120
77
|
});
|
|
121
78
|
|
|
122
79
|
it("should render default sites list view", async () => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
{ id: 2, locale: "es_ES", language: "Spanish", label: "ES", isDefault: false },
|
|
132
|
-
],
|
|
133
|
-
token: "eyJhbGciOiJIUzI",
|
|
134
|
-
},
|
|
135
|
-
users: userDataMock,
|
|
136
|
-
sites: sitesDataMock,
|
|
137
|
-
structuredData: { global: [], sites: [] },
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const middlewares: any = [thunk];
|
|
141
|
-
const mockStore = configureStore(middlewares);
|
|
142
|
-
const store = mockStore(initialStore);
|
|
143
|
-
|
|
144
|
-
const initialState = { ...initialStore, ...defaultProps };
|
|
145
|
-
|
|
146
|
-
const Component = (
|
|
147
|
-
<Router history={history}>
|
|
148
|
-
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
149
|
-
<Sites {...initialState} />
|
|
150
|
-
</ThemeProvider>
|
|
151
|
-
</Router>
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
await act(async () => {
|
|
155
|
-
render(Component, { store });
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const sectionHeader = screen.getByTestId("all-sites-header");
|
|
159
|
-
const title = screen.getByTestId("all-sites-title");
|
|
160
|
-
const headerIconsWrapper = screen.getByTestId("all-sites-header-icons");
|
|
161
|
-
const filterSelect = screen.getByTestId("all-sites-grid-filter");
|
|
162
|
-
const filterSelectLabel = screen.getByTestId("all-sites-grid-filter-label");
|
|
163
|
-
const sitesGridList = screen.getByTestId("sites-grid-list");
|
|
164
|
-
|
|
165
|
-
expect(sectionHeader).toBeTruthy();
|
|
166
|
-
expect(title).toBeTruthy();
|
|
167
|
-
expect(headerIconsWrapper).toBeTruthy();
|
|
168
|
-
expect(filterSelect).toBeTruthy();
|
|
169
|
-
expect(filterSelectLabel).toBeTruthy();
|
|
170
|
-
expect(sitesGridList).toBeTruthy();
|
|
80
|
+
await renderSites();
|
|
81
|
+
|
|
82
|
+
expect(screen.getByTestId("all-sites-header")).toBeTruthy();
|
|
83
|
+
expect(screen.getByTestId("all-sites-title")).toBeTruthy();
|
|
84
|
+
expect(screen.getByTestId("all-sites-header-icons")).toBeTruthy();
|
|
85
|
+
expect(screen.getByTestId("all-sites-grid-filter")).toBeTruthy();
|
|
86
|
+
expect(screen.getByTestId("all-sites-grid-filter-label")).toBeTruthy();
|
|
87
|
+
expect(screen.getByTestId("sites-grid-list")).toBeTruthy();
|
|
171
88
|
});
|
|
172
89
|
|
|
173
90
|
it("should not render recent sites list when recent sites list is empty", async () => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const initialStore = {
|
|
178
|
-
app: {
|
|
179
|
-
isLoading: false,
|
|
180
|
-
globalLangs: [
|
|
181
|
-
{ id: 4, locale: "en_GB", language: "English", label: "EN", isDefault: true },
|
|
182
|
-
{ id: 2, locale: "es_ES", language: "Spanish", label: "ES", isDefault: false },
|
|
183
|
-
],
|
|
184
|
-
token: "eyJhbGciOiJIUzI",
|
|
185
|
-
},
|
|
186
|
-
users: userDataMock,
|
|
187
|
-
sites: {
|
|
188
|
-
totalItems: 2,
|
|
189
|
-
sites: sitesDataMock.sites,
|
|
190
|
-
recentSites: [],
|
|
191
|
-
config: sitesDataMock.config,
|
|
192
|
-
},
|
|
193
|
-
structuredData: { global: [], sites: [] },
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
const middlewares: any = [thunk];
|
|
197
|
-
const mockStore = configureStore(middlewares);
|
|
198
|
-
const store = mockStore(initialStore);
|
|
199
|
-
|
|
200
|
-
const initialState = { ...initialStore, ...defaultProps };
|
|
201
|
-
|
|
202
|
-
const Component = (
|
|
203
|
-
<Router history={history}>
|
|
204
|
-
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
205
|
-
<Sites {...initialState} />
|
|
206
|
-
</ThemeProvider>
|
|
207
|
-
</Router>
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
await act(async () => {
|
|
211
|
-
render(Component, { store });
|
|
91
|
+
await renderSites({
|
|
92
|
+
...baseStore,
|
|
93
|
+
sites: { totalItems: 2, sites: sitesDataMock.sites, recentSites: [], config: sitesDataMock.config },
|
|
212
94
|
});
|
|
213
95
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
expect(recentSitesList).not.toBeTruthy();
|
|
96
|
+
expect(screen.queryByTestId("recent-sites-list")).not.toBeTruthy();
|
|
217
97
|
});
|
|
218
98
|
|
|
219
99
|
it("should render empty state when no sites", async () => {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const initialStore = {
|
|
224
|
-
app: {
|
|
225
|
-
isLoading: false,
|
|
226
|
-
globalLangs: [
|
|
227
|
-
{ id: 4, locale: "en_GB", language: "English", label: "EN", isDefault: true },
|
|
228
|
-
{ id: 2, locale: "es_ES", language: "Spanish", label: "ES", isDefault: false },
|
|
229
|
-
],
|
|
230
|
-
token: "eyJhbGciOiJIUzI",
|
|
231
|
-
},
|
|
232
|
-
users: userDataMock,
|
|
233
|
-
sites: {
|
|
234
|
-
totalItems: 0,
|
|
235
|
-
sites: [],
|
|
236
|
-
recentSites: [],
|
|
237
|
-
config: sitesDataMock.config,
|
|
238
|
-
},
|
|
239
|
-
structuredData: { global: [], sites: [] },
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const middlewares: any = [thunk];
|
|
243
|
-
const mockStore = configureStore(middlewares);
|
|
244
|
-
const store = mockStore(initialStore);
|
|
245
|
-
|
|
246
|
-
const initialState = { ...initialStore, ...defaultProps };
|
|
247
|
-
|
|
248
|
-
const Component = (
|
|
249
|
-
<Router history={history}>
|
|
250
|
-
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
251
|
-
<Sites {...initialState} />
|
|
252
|
-
</ThemeProvider>
|
|
253
|
-
</Router>
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
await act(async () => {
|
|
257
|
-
render(Component, { store });
|
|
100
|
+
await renderSites({
|
|
101
|
+
...baseStore,
|
|
102
|
+
sites: { totalItems: 0, sites: [], recentSites: [], config: sitesDataMock.config },
|
|
258
103
|
});
|
|
259
104
|
|
|
260
|
-
|
|
261
|
-
expect(emptyState).toBeTruthy();
|
|
105
|
+
expect(screen.getByTestId("empty-state")).toBeTruthy();
|
|
262
106
|
});
|
|
263
107
|
});
|
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { ThemeProvider } from "styled-components";
|
|
4
|
-
import { screen, cleanup, act } from "@testing-library/react";
|
|
5
|
-
import { render } from "../../../../../../../config/jest/test-utils";
|
|
6
1
|
import "@testing-library/jest-dom";
|
|
2
|
+
|
|
3
|
+
import { parseTheme } from "@ax/helpers";
|
|
4
|
+
import type { IBulkHeaderProps } from "@ax/modules/Sites/SitesList/ListView/BulkHeader";
|
|
5
|
+
import BulkHeader from "@ax/modules/Sites/SitesList/ListView/BulkHeader";
|
|
6
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
7
|
+
|
|
8
|
+
import { act, cleanup, screen } from "@testing-library/react";
|
|
7
9
|
import { mock } from "jest-mock-extended";
|
|
8
10
|
import configureStore from "redux-mock-store";
|
|
9
11
|
import thunk from "redux-thunk";
|
|
12
|
+
import { ThemeProvider } from "styled-components";
|
|
10
13
|
|
|
11
|
-
import {
|
|
12
|
-
import BulkHeader, { IBulkHeaderProps } from "@ax/modules/Sites/SitesList/ListView/BulkHeader";
|
|
14
|
+
import { render } from "../../../../../../../config/jest/test-utils";
|
|
13
15
|
import { defaultStore } from "./../../../../../../__mocks__/store/GenericStore";
|
|
14
16
|
|
|
15
|
-
import globalTheme from "@ax/themes/theme.json";
|
|
16
|
-
|
|
17
17
|
afterEach(cleanup);
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
const mockStore = configureStore(middlewares);
|
|
21
|
-
const store = mockStore(defaultStore);
|
|
22
|
-
|
|
19
|
+
const store = configureStore([thunk])(defaultStore);
|
|
23
20
|
const defaultProps = mock<IBulkHeaderProps>();
|
|
24
21
|
|
|
25
22
|
describe("BulkHeader component rendering", () => {
|
|
26
23
|
it("should render table header", async () => {
|
|
27
24
|
defaultProps.showBulk = false;
|
|
28
25
|
defaultProps.checkState = { isAllSelected: false, indeterminate: false };
|
|
29
|
-
defaultProps.filterValues = {
|
|
30
|
-
|
|
26
|
+
defaultProps.filterValues = {
|
|
27
|
+
order: [{ value: "lastAccess-desc", label: "lastAccess-desc" }],
|
|
28
|
+
liveStatus: [{ value: "all", label: "All" }],
|
|
29
|
+
};
|
|
30
|
+
defaultProps.sortedListStatus = {
|
|
31
|
+
isAscending: false,
|
|
32
|
+
sortedByTitle: false,
|
|
33
|
+
sortedByLastAccess: true,
|
|
34
|
+
sortedByDateCreated: false,
|
|
35
|
+
};
|
|
31
36
|
defaultProps.totalItems = 22;
|
|
32
37
|
|
|
33
38
|
await act(async () => {
|
|
@@ -39,8 +44,7 @@ describe("BulkHeader component rendering", () => {
|
|
|
39
44
|
);
|
|
40
45
|
});
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
expect(tableHeader).toBeTruthy();
|
|
47
|
+
expect(screen.getByTestId("sites-table-header")).toBeTruthy();
|
|
44
48
|
});
|
|
45
49
|
|
|
46
50
|
it("should render bulk header", async () => {
|