@blaze-cms/nextjs-tools 0.118.0 → 0.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +1 -0
- package/build/next.base.config.js +1 -1
- package/example.env +1 -1
- package/lib/application/query/index.js +5 -5
- package/lib/application/query/index.js.map +1 -1
- package/lib/blaze.config.js +2 -1
- package/lib/blaze.config.js.map +1 -1
- package/lib/helpers/check-url.js +13 -12
- package/lib/helpers/check-url.js.map +1 -1
- package/lib/helpers/static-route-handlers/robots-txt.js +2 -2
- package/lib/helpers/static-route-handlers/robots-txt.js.map +1 -1
- package/lib/helpers/static-route-handlers/sitemap-file.js +2 -2
- package/lib/helpers/static-route-handlers/sitemap-file.js.map +1 -1
- package/lib/helpers/static-route-handlers/sitemap.js +2 -2
- package/lib/helpers/static-route-handlers/sitemap.js.map +1 -1
- package/lib/hoc/withBlaze.js +37 -30
- package/lib/hoc/withBlaze.js.map +1 -1
- package/lib/hooks/use-get-page.js +2 -2
- package/lib/hooks/use-get-page.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-es/application/query/index.js +5 -1
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/blaze.config.js +2 -1
- package/lib-es/blaze.config.js.map +1 -1
- package/lib-es/helpers/check-url.js +1 -0
- package/lib-es/helpers/check-url.js.map +1 -1
- package/lib-es/helpers/static-route-handlers/robots-txt.js +1 -1
- package/lib-es/helpers/static-route-handlers/robots-txt.js.map +1 -1
- package/lib-es/helpers/static-route-handlers/sitemap-file.js +1 -1
- package/lib-es/helpers/static-route-handlers/sitemap-file.js.map +1 -1
- package/lib-es/helpers/static-route-handlers/sitemap.js +1 -1
- package/lib-es/helpers/static-route-handlers/sitemap.js.map +1 -1
- package/lib-es/hoc/withBlaze.js +36 -30
- package/lib-es/hoc/withBlaze.js.map +1 -1
- package/lib-es/hooks/use-get-page.js +1 -1
- package/lib-es/hooks/use-get-page.js.map +1 -1
- package/lib-es/index.js +1 -1
- package/lib-es/index.js.map +1 -1
- package/package.json +17 -17
- package/src/application/query/index.js +5 -1
- package/src/blaze.config.js +2 -1
- package/src/helpers/check-url.js +1 -0
- package/src/helpers/static-route-handlers/robots-txt.js +1 -1
- package/src/helpers/static-route-handlers/sitemap-file.js +1 -1
- package/src/helpers/static-route-handlers/sitemap.js +1 -1
- package/src/hoc/withBlaze.js +34 -30
- package/src/hooks/use-get-page.js +1 -1
- package/src/index.js +1 -1
- package/tests/unit/src/components/DebugSidebar/DebugSidebar.test.js +1 -1
- package/tests/unit/src/containers/ContentContainer.test.js +1 -1
- package/tests/unit/src/helpers/check-url.test.js +20 -1
- package/tests/unit/src/helpers/static-route-handlers/generic-file-handler.test.js +1 -1
- package/tests/unit/src/hoc/withBlaze.test.js +19 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { MockedProvider } from '@apollo/
|
|
3
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
4
4
|
import { render, act, fireEvent } from '@testing-library/react';
|
|
5
5
|
import { DebugSidebar } from '../../../../../src/components';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
-
import { MockedProvider } from '@apollo/
|
|
4
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import { buildPBComponents, getLightboxImages } from '@blaze-cms/plugin-page-builder-fe';
|
|
7
7
|
import { ContentContainer } from '../../../../src/containers';
|
|
@@ -49,7 +49,8 @@ describe('Check url', () => {
|
|
|
49
49
|
statusCode,
|
|
50
50
|
writeHead: jest.fn(),
|
|
51
51
|
write: jest.fn(),
|
|
52
|
-
end: jest.fn()
|
|
52
|
+
end: jest.fn(),
|
|
53
|
+
setHeader: jest.fn()
|
|
53
54
|
};
|
|
54
55
|
const asPath = '/page-slug';
|
|
55
56
|
const urlTo = '/redirect-url';
|
|
@@ -115,6 +116,24 @@ describe('Check url', () => {
|
|
|
115
116
|
expect(handleStaticRoutes.getHandler).not.toHaveBeenCalled();
|
|
116
117
|
});
|
|
117
118
|
|
|
119
|
+
it('should set empty Cache-Control header', async () => {
|
|
120
|
+
await checkUrl(props);
|
|
121
|
+
expect(res.setHeader).toHaveBeenCalledWith('Cache-Control', '');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should set Cache-Control header from env', async () => {
|
|
125
|
+
const cacheEnvs = {
|
|
126
|
+
BLAZE_CACHE_CONTROL_HEADER: 'max-age=0'
|
|
127
|
+
};
|
|
128
|
+
setEnvs(cacheEnvs);
|
|
129
|
+
await checkUrl(props);
|
|
130
|
+
expect(res.setHeader).toHaveBeenCalledWith(
|
|
131
|
+
'Cache-Control',
|
|
132
|
+
cacheEnvs.BLAZE_CACHE_CONTROL_HEADER
|
|
133
|
+
);
|
|
134
|
+
deleteEnvs(cacheEnvs);
|
|
135
|
+
});
|
|
136
|
+
|
|
118
137
|
it('should return disableSsr prop', async () => {
|
|
119
138
|
getAccessToken.mockReturnValueOnce(true);
|
|
120
139
|
const result = await checkUrl({ ...props });
|
|
@@ -11,12 +11,14 @@ jest.mock('@blaze-cms/core-ui', () => {
|
|
|
11
11
|
extract: jest.fn(() => ({ cache: true }))
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
+
|
|
14
15
|
const mockBlaze = {
|
|
15
16
|
ctx: { req: {}, res: {} },
|
|
16
17
|
initComplete: jest.fn(() => true),
|
|
17
18
|
init: jest.fn(async () => true),
|
|
18
19
|
getClient: jest.fn(() => null),
|
|
19
20
|
createClient: jest.fn(() => apolloClient),
|
|
21
|
+
getProcessedEntities: jest.fn(() => ({ typePolicyQueryFields: {}, possibleTypes: {} })),
|
|
20
22
|
events: {
|
|
21
23
|
emit: jest.fn()
|
|
22
24
|
},
|
|
@@ -37,7 +39,15 @@ describe('withBlaze HOC', () => {
|
|
|
37
39
|
const props = {
|
|
38
40
|
test: true
|
|
39
41
|
};
|
|
40
|
-
const expectedProps = [
|
|
42
|
+
const expectedProps = [
|
|
43
|
+
{
|
|
44
|
+
...props,
|
|
45
|
+
apolloClient: blazeMock.createClient(),
|
|
46
|
+
apolloState: {},
|
|
47
|
+
processedBlazeEntities: undefined
|
|
48
|
+
},
|
|
49
|
+
{}
|
|
50
|
+
];
|
|
41
51
|
|
|
42
52
|
const Component = 'Component';
|
|
43
53
|
const AppTree = jest.fn(() => null);
|
|
@@ -67,6 +77,7 @@ describe('withBlaze HOC', () => {
|
|
|
67
77
|
it('should wrap component and use buildConfig function', async () => {
|
|
68
78
|
const AppWithBlaze = withBlaze(App);
|
|
69
79
|
const { asFragment, queryByText } = render(<AppWithBlaze {...props} />);
|
|
80
|
+
|
|
70
81
|
await waitFor(() => expect(queryByText(appString)).toBeDefined());
|
|
71
82
|
|
|
72
83
|
expect(App).toHaveBeenCalledWith(...expectedProps);
|
|
@@ -100,7 +111,12 @@ describe('withBlaze HOC', () => {
|
|
|
100
111
|
expect(buildConfig).toHaveBeenCalledWith(blazeConfig);
|
|
101
112
|
|
|
102
113
|
const initialProps = await AppWithBlaze.getInitialProps(context);
|
|
103
|
-
expect(initialProps).toEqual({
|
|
114
|
+
expect(initialProps).toEqual({
|
|
115
|
+
...appProps,
|
|
116
|
+
pageProps: {},
|
|
117
|
+
apolloState: { cache: true },
|
|
118
|
+
processedBlazeEntities: blazeMock.getProcessedEntities()
|
|
119
|
+
});
|
|
104
120
|
expect(App.getInitialProps).toHaveBeenCalledWith(context);
|
|
105
121
|
const [firstApprTreeCall] = AppTree.mock.calls;
|
|
106
122
|
expect(firstApprTreeCall[0]).toEqual({
|
|
@@ -110,6 +126,7 @@ describe('withBlaze HOC', () => {
|
|
|
110
126
|
apolloClient: blazeMock.createClient()
|
|
111
127
|
});
|
|
112
128
|
expect(blazeMock.init).toHaveBeenCalledTimes(3);
|
|
129
|
+
expect(blazeMock.getProcessedEntities).toHaveBeenCalledTimes(2);
|
|
113
130
|
});
|
|
114
131
|
|
|
115
132
|
it('should add getInitialProps and not render in client', async () => {
|