@blaze-cms/nextjs-tools 0.146.0-node18.0 → 0.146.0-rc-eagle.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 +20 -5
- package/README.md +6 -0
- package/lib/application/query/index.js +68 -15
- package/lib/application/query/index.js.map +1 -1
- package/lib/blaze.config.js +16 -18
- package/lib/blaze.config.js.map +1 -1
- package/lib/components/DebugSidebar/DebugSidebar.js +115 -0
- package/lib/components/DebugSidebar/DebugSidebar.js.map +1 -0
- package/lib/components/DebugSidebar/DebugSidebarRender.js +65 -0
- package/lib/components/DebugSidebar/DebugSidebarRender.js.map +1 -0
- package/lib/components/DebugSidebar/index.js +3 -73
- package/lib/components/DebugSidebar/index.js.map +1 -1
- package/lib/components/HashObserver.js +14 -0
- package/lib/components/HashObserver.js.map +1 -0
- package/lib/components/index.js +9 -3
- package/lib/components/index.js.map +1 -1
- package/lib/constants.js +68 -61
- package/lib/constants.js.map +1 -1
- package/lib/containers/ContentContainer.js +65 -74
- package/lib/containers/ContentContainer.js.map +1 -1
- package/lib/containers/index.js +2 -3
- package/lib/containers/index.js.map +1 -1
- package/lib/helpers/build-admin-href.js +8 -11
- package/lib/helpers/build-admin-href.js.map +1 -1
- package/lib/helpers/check-for-gtm.js +10 -17
- package/lib/helpers/check-for-gtm.js.map +1 -1
- package/lib/helpers/check-parent.js +3 -5
- package/lib/helpers/check-parent.js.map +1 -1
- package/lib/helpers/check-preview-url.js +3 -6
- package/lib/helpers/check-preview-url.js.map +1 -1
- package/lib/helpers/check-url.js +197 -217
- package/lib/helpers/check-url.js.map +1 -1
- package/lib/helpers/get-entitys-actions.js +11 -11
- package/lib/helpers/get-entitys-actions.js.map +1 -1
- package/lib/helpers/get-error-message.js +4 -6
- package/lib/helpers/get-error-message.js.map +1 -1
- package/lib/helpers/get-from-local.js +17 -0
- package/lib/helpers/get-from-local.js.map +1 -0
- package/lib/helpers/get-page-data.js +34 -59
- package/lib/helpers/get-page-data.js.map +1 -1
- package/lib/helpers/get-root-selector-classes.js +8 -18
- package/lib/helpers/get-root-selector-classes.js.map +1 -1
- package/lib/helpers/get-search-filter.js +8 -12
- package/lib/helpers/get-search-filter.js.map +1 -1
- package/lib/helpers/handle-static-routes.js +5 -35
- package/lib/helpers/handle-static-routes.js.map +1 -1
- package/lib/helpers/index.js +29 -23
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/render-apple-tags.js +11 -17
- package/lib/helpers/render-apple-tags.js.map +1 -1
- package/lib/helpers/set-blaze-debug.js +30 -21
- package/lib/helpers/set-blaze-debug.js.map +1 -1
- package/lib/helpers/static-route-handlers/generic-file-handler.js +35 -66
- package/lib/helpers/static-route-handlers/generic-file-handler.js.map +1 -1
- package/lib/helpers/static-route-handlers/index.js +22 -20
- package/lib/helpers/static-route-handlers/index.js.map +1 -1
- package/lib/helpers/static-route-handlers/llms.js +26 -0
- package/lib/helpers/static-route-handlers/llms.js.map +1 -0
- package/lib/helpers/static-route-handlers/robots-txt.js +15 -10
- package/lib/helpers/static-route-handlers/robots-txt.js.map +1 -1
- package/lib/helpers/static-route-handlers/sitemap-file.js +17 -13
- package/lib/helpers/static-route-handlers/sitemap-file.js.map +1 -1
- package/lib/helpers/static-route-handlers/sitemap.js +14 -9
- package/lib/helpers/static-route-handlers/sitemap.js.map +1 -1
- package/lib/hoc/withBlaze.js +117 -209
- package/lib/hoc/withBlaze.js.map +1 -1
- package/lib/hooks/use-get-page.js +14 -15
- package/lib/hooks/use-get-page.js.map +1 -1
- package/lib/hooks/use-hash-observer.js +101 -0
- package/lib/hooks/use-hash-observer.js.map +1 -0
- package/lib/index.js +10 -19
- package/lib/index.js.map +1 -1
- package/lib/pages/Resolver.js +43 -70
- package/lib/pages/Resolver.js.map +1 -1
- package/lib/pages/document/DocumentBody.js +6 -8
- package/lib/pages/document/DocumentBody.js.map +1 -1
- package/lib/pages/document/_document.js +21 -23
- package/lib/pages/document/_document.js.map +1 -1
- package/lib/server/index.js +13 -35
- package/lib/server/index.js.map +1 -1
- package/package.json +24 -26
- package/src/application/query/index.js +5 -0
- package/src/blaze.config.js +5 -1
- package/src/components/DebugSidebar/DebugSidebar.js +110 -0
- package/src/components/DebugSidebar/DebugSidebarRender.js +64 -0
- package/src/components/DebugSidebar/index.js +2 -61
- package/src/components/HashObserver.js +8 -0
- package/src/components/index.js +2 -1
- package/src/constants.js +12 -1
- package/src/containers/ContentContainer.js +16 -1
- package/src/helpers/check-url.js +76 -33
- package/src/helpers/get-from-local.js +12 -0
- package/src/helpers/index.js +2 -0
- package/src/helpers/set-blaze-debug.js +25 -15
- package/src/helpers/static-route-handlers/index.js +3 -0
- package/{lib-es/helpers/static-route-handlers/robots-txt.js → src/helpers/static-route-handlers/llms.js} +7 -4
- package/src/hoc/withBlaze.js +2 -0
- package/src/hooks/use-hash-observer.js +116 -0
- package/src/index.js +0 -1
- package/src/pages/Resolver.js +7 -4
- package/src/pages/document/_document.js +11 -5
- package/tests/unit/src/__snapshots__/constants.test.js.snap +6 -0
- package/tests/unit/src/application/query/__snapshots__/index.test.js.snap +98 -2
- package/tests/unit/src/components/DebugSidebar/DebugSidebar.test.js +14 -5
- package/tests/unit/src/components/DebugSidebar/__snapshots__/DebugSidebar.test.js.snap +23 -0
- package/tests/unit/src/containers/ContentContainer.test.js +2 -0
- package/tests/unit/src/containers/__snapshots__/ContentContainer.test.js.snap +7 -2
- package/tests/unit/src/helpers/check-url.test.js +55 -12
- package/tests/unit/src/helpers/static-route-handlers/__snapshots__/index.test.js.snap +1 -0
- package/tests/unit/src/helpers/static-route-handlers/__snapshots__/llms.test.js.snap +158 -0
- package/tests/unit/src/helpers/static-route-handlers/llms.test.js +4 -0
- package/tests/unit/src/hooks/use-hash-observer.test.js +260 -0
- package/tests/unit/src/pages/Resolver.test.js +5 -1
- package/tests/unit/src/pages/__snapshots__/Resolver.test.js.snap +5 -1
- package/build/next.base.config.js +0 -185
- package/lib/server/routes.js +0 -37
- package/lib/server/routes.js.map +0 -1
- package/lib-es/application/query/index.js +0 -66
- package/lib-es/application/query/index.js.map +0 -1
- package/lib-es/blaze.config.js +0 -24
- package/lib-es/blaze.config.js.map +0 -1
- package/lib-es/components/DebugSidebar/index.js +0 -55
- package/lib-es/components/DebugSidebar/index.js.map +0 -1
- package/lib-es/components/index.js +0 -3
- package/lib-es/components/index.js.map +0 -1
- package/lib-es/constants.js +0 -92
- package/lib-es/constants.js.map +0 -1
- package/lib-es/containers/ContentContainer.js +0 -81
- package/lib-es/containers/ContentContainer.js.map +0 -1
- package/lib-es/containers/index.js +0 -3
- package/lib-es/containers/index.js.map +0 -1
- package/lib-es/helpers/build-admin-href.js +0 -11
- package/lib-es/helpers/build-admin-href.js.map +0 -1
- package/lib-es/helpers/check-for-gtm.js +0 -11
- package/lib-es/helpers/check-for-gtm.js.map +0 -1
- package/lib-es/helpers/check-parent.js +0 -8
- package/lib-es/helpers/check-parent.js.map +0 -1
- package/lib-es/helpers/check-preview-url.js +0 -9
- package/lib-es/helpers/check-preview-url.js.map +0 -1
- package/lib-es/helpers/check-url.js +0 -190
- package/lib-es/helpers/check-url.js.map +0 -1
- package/lib-es/helpers/get-entitys-actions.js +0 -16
- package/lib-es/helpers/get-entitys-actions.js.map +0 -1
- package/lib-es/helpers/get-error-message.js +0 -13
- package/lib-es/helpers/get-error-message.js.map +0 -1
- package/lib-es/helpers/get-page-data.js +0 -39
- package/lib-es/helpers/get-page-data.js.map +0 -1
- package/lib-es/helpers/get-root-selector-classes.js +0 -14
- package/lib-es/helpers/get-root-selector-classes.js.map +0 -1
- package/lib-es/helpers/get-search-filter.js +0 -14
- package/lib-es/helpers/get-search-filter.js.map +0 -1
- package/lib-es/helpers/handle-static-routes.js +0 -12
- package/lib-es/helpers/handle-static-routes.js.map +0 -1
- package/lib-es/helpers/index.js +0 -13
- package/lib-es/helpers/index.js.map +0 -1
- package/lib-es/helpers/render-apple-tags.js +0 -13
- package/lib-es/helpers/render-apple-tags.js.map +0 -1
- package/lib-es/helpers/set-blaze-debug.js +0 -22
- package/lib-es/helpers/set-blaze-debug.js.map +0 -1
- package/lib-es/helpers/static-route-handlers/generic-file-handler.js +0 -43
- package/lib-es/helpers/static-route-handlers/generic-file-handler.js.map +0 -1
- package/lib-es/helpers/static-route-handlers/index.js +0 -21
- package/lib-es/helpers/static-route-handlers/index.js.map +0 -1
- package/lib-es/helpers/static-route-handlers/robots-txt.js.map +0 -1
- package/lib-es/helpers/static-route-handlers/sitemap-file.js +0 -27
- package/lib-es/helpers/static-route-handlers/sitemap-file.js.map +0 -1
- package/lib-es/helpers/static-route-handlers/sitemap.js +0 -19
- package/lib-es/helpers/static-route-handlers/sitemap.js.map +0 -1
- package/lib-es/hoc/withBlaze.js +0 -152
- package/lib-es/hoc/withBlaze.js.map +0 -1
- package/lib-es/hooks/use-get-page.js +0 -19
- package/lib-es/hooks/use-get-page.js.map +0 -1
- package/lib-es/index.js +0 -9
- package/lib-es/index.js.map +0 -1
- package/lib-es/pages/Resolver.js +0 -88
- package/lib-es/pages/Resolver.js.map +0 -1
- package/lib-es/pages/document/DocumentBody.js +0 -11
- package/lib-es/pages/document/DocumentBody.js.map +0 -1
- package/lib-es/pages/document/_document.js +0 -18
- package/lib-es/pages/document/_document.js.map +0 -1
- package/lib-es/server/index.js +0 -16
- package/lib-es/server/index.js.map +0 -1
- package/lib-es/server/routes.js +0 -36
- package/lib-es/server/routes.js.map +0 -1
- package/src/server/routes.js +0 -42
- package/tests/unit/src/server/__snapshots__/routes.test.js.snap +0 -31
- package/tests/unit/src/server/routes.test.js +0 -11
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`llms route handler should match snapshot 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"fileQuery": Object {
|
|
6
|
+
"definitions": Array [
|
|
7
|
+
Object {
|
|
8
|
+
"directives": Array [],
|
|
9
|
+
"kind": "OperationDefinition",
|
|
10
|
+
"name": undefined,
|
|
11
|
+
"operation": "query",
|
|
12
|
+
"selectionSet": Object {
|
|
13
|
+
"kind": "SelectionSet",
|
|
14
|
+
"selections": Array [
|
|
15
|
+
Object {
|
|
16
|
+
"alias": Object {
|
|
17
|
+
"kind": "Name",
|
|
18
|
+
"value": "files",
|
|
19
|
+
},
|
|
20
|
+
"arguments": Array [
|
|
21
|
+
Object {
|
|
22
|
+
"kind": "Argument",
|
|
23
|
+
"name": Object {
|
|
24
|
+
"kind": "Name",
|
|
25
|
+
"value": "where",
|
|
26
|
+
},
|
|
27
|
+
"value": Object {
|
|
28
|
+
"fields": Array [
|
|
29
|
+
Object {
|
|
30
|
+
"kind": "ObjectField",
|
|
31
|
+
"name": Object {
|
|
32
|
+
"kind": "Name",
|
|
33
|
+
"value": "storeKey",
|
|
34
|
+
},
|
|
35
|
+
"value": Object {
|
|
36
|
+
"block": false,
|
|
37
|
+
"kind": "StringValue",
|
|
38
|
+
"value": "default",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
Object {
|
|
42
|
+
"kind": "ObjectField",
|
|
43
|
+
"name": Object {
|
|
44
|
+
"kind": "Name",
|
|
45
|
+
"value": "filename",
|
|
46
|
+
},
|
|
47
|
+
"value": Object {
|
|
48
|
+
"block": false,
|
|
49
|
+
"kind": "StringValue",
|
|
50
|
+
"value": "llms.txt",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
"kind": "ObjectValue",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
Object {
|
|
58
|
+
"kind": "Argument",
|
|
59
|
+
"name": Object {
|
|
60
|
+
"kind": "Name",
|
|
61
|
+
"value": "limit",
|
|
62
|
+
},
|
|
63
|
+
"value": Object {
|
|
64
|
+
"kind": "IntValue",
|
|
65
|
+
"value": "1",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
Object {
|
|
69
|
+
"kind": "Argument",
|
|
70
|
+
"name": Object {
|
|
71
|
+
"kind": "Name",
|
|
72
|
+
"value": "sort",
|
|
73
|
+
},
|
|
74
|
+
"value": Object {
|
|
75
|
+
"kind": "ListValue",
|
|
76
|
+
"values": Array [
|
|
77
|
+
Object {
|
|
78
|
+
"fields": Array [
|
|
79
|
+
Object {
|
|
80
|
+
"kind": "ObjectField",
|
|
81
|
+
"name": Object {
|
|
82
|
+
"kind": "Name",
|
|
83
|
+
"value": "property",
|
|
84
|
+
},
|
|
85
|
+
"value": Object {
|
|
86
|
+
"block": false,
|
|
87
|
+
"kind": "StringValue",
|
|
88
|
+
"value": "created",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
Object {
|
|
92
|
+
"kind": "ObjectField",
|
|
93
|
+
"name": Object {
|
|
94
|
+
"kind": "Name",
|
|
95
|
+
"value": "direction",
|
|
96
|
+
},
|
|
97
|
+
"value": Object {
|
|
98
|
+
"block": false,
|
|
99
|
+
"kind": "StringValue",
|
|
100
|
+
"value": "desc",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
"kind": "ObjectValue",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
"directives": Array [],
|
|
111
|
+
"kind": "Field",
|
|
112
|
+
"name": Object {
|
|
113
|
+
"kind": "Name",
|
|
114
|
+
"value": "getFiles",
|
|
115
|
+
},
|
|
116
|
+
"selectionSet": Object {
|
|
117
|
+
"kind": "SelectionSet",
|
|
118
|
+
"selections": Array [
|
|
119
|
+
Object {
|
|
120
|
+
"alias": undefined,
|
|
121
|
+
"arguments": Array [],
|
|
122
|
+
"directives": Array [],
|
|
123
|
+
"kind": "Field",
|
|
124
|
+
"name": Object {
|
|
125
|
+
"kind": "Name",
|
|
126
|
+
"value": "mimetype",
|
|
127
|
+
},
|
|
128
|
+
"selectionSet": undefined,
|
|
129
|
+
},
|
|
130
|
+
Object {
|
|
131
|
+
"alias": undefined,
|
|
132
|
+
"arguments": Array [],
|
|
133
|
+
"directives": Array [],
|
|
134
|
+
"kind": "Field",
|
|
135
|
+
"name": Object {
|
|
136
|
+
"kind": "Name",
|
|
137
|
+
"value": "url",
|
|
138
|
+
},
|
|
139
|
+
"selectionSet": undefined,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
"variableDefinitions": Array [],
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
"kind": "Document",
|
|
150
|
+
"loc": Object {
|
|
151
|
+
"end": 206,
|
|
152
|
+
"start": 0,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
"handler": [Function],
|
|
156
|
+
"pattern": /\\\\/llms\\.txt/,
|
|
157
|
+
}
|
|
158
|
+
`;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
import { render, act } from '@testing-library/react';
|
|
7
|
+
import Router from 'next/router';
|
|
8
|
+
import useHashObserver from '../../../../src/hooks/use-hash-observer';
|
|
9
|
+
|
|
10
|
+
jest.mock('next/router', () => ({
|
|
11
|
+
events: {
|
|
12
|
+
on: jest.fn(),
|
|
13
|
+
off: jest.fn()
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
function TestComponent({ timeout }) {
|
|
18
|
+
useHashObserver(timeout);
|
|
19
|
+
return <div data-testid="test-component">Test</div>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
describe('useHashObserver', () => {
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
document.body.innerHTML = '';
|
|
25
|
+
jest.clearAllMocks();
|
|
26
|
+
|
|
27
|
+
delete window.location;
|
|
28
|
+
window.location = { hash: '' };
|
|
29
|
+
|
|
30
|
+
Element.prototype.scrollIntoView = jest.fn();
|
|
31
|
+
|
|
32
|
+
Router.events = {
|
|
33
|
+
on: jest.fn(),
|
|
34
|
+
off: jest.fn()
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
jest.clearAllTimers();
|
|
40
|
+
jest.useRealTimers();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should register router event listeners on mount', () => {
|
|
44
|
+
const { unmount } = render(<TestComponent />);
|
|
45
|
+
|
|
46
|
+
expect(Router.events.on).toHaveBeenCalledWith('routeChangeComplete', expect.any(Function));
|
|
47
|
+
expect(Router.events.on).toHaveBeenCalledWith('hashChangeComplete', expect.any(Function));
|
|
48
|
+
|
|
49
|
+
unmount();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should cleanup event listeners on unmount', () => {
|
|
53
|
+
const { unmount } = render(<TestComponent />);
|
|
54
|
+
|
|
55
|
+
unmount();
|
|
56
|
+
|
|
57
|
+
expect(Router.events.off).toHaveBeenCalledWith('routeChangeComplete', expect.any(Function));
|
|
58
|
+
expect(Router.events.off).toHaveBeenCalledWith('hashChangeComplete', expect.any(Function));
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should scroll to element if it exists immediately', async () => {
|
|
62
|
+
jest.useFakeTimers();
|
|
63
|
+
|
|
64
|
+
const testElement = document.createElement('div');
|
|
65
|
+
testElement.id = 'test-section';
|
|
66
|
+
document.body.appendChild(testElement);
|
|
67
|
+
|
|
68
|
+
window.location.hash = '#test-section';
|
|
69
|
+
|
|
70
|
+
act(() => {
|
|
71
|
+
render(<TestComponent />);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
act(() => {
|
|
75
|
+
jest.runAllTimers();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(testElement.scrollIntoView).toHaveBeenCalledWith();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should handle route change with hash', () => {
|
|
82
|
+
const testElement = document.createElement('div');
|
|
83
|
+
testElement.id = 'route-section';
|
|
84
|
+
document.body.appendChild(testElement);
|
|
85
|
+
|
|
86
|
+
render(<TestComponent />);
|
|
87
|
+
|
|
88
|
+
const routeChangeHandler = Router.events.on.mock.calls.find(
|
|
89
|
+
call => call[0] === 'routeChangeComplete'
|
|
90
|
+
)[1];
|
|
91
|
+
|
|
92
|
+
act(() => {
|
|
93
|
+
routeChangeHandler('/page#route-section');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(testElement.scrollIntoView).toHaveBeenCalled();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should handle route change without hash', () => {
|
|
100
|
+
render(<TestComponent />);
|
|
101
|
+
|
|
102
|
+
const routeChangeHandler = Router.events.on.mock.calls.find(
|
|
103
|
+
call => call[0] === 'routeChangeComplete'
|
|
104
|
+
)[1];
|
|
105
|
+
|
|
106
|
+
expect(() => {
|
|
107
|
+
act(() => {
|
|
108
|
+
routeChangeHandler('/page');
|
|
109
|
+
});
|
|
110
|
+
}).not.toThrow();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should handle hash change', () => {
|
|
114
|
+
const testElement = document.createElement('div');
|
|
115
|
+
testElement.id = 'hash-section';
|
|
116
|
+
document.body.appendChild(testElement);
|
|
117
|
+
|
|
118
|
+
render(<TestComponent />);
|
|
119
|
+
|
|
120
|
+
const hashChangeHandler = Router.events.on.mock.calls.find(
|
|
121
|
+
call => call[0] === 'hashChangeComplete'
|
|
122
|
+
)[1];
|
|
123
|
+
|
|
124
|
+
act(() => {
|
|
125
|
+
hashChangeHandler('/page#hash-section');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
expect(testElement.scrollIntoView).toHaveBeenCalled();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should stop observing after timeout', () => {
|
|
132
|
+
jest.useFakeTimers();
|
|
133
|
+
|
|
134
|
+
render(<TestComponent timeout={1000} />);
|
|
135
|
+
|
|
136
|
+
const hashChangeHandler = Router.events.on.mock.calls.find(
|
|
137
|
+
call => call[0] === 'hashChangeComplete'
|
|
138
|
+
)[1];
|
|
139
|
+
|
|
140
|
+
act(() => {
|
|
141
|
+
hashChangeHandler('/page#nonexistent');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
act(() => {
|
|
145
|
+
jest.advanceTimersByTime(1100);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const lateElement = document.createElement('div');
|
|
149
|
+
lateElement.id = 'nonexistent';
|
|
150
|
+
document.body.appendChild(lateElement);
|
|
151
|
+
|
|
152
|
+
expect(lateElement.scrollIntoView).not.toHaveBeenCalled();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should handle rapid hash changes', () => {
|
|
156
|
+
jest.useFakeTimers();
|
|
157
|
+
|
|
158
|
+
const element2 = document.createElement('div');
|
|
159
|
+
element2.id = 'section-2';
|
|
160
|
+
document.body.appendChild(element2);
|
|
161
|
+
|
|
162
|
+
render(<TestComponent />);
|
|
163
|
+
|
|
164
|
+
const hashChangeHandler = Router.events.on.mock.calls.find(
|
|
165
|
+
call => call[0] === 'hashChangeComplete'
|
|
166
|
+
)[1];
|
|
167
|
+
|
|
168
|
+
act(() => {
|
|
169
|
+
hashChangeHandler('/page#section-1');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
act(() => {
|
|
173
|
+
hashChangeHandler('/page#section-2');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
expect(element2.scrollIntoView).toHaveBeenCalled();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('should handle empty hash gracefully', () => {
|
|
180
|
+
render(<TestComponent />);
|
|
181
|
+
|
|
182
|
+
const hashChangeHandler = Router.events.on.mock.calls.find(
|
|
183
|
+
call => call[0] === 'hashChangeComplete'
|
|
184
|
+
)[1];
|
|
185
|
+
|
|
186
|
+
expect(() => {
|
|
187
|
+
act(() => {
|
|
188
|
+
hashChangeHandler('/page');
|
|
189
|
+
});
|
|
190
|
+
}).not.toThrow();
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('should use custom timeout value', () => {
|
|
194
|
+
jest.useFakeTimers();
|
|
195
|
+
|
|
196
|
+
const customTimeout = 5000;
|
|
197
|
+
render(<TestComponent timeout={customTimeout} />);
|
|
198
|
+
|
|
199
|
+
const hashChangeHandler = Router.events.on.mock.calls.find(
|
|
200
|
+
call => call[0] === 'hashChangeComplete'
|
|
201
|
+
)[1];
|
|
202
|
+
|
|
203
|
+
act(() => {
|
|
204
|
+
hashChangeHandler('/page#nonexistent');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
act(() => {
|
|
208
|
+
jest.advanceTimersByTime(4999);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const element = document.createElement('div');
|
|
212
|
+
element.id = 'nonexistent';
|
|
213
|
+
document.body.appendChild(element);
|
|
214
|
+
|
|
215
|
+
act(() => {
|
|
216
|
+
jest.advanceTimersByTime(1);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
expect(element.scrollIntoView).not.toHaveBeenCalled();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('should verify observer stops after timeout', () => {
|
|
223
|
+
jest.useFakeTimers();
|
|
224
|
+
|
|
225
|
+
render(<TestComponent timeout={1000} />);
|
|
226
|
+
|
|
227
|
+
const hashChangeHandler = Router.events.on.mock.calls.find(
|
|
228
|
+
call => call[0] === 'hashChangeComplete'
|
|
229
|
+
)[1];
|
|
230
|
+
|
|
231
|
+
act(() => {
|
|
232
|
+
hashChangeHandler('/page#delayed-element');
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
act(() => {
|
|
236
|
+
jest.advanceTimersByTime(1000);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const element = document.createElement('div');
|
|
240
|
+
element.id = 'delayed-element';
|
|
241
|
+
document.body.appendChild(element);
|
|
242
|
+
|
|
243
|
+
act(() => {
|
|
244
|
+
jest.advanceTimersByTime(100);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
expect(element.scrollIntoView).not.toHaveBeenCalled();
|
|
248
|
+
|
|
249
|
+
const anotherElement = document.createElement('div');
|
|
250
|
+
anotherElement.id = 'another-element';
|
|
251
|
+
document.body.appendChild(anotherElement);
|
|
252
|
+
|
|
253
|
+
act(() => {
|
|
254
|
+
jest.advanceTimersByTime(100);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
expect(element.scrollIntoView).not.toHaveBeenCalled();
|
|
258
|
+
expect(anotherElement.scrollIntoView).not.toHaveBeenCalled();
|
|
259
|
+
});
|
|
260
|
+
});
|
|
@@ -9,7 +9,11 @@ import Resolver from '../../../../src/pages/Resolver';
|
|
|
9
9
|
jest.mock('../../../../src/containers/ContentContainer', () => jest.fn(() => 'ContentContainer'));
|
|
10
10
|
|
|
11
11
|
jest.mock('next/router', () => ({
|
|
12
|
-
useRouter: jest.fn(() => ({
|
|
12
|
+
useRouter: jest.fn(() => ({
|
|
13
|
+
asPath: 'some-url',
|
|
14
|
+
push: () => {},
|
|
15
|
+
events: { on: () => {}, off: () => {} }
|
|
16
|
+
}))
|
|
13
17
|
}));
|
|
14
18
|
|
|
15
19
|
jest.mock('next/error', () => jest.fn(() => 'NextError'));
|
|
@@ -14,7 +14,11 @@ exports[`Resolver page should disable SSR 1`] = `<DocumentFragment />`;
|
|
|
14
14
|
|
|
15
15
|
exports[`Resolver page should render 404 error if pageData, itemId or itemEntity falsey 1`] = `
|
|
16
16
|
<DocumentFragment>
|
|
17
|
-
|
|
17
|
+
<div
|
|
18
|
+
class="next_error"
|
|
19
|
+
>
|
|
20
|
+
NextError
|
|
21
|
+
</div>
|
|
18
22
|
</DocumentFragment>
|
|
19
23
|
`;
|
|
20
24
|
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
require('dotenv').config();
|
|
2
|
-
|
|
3
|
-
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
4
|
-
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
|
|
5
|
-
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
8
|
-
const rootPath = '../../../';
|
|
9
|
-
|
|
10
|
-
const nextConfig = {
|
|
11
|
-
dir: './src',
|
|
12
|
-
env: {
|
|
13
|
-
DFP_NETWORK_ID: process.env.DFP_NETWORK_ID,
|
|
14
|
-
DFP_BASE_ADUNIT: process.env.DFP_BASE_ADUNIT,
|
|
15
|
-
BLAZE_GRAPHQL_URI: process.env.BLAZE_GRAPHQL_URI,
|
|
16
|
-
GOOGLE_MAPS_API_KEY: process.env.GOOGLE_MAPS_API_KEY,
|
|
17
|
-
BLAZE_ADMIN_URL: process.env.BLAZE_ADMIN_URL,
|
|
18
|
-
BLAZE_SENTRY_ENVIRONMENT: process.env.BLAZE_SENTRY_ENVIRONMENT,
|
|
19
|
-
BLAZE_SENTRY_DEBUG: process.env.BLAZE_SENTRY_DEBUG,
|
|
20
|
-
BLAZE_SENTRY_ATTACH_STRACKTRACE: process.env.BLAZE_SENTRY_ATTACH_STRACKTRACE,
|
|
21
|
-
BLAZE_SENTRY_DSN: process.env.BLAZE_SENTRY_DSN,
|
|
22
|
-
BLAZE_DATADOG_APM_ACTIVE: process.env.BLAZE_DATADOG_APM_ACTIVE,
|
|
23
|
-
BLAZE_ROUTE_REGEX: process.env.BLAZE_ROUTE_REGEX,
|
|
24
|
-
BLAZE_X_FRAME_OPTIONS: process.env.BLAZE_X_FRAME_OPTIONS,
|
|
25
|
-
BLAZE_VARIANTS: process.env.BLAZE_VARIANTS
|
|
26
|
-
},
|
|
27
|
-
output: {
|
|
28
|
-
clean: true
|
|
29
|
-
},
|
|
30
|
-
future: {
|
|
31
|
-
webpack5: true
|
|
32
|
-
},
|
|
33
|
-
productionBrowserSourceMaps: true,
|
|
34
|
-
experimental: {
|
|
35
|
-
modern: true
|
|
36
|
-
},
|
|
37
|
-
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
|
|
38
|
-
config.plugins.push(
|
|
39
|
-
new LodashModuleReplacementPlugin({
|
|
40
|
-
collections: true,
|
|
41
|
-
paths: true
|
|
42
|
-
})
|
|
43
|
-
);
|
|
44
|
-
if (!isServer) {
|
|
45
|
-
// eslint-disable-next-line no-param-reassign
|
|
46
|
-
config.node = {
|
|
47
|
-
fs: 'empty'
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
...config,
|
|
52
|
-
optimization: {
|
|
53
|
-
...config.optimization,
|
|
54
|
-
minimize: true,
|
|
55
|
-
minimizer: [`...`, new CssMinimizerPlugin()],
|
|
56
|
-
usedExports: true,
|
|
57
|
-
removeAvailableModules: true,
|
|
58
|
-
concatenateModules: true
|
|
59
|
-
},
|
|
60
|
-
devtool: 'cheap-module-source-map',
|
|
61
|
-
devServer: {
|
|
62
|
-
hot: true
|
|
63
|
-
},
|
|
64
|
-
resolve: {
|
|
65
|
-
alias: {
|
|
66
|
-
...config.resolve.alias,
|
|
67
|
-
'@blaze-cms/nextjs-tools': path.resolve(
|
|
68
|
-
__dirname,
|
|
69
|
-
rootPath,
|
|
70
|
-
'packages',
|
|
71
|
-
'blaze-nextjs-tools',
|
|
72
|
-
'src'
|
|
73
|
-
),
|
|
74
|
-
'@blaze-cms/nextjs-components': path.resolve(
|
|
75
|
-
__dirname,
|
|
76
|
-
rootPath,
|
|
77
|
-
'packages',
|
|
78
|
-
'blaze-nextjs-components',
|
|
79
|
-
'src'
|
|
80
|
-
),
|
|
81
|
-
'@blaze-cms/plugin-search-ui': path.resolve(
|
|
82
|
-
__dirname,
|
|
83
|
-
rootPath,
|
|
84
|
-
'packages',
|
|
85
|
-
'blaze-plugin-search-ui',
|
|
86
|
-
'src'
|
|
87
|
-
),
|
|
88
|
-
'@blaze-cms/core-errors-ui': path.resolve(
|
|
89
|
-
__dirname,
|
|
90
|
-
rootPath,
|
|
91
|
-
'packages',
|
|
92
|
-
'blaze-core-errors-ui',
|
|
93
|
-
'src'
|
|
94
|
-
),
|
|
95
|
-
'@blaze-cms/plugin-page-builder-fe': path.resolve(
|
|
96
|
-
__dirname,
|
|
97
|
-
rootPath,
|
|
98
|
-
'packages',
|
|
99
|
-
'blaze-plugin-page-builder-fe',
|
|
100
|
-
'src'
|
|
101
|
-
),
|
|
102
|
-
'@blaze-cms/plugin-gtm-fe': path.resolve(
|
|
103
|
-
__dirname,
|
|
104
|
-
rootPath,
|
|
105
|
-
'packages',
|
|
106
|
-
'blaze-plugin-gtm-fe',
|
|
107
|
-
'src'
|
|
108
|
-
),
|
|
109
|
-
'@blaze-cms/plugin-google-maps-fe': path.resolve(
|
|
110
|
-
__dirname,
|
|
111
|
-
rootPath,
|
|
112
|
-
'packages',
|
|
113
|
-
'blaze-plugin-google-maps-fe',
|
|
114
|
-
'src'
|
|
115
|
-
),
|
|
116
|
-
'@blaze-cms/plugin-preview-fe': path.resolve(
|
|
117
|
-
__dirname,
|
|
118
|
-
rootPath,
|
|
119
|
-
'packages',
|
|
120
|
-
'blaze-plugin-preview-fe',
|
|
121
|
-
'src'
|
|
122
|
-
),
|
|
123
|
-
'@blaze-cms/react-page-builder': path.resolve(
|
|
124
|
-
__dirname,
|
|
125
|
-
rootPath,
|
|
126
|
-
'packages',
|
|
127
|
-
'blaze-react-page-builder',
|
|
128
|
-
'src'
|
|
129
|
-
),
|
|
130
|
-
'@blaze-cms/plugin-auth-fe': path.resolve(
|
|
131
|
-
__dirname,
|
|
132
|
-
'../../',
|
|
133
|
-
'blaze-plugin-auth-fe',
|
|
134
|
-
'src'
|
|
135
|
-
),
|
|
136
|
-
'@sentry/browser': '@sentry/browser/esm'
|
|
137
|
-
},
|
|
138
|
-
fallback: { path: false, fs: false }
|
|
139
|
-
},
|
|
140
|
-
module: {
|
|
141
|
-
rules: [
|
|
142
|
-
...config.module.rules,
|
|
143
|
-
{
|
|
144
|
-
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
|
|
145
|
-
type: 'asset/inline'
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
test: /\.(js|jsx)$/,
|
|
149
|
-
exclude: /node_modules/,
|
|
150
|
-
use: {
|
|
151
|
-
loader: 'babel-loader',
|
|
152
|
-
options: {
|
|
153
|
-
sourceType: 'unambiguous',
|
|
154
|
-
presets: [
|
|
155
|
-
[
|
|
156
|
-
'next/babel',
|
|
157
|
-
{
|
|
158
|
-
'preset-env': {
|
|
159
|
-
modules: false,
|
|
160
|
-
targets: {
|
|
161
|
-
esmodules: true
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
'transform-runtime': {},
|
|
165
|
-
'styled-jsx': {},
|
|
166
|
-
'class-properties': {}
|
|
167
|
-
}
|
|
168
|
-
]
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// eslint-disable-next-line no-console
|
|
180
|
-
console.log(
|
|
181
|
-
'blaze-nextjs-tools/build has been deprecated and will be removed in the future.',
|
|
182
|
-
'Please use/update blaze-nextjs-build-tools package for generating next config.'
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
module.exports = nextConfig;
|
package/lib/server/routes.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var Router = require('nextjs-dynamic-routes');
|
|
4
|
-
var _require = require('../constants'),
|
|
5
|
-
ROUTE_REGEX = _require.ROUTE_REGEX,
|
|
6
|
-
PREVIEW_REGEX = _require.PREVIEW_REGEX,
|
|
7
|
-
ROUTE_PATTERN_SITEMAP = _require.ROUTE_PATTERN_SITEMAP,
|
|
8
|
-
ROUTE_PATTERN_SITEMAP_FILE_REGEX = _require.ROUTE_PATTERN_SITEMAP_FILE_REGEX,
|
|
9
|
-
ROUTE_PATTERN_ROBOTS_TXT = _require.ROUTE_PATTERN_ROBOTS_TXT;
|
|
10
|
-
var router = new Router();
|
|
11
|
-
router.add({
|
|
12
|
-
name: 'resolver',
|
|
13
|
-
pattern: ROUTE_REGEX,
|
|
14
|
-
page: '/Resolver'
|
|
15
|
-
});
|
|
16
|
-
router.add({
|
|
17
|
-
name: 'preview',
|
|
18
|
-
pattern: PREVIEW_REGEX,
|
|
19
|
-
page: '/Resolver'
|
|
20
|
-
});
|
|
21
|
-
router.add({
|
|
22
|
-
name: 'sitemap',
|
|
23
|
-
pattern: ROUTE_PATTERN_SITEMAP,
|
|
24
|
-
page: '/Resolver'
|
|
25
|
-
});
|
|
26
|
-
router.add({
|
|
27
|
-
name: 'sitemap file',
|
|
28
|
-
pattern: ROUTE_PATTERN_SITEMAP_FILE_REGEX,
|
|
29
|
-
page: '/Resolver'
|
|
30
|
-
});
|
|
31
|
-
router.add({
|
|
32
|
-
name: 'robots',
|
|
33
|
-
pattern: ROUTE_PATTERN_ROBOTS_TXT,
|
|
34
|
-
page: '/Resolver'
|
|
35
|
-
});
|
|
36
|
-
module.exports = router;
|
|
37
|
-
//# sourceMappingURL=routes.js.map
|
package/lib/server/routes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","names":["Router","require","_require","ROUTE_REGEX","PREVIEW_REGEX","ROUTE_PATTERN_SITEMAP","ROUTE_PATTERN_SITEMAP_FILE_REGEX","ROUTE_PATTERN_ROBOTS_TXT","router","add","name","pattern","page","module","exports"],"sources":["../../src/server/routes.js"],"sourcesContent":["const Router = require('nextjs-dynamic-routes');\nconst {\n ROUTE_REGEX,\n PREVIEW_REGEX,\n ROUTE_PATTERN_SITEMAP,\n ROUTE_PATTERN_SITEMAP_FILE_REGEX,\n ROUTE_PATTERN_ROBOTS_TXT\n} = require('../constants');\n\nconst router = new Router();\n\nrouter.add({\n name: 'resolver',\n pattern: ROUTE_REGEX,\n page: '/Resolver'\n});\n\nrouter.add({\n name: 'preview',\n pattern: PREVIEW_REGEX,\n page: '/Resolver'\n});\n\nrouter.add({\n name: 'sitemap',\n pattern: ROUTE_PATTERN_SITEMAP,\n page: '/Resolver'\n});\n\nrouter.add({\n name: 'sitemap file',\n pattern: ROUTE_PATTERN_SITEMAP_FILE_REGEX,\n page: '/Resolver'\n});\n\nrouter.add({\n name: 'robots',\n pattern: ROUTE_PATTERN_ROBOTS_TXT,\n page: '/Resolver'\n});\n\nmodule.exports = router;\n"],"mappings":";;AAAA,IAAMA,MAAM,GAAGC,OAAO,CAAC,uBAAuB,CAAC;AAC/C,IAAAC,QAAA,GAMID,OAAO,CAAC,cAAc,CAAC;EALzBE,WAAW,GAAAD,QAAA,CAAXC,WAAW;EACXC,aAAa,GAAAF,QAAA,CAAbE,aAAa;EACbC,qBAAqB,GAAAH,QAAA,CAArBG,qBAAqB;EACrBC,gCAAgC,GAAAJ,QAAA,CAAhCI,gCAAgC;EAChCC,wBAAwB,GAAAL,QAAA,CAAxBK,wBAAwB;AAG1B,IAAMC,MAAM,GAAG,IAAIR,MAAM,CAAC,CAAC;AAE3BQ,MAAM,CAACC,GAAG,CAAC;EACTC,IAAI,EAAE,UAAU;EAChBC,OAAO,EAAER,WAAW;EACpBS,IAAI,EAAE;AACR,CAAC,CAAC;AAEFJ,MAAM,CAACC,GAAG,CAAC;EACTC,IAAI,EAAE,SAAS;EACfC,OAAO,EAAEP,aAAa;EACtBQ,IAAI,EAAE;AACR,CAAC,CAAC;AAEFJ,MAAM,CAACC,GAAG,CAAC;EACTC,IAAI,EAAE,SAAS;EACfC,OAAO,EAAEN,qBAAqB;EAC9BO,IAAI,EAAE;AACR,CAAC,CAAC;AAEFJ,MAAM,CAACC,GAAG,CAAC;EACTC,IAAI,EAAE,cAAc;EACpBC,OAAO,EAAEL,gCAAgC;EACzCM,IAAI,EAAE;AACR,CAAC,CAAC;AAEFJ,MAAM,CAACC,GAAG,CAAC;EACTC,IAAI,EAAE,QAAQ;EACdC,OAAO,EAAEJ,wBAAwB;EACjCK,IAAI,EAAE;AACR,CAAC,CAAC;AAEFC,MAAM,CAACC,OAAO,GAAGN,MAAM","ignoreList":[]}
|