@blaze-cms/react-page-builder 0.146.0-node18-core-styles-tooltips.38 → 0.146.0-node18-tooltips.33
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 +44 -90
- package/lib/BannerContext/index.js +2 -1
- package/lib/BannerContext/index.js.map +1 -1
- package/lib/HOC/withInfiniteScroll.js +2 -1
- package/lib/HOC/withInfiniteScroll.js.map +1 -1
- package/lib/HOC/withTitle.js +2 -1
- package/lib/HOC/withTitle.js.map +1 -1
- package/lib/application/query/index.js +8 -8
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/BackToTop/BackToTop.js +2 -1
- package/lib/components/BackToTop/BackToTop.js.map +1 -1
- package/lib/components/Banner/AdSlotRender.js +2 -1
- package/lib/components/Banner/AdSlotRender.js.map +1 -1
- package/lib/components/Banner/Banner.js +2 -1
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Banner/index.js +2 -1
- package/lib/components/Banner/index.js.map +1 -1
- package/lib/components/BlazeLink.js +2 -1
- package/lib/components/BlazeLink.js.map +1 -1
- package/lib/components/Breadcrumb/Breadcrumb.js +2 -1
- package/lib/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/lib/components/Button.js +2 -1
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/Card.js +2 -1
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Card/CardsContainer.js +2 -1
- package/lib/components/Card/CardsContainer.js.map +1 -1
- package/lib/components/Card/CardsRender.js +2 -1
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/Carousel/Carousel.js +44 -7
- package/lib/components/Carousel/Carousel.js.map +1 -1
- package/lib/components/Carousel/CarouselImage/CarouselImage.js +2 -1
- package/lib/components/Carousel/CarouselImage/CarouselImage.js.map +1 -1
- package/lib/components/CarouselWrapper/DefaultCarousel.js +2 -1
- package/lib/components/CarouselWrapper/DefaultCarousel.js.map +1 -1
- package/lib/components/ClickWrapper.js +2 -1
- package/lib/components/ClickWrapper.js.map +1 -1
- package/lib/components/Code/Code.js +2 -1
- package/lib/components/Code/Code.js.map +1 -1
- package/lib/components/Code/ScriptTag.js +2 -1
- package/lib/components/Code/ScriptTag.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroup.js +2 -1
- package/lib/components/ContentGroup/ContentGroup.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroupAccordion.js +2 -1
- package/lib/components/ContentGroup/ContentGroupAccordion.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroupTabs.js +2 -1
- package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryFactory.js +2 -1
- package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/HeadingLargeSummary/HeadingLargeSummaryContent.js +2 -1
- package/lib/components/DataSummary/DataSummaryTypes/HeadingLargeSummary/HeadingLargeSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js +2 -1
- package/lib/components/DataSummary/DataSummaryTypes/ItemDetailsSummary/ItemDetailsSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/LargeSummary/LargeSummaryContent.js +2 -1
- package/lib/components/DataSummary/DataSummaryTypes/LargeSummary/LargeSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/ListSummary/ListSummaryContent.js +2 -1
- package/lib/components/DataSummary/DataSummaryTypes/ListSummary/ListSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/TextSummary/TextSummaryContent.js +2 -1
- package/lib/components/DataSummary/DataSummaryTypes/TextSummary/TextSummaryContent.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryTypes/index.js +2 -1
- package/lib/components/DataSummary/DataSummaryTypes/index.js.map +1 -1
- package/lib/components/EmailConfirm/EmailConfirm.js +2 -1
- package/lib/components/EmailConfirm/EmailConfirm.js.map +1 -1
- package/lib/components/ErrorMessage/index.js +2 -1
- package/lib/components/ErrorMessage/index.js.map +1 -1
- package/lib/components/Image/GlobalLightbox/GlobalLightbox.js +2 -1
- package/lib/components/Image/GlobalLightbox/GlobalLightbox.js.map +1 -1
- package/lib/components/Image/GlobalLightbox/index.js +2 -1
- package/lib/components/Image/GlobalLightbox/index.js.map +1 -1
- package/lib/components/Image/Image.js +2 -1
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/Image/ImageFactory.js +2 -1
- package/lib/components/Image/ImageFactory.js.map +1 -1
- package/lib/components/Image/Lightbox/Lightbox.js +2 -1
- package/lib/components/Image/Lightbox/Lightbox.js.map +1 -1
- package/lib/components/ItemList/ItemListButton/ItemListButton.js +2 -1
- package/lib/components/ItemList/ItemListButton/ItemListButton.js.map +1 -1
- package/lib/components/Layout/LayoutFactory.js +2 -1
- package/lib/components/Layout/LayoutFactory.js.map +1 -1
- package/lib/components/Layout/LayoutWithStickyTimer.js +2 -1
- package/lib/components/Layout/LayoutWithStickyTimer.js.map +1 -1
- package/lib/components/LazyImage/index.js +2 -1
- package/lib/components/LazyImage/index.js.map +1 -1
- package/lib/components/List/ListFactory.js +2 -1
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/ListRender.js +2 -1
- package/lib/components/List/ListRender.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRender.js +2 -1
- package/lib/components/List/components/Cards/CardsRender.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRenderWrapper.js +2 -1
- package/lib/components/List/components/Cards/CardsRenderWrapper.js.map +1 -1
- package/lib/components/List/components/Full/FullRender.js +2 -1
- package/lib/components/List/components/Full/FullRender.js.map +1 -1
- package/lib/components/List/components/Full/FullRenderItem.js +2 -1
- package/lib/components/List/components/Full/FullRenderItem.js.map +1 -1
- package/lib/components/List/components/Pagination/ListPagination.js +2 -1
- package/lib/components/List/components/Pagination/ListPagination.js.map +1 -1
- package/lib/components/Loading/index.js +2 -1
- package/lib/components/Loading/index.js.map +1 -1
- package/lib/components/Menu/Menu.js +3 -5
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/MenuContext.js +1 -2
- package/lib/components/Menu/MenuContext.js.map +1 -1
- package/lib/components/MenuItem/MenuItemRender.js +14 -28
- package/lib/components/MenuItem/MenuItemRender.js.map +1 -1
- package/lib/components/MenuItem/helpers/index.js +0 -14
- package/lib/components/MenuItem/helpers/index.js.map +1 -1
- package/lib/components/ModalAdapter/index.js +2 -1
- package/lib/components/ModalAdapter/index.js.map +1 -1
- package/lib/components/SearchContent/SearchContent.js +6 -3
- package/lib/components/SearchContent/SearchContent.js.map +1 -1
- package/lib/components/SearchContent/SearchContentResults.js +2 -1
- package/lib/components/SearchContent/SearchContentResults.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/FiltersList.js +2 -1
- package/lib/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +2 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +2 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/components/Checkbox.js +2 -1
- package/lib/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib/components/Video/VideoModal.js +2 -1
- package/lib/components/Video/VideoModal.js.map +1 -1
- package/lib/components/Video/VideoRender.js +2 -1
- package/lib/components/Video/VideoRender.js.map +1 -1
- package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js +2 -1
- package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js.map +1 -1
- package/lib/components/Video/providers/Vimeo/VimeoProvider.js +2 -1
- package/lib/components/Video/providers/Vimeo/VimeoProvider.js.map +1 -1
- package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js +2 -1
- package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js.map +1 -1
- package/lib/components/Video/providers/get-provider.js +2 -1
- package/lib/components/Video/providers/get-provider.js.map +1 -1
- package/lib/components/index.js +2 -1
- package/lib/components/index.js.map +1 -1
- package/lib/helpers/parse-TextBlock.js +2 -1
- package/lib/helpers/parse-TextBlock.js.map +1 -1
- package/lib/helpers/parse-props-to-display.js +2 -1
- package/lib/helpers/parse-props-to-display.js.map +1 -1
- package/lib/hooks/use-get-image-id-from-relation.js +4 -3
- package/lib/hooks/use-get-image-id-from-relation.js.map +1 -1
- package/lib/hooks/use-portal.js +2 -1
- package/lib/hooks/use-portal.js.map +1 -1
- package/lib/system-components/EditorMode/BlazeLogo.js +2 -1
- package/lib/system-components/EditorMode/BlazeLogo.js.map +1 -1
- package/lib/system-components/EditorMode/PbWrapper.js +2 -1
- package/lib/system-components/EditorMode/PbWrapper.js.map +1 -1
- package/lib/system-components/index.js +2 -1
- package/lib/system-components/index.js.map +1 -1
- package/lib/variants/Infographic/index.js +2 -1
- package/lib/variants/Infographic/index.js.map +1 -1
- package/lib/variants/LiveBlogList/LiveBlogList.js +2 -1
- package/lib/variants/LiveBlogList/LiveBlogList.js.map +1 -1
- package/lib/variants/LiveBlogList/index.js +2 -1
- package/lib/variants/LiveBlogList/index.js.map +1 -1
- package/lib/variants/LongformGallery/index.js +2 -1
- package/lib/variants/LongformGallery/index.js.map +1 -1
- package/lib/variants/SlideSummary/index.js +2 -1
- package/lib/variants/SlideSummary/index.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/index.js +2 -1
- package/lib/variants/ThumbnailCarousel/index.js.map +1 -1
- package/lib-es/components/Carousel/Carousel.js +39 -9
- package/lib-es/components/Carousel/Carousel.js.map +1 -1
- package/lib-es/components/Carousel/CarouselImage/CarouselImage.js +2 -1
- package/lib-es/components/Carousel/CarouselImage/CarouselImage.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +1 -4
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/Menu/MenuContext.js +1 -2
- package/lib-es/components/Menu/MenuContext.js.map +1 -1
- package/lib-es/components/MenuItem/MenuItemRender.js +11 -25
- package/lib-es/components/MenuItem/MenuItemRender.js.map +1 -1
- package/lib-es/components/MenuItem/helpers/index.js +1 -3
- package/lib-es/components/MenuItem/helpers/index.js.map +1 -1
- package/lib-es/components/SearchContent/SearchContent.js +8 -2
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -1
- package/lib-es/components/SearchContent/SearchContentResults.js +2 -1
- package/lib-es/components/SearchContent/SearchContentResults.js.map +1 -1
- package/lib-es/hooks/use-get-image-id-from-relation.js +2 -2
- package/lib-es/hooks/use-get-image-id-from-relation.js.map +1 -1
- package/package.json +10 -10
- package/src/components/Carousel/Carousel.js +46 -9
- package/src/components/Carousel/CarouselImage/CarouselImage.js +3 -1
- package/src/components/Menu/Menu.js +1 -3
- package/src/components/Menu/MenuContext.js +1 -1
- package/src/components/MenuItem/MenuItemRender.js +12 -40
- package/src/components/MenuItem/helpers/index.js +1 -3
- package/src/components/SearchContent/SearchContent.js +8 -2
- package/src/components/SearchContent/SearchContentResults.js +1 -1
- package/src/hooks/use-get-image-id-from-relation.js +2 -1
- package/tests/unit/src/components/Carousel/Carousel.test.js +45 -35
- package/tests/unit/src/components/Carousel/__snapshots__/Carousel.test.js.snap +49 -8
- package/tests/unit/src/components/MenuItem/MenuItem.test.js +0 -5
- package/tests/unit/src/components/MenuItem/MenuItemRender.test.js +3 -11
- package/tests/unit/src/components/SearchContent/SearchContent.test.js +32 -1
- package/lib/components/MenuItem/helpers/has-active-child.js +0 -19
- package/lib/components/MenuItem/helpers/has-active-child.js.map +0 -1
- package/lib/components/MenuItem/helpers/isUrlPathMatch.js +0 -18
- package/lib/components/MenuItem/helpers/isUrlPathMatch.js.map +0 -1
- package/lib-es/components/MenuItem/helpers/has-active-child.js +0 -5
- package/lib-es/components/MenuItem/helpers/has-active-child.js.map +0 -1
- package/lib-es/components/MenuItem/helpers/isUrlPathMatch.js +0 -8
- package/lib-es/components/MenuItem/helpers/isUrlPathMatch.js.map +0 -1
- package/src/components/MenuItem/helpers/has-active-child.js +0 -10
- package/src/components/MenuItem/helpers/isUrlPathMatch.js +0 -10
- package/tests/unit/src/components/MenuItem/helpers/constants.js +0 -73
- package/tests/unit/src/components/MenuItem/helpers/has-active-child.test.js +0 -35
- package/tests/unit/src/components/MenuItem/helpers/is-url-path-match.test.js +0 -53
|
@@ -4,28 +4,35 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import '@testing-library/jest-dom/extend-expect';
|
|
6
6
|
import { MockedProvider } from '@apollo/client/testing';
|
|
7
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
7
|
+
import { render, screen, act, waitFor } from '@testing-library/react';
|
|
8
|
+
import { MockedRoot } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
8
9
|
import { getFileById } from '../../../../../src/application/query';
|
|
9
10
|
import Carousel from '../../../../../src/components/Carousel';
|
|
11
|
+
import { MOCK_RELATION } from '../Image/mocks';
|
|
10
12
|
|
|
11
13
|
const imageId = 'test-id';
|
|
12
|
-
const getMockedProps = overrides => ({
|
|
14
|
+
const getMockedProps = (overrides = {}) => ({
|
|
13
15
|
imageIds: [imageId],
|
|
14
16
|
enableLightbox: true,
|
|
15
17
|
imageId,
|
|
16
18
|
toggleModal: jest.fn(),
|
|
17
19
|
handleSelectedImage: jest.fn(),
|
|
18
20
|
displayCount: true,
|
|
21
|
+
entity: 'page',
|
|
22
|
+
imagesProperty: ['publishedPage.otherImageIds'],
|
|
23
|
+
parent: {
|
|
24
|
+
itemId: 'parentId',
|
|
25
|
+
getAction: 'getPublishedPage',
|
|
26
|
+
itemEntity: 'page'
|
|
27
|
+
},
|
|
19
28
|
...overrides
|
|
20
29
|
});
|
|
21
30
|
|
|
22
|
-
const
|
|
31
|
+
const mocks = [
|
|
23
32
|
{
|
|
24
33
|
request: {
|
|
25
34
|
query: getFileById,
|
|
26
|
-
variables: {
|
|
27
|
-
id: imageId
|
|
28
|
-
}
|
|
35
|
+
variables: { id: imageId }
|
|
29
36
|
},
|
|
30
37
|
result: {
|
|
31
38
|
data: {
|
|
@@ -42,73 +49,76 @@ const mock = [
|
|
|
42
49
|
}
|
|
43
50
|
];
|
|
44
51
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const mockComponent = (
|
|
49
|
-
<MockedProvider mocks={mock}>
|
|
52
|
+
const setup = props =>
|
|
53
|
+
render(
|
|
54
|
+
<MockedProvider mocks={mocks}>
|
|
50
55
|
<Carousel {...props} />
|
|
51
56
|
</MockedProvider>
|
|
52
57
|
);
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
const setupWithRoot = async (props, mockOverrides) => {
|
|
60
|
+
const component = (
|
|
61
|
+
<MockedRoot mocks={mockOverrides}>
|
|
62
|
+
<Carousel {...props} />
|
|
63
|
+
</MockedRoot>
|
|
64
|
+
);
|
|
65
|
+
let renderResults;
|
|
66
|
+
await act(async () => {
|
|
67
|
+
renderResults = render(component);
|
|
68
|
+
});
|
|
69
|
+
return renderResults;
|
|
55
70
|
};
|
|
56
71
|
|
|
57
72
|
describe('Carousel component', () => {
|
|
58
73
|
it('should render loading state initially', async () => {
|
|
59
|
-
const { container } =
|
|
60
|
-
|
|
74
|
+
const { container } = setup(getMockedProps());
|
|
61
75
|
expect(container.innerHTML).toContain('carousel');
|
|
62
76
|
});
|
|
63
77
|
|
|
64
78
|
it('should render carousel and match snapshot', async () => {
|
|
65
|
-
const { asFragment } =
|
|
66
|
-
|
|
67
|
-
await waitFor(() => expect(asFragment()).toBeDefined());
|
|
68
|
-
|
|
79
|
+
const { asFragment } = setup(getMockedProps());
|
|
69
80
|
await waitFor(() => expect(asFragment()).toMatchSnapshot());
|
|
70
81
|
});
|
|
71
82
|
|
|
72
83
|
it('should render priority images and match snapshot', async () => {
|
|
73
|
-
const { asFragment, getAllByRole } =
|
|
74
|
-
|
|
75
|
-
await waitFor(() => expect(asFragment()).toBeDefined());
|
|
76
|
-
|
|
84
|
+
const { asFragment, getAllByRole } = setup(getMockedProps({ priorityLimit: 1 }));
|
|
77
85
|
await waitFor(() => expect(asFragment()).toMatchSnapshot());
|
|
78
|
-
expect(getAllByRole('button')
|
|
86
|
+
expect(getAllByRole('button')).toHaveLength(3);
|
|
79
87
|
});
|
|
80
88
|
|
|
81
89
|
it('should return null if there are no imageIds', () => {
|
|
82
|
-
const
|
|
83
|
-
const { container } = setup(mockedProps);
|
|
84
|
-
|
|
90
|
+
const { container } = setup(getMockedProps({ imageIds: [] }));
|
|
85
91
|
expect(container.innerHTML).toBe('');
|
|
86
92
|
});
|
|
87
93
|
|
|
94
|
+
it('should render image fetching data from relation', async () => {
|
|
95
|
+
const { asFragment, container } = await setupWithRoot(getMockedProps({ imageIds: [] }), [
|
|
96
|
+
...MOCK_RELATION,
|
|
97
|
+
...mocks
|
|
98
|
+
]);
|
|
99
|
+
await waitFor(() => expect(container.childNodes.length).toBeGreaterThan(1));
|
|
100
|
+
expect(asFragment()).toMatchSnapshot();
|
|
101
|
+
});
|
|
102
|
+
|
|
88
103
|
it('should display caption if shouldDisplayCaption is true', () => {
|
|
89
104
|
const caption = 'caption test';
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
setup(mockedProps);
|
|
105
|
+
setup(getMockedProps({ isCaptionDisplayed: true, caption }));
|
|
93
106
|
expect(screen.getByText(caption)).toBeInTheDocument();
|
|
94
107
|
});
|
|
95
108
|
|
|
96
109
|
it('should render VariantComponent if it is set', () => {
|
|
97
|
-
const mockedProps = getMockedProps({ VariantComponent:
|
|
110
|
+
const mockedProps = getMockedProps({ VariantComponent: () => <div>Variation component</div> });
|
|
98
111
|
const { container } = setup(mockedProps);
|
|
99
|
-
|
|
100
112
|
expect(container.innerHTML).toBe('<div>Variation component</div>');
|
|
101
113
|
});
|
|
102
114
|
|
|
103
115
|
it('should display image count if displayCount is true', () => {
|
|
104
|
-
|
|
105
|
-
setup(mockedProps);
|
|
116
|
+
setup(getMockedProps({ imageIds: ['id1', 'id2', 'id3'] }));
|
|
106
117
|
expect(screen.getByTestId('count')).toHaveTextContent('3 images');
|
|
107
118
|
});
|
|
108
119
|
|
|
109
120
|
it('should not display image count if displayCount is false', () => {
|
|
110
|
-
|
|
111
|
-
setup(mockedProps);
|
|
121
|
+
setup(getMockedProps({ displayCount: false }));
|
|
112
122
|
expect(screen.queryByTestId('count')).toBeNull();
|
|
113
123
|
});
|
|
114
124
|
});
|
|
@@ -43,6 +43,54 @@ exports[`Carousel component should render carousel and match snapshot 1`] = `
|
|
|
43
43
|
</DocumentFragment>
|
|
44
44
|
`;
|
|
45
45
|
|
|
46
|
+
exports[`Carousel component should render image fetching data from relation 1`] = `
|
|
47
|
+
<DocumentFragment>
|
|
48
|
+
<div
|
|
49
|
+
class="carousel"
|
|
50
|
+
>
|
|
51
|
+
<div>
|
|
52
|
+
<div
|
|
53
|
+
aria-label="Previous Slide"
|
|
54
|
+
class="carousel__button carousel__button--previous"
|
|
55
|
+
role="button"
|
|
56
|
+
>
|
|
57
|
+
<div
|
|
58
|
+
class="arrow arrow--left"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
<div
|
|
62
|
+
class="carousel__list"
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
class="carousel__slide"
|
|
66
|
+
>
|
|
67
|
+
<span />
|
|
68
|
+
</div>
|
|
69
|
+
<div
|
|
70
|
+
class="carousel__slide"
|
|
71
|
+
>
|
|
72
|
+
<span />
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
<div
|
|
76
|
+
aria-label="Next Slide"
|
|
77
|
+
class="carousel__button carousel__button--next"
|
|
78
|
+
role="button"
|
|
79
|
+
>
|
|
80
|
+
<p
|
|
81
|
+
data-testid="count"
|
|
82
|
+
>
|
|
83
|
+
2 images
|
|
84
|
+
</p>
|
|
85
|
+
<div
|
|
86
|
+
class="arrow arrow--right"
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</DocumentFragment>
|
|
92
|
+
`;
|
|
93
|
+
|
|
46
94
|
exports[`Carousel component should render priority images and match snapshot 1`] = `
|
|
47
95
|
<DocumentFragment>
|
|
48
96
|
<div
|
|
@@ -64,14 +112,7 @@ exports[`Carousel component should render priority images and match snapshot 1`]
|
|
|
64
112
|
<div
|
|
65
113
|
class="carousel__slide"
|
|
66
114
|
>
|
|
67
|
-
<span
|
|
68
|
-
<img
|
|
69
|
-
alt="Carousel image"
|
|
70
|
-
aria-label="View Image"
|
|
71
|
-
role="button"
|
|
72
|
-
src="test-url"
|
|
73
|
-
/>
|
|
74
|
-
</span>
|
|
115
|
+
<span />
|
|
75
116
|
</div>
|
|
76
117
|
</div>
|
|
77
118
|
<div
|
|
@@ -19,11 +19,6 @@ jest.mock('next/router', () => ({
|
|
|
19
19
|
useRouter: () => ({ asPath: '/' })
|
|
20
20
|
}));
|
|
21
21
|
|
|
22
|
-
// todo: add extra tests to support this util
|
|
23
|
-
jest.mock('../../../../../src/components/MenuItem/helpers/has-active-child', () =>
|
|
24
|
-
jest.fn(() => false)
|
|
25
|
-
);
|
|
26
|
-
|
|
27
22
|
const componentProps = {
|
|
28
23
|
id: 'id',
|
|
29
24
|
name: 'mock name',
|
|
@@ -11,22 +11,14 @@ const MENU_ITEM_CHILDREN_CLASS = 'menu--item-children';
|
|
|
11
11
|
|
|
12
12
|
let mockAsPathValue = '/';
|
|
13
13
|
|
|
14
|
-
jest.mock('next/router', () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
useRouter: () => router
|
|
18
|
-
};
|
|
19
|
-
});
|
|
14
|
+
jest.mock('next/router', () => ({
|
|
15
|
+
useRouter: () => ({ asPath: mockAsPathValue })
|
|
16
|
+
}));
|
|
20
17
|
|
|
21
18
|
jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
22
19
|
useStringTemplate: jest.fn((parent, [title]) => ({ loading: false, data: [title] }))
|
|
23
20
|
}));
|
|
24
21
|
|
|
25
|
-
// todo: add extra tests to support this util
|
|
26
|
-
jest.mock('../../../../../src/components/MenuItem/helpers/has-active-child', () =>
|
|
27
|
-
jest.fn(() => false)
|
|
28
|
-
);
|
|
29
|
-
|
|
30
22
|
describe('MenuRender component', () => {
|
|
31
23
|
it('renders menu item with link when URL is provided', () => {
|
|
32
24
|
const { getByText } = render(<MenuRender eventType="click" text="Home" url="/home" />);
|
|
@@ -12,8 +12,16 @@ jest.mock('@apollo/client', () => ({
|
|
|
12
12
|
useQuery: jest.fn(() => ({ data: {}, loading: false, error: null }))
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
+
const mockPush = jest.fn();
|
|
16
|
+
const mockOn = jest.fn();
|
|
17
|
+
const mockOff = jest.fn();
|
|
18
|
+
|
|
15
19
|
jest.mock('next/router', () => ({
|
|
16
|
-
useRouter: jest.fn(() => ({
|
|
20
|
+
useRouter: jest.fn(() => ({
|
|
21
|
+
asPath: 'test-url',
|
|
22
|
+
push: mockPush,
|
|
23
|
+
events: { on: mockOn, off: mockOff }
|
|
24
|
+
}))
|
|
17
25
|
}));
|
|
18
26
|
|
|
19
27
|
const SEARCH_INPUT_TEST_ID = 'search-content-input';
|
|
@@ -54,4 +62,27 @@ describe('SearchContent', () => {
|
|
|
54
62
|
fireEvent.click(closeIcon);
|
|
55
63
|
await waitFor(() => expect(queryByTestId(SEARCH_INPUT_TEST_ID)).toBeNull());
|
|
56
64
|
});
|
|
65
|
+
|
|
66
|
+
it('should trigger autosuggest again after navigation and typing', async () => {
|
|
67
|
+
const { getByTestId, queryByTestId } = render(
|
|
68
|
+
<MockedProvider mocks={[]} addTypename={false}>
|
|
69
|
+
<SearchContent entities={entities} />
|
|
70
|
+
</MockedProvider>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const input = getByTestId(SEARCH_INPUT_TEST_ID);
|
|
74
|
+
|
|
75
|
+
fireEvent.change(input, { target: { value: 'novartis' } });
|
|
76
|
+
|
|
77
|
+
await waitFor(() => expect(queryByTestId('search-content-results')).toBeTruthy());
|
|
78
|
+
|
|
79
|
+
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter' });
|
|
80
|
+
|
|
81
|
+
const routeChangeHandler = mockOn.mock.calls[0][1];
|
|
82
|
+
routeChangeHandler();
|
|
83
|
+
|
|
84
|
+
fireEvent.change(input, { target: { value: 'blaze' } });
|
|
85
|
+
|
|
86
|
+
await waitFor(() => expect(queryByTestId('search-content-results')).toBeTruthy());
|
|
87
|
+
});
|
|
57
88
|
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.object.define-property.js");
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
require("core-js/modules/es.array.find.js");
|
|
10
|
-
require("core-js/modules/es.object.to-string.js");
|
|
11
|
-
var _isUrlPathMatch = _interopRequireDefault(require("./isUrlPathMatch"));
|
|
12
|
-
var _helpers = require("../../../helpers");
|
|
13
|
-
var hasActiveChild = function hasActiveChild(path, children) {
|
|
14
|
-
return (0, _helpers.hasChildren)(children) && children.props.children[1][0].props.component.items.find(function (menuItem) {
|
|
15
|
-
return (0, _isUrlPathMatch["default"])(path, menuItem.settings.url);
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
var _default = exports["default"] = hasActiveChild;
|
|
19
|
-
//# sourceMappingURL=has-active-child.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"has-active-child.js","names":["_isUrlPathMatch","_interopRequireDefault","require","_helpers","hasActiveChild","path","children","hasChildren","props","component","items","find","menuItem","isUrlPathMatch","settings","url","_default","exports"],"sources":["../../../../src/components/MenuItem/helpers/has-active-child.js"],"sourcesContent":["import isUrlPathMatch from './isUrlPathMatch';\nimport { hasChildren } from '../../../helpers';\n\nconst hasActiveChild = (path, children) =>\n hasChildren(children) &&\n children.props.children[1][0].props.component.items.find(menuItem =>\n isUrlPathMatch(path, menuItem.settings.url)\n );\n\nexport default hasActiveChild;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAME,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,IAAI,EAAEC,QAAQ;EAAA,OACpC,IAAAC,oBAAW,EAACD,QAAQ,CAAC,IACrBA,QAAQ,CAACE,KAAK,CAACF,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACE,KAAK,CAACC,SAAS,CAACC,KAAK,CAACC,IAAI,CAAC,UAAAC,QAAQ;IAAA,OAC/D,IAAAC,0BAAc,EAACR,IAAI,EAAEO,QAAQ,CAACE,QAAQ,CAACC,GAAG,CAAC;EAAA,CAC7C,CAAC;AAAA;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEWb,cAAc","ignoreList":[]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.object.define-property.js");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = void 0;
|
|
8
|
-
require("core-js/modules/es.regexp.constructor.js");
|
|
9
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
10
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
11
|
-
var isUrlPathMatch = function isUrlPathMatch(path, itemUrl) {
|
|
12
|
-
if (!itemUrl || !path) return false;
|
|
13
|
-
var reg = new RegExp(/^[^#?]+/);
|
|
14
|
-
var _path = reg.exec(path)[0];
|
|
15
|
-
return _path === itemUrl || _path === "/".concat(itemUrl);
|
|
16
|
-
};
|
|
17
|
-
var _default = exports["default"] = isUrlPathMatch;
|
|
18
|
-
//# sourceMappingURL=isUrlPathMatch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isUrlPathMatch.js","names":["isUrlPathMatch","path","itemUrl","reg","RegExp","_path","exec","concat","_default","exports"],"sources":["../../../../src/components/MenuItem/helpers/isUrlPathMatch.js"],"sourcesContent":["const isUrlPathMatch = (path, itemUrl) => {\n if (!itemUrl || !path) return false;\n\n const reg = new RegExp(/^[^#?]+/);\n const _path = reg.exec(path)[0];\n\n return _path === itemUrl || _path === `/${itemUrl}`;\n};\n\nexport default isUrlPathMatch;\n"],"mappings":";;;;;;;;;;AAAA,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CAAIC,IAAI,EAAEC,OAAO,EAAK;EACxC,IAAI,CAACA,OAAO,IAAI,CAACD,IAAI,EAAE,OAAO,KAAK;EAEnC,IAAME,GAAG,GAAG,IAAIC,MAAM,CAAC,SAAS,CAAC;EACjC,IAAMC,KAAK,GAAGF,GAAG,CAACG,IAAI,CAACL,IAAI,CAAC,CAAC,CAAC,CAAC;EAE/B,OAAOI,KAAK,KAAKH,OAAO,IAAIG,KAAK,SAAAE,MAAA,CAASL,OAAO,CAAE;AACrD,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,cAEaT,cAAc","ignoreList":[]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import isUrlPathMatch from './isUrlPathMatch';
|
|
2
|
-
import { hasChildren } from '../../../helpers';
|
|
3
|
-
const hasActiveChild = (path, children) => hasChildren(children) && children.props.children[1][0].props.component.items.find(menuItem => isUrlPathMatch(path, menuItem.settings.url));
|
|
4
|
-
export default hasActiveChild;
|
|
5
|
-
//# sourceMappingURL=has-active-child.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"has-active-child.js","names":["isUrlPathMatch","hasChildren","hasActiveChild","path","children","props","component","items","find","menuItem","settings","url"],"sources":["../../../../src/components/MenuItem/helpers/has-active-child.js"],"sourcesContent":["import isUrlPathMatch from './isUrlPathMatch';\nimport { hasChildren } from '../../../helpers';\n\nconst hasActiveChild = (path, children) =>\n hasChildren(children) &&\n children.props.children[1][0].props.component.items.find(menuItem =>\n isUrlPathMatch(path, menuItem.settings.url)\n );\n\nexport default hasActiveChild;\n"],"mappings":"AAAA,OAAOA,cAAc,MAAM,kBAAkB;AAC7C,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,MAAMC,cAAc,GAAGA,CAACC,IAAI,EAAEC,QAAQ,KACpCH,WAAW,CAACG,QAAQ,CAAC,IACrBA,QAAQ,CAACC,KAAK,CAACD,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,KAAK,CAACC,SAAS,CAACC,KAAK,CAACC,IAAI,CAACC,QAAQ,IAC/DT,cAAc,CAACG,IAAI,EAAEM,QAAQ,CAACC,QAAQ,CAACC,GAAG,CAC5C,CAAC;AAEH,eAAeT,cAAc","ignoreList":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const isUrlPathMatch = (path, itemUrl) => {
|
|
2
|
-
if (!itemUrl || !path) return false;
|
|
3
|
-
const reg = new RegExp(/^[^#?]+/);
|
|
4
|
-
const _path = reg.exec(path)[0];
|
|
5
|
-
return _path === itemUrl || _path === `/${itemUrl}`;
|
|
6
|
-
};
|
|
7
|
-
export default isUrlPathMatch;
|
|
8
|
-
//# sourceMappingURL=isUrlPathMatch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isUrlPathMatch.js","names":["isUrlPathMatch","path","itemUrl","reg","RegExp","_path","exec"],"sources":["../../../../src/components/MenuItem/helpers/isUrlPathMatch.js"],"sourcesContent":["const isUrlPathMatch = (path, itemUrl) => {\n if (!itemUrl || !path) return false;\n\n const reg = new RegExp(/^[^#?]+/);\n const _path = reg.exec(path)[0];\n\n return _path === itemUrl || _path === `/${itemUrl}`;\n};\n\nexport default isUrlPathMatch;\n"],"mappings":"AAAA,MAAMA,cAAc,GAAGA,CAACC,IAAI,EAAEC,OAAO,KAAK;EACxC,IAAI,CAACA,OAAO,IAAI,CAACD,IAAI,EAAE,OAAO,KAAK;EAEnC,MAAME,GAAG,GAAG,IAAIC,MAAM,CAAC,SAAS,CAAC;EACjC,MAAMC,KAAK,GAAGF,GAAG,CAACG,IAAI,CAACL,IAAI,CAAC,CAAC,CAAC,CAAC;EAE/B,OAAOI,KAAK,KAAKH,OAAO,IAAIG,KAAK,KAAK,IAAIH,OAAO,EAAE;AACrD,CAAC;AAED,eAAeF,cAAc","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import isUrlPathMatch from './isUrlPathMatch';
|
|
2
|
-
import { hasChildren } from '../../../helpers';
|
|
3
|
-
|
|
4
|
-
const hasActiveChild = (path, children) =>
|
|
5
|
-
hasChildren(children) &&
|
|
6
|
-
children.props.children[1][0].props.component.items.find(menuItem =>
|
|
7
|
-
isUrlPathMatch(path, menuItem.settings.url)
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
export default hasActiveChild;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export const mockMenuProps = {
|
|
2
|
-
props: {
|
|
3
|
-
children: [
|
|
4
|
-
false,
|
|
5
|
-
[
|
|
6
|
-
{
|
|
7
|
-
props: {
|
|
8
|
-
component: {
|
|
9
|
-
items: [
|
|
10
|
-
{
|
|
11
|
-
type: 'menuitem',
|
|
12
|
-
settings: {
|
|
13
|
-
name: 'menuitem-card',
|
|
14
|
-
url: 'card',
|
|
15
|
-
text: 'Card'
|
|
16
|
-
},
|
|
17
|
-
id: 'menuitem-card-1',
|
|
18
|
-
items: [],
|
|
19
|
-
name: 'menuitem-card-1'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
type: 'menuitem',
|
|
23
|
-
settings: {
|
|
24
|
-
name: 'menuitem-Card',
|
|
25
|
-
|
|
26
|
-
url: 'card',
|
|
27
|
-
text: 'Card'
|
|
28
|
-
},
|
|
29
|
-
id: 'menuitem-Card-1',
|
|
30
|
-
items: [],
|
|
31
|
-
name: 'menuitem-Card-1'
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
type: 'menuitem',
|
|
35
|
-
settings: {
|
|
36
|
-
name: 'menuitem-card-Carousel',
|
|
37
|
-
url: 'card-carousel',
|
|
38
|
-
text: 'Card Carousel'
|
|
39
|
-
},
|
|
40
|
-
id: 'menuitem-card-carousel-1',
|
|
41
|
-
items: [],
|
|
42
|
-
name: 'menuitem-card-carousel-1'
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
type: 'menuitem',
|
|
46
|
-
settings: {
|
|
47
|
-
eventType: 'hover',
|
|
48
|
-
name: 'menuitem-Content-Group',
|
|
49
|
-
modifier: null,
|
|
50
|
-
url: 'content-group',
|
|
51
|
-
text: 'Content Group',
|
|
52
|
-
variant: null,
|
|
53
|
-
gtmClassName: null,
|
|
54
|
-
entities: [],
|
|
55
|
-
filterByProperty: [],
|
|
56
|
-
filterByFeatured: 'off',
|
|
57
|
-
filterBySponsored: 'off',
|
|
58
|
-
operator: 'AND',
|
|
59
|
-
filterBy: [],
|
|
60
|
-
sortProperties: []
|
|
61
|
-
},
|
|
62
|
-
id: 'menuitem-Content-Group-1',
|
|
63
|
-
items: [],
|
|
64
|
-
name: 'menuitem-Content-Group-1'
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
-
import { hasActiveChild } from '../../../../../../src/components/MenuItem/helpers';
|
|
4
|
-
import { mockMenuProps } from './constants';
|
|
5
|
-
|
|
6
|
-
describe('hasActiveChild', () => {
|
|
7
|
-
const structuredClone = val => JSON.parse(JSON.stringify(val));
|
|
8
|
-
|
|
9
|
-
it('should return true for finding active menu-item child', () => {
|
|
10
|
-
const activePath = '/card';
|
|
11
|
-
const menuProps = mockMenuProps;
|
|
12
|
-
const result = !!hasActiveChild(activePath, menuProps);
|
|
13
|
-
expect(result).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('shoul return false for findng no exact match', () => {
|
|
17
|
-
const activePath = '/carousel';
|
|
18
|
-
const menuProps = mockMenuProps;
|
|
19
|
-
|
|
20
|
-
const result = !!hasActiveChild(activePath, menuProps);
|
|
21
|
-
expect(result).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should return false for empty children-items', () => {
|
|
25
|
-
const activePath = '/carousel';
|
|
26
|
-
const menuWithNoChildrenProps = (() => {
|
|
27
|
-
const obj = structuredClone(mockMenuProps);
|
|
28
|
-
obj.props.children[1][0].props.component.items = [];
|
|
29
|
-
return obj;
|
|
30
|
-
}).call();
|
|
31
|
-
|
|
32
|
-
const result = !!hasActiveChild(activePath, menuWithNoChildrenProps);
|
|
33
|
-
expect(result).toBe(false);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
-
import { isUrlPathMatch } from '../../../../../../src/components/MenuItem/helpers';
|
|
3
|
-
|
|
4
|
-
describe('isUrlPathMatch', () => {
|
|
5
|
-
it('should return true since path and itemUrl match', () => {
|
|
6
|
-
const path = '/button';
|
|
7
|
-
const itemUrl = 'button';
|
|
8
|
-
const result = isUrlPathMatch(path, itemUrl);
|
|
9
|
-
expect(result).toBeTruthy();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should match since path and itemUrl do not match', () => {
|
|
13
|
-
const path = '/card';
|
|
14
|
-
const itemUrl = 'button';
|
|
15
|
-
const result = isUrlPathMatch(path, itemUrl);
|
|
16
|
-
expect(result).toBeFalsy();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should not match since path and itemUrl is a partial match', () => {
|
|
20
|
-
const path = '/button-card';
|
|
21
|
-
const itemUrl = 'button';
|
|
22
|
-
const result = isUrlPathMatch(path, itemUrl);
|
|
23
|
-
expect(result).toBeFalsy();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should not match since nested path and itemUrl is a partial match', () => {
|
|
27
|
-
const path = '/button/child';
|
|
28
|
-
const itemUrl = 'button';
|
|
29
|
-
const result = isUrlPathMatch(path, itemUrl);
|
|
30
|
-
expect(result).toBeFalsy();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should match with uri-with-fragment', () => {
|
|
34
|
-
const path = '/button#dark';
|
|
35
|
-
const itemUrl = 'button';
|
|
36
|
-
const result = isUrlPathMatch(path, itemUrl);
|
|
37
|
-
expect(result).toBeTruthy();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should match with uri-with-parameters', () => {
|
|
41
|
-
const path = '/button?paramater=value';
|
|
42
|
-
const itemUrl = 'button';
|
|
43
|
-
const result = isUrlPathMatch(path, itemUrl);
|
|
44
|
-
expect(result).toBeTruthy();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should not match with empty itemUrl', () => {
|
|
48
|
-
const path = '/';
|
|
49
|
-
const itemUrl = null;
|
|
50
|
-
const result = isUrlPathMatch(path, itemUrl);
|
|
51
|
-
expect(result).toBeFalsy();
|
|
52
|
-
});
|
|
53
|
-
});
|