@blaze-cms/react-page-builder 0.118.0-alpha.2 → 0.119.0-alpha.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/CHANGELOG.md +41 -0
- package/README.md +22 -0
- package/lib/application/query/index.js +12 -12
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/Banner/AdSlotRender.js +104 -0
- package/lib/components/Banner/AdSlotRender.js.map +1 -0
- package/lib/components/Banner/Banner.js +2 -2
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Banner/BannerRender.js +23 -33
- package/lib/components/Banner/BannerRender.js.map +1 -1
- package/lib/components/Button.js +2 -2
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/CardContainer.js +6 -2
- package/lib/components/Card/CardContainer.js.map +1 -1
- package/lib/components/Card/CardFactory.js +2 -2
- package/lib/components/Card/CardFactory.js.map +1 -1
- package/lib/components/Card/CardRender.js +3 -3
- package/lib/components/Card/CardRender.js.map +1 -1
- package/lib/components/Card/helpers/filter-query-setup.js +7 -7
- package/lib/components/Card/helpers/filter-query-setup.js.map +1 -1
- package/lib/components/CarouselWrapper.js +54 -14
- package/lib/components/CarouselWrapper.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryFactory.js +2 -2
- package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryRender.js +2 -2
- package/lib/components/DataSummary/DataSummaryRender.js.map +1 -1
- package/lib/components/EmailConfirm/EmailConfirm.js +2 -2
- package/lib/components/EmailConfirm/EmailConfirm.js.map +1 -1
- package/lib/components/EmailConfirm/mutation.js +2 -2
- package/lib/components/EmailConfirm/mutation.js.map +1 -1
- package/lib/components/Image/ImageFactory.js +9 -5
- package/lib/components/Image/ImageFactory.js.map +1 -1
- package/lib/components/List/ListBuilder.js +21 -21
- package/lib/components/List/ListBuilder.js.map +1 -1
- package/lib/components/List/ListFactory.js +3 -3
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/ListRender.js +2 -2
- package/lib/components/List/ListRender.js.map +1 -1
- package/lib/components/Login/LoggedInMessage.js +1 -1
- package/lib/components/Login/LoggedInMessage.js.map +1 -1
- package/lib/components/Login/Login.js +2 -2
- package/lib/components/Login/Login.js.map +1 -1
- package/lib/components/Menu/Menu.js +39 -6
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/PasswordReset/PasswordReset.js +2 -2
- package/lib/components/PasswordReset/PasswordReset.js.map +1 -1
- package/lib/components/PasswordResetRequest/PasswordResetRequest.js +2 -2
- package/lib/components/PasswordResetRequest/PasswordResetRequest.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +2 -2
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/constants/index.js +8 -2
- package/lib/constants/index.js.map +1 -1
- package/lib/helpers/build-props-query.js +2 -2
- package/lib/helpers/build-props-query.js.map +1 -1
- package/lib/hooks/use-get-entity-schema.js +3 -3
- package/lib/hooks/use-get-entity-schema.js.map +1 -1
- package/lib/hooks/use-get-entity-schemas-as-obj.js +2 -2
- package/lib/hooks/use-get-entity-schemas-as-obj.js.map +1 -1
- package/lib/hooks/use-get-image-id-from-relation.js +2 -2
- package/lib/hooks/use-get-image-id-from-relation.js.map +1 -1
- package/lib/hooks/use-get-images.js +2 -2
- package/lib/hooks/use-get-images.js.map +1 -1
- package/lib/hooks/use-get-single-entity-schema.js +2 -2
- package/lib/hooks/use-get-single-entity-schema.js.map +1 -1
- package/lib-es/application/query/index.js +1 -5
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/Banner/AdSlotRender.js +54 -0
- package/lib-es/components/Banner/AdSlotRender.js.map +1 -0
- package/lib-es/components/Banner/Banner.js +1 -1
- package/lib-es/components/Banner/Banner.js.map +1 -1
- package/lib-es/components/Banner/BannerRender.js +21 -29
- package/lib-es/components/Banner/BannerRender.js.map +1 -1
- package/lib-es/components/Button.js +1 -1
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/Card/CardContainer.js +7 -3
- package/lib-es/components/Card/CardContainer.js.map +1 -1
- package/lib-es/components/Card/CardFactory.js +1 -1
- package/lib-es/components/Card/CardFactory.js.map +1 -1
- package/lib-es/components/Card/CardRender.js +1 -1
- package/lib-es/components/Card/CardRender.js.map +1 -1
- package/lib-es/components/Card/helpers/filter-query-setup.js +1 -1
- package/lib-es/components/Card/helpers/filter-query-setup.js.map +1 -1
- package/lib-es/components/CarouselWrapper.js +50 -14
- package/lib-es/components/CarouselWrapper.js.map +1 -1
- package/lib-es/components/DataSummary/DataSummaryFactory.js +1 -1
- package/lib-es/components/DataSummary/DataSummaryFactory.js.map +1 -1
- package/lib-es/components/DataSummary/DataSummaryRender.js +1 -1
- package/lib-es/components/DataSummary/DataSummaryRender.js.map +1 -1
- package/lib-es/components/EmailConfirm/EmailConfirm.js +1 -1
- package/lib-es/components/EmailConfirm/EmailConfirm.js.map +1 -1
- package/lib-es/components/EmailConfirm/mutation.js +1 -1
- package/lib-es/components/EmailConfirm/mutation.js.map +1 -1
- package/lib-es/components/Image/ImageFactory.js +8 -4
- package/lib-es/components/Image/ImageFactory.js.map +1 -1
- package/lib-es/components/List/ListBuilder.js +2 -2
- package/lib-es/components/List/ListBuilder.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +1 -1
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/ListRender.js +1 -1
- package/lib-es/components/List/ListRender.js.map +1 -1
- package/lib-es/components/Login/LoggedInMessage.js +1 -1
- package/lib-es/components/Login/LoggedInMessage.js.map +1 -1
- package/lib-es/components/Login/Login.js +1 -1
- package/lib-es/components/Login/Login.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +44 -11
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/PasswordReset/PasswordReset.js +1 -1
- package/lib-es/components/PasswordReset/PasswordReset.js.map +1 -1
- package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js +1 -1
- package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/constants/index.js +4 -1
- package/lib-es/constants/index.js.map +1 -1
- package/lib-es/helpers/build-props-query.js +2 -2
- package/lib-es/helpers/build-props-query.js.map +1 -1
- package/lib-es/hooks/use-get-entity-schema.js +1 -1
- package/lib-es/hooks/use-get-entity-schema.js.map +1 -1
- package/lib-es/hooks/use-get-entity-schemas-as-obj.js +1 -1
- package/lib-es/hooks/use-get-entity-schemas-as-obj.js.map +1 -1
- package/lib-es/hooks/use-get-image-id-from-relation.js +1 -1
- package/lib-es/hooks/use-get-image-id-from-relation.js.map +1 -1
- package/lib-es/hooks/use-get-images.js +1 -1
- package/lib-es/hooks/use-get-images.js.map +1 -1
- package/lib-es/hooks/use-get-single-entity-schema.js +1 -1
- package/lib-es/hooks/use-get-single-entity-schema.js.map +1 -1
- package/package.json +9 -13
- package/src/application/query/index.js +1 -5
- package/src/components/Banner/AdSlotRender.js +62 -0
- package/src/components/Banner/Banner.js +1 -1
- package/src/components/Banner/BannerRender.js +22 -27
- package/src/components/Button.js +1 -1
- package/src/components/Card/CardContainer.js +5 -1
- package/src/components/Card/CardFactory.js +1 -1
- package/src/components/Card/CardRender.js +1 -1
- package/src/components/Card/helpers/filter-query-setup.js +1 -1
- package/src/components/CarouselWrapper.js +64 -19
- package/src/components/DataSummary/DataSummaryFactory.js +1 -1
- package/src/components/DataSummary/DataSummaryRender.js +1 -1
- package/src/components/EmailConfirm/EmailConfirm.js +1 -1
- package/src/components/EmailConfirm/mutation.js +1 -1
- package/src/components/Image/ImageFactory.js +10 -7
- package/src/components/List/ListBuilder.js +2 -2
- package/src/components/List/ListFactory.js +1 -1
- package/src/components/List/ListRender.js +1 -1
- package/src/components/Login/LoggedInMessage.js +1 -1
- package/src/components/Login/Login.js +1 -1
- package/src/components/Menu/Menu.js +50 -12
- package/src/components/PasswordReset/PasswordReset.js +1 -1
- package/src/components/PasswordResetRequest/PasswordResetRequest.js +1 -1
- package/src/components/SearchFilter/SearchFilterContainer.js +1 -1
- package/src/constants/index.js +6 -0
- package/src/helpers/build-props-query.js +2 -2
- package/src/hooks/use-get-entity-schema.js +1 -1
- package/src/hooks/use-get-entity-schemas-as-obj.js +1 -1
- package/src/hooks/use-get-image-id-from-relation.js +1 -1
- package/src/hooks/use-get-images.js +1 -1
- package/src/hooks/use-get-single-entity-schema.js +1 -1
- package/tests/unit/src/components/Banner/AdSlotRender.test.js +81 -0
- package/tests/unit/src/components/Banner/Banner.test.js +2 -1
- package/tests/unit/src/components/Banner/BannerRender.test.js +119 -0
- package/tests/unit/src/components/Banner/__snapshots__/AdSlotRender.test.js.snap +54 -0
- package/tests/unit/src/components/Banner/__snapshots__/BannerRender.test.js.snap +10 -0
- package/tests/unit/src/components/Button.test.js +2 -1
- package/tests/unit/src/components/Card/CardRender.test.js +1 -1
- package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +4 -4
- package/tests/unit/src/components/Carousel/Carousel.test.js +1 -1
- package/tests/unit/src/components/DataSummary/DataSummaryFactory.test.js +3 -2
- package/tests/unit/src/components/EmailConfirm/EmailConfirm.test.js +2 -1
- package/tests/unit/src/components/Image/GlobalLightbox/GlobalLightbox.test.js +10 -6
- package/tests/unit/src/components/Image/ImageFactory.test.js +11 -19
- package/tests/unit/src/components/Image/__snapshots__/ImageFactory.test.js.snap +34 -1
- package/tests/unit/src/components/Image/mocks.js +80 -24
- package/tests/unit/src/components/List/ListRender.test.js +2 -1
- package/tests/unit/src/components/Login/Login.test.js +2 -1
- package/tests/unit/src/components/PasswordReset/PasswordReset.test.js +2 -2
- package/tests/unit/src/components/PasswordResetRequest/PasswordResetRequest.test.js +2 -2
- package/tests/unit/src/components/SearchFilter/SearchFilterContainer.test.js +2 -1
- package/tests/unit/src/components/Video/providers/JWPlayer/JWPlayerProvider.test.js +1 -1
- package/tests/unit/src/components/__snapshots__/CarouselWrapper.test.js.snap +12 -12
- package/tests/unit/src/helpers/build-props-query.test.js +6 -6
- package/tests/unit/src/hooks/use-get-entity-schema-as-obj.test.js +2 -2
- package/tests/unit/src/hooks/use-get-image-id-from-relation.test.js +1 -1
- package/tests/unit/src/hooks/use-get-images.test.js +4 -14
- package/tests/unit/src/hooks/use-get-single-entity-schema.test.js +2 -4
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Input from '@blaze-react/input';
|
|
4
4
|
import Button from '@blaze-react/button';
|
|
5
|
-
import { useMutation } from '
|
|
5
|
+
import { useMutation } from '@apollo/client';
|
|
6
6
|
import { useRouter } from 'next/router';
|
|
7
7
|
import { checkIfLoggedIn, REQUEST_USER_PASSWORD_RESET_MUTATION } from '@blaze-cms/core-auth-ui';
|
|
8
8
|
import { GRAPH_QL_ERROR } from '../../constants';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useRef } from 'react';
|
|
2
2
|
import { useRouter } from 'next/router';
|
|
3
|
-
import { useQuery } from '@apollo/
|
|
3
|
+
import { useQuery } from '@apollo/client';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { parseUrl, stringify } from 'query-string';
|
|
6
6
|
import SearchFilter from './SearchFilter';
|
package/src/constants/index.js
CHANGED
|
@@ -194,10 +194,16 @@ const ALL_AZ_SORT = {
|
|
|
194
194
|
|
|
195
195
|
const SCROLL_OFFSET = process.env.BLAZE_SCROLL_OFFSET || 50;
|
|
196
196
|
|
|
197
|
+
const BANNER_LOADING = 'loading';
|
|
198
|
+
const BANNER_EMPTY = 'empty';
|
|
199
|
+
const BANNER_LOADED = 'loaded';
|
|
197
200
|
const ANCHOR_TAG = 'a';
|
|
198
201
|
const TARGET_BLANK = '_blank';
|
|
199
202
|
|
|
200
203
|
export {
|
|
204
|
+
BANNER_LOADING,
|
|
205
|
+
BANNER_EMPTY,
|
|
206
|
+
BANNER_LOADED,
|
|
201
207
|
BLANK_SPACE_UNICODE_STRING,
|
|
202
208
|
BOLD_TAG,
|
|
203
209
|
BUTTON,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';
|
|
2
2
|
|
|
3
3
|
const defaultProps = [ID, 'name'];
|
|
4
|
-
const categoryProps = 'publishedListingPage{url}';
|
|
4
|
+
const categoryProps = 'id publishedListingPage{id, url}';
|
|
5
5
|
|
|
6
6
|
const checkProps = props =>
|
|
7
7
|
!!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);
|
|
@@ -77,7 +77,7 @@ const getContentProps = (isContent, displayThumbnail) => {
|
|
|
77
77
|
if (!isContent) return [];
|
|
78
78
|
|
|
79
79
|
const props = ['url', 'sponsored', 'featured'];
|
|
80
|
-
if (displayThumbnail) props.push('image.url', 'image.data');
|
|
80
|
+
if (displayThumbnail) props.push('image.id', 'image.url', 'image.data');
|
|
81
81
|
|
|
82
82
|
return props;
|
|
83
83
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
+
import { render, fireEvent, waitFor } from '@testing-library/react';
|
|
4
|
+
import AdSlotRender from '../../../../../src/components/Banner/AdSlotRender';
|
|
5
|
+
|
|
6
|
+
jest.mock('react-dfp', () => {
|
|
7
|
+
const AdSlot = ({ onSlotRender }) => (
|
|
8
|
+
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
9
|
+
<div
|
|
10
|
+
data-testid="adslot-test"
|
|
11
|
+
role="button"
|
|
12
|
+
onMouseLeave={() => onSlotRender({ event: { isEmpty: true } })}
|
|
13
|
+
onMouseOver={() => onSlotRender({ event: { isEmpty: false } })}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
return { AdSlot };
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const slotTestId = 'adslot-test';
|
|
20
|
+
const sizeMapping = [
|
|
21
|
+
{
|
|
22
|
+
viewport: [970, 250],
|
|
23
|
+
sizes: [[970, 250], [970, 528]]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
viewport: [320, 100],
|
|
27
|
+
sizes: [[320, 100]]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
viewport: [728, 90],
|
|
31
|
+
sizes: [[320, 100]]
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const defaultProps = {
|
|
36
|
+
shouldShowBanner: true,
|
|
37
|
+
sizeMapping,
|
|
38
|
+
sizeId: 'sizeId',
|
|
39
|
+
parsedAdunit: 'unit-name',
|
|
40
|
+
parsedSizes: [],
|
|
41
|
+
targetingArguments: {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
describe('Banner render component', () => {
|
|
45
|
+
it('should not render AdSlot if shouldShowBanner=false but should render styles and wrapper', () => {
|
|
46
|
+
const { asFragment, container, getByTestId } = render(
|
|
47
|
+
<AdSlotRender {...defaultProps} shouldShowBanner={false} />
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(container.childNodes[0].nodeName).toEqual('STYLE');
|
|
51
|
+
expect(container.childNodes[1]).toHaveClass('ad-slot ad-slot-loading banner-sizeId');
|
|
52
|
+
expect(() => getByTestId(slotTestId)).toThrow();
|
|
53
|
+
expect(asFragment()).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('AdSlot loading', () => {
|
|
57
|
+
it('should render AdSlot', () => {
|
|
58
|
+
const { asFragment, container, getByTestId } = render(<AdSlotRender {...defaultProps} />);
|
|
59
|
+
expect(getByTestId('adslot-test')).toBeDefined();
|
|
60
|
+
expect(container.childNodes[1]).toHaveClass('ad-slot ad-slot-loading banner-sizeId');
|
|
61
|
+
expect(asFragment()).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should change class and remove styles after loaded events', async () => {
|
|
65
|
+
const { asFragment, container, getByTestId } = render(<AdSlotRender {...defaultProps} />);
|
|
66
|
+
const adSlot = getByTestId(slotTestId);
|
|
67
|
+
|
|
68
|
+
fireEvent.mouseOver(adSlot);
|
|
69
|
+
await waitFor(() =>
|
|
70
|
+
expect(container.childNodes[0]).toHaveClass('ad-slot ad-slot-loaded banner-sizeId')
|
|
71
|
+
);
|
|
72
|
+
expect(asFragment()).toMatchSnapshot();
|
|
73
|
+
|
|
74
|
+
fireEvent.mouseLeave(adSlot);
|
|
75
|
+
await waitFor(() =>
|
|
76
|
+
expect(container.childNodes[0]).toHaveClass('ad-slot ad-slot-empty banner-sizeId')
|
|
77
|
+
);
|
|
78
|
+
expect(asFragment()).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -2,7 +2,8 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
2
2
|
import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
3
3
|
import Banner from '../../../../../src/components/Banner/Banner';
|
|
4
4
|
|
|
5
|
-
jest.mock('@apollo/
|
|
5
|
+
jest.mock('@apollo/client', () => ({
|
|
6
|
+
...jest.requireActual('@apollo/client'),
|
|
6
7
|
useQuery: jest.fn(({ data, loading, error }) => ({ data, loading, error }))
|
|
7
8
|
}));
|
|
8
9
|
jest.mock('next/router', () => ({
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import BannerRender from '../../../../../src/components/Banner/BannerRender';
|
|
6
|
+
import { getAction, generateSingleItemQuery, getCount } from '../../../../../src/application/query';
|
|
7
|
+
import {
|
|
8
|
+
BANNER_QUERY_PROPS,
|
|
9
|
+
COUNT_CONTENT_HIERARCHIES,
|
|
10
|
+
GET_BANNER,
|
|
11
|
+
PUBLISHED
|
|
12
|
+
} from '../../../../../src/constants';
|
|
13
|
+
|
|
14
|
+
const actionKey = 'getPublishedPage';
|
|
15
|
+
const id = 'record id';
|
|
16
|
+
const action = getAction(actionKey, 'id, name');
|
|
17
|
+
const getEntityDataMock = {
|
|
18
|
+
request: {
|
|
19
|
+
query: action,
|
|
20
|
+
variables: {
|
|
21
|
+
id
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
result: {
|
|
25
|
+
data: {
|
|
26
|
+
[actionKey]: {
|
|
27
|
+
id,
|
|
28
|
+
name: 'record name'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const sizeId = 'sizeId';
|
|
35
|
+
const sizes = [
|
|
36
|
+
{
|
|
37
|
+
width: 320,
|
|
38
|
+
height: 100,
|
|
39
|
+
viewports: [
|
|
40
|
+
{
|
|
41
|
+
width: 320,
|
|
42
|
+
height: 100
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
const getBannerMock = {
|
|
48
|
+
request: {
|
|
49
|
+
query: generateSingleItemQuery(GET_BANNER, BANNER_QUERY_PROPS),
|
|
50
|
+
variables: { id: sizeId },
|
|
51
|
+
skip: false
|
|
52
|
+
},
|
|
53
|
+
result: {
|
|
54
|
+
data: {
|
|
55
|
+
entityData: {
|
|
56
|
+
sizes,
|
|
57
|
+
id,
|
|
58
|
+
__typename: 'Banner'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const getCountMock = {
|
|
65
|
+
request: {
|
|
66
|
+
query: getCount(COUNT_CONTENT_HIERARCHIES),
|
|
67
|
+
variables: {
|
|
68
|
+
where: {
|
|
69
|
+
parentId: id,
|
|
70
|
+
childEntity: {
|
|
71
|
+
_ilike: `${PUBLISHED}_%`
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
result: {
|
|
77
|
+
data: {
|
|
78
|
+
entityData: {
|
|
79
|
+
sizes,
|
|
80
|
+
id,
|
|
81
|
+
__typename: 'Banner'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const mocks = [getEntityDataMock, getBannerMock, getCountMock];
|
|
88
|
+
|
|
89
|
+
const otherProps = { id };
|
|
90
|
+
const defaultProps = {
|
|
91
|
+
parent: {},
|
|
92
|
+
asPath: 'path',
|
|
93
|
+
action,
|
|
94
|
+
actionKey,
|
|
95
|
+
adunit: '',
|
|
96
|
+
baseAdunit: '',
|
|
97
|
+
sizeId,
|
|
98
|
+
propsToDisplay: [],
|
|
99
|
+
entity: '',
|
|
100
|
+
targetings: '',
|
|
101
|
+
sizes: '',
|
|
102
|
+
cardBannerIndex: null,
|
|
103
|
+
...otherProps
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const setup = (props = defaultProps) =>
|
|
107
|
+
render(
|
|
108
|
+
<MockedProvider mocks={mocks}>
|
|
109
|
+
<BannerRender {...props} />
|
|
110
|
+
</MockedProvider>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
describe('Banner render component', () => {
|
|
114
|
+
it('should render', () => {
|
|
115
|
+
const { asFragment } = setup();
|
|
116
|
+
|
|
117
|
+
expect(asFragment()).toMatchSnapshot();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Banner render component AdSlot loading should change class and remove styles after loaded events 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="ad-slot ad-slot-loaded banner-sizeId"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
data-testid="adslot-test"
|
|
10
|
+
role="button"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
</DocumentFragment>
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports[`Banner render component AdSlot loading should change class and remove styles after loaded events 2`] = `
|
|
17
|
+
<DocumentFragment>
|
|
18
|
+
<div
|
|
19
|
+
class="ad-slot ad-slot-empty banner-sizeId"
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
data-testid="adslot-test"
|
|
23
|
+
role="button"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
</DocumentFragment>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`Banner render component AdSlot loading should render AdSlot 1`] = `
|
|
30
|
+
<DocumentFragment>
|
|
31
|
+
<style>
|
|
32
|
+
@media(min-width:320px){.banner-sizeId{min-height:100px;}@media(min-width:728px){.banner-sizeId{min-height:100px;}@media(min-width:970px){.banner-sizeId{min-height:250px;}
|
|
33
|
+
</style>
|
|
34
|
+
<div
|
|
35
|
+
class="ad-slot ad-slot-loading banner-sizeId"
|
|
36
|
+
>
|
|
37
|
+
<div
|
|
38
|
+
data-testid="adslot-test"
|
|
39
|
+
role="button"
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
</DocumentFragment>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Banner render component should not render AdSlot if shouldShowBanner=false but should render styles and wrapper 1`] = `
|
|
46
|
+
<DocumentFragment>
|
|
47
|
+
<style>
|
|
48
|
+
@media(min-width:320px){.banner-sizeId{min-height:100px;}@media(min-width:728px){.banner-sizeId{min-height:100px;}@media(min-width:970px){.banner-sizeId{min-height:250px;}
|
|
49
|
+
</style>
|
|
50
|
+
<div
|
|
51
|
+
class="ad-slot ad-slot-loading banner-sizeId"
|
|
52
|
+
/>
|
|
53
|
+
</DocumentFragment>
|
|
54
|
+
`;
|
|
@@ -3,7 +3,8 @@ import { act, render } from '@testing-library/react';
|
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import Button from '../../../../src/components/Button';
|
|
5
5
|
|
|
6
|
-
jest.mock('
|
|
6
|
+
jest.mock('@apollo/client', () => ({
|
|
7
|
+
...jest.requireActual('@apollo/client'),
|
|
7
8
|
useApolloClient: jest.fn(() => ({ resetStore: () => null }))
|
|
8
9
|
}));
|
|
9
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
-
import { MockedProvider } from '@apollo/
|
|
3
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
4
4
|
import { render, act } from '@testing-library/react';
|
|
5
5
|
import {
|
|
6
6
|
CARD_RENDER_ENTITY_DATA_MOCK,
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
exports[`CardContainer component should render with carousel if option is enabled 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="
|
|
6
|
+
class="cards-carousel"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
|
-
class="
|
|
9
|
+
class="cards-carousel--left-button-wrapper"
|
|
10
10
|
/>
|
|
11
11
|
<div
|
|
12
|
-
class="
|
|
12
|
+
class="cards-carousel--right-button-wrapper"
|
|
13
13
|
/>
|
|
14
14
|
<div
|
|
15
|
-
class="
|
|
15
|
+
class="cards-carousel--content items-per-row-1"
|
|
16
16
|
>
|
|
17
17
|
<div
|
|
18
18
|
class="card card--portrait"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
-
import { MockedProvider } from '@apollo/
|
|
3
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
4
4
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
5
|
import { getFileById } from '../../../../../src/application/query';
|
|
6
6
|
import Carousel from '../../../../../src/components/Carousel';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
2
2
|
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
-
import { useQuery } from '@apollo/
|
|
3
|
+
import { useQuery } from '@apollo/client';
|
|
4
4
|
import { DATA_SUMMARY_MOCK } from '../../../../helpers/mocks';
|
|
5
5
|
|
|
6
6
|
import DataSummaryFactory from '../../../../../src/components/DataSummary/DataSummaryFactory';
|
|
7
7
|
|
|
8
|
-
jest.mock('@apollo/
|
|
8
|
+
jest.mock('@apollo/client', () => ({
|
|
9
|
+
...jest.requireActual('@apollo/client'),
|
|
9
10
|
useQuery: jest.fn()
|
|
10
11
|
}));
|
|
11
12
|
|
|
@@ -3,7 +3,8 @@ import { render, act } from '@testing-library/react';
|
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import EmailConfirm from '../../../../../src/components/EmailConfirm';
|
|
5
5
|
|
|
6
|
-
jest.mock('
|
|
6
|
+
jest.mock('@apollo/client', () => ({
|
|
7
|
+
...jest.requireActual('@apollo/client'),
|
|
7
8
|
useMutation: jest.fn(() => [variables => variables, { loading: false }])
|
|
8
9
|
}));
|
|
9
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
-
import { MockedProvider } from '@apollo/
|
|
3
|
-
import { render, act, screen } from '@testing-library/react';
|
|
2
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
3
|
+
import { render, act, screen, waitFor } from '@testing-library/react';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { Router } from 'react-router-dom';
|
|
6
6
|
import { createMemoryHistory } from 'history';
|
|
@@ -10,6 +10,7 @@ import LIGHTBOX_MOCKS from './mocks';
|
|
|
10
10
|
|
|
11
11
|
const [MOCK_WITH_DATA, MOCK_WITH_ERROR] = LIGHTBOX_MOCKS;
|
|
12
12
|
|
|
13
|
+
const testId = 'globalLightboxImage';
|
|
13
14
|
const credits = 'credits test';
|
|
14
15
|
|
|
15
16
|
const mockProps = {
|
|
@@ -65,21 +66,24 @@ describe('GlobalLightbox component', () => {
|
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
it('should match snapshot', async () => {
|
|
68
|
-
const { asFragment } = await setupTest();
|
|
69
|
+
const { asFragment, getByTestId } = await setupTest();
|
|
70
|
+
await waitFor(() => getByTestId(testId));
|
|
69
71
|
expect(asFragment()).toMatchSnapshot();
|
|
70
72
|
});
|
|
71
73
|
|
|
72
74
|
it('should not render caption if image does not have it', async () => {
|
|
73
75
|
const { getByTestId } = await setupTest();
|
|
74
|
-
|
|
76
|
+
await waitFor(() => getByTestId(testId));
|
|
77
|
+
const image = await getByTestId(testId);
|
|
75
78
|
expect(image).toHaveAttribute('alt', '');
|
|
76
79
|
});
|
|
77
80
|
|
|
78
81
|
it('should return error message if error', async () => {
|
|
79
82
|
const props = getMockedLightboxProps({ images: [{ imageId: 'error' }] });
|
|
80
83
|
const componentMock = await setup(props, MOCK_WITH_ERROR);
|
|
81
|
-
const { container } = await renderComponent(componentMock);
|
|
82
|
-
|
|
84
|
+
const { container, getByText } = await renderComponent(componentMock);
|
|
85
|
+
await waitFor(() => getByText('this is an error'));
|
|
86
|
+
expect(container.innerHTML).toContain('this is an error');
|
|
83
87
|
});
|
|
84
88
|
|
|
85
89
|
it('should render ImageDetails if shouldDisplayCredits & shouldDisplayCaptions are true', async () => {
|
|
@@ -3,14 +3,14 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
3
3
|
import { render, act, waitFor } from '@testing-library/react';
|
|
4
4
|
import { MockedRoot } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
5
5
|
import ImageFactory from '../../../../../src/components/Image/ImageFactory';
|
|
6
|
-
import { MOCK_BASIC, MOCK_NO_URL, MOCK_WITH_ERR } from './mocks';
|
|
6
|
+
import { MOCK_BASIC, MOCK_NO_URL, MOCK_WITH_ERR, MOCK_RELATION } from './mocks';
|
|
7
7
|
|
|
8
8
|
jest.mock('@blaze-react/utils/lib/customHooks', () => ({
|
|
9
9
|
useInView: jest.fn(() => [true, null])
|
|
10
10
|
}));
|
|
11
11
|
|
|
12
12
|
const setup = async (props, mocks) => (
|
|
13
|
-
<MockedRoot mocks={mocks}
|
|
13
|
+
<MockedRoot mocks={mocks}>
|
|
14
14
|
<ImageFactory {...props} />
|
|
15
15
|
</MockedRoot>
|
|
16
16
|
);
|
|
@@ -30,14 +30,14 @@ const renderComponent = async component => {
|
|
|
30
30
|
const setupTest = async (props = {}, mocks = {}) => {
|
|
31
31
|
const mockProps = {
|
|
32
32
|
parent: {
|
|
33
|
+
itemId: 'parentId',
|
|
33
34
|
getAction: 'getPublishedPage'
|
|
34
35
|
},
|
|
35
36
|
imageId: 'test-id',
|
|
36
37
|
url: 'www.url-test-prop.com',
|
|
37
38
|
style: {},
|
|
38
39
|
enableLightbox: false,
|
|
39
|
-
imageRelation: ['publishedPage.
|
|
40
|
-
|
|
40
|
+
imageRelation: ['publishedPage.otherImageIds'],
|
|
41
41
|
...props
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -65,23 +65,19 @@ describe('ImageFactory component', () => {
|
|
|
65
65
|
it('should render image', async () => {
|
|
66
66
|
const { asFragment } = await setupTest({}, MOCK_BASIC);
|
|
67
67
|
|
|
68
|
-
await waitFor(() =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
expect(asFragment()).toMatchSnapshot();
|
|
72
|
-
}, options);
|
|
68
|
+
await waitFor(() => expect(asFragment()).toBeDefined(), options);
|
|
69
|
+
expect(asFragment()).toMatchSnapshot();
|
|
73
70
|
});
|
|
74
71
|
|
|
75
72
|
it('should render image fetching data from relation', async () => {
|
|
76
|
-
// todo: extend to fully test relation
|
|
77
73
|
const entity = 'page';
|
|
78
|
-
const { asFragment } = await setupTest(
|
|
74
|
+
const { asFragment, container } = await setupTest(
|
|
79
75
|
{ imageId: null, entity, fetchFromRelation: true },
|
|
80
|
-
|
|
76
|
+
MOCK_RELATION
|
|
81
77
|
);
|
|
82
78
|
|
|
83
79
|
await waitFor(() => {
|
|
84
|
-
expect(
|
|
80
|
+
expect(container.childNodes.length).toBeGreaterThan(1);
|
|
85
81
|
});
|
|
86
82
|
expect(asFragment()).toMatchSnapshot();
|
|
87
83
|
});
|
|
@@ -97,12 +93,8 @@ describe('ImageFactory component', () => {
|
|
|
97
93
|
});
|
|
98
94
|
|
|
99
95
|
it('should return error message if error', async () => {
|
|
100
|
-
const { container } = await setupTest({ imageId: '
|
|
101
|
-
|
|
102
|
-
await waitFor(() => {
|
|
103
|
-
expect(container).toBeDefined();
|
|
104
|
-
});
|
|
96
|
+
const { container } = await setupTest({ imageId: 'error' }, MOCK_WITH_ERR);
|
|
105
97
|
|
|
106
|
-
expect(container.innerHTML).toContain('error');
|
|
98
|
+
await waitFor(() => expect(container.innerHTML).toContain('error'));
|
|
107
99
|
});
|
|
108
100
|
});
|
|
@@ -20,4 +20,37 @@ exports[`ImageFactory component should render image 1`] = `
|
|
|
20
20
|
</DocumentFragment>
|
|
21
21
|
`;
|
|
22
22
|
|
|
23
|
-
exports[`ImageFactory component should render image fetching data from relation 1`] =
|
|
23
|
+
exports[`ImageFactory component should render image fetching data from relation 1`] = `
|
|
24
|
+
<DocumentFragment>
|
|
25
|
+
<div
|
|
26
|
+
class="image "
|
|
27
|
+
>
|
|
28
|
+
<a
|
|
29
|
+
class="image__wrapper"
|
|
30
|
+
href="http://www.url-test-prop.com"
|
|
31
|
+
rel="noopener nofollow"
|
|
32
|
+
target="_blank"
|
|
33
|
+
>
|
|
34
|
+
<img
|
|
35
|
+
alt=""
|
|
36
|
+
src="test-url"
|
|
37
|
+
/>
|
|
38
|
+
</a>
|
|
39
|
+
</div>
|
|
40
|
+
<div
|
|
41
|
+
class="image "
|
|
42
|
+
>
|
|
43
|
+
<a
|
|
44
|
+
class="image__wrapper"
|
|
45
|
+
href="http://www.url-test-prop.com"
|
|
46
|
+
rel="noopener nofollow"
|
|
47
|
+
target="_blank"
|
|
48
|
+
>
|
|
49
|
+
<img
|
|
50
|
+
alt=""
|
|
51
|
+
src="test-url-2"
|
|
52
|
+
/>
|
|
53
|
+
</a>
|
|
54
|
+
</div>
|
|
55
|
+
</DocumentFragment>
|
|
56
|
+
`;
|