@elementor/editor-site-navigation 0.10.2 → 0.11.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 +19 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +4 -4
- package/src/components/panel/pages-list/__tests__/page-list-item.test.tsx +12 -12
- package/src/components/panel/pages-list/__tests__/pages-collapsible-list.test.tsx +8 -8
- package/src/components/top-bar/__tests__/add-new-page.test.tsx +11 -12
- package/src/components/top-bar/__tests__/recently-edited.test.tsx +30 -30
- package/src/env.ts +2 -2
- package/src/hooks/__tests__/use-create-page.test.ts +6 -8
- package/src/hooks/__tests__/use-posts.test.ts +3 -5
- package/src/hooks/__tests__/use-recent-posts.test.ts +4 -4
- package/src/init.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.11.0](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.10.3...@elementor/editor-site-navigation@0.11.0) (2023-07-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **pages-panel:** change env key name in pages panel [ED-11514] ([#92](https://github.com/elementor/elementor-packages/issues/92)) ([52bf226](https://github.com/elementor/elementor-packages/commit/52bf22632bea544b69c0d58c4383c33b8d1c4aa8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.10.3](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.10.2...@elementor/editor-site-navigation@0.10.3) (2023-07-17)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @elementor/editor-site-navigation
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.10.2](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.10.1...@elementor/editor-site-navigation@0.10.2) (2023-07-17)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @elementor/editor-site-navigation
|
package/dist/index.js
CHANGED
|
@@ -645,7 +645,7 @@ var { env, validateEnv } = (0, import_env.parseEnv)("@elementor/editor-site-navi
|
|
|
645
645
|
// src/init.ts
|
|
646
646
|
function init() {
|
|
647
647
|
registerTopBarMenuItems();
|
|
648
|
-
if (env.
|
|
648
|
+
if (env.is_pages_panel_active) {
|
|
649
649
|
(0, import_editor_panels3.registerPanel)(panel);
|
|
650
650
|
registerButton();
|
|
651
651
|
}
|
|
@@ -653,7 +653,7 @@ function init() {
|
|
|
653
653
|
function registerTopBarMenuItems() {
|
|
654
654
|
(0, import_editor_app_bar.injectIntoPageIndication)({
|
|
655
655
|
id: "document-recently-edited",
|
|
656
|
-
|
|
656
|
+
component: RecentlyEdited
|
|
657
657
|
});
|
|
658
658
|
}
|
|
659
659
|
function registerButton() {
|
package/dist/index.mjs
CHANGED
|
@@ -636,7 +636,7 @@ var { env, validateEnv } = parseEnv("@elementor/editor-site-navigation", (envDat
|
|
|
636
636
|
// src/init.ts
|
|
637
637
|
function init() {
|
|
638
638
|
registerTopBarMenuItems();
|
|
639
|
-
if (env.
|
|
639
|
+
if (env.is_pages_panel_active) {
|
|
640
640
|
registerPanel(panel);
|
|
641
641
|
registerButton();
|
|
642
642
|
}
|
|
@@ -644,7 +644,7 @@ function init() {
|
|
|
644
644
|
function registerTopBarMenuItems() {
|
|
645
645
|
injectIntoPageIndication({
|
|
646
646
|
id: "document-recently-edited",
|
|
647
|
-
|
|
647
|
+
component: RecentlyEdited
|
|
648
648
|
});
|
|
649
649
|
}
|
|
650
650
|
function registerButton() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-site-navigation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@elementor/editor-app-bar": "^0.6.
|
|
35
|
+
"@elementor/editor-app-bar": "^0.6.9",
|
|
36
36
|
"@elementor/editor-documents": "^0.8.3",
|
|
37
|
-
"@elementor/editor-panels": "^0.1.
|
|
37
|
+
"@elementor/editor-panels": "^0.1.5",
|
|
38
38
|
"@elementor/env": "^0.2.0",
|
|
39
39
|
"@elementor/icons": "^0.6.1",
|
|
40
40
|
"@elementor/query": "^0.1.1",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"elementor": {
|
|
50
50
|
"type": "extension"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "2cd16cef577fdeafc697fc3ce1a3cfc7e17b569b"
|
|
53
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { act, render } from '@testing-library/react';
|
|
2
|
+
import { act, render, screen } from '@testing-library/react';
|
|
3
3
|
import { Post } from '../../../../types';
|
|
4
4
|
import PageListItem from '../page-list-item';
|
|
5
5
|
import { useNavigateToDocument } from '@elementor/editor-documents';
|
|
@@ -27,14 +27,14 @@ describe( '@elementor/editor-site-navigation - PageListItem', () => {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// Act.
|
|
30
|
-
|
|
30
|
+
render( <PageListItem page={ page } /> );
|
|
31
31
|
|
|
32
32
|
// Assert.
|
|
33
|
-
const label = getByText( 'Test Page' );
|
|
34
|
-
const publishedLabel = queryByText( 'publish', { exact: false } );
|
|
33
|
+
const label = screen.getByText( 'Test Page' );
|
|
34
|
+
const publishedLabel = screen.queryByText( 'publish', { exact: false } );
|
|
35
35
|
|
|
36
36
|
expect( label ).toBeInTheDocument();
|
|
37
|
-
expect( publishedLabel ).
|
|
37
|
+
expect( publishedLabel ).not.toBeInTheDocument();
|
|
38
38
|
} );
|
|
39
39
|
|
|
40
40
|
it( 'should show the page status for non-published pages', () => {
|
|
@@ -50,10 +50,10 @@ describe( '@elementor/editor-site-navigation - PageListItem', () => {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
// Act.
|
|
53
|
-
|
|
53
|
+
render( <PageListItem page={ page } /> );
|
|
54
54
|
|
|
55
55
|
// Assert.
|
|
56
|
-
const label = getByText( 'draft', { exact: false } );
|
|
56
|
+
const label = screen.getByText( 'draft', { exact: false } );
|
|
57
57
|
expect( label ).toBeInTheDocument();
|
|
58
58
|
} );
|
|
59
59
|
|
|
@@ -72,8 +72,8 @@ describe( '@elementor/editor-site-navigation - PageListItem', () => {
|
|
|
72
72
|
const actions = [ 'View Page', 'Rename', 'Duplicate', 'Delete', 'Set as homepage' ];
|
|
73
73
|
|
|
74
74
|
// Act.
|
|
75
|
-
|
|
76
|
-
const buttons = getAllByRole( 'button' );
|
|
75
|
+
render( <PageListItem page={ page } /> );
|
|
76
|
+
const buttons = screen.getAllByRole( 'button' );
|
|
77
77
|
// Button to open menu
|
|
78
78
|
const button = buttons[ 1 ];
|
|
79
79
|
|
|
@@ -84,7 +84,7 @@ describe( '@elementor/editor-site-navigation - PageListItem', () => {
|
|
|
84
84
|
|
|
85
85
|
// Assert.
|
|
86
86
|
actions.forEach( ( action ) => {
|
|
87
|
-
const label = getByText( action );
|
|
87
|
+
const label = screen.getByText( action );
|
|
88
88
|
expect( label ).toBeInTheDocument();
|
|
89
89
|
} );
|
|
90
90
|
} );
|
|
@@ -107,8 +107,8 @@ describe( '@elementor/editor-site-navigation - PageListItem', () => {
|
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
// Act.
|
|
110
|
-
|
|
111
|
-
const buttons = getAllByRole( 'button' );
|
|
110
|
+
render( <PageListItem page={ page } /> );
|
|
111
|
+
const buttons = screen.getAllByRole( 'button' );
|
|
112
112
|
const button = buttons[ 0 ];
|
|
113
113
|
|
|
114
114
|
act( () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import PagesCollapsibleList from '../pages-collapsible-list';
|
|
4
4
|
|
|
5
5
|
jest.mock( '../../../../hooks/use-posts', () => ( {
|
|
@@ -29,29 +29,29 @@ describe( '@elementor/editor-site-navigation - PagesCollapsibleList', () => {
|
|
|
29
29
|
|
|
30
30
|
it( 'should render closed list', () => {
|
|
31
31
|
// Act.
|
|
32
|
-
|
|
32
|
+
render(
|
|
33
33
|
<PagesCollapsibleList isOpenByDefault={ false } />,
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
// Assert.
|
|
37
|
-
const label = getByText( `Pages (3)` );
|
|
37
|
+
const label = screen.getByText( `Pages (3)` );
|
|
38
38
|
expect( label ).toBeInTheDocument();
|
|
39
39
|
|
|
40
|
-
const postInList = queryByText( 'Services' );
|
|
41
|
-
expect( postInList ).
|
|
40
|
+
const postInList = screen.queryByText( 'Services' );
|
|
41
|
+
expect( postInList ).not.toBeInTheDocument();
|
|
42
42
|
} );
|
|
43
43
|
|
|
44
44
|
it( 'should render open list', () => {
|
|
45
45
|
// Act.
|
|
46
|
-
|
|
46
|
+
render(
|
|
47
47
|
<PagesCollapsibleList isOpenByDefault={ true } />,
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
// Assert.
|
|
51
|
-
const label = getByText( `Pages (3)` );
|
|
51
|
+
const label = screen.getByText( `Pages (3)` );
|
|
52
52
|
expect( label ).toBeInTheDocument();
|
|
53
53
|
|
|
54
|
-
const postInList = getByText( 'Services' );
|
|
54
|
+
const postInList = screen.getByText( 'Services' );
|
|
55
55
|
expect( postInList ).toBeInTheDocument();
|
|
56
56
|
} );
|
|
57
57
|
} );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { fireEvent, render, waitFor } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import { useHostDocument, useActiveDocument, useNavigateToDocument } from '@elementor/editor-documents';
|
|
4
4
|
import RecentlyEdited from '../recently-edited';
|
|
5
5
|
import { createMockDocument } from 'test-utils';
|
|
@@ -45,14 +45,14 @@ describe( '@elementor/recently-edited - Top bar add new page', () => {
|
|
|
45
45
|
|
|
46
46
|
jest.mocked( useRecentPosts ).mockReturnValue( { isLoading, recentPosts } );
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
render( <RecentlyEdited /> );
|
|
49
49
|
|
|
50
50
|
// Act.
|
|
51
|
-
const buttons = getAllByRole( 'button' );
|
|
51
|
+
const buttons = screen.getAllByRole( 'button' );
|
|
52
52
|
fireEvent.click( buttons[ 0 ] ); // Opens the recently edited menu
|
|
53
53
|
|
|
54
54
|
// Assert.
|
|
55
|
-
const label = getByText( 'Add new page', { exact: false } );
|
|
55
|
+
const label = screen.getByText( 'Add new page', { exact: false } );
|
|
56
56
|
expect( label ).toBeInTheDocument();
|
|
57
57
|
} );
|
|
58
58
|
|
|
@@ -69,22 +69,21 @@ describe( '@elementor/recently-edited - Top bar add new page', () => {
|
|
|
69
69
|
jest.mocked( useCreatePage ).mockReturnValue( { isLoading, create } );
|
|
70
70
|
jest.mocked( useNavigateToDocument ).mockReturnValue( navigateToDocument );
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
render( <RecentlyEdited /> );
|
|
73
73
|
|
|
74
74
|
// Act.
|
|
75
|
-
const buttons = getAllByRole( 'button' );
|
|
75
|
+
const buttons = screen.getAllByRole( 'button' );
|
|
76
76
|
fireEvent.click( buttons[ 0 ] ); // Opens the recently edited menu
|
|
77
77
|
|
|
78
|
-
const addNewPage = getByText( 'Add new page', { exact: false } );
|
|
78
|
+
const addNewPage = screen.getByText( 'Add new page', { exact: false } );
|
|
79
79
|
fireEvent.click( addNewPage );
|
|
80
80
|
|
|
81
81
|
// Assert.
|
|
82
|
-
|
|
83
|
-
expect( create ).toHaveBeenCalledTimes( 1 );
|
|
82
|
+
expect( create ).toHaveBeenCalledTimes( 1 );
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
await waitFor( () => expect( navigateToDocument ).toHaveBeenCalledTimes( 1 ) );
|
|
85
|
+
|
|
86
|
+
expect( navigateToDocument ).toHaveBeenCalledWith( 123 );
|
|
88
87
|
} );
|
|
89
88
|
} );
|
|
90
89
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
3
|
import { useHostDocument, useActiveDocument, useNavigateToDocument } from '@elementor/editor-documents';
|
|
4
4
|
import RecentlyEdited from '../recently-edited';
|
|
5
5
|
import { createMockDocument } from 'test-utils';
|
|
@@ -31,11 +31,11 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
31
31
|
|
|
32
32
|
it( 'should show the title of the active document without its status when the document is published', async () => {
|
|
33
33
|
// Act.
|
|
34
|
-
|
|
34
|
+
render( <RecentlyEdited /> );
|
|
35
35
|
|
|
36
36
|
// Assert.
|
|
37
|
-
expect(
|
|
38
|
-
expect( queryByText( '(publish)' ) ).not.
|
|
37
|
+
expect( screen.getByText( 'Active Document' ) ).toBeInTheDocument();
|
|
38
|
+
expect( screen.queryByText( '(publish)' ) ).not.toBeInTheDocument();
|
|
39
39
|
} );
|
|
40
40
|
|
|
41
41
|
it( 'should show the title of the active document with its status when the document is not published', async () => {
|
|
@@ -52,11 +52,11 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
// Act.
|
|
55
|
-
|
|
55
|
+
render( <RecentlyEdited /> );
|
|
56
56
|
|
|
57
57
|
// Assert.
|
|
58
|
-
expect(
|
|
59
|
-
expect(
|
|
58
|
+
expect( screen.getByText( 'Active Document' ) ).toBeInTheDocument();
|
|
59
|
+
expect( screen.getByText( '(Draft)' ) ).toBeInTheDocument();
|
|
60
60
|
} );
|
|
61
61
|
|
|
62
62
|
it( 'should show the title of the host document when there is no active document', () => {
|
|
@@ -64,10 +64,10 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
64
64
|
jest.mocked( useActiveDocument ).mockImplementation( () => null );
|
|
65
65
|
|
|
66
66
|
// Act.
|
|
67
|
-
|
|
67
|
+
render( <RecentlyEdited /> );
|
|
68
68
|
|
|
69
69
|
// Assert.
|
|
70
|
-
expect(
|
|
70
|
+
expect( screen.getByText( 'Host Document' ) ).toBeInTheDocument();
|
|
71
71
|
} );
|
|
72
72
|
|
|
73
73
|
it( 'should show the title of the host document when the active document is kit', () => {
|
|
@@ -85,10 +85,10 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
// Act.
|
|
88
|
-
|
|
88
|
+
render( <RecentlyEdited /> );
|
|
89
89
|
|
|
90
90
|
// Assert.
|
|
91
|
-
expect(
|
|
91
|
+
expect( screen.getByText( 'Host Document' ) ).toBeInTheDocument();
|
|
92
92
|
} );
|
|
93
93
|
|
|
94
94
|
it( 'should show nothing if there are no documents', () => {
|
|
@@ -97,11 +97,11 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
97
97
|
jest.mocked( useHostDocument ).mockImplementation( () => null );
|
|
98
98
|
|
|
99
99
|
// Act.
|
|
100
|
-
|
|
100
|
+
render( <RecentlyEdited /> );
|
|
101
101
|
|
|
102
102
|
// Assert.
|
|
103
|
-
expect( queryByText( 'Host Document' ) ).not.
|
|
104
|
-
expect( queryByText( 'Active Document' ) ).not.
|
|
103
|
+
expect( screen.queryByText( 'Host Document' ) ).not.toBeInTheDocument();
|
|
104
|
+
expect( screen.queryByText( 'Active Document' ) ).not.toBeInTheDocument();
|
|
105
105
|
} );
|
|
106
106
|
|
|
107
107
|
it( 'should show empty state', () => {
|
|
@@ -122,14 +122,14 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
122
122
|
|
|
123
123
|
jest.mocked( useRecentPosts ).mockReturnValue( { isLoading, recentPosts } );
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
render( <RecentlyEdited /> );
|
|
126
126
|
|
|
127
127
|
// Act.
|
|
128
|
-
const buttons = getAllByRole( 'button' );
|
|
128
|
+
const buttons = screen.getAllByRole( 'button' );
|
|
129
129
|
fireEvent.click( buttons[ 0 ] ); // Opens the recently edited menu
|
|
130
130
|
|
|
131
131
|
// Assert.
|
|
132
|
-
const label = getByText( 'There are no other pages or templates on this site yet', { exact: false } );
|
|
132
|
+
const label = screen.getByText( 'There are no other pages or templates on this site yet', { exact: false } );
|
|
133
133
|
expect( label ).toBeInTheDocument();
|
|
134
134
|
} );
|
|
135
135
|
|
|
@@ -161,20 +161,20 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
161
161
|
|
|
162
162
|
jest.mocked( useRecentPosts ).mockReturnValue( { isLoading, recentPosts } );
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
render( <RecentlyEdited /> );
|
|
165
165
|
|
|
166
166
|
// Act.
|
|
167
|
-
const buttons = getAllByRole( 'button' );
|
|
167
|
+
const buttons = screen.getAllByRole( 'button' );
|
|
168
168
|
fireEvent.click( buttons[ 0 ] ); // Opens the recently edited menu
|
|
169
169
|
|
|
170
170
|
// Assert.
|
|
171
|
-
const menu = getByRole( 'menu' );
|
|
171
|
+
const menu = screen.getByRole( 'menu' );
|
|
172
172
|
expect( menu ).toBeInTheDocument();
|
|
173
173
|
|
|
174
|
-
const label = getByText( 'Recent' );
|
|
174
|
+
const label = screen.getByText( 'Recent' );
|
|
175
175
|
expect( label ).toBeInTheDocument();
|
|
176
176
|
|
|
177
|
-
expect( getByText( 'Test post' ) ).toBeInTheDocument();
|
|
177
|
+
expect( screen.getByText( 'Test post' ) ).toBeInTheDocument();
|
|
178
178
|
} );
|
|
179
179
|
|
|
180
180
|
it( 'should render titles with HTML entities', () => {
|
|
@@ -219,17 +219,17 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
219
219
|
jest.mocked( useRecentPosts ).mockReturnValue( { isLoading, recentPosts } );
|
|
220
220
|
|
|
221
221
|
// Act.
|
|
222
|
-
|
|
222
|
+
render( <RecentlyEdited /> );
|
|
223
223
|
|
|
224
224
|
// Assert - the document title should be rendered with the HTML entity.
|
|
225
|
-
expect( getByText( 'Header title with special char ¥' ) ).toBeInTheDocument();
|
|
225
|
+
expect( screen.getByText( 'Header title with special char ¥' ) ).toBeInTheDocument();
|
|
226
226
|
|
|
227
227
|
// Open the posts list.
|
|
228
|
-
fireEvent.click( getByRole( 'button' ) );
|
|
228
|
+
fireEvent.click( screen.getByRole( 'button' ) );
|
|
229
229
|
|
|
230
230
|
// Assert - the post title should be rendered with the HTML entity.
|
|
231
|
-
expect( getByText( 'Post title with <h1>HTML</h1>' ) ).toBeInTheDocument();
|
|
232
|
-
expect( getByText( 'Post title with <HTML entities>' ) ).toBeInTheDocument();
|
|
231
|
+
expect( screen.getByText( 'Post title with <h1>HTML</h1>' ) ).toBeInTheDocument();
|
|
232
|
+
expect( screen.getByText( 'Post title with <HTML entities>' ) ).toBeInTheDocument();
|
|
233
233
|
} );
|
|
234
234
|
|
|
235
235
|
it( 'should navigate to document on click', () => {
|
|
@@ -253,13 +253,13 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
|
|
|
253
253
|
} ],
|
|
254
254
|
} );
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
render( <RecentlyEdited /> );
|
|
257
257
|
|
|
258
258
|
// Open the posts list.
|
|
259
|
-
fireEvent.click( getByRole( 'button' ) );
|
|
259
|
+
fireEvent.click( screen.getByRole( 'button' ) );
|
|
260
260
|
|
|
261
261
|
// Act.
|
|
262
|
-
fireEvent.click( getByText( 'Test post' ) );
|
|
262
|
+
fireEvent.click( screen.getByText( 'Test post' ) );
|
|
263
263
|
|
|
264
264
|
// Assert.
|
|
265
265
|
expect( navigateToDocument ).toHaveBeenCalledTimes( 1 );
|
package/src/env.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { parseEnv } from '@elementor/env';
|
|
2
2
|
|
|
3
3
|
export const { env, validateEnv } = parseEnv<{
|
|
4
|
-
|
|
4
|
+
is_pages_panel_active: boolean;
|
|
5
5
|
}>( '@elementor/editor-site-navigation', ( envData ) => {
|
|
6
6
|
return envData as {
|
|
7
|
-
|
|
7
|
+
is_pages_panel_active: boolean;
|
|
8
8
|
};
|
|
9
9
|
} );
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renderHook } from '@testing-library/react';
|
|
2
2
|
import apiFetch from '@wordpress/api-fetch';
|
|
3
3
|
import useCreatePage, { endpointPath } from '../use-create-page';
|
|
4
4
|
|
|
@@ -29,13 +29,11 @@ describe( '@elementor/recently-edited/use-page', () => {
|
|
|
29
29
|
create();
|
|
30
30
|
|
|
31
31
|
// Assert.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} );
|
|
38
|
-
expect( apiFetch ).toHaveBeenCalledTimes( 1 );
|
|
32
|
+
expect( apiFetch ).toHaveBeenCalledTimes( 1 );
|
|
33
|
+
expect( apiFetch ).toHaveBeenCalledWith( {
|
|
34
|
+
data: { post_type: 'page' },
|
|
35
|
+
method: 'POST',
|
|
36
|
+
path: endpointPath,
|
|
39
37
|
} );
|
|
40
38
|
} );
|
|
41
39
|
} );
|
|
@@ -29,12 +29,10 @@ describe( '@elementor/site-settings/use-posts', () => {
|
|
|
29
29
|
// Assert.
|
|
30
30
|
const expectedPath = `/wp/v2/pages?status=any&per_page=-1&_fields=${ encodeURIComponent( 'id,type,title,link,status' ) }`;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
path: expectedPath,
|
|
35
|
-
} );
|
|
36
|
-
expect( apiFetch ).toHaveBeenCalledTimes( 1 );
|
|
32
|
+
expect( apiFetch ).toHaveBeenCalledWith( {
|
|
33
|
+
path: expectedPath,
|
|
37
34
|
} );
|
|
35
|
+
expect( apiFetch ).toHaveBeenCalledTimes( 1 );
|
|
38
36
|
|
|
39
37
|
await waitFor( () => {
|
|
40
38
|
return component.result.current.isSuccess;
|
|
@@ -30,11 +30,11 @@ describe( 'useRecentPosts', () => {
|
|
|
30
30
|
|
|
31
31
|
const { result } = renderHook( () => useRecentPosts( 1 ) );
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} );
|
|
33
|
+
expect( apiFetch ).toHaveBeenCalledWith( {
|
|
34
|
+
path: endpointPath + '?posts_per_page=5&post__not_in=1',
|
|
35
|
+
} );
|
|
37
36
|
|
|
37
|
+
await waitFor( () => {
|
|
38
38
|
expect( result.current.recentPosts ).toBe( posts );
|
|
39
39
|
} );
|
|
40
40
|
} );
|
package/src/init.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { env } from './env';
|
|
|
8
8
|
export default function init() {
|
|
9
9
|
registerTopBarMenuItems();
|
|
10
10
|
// TODO 06/06/2023 : remove if when we are production ready
|
|
11
|
-
if ( env.
|
|
11
|
+
if ( env.is_pages_panel_active ) {
|
|
12
12
|
registerPanel( panel );
|
|
13
13
|
registerButton();
|
|
14
14
|
}
|
|
@@ -17,7 +17,7 @@ export default function init() {
|
|
|
17
17
|
function registerTopBarMenuItems() {
|
|
18
18
|
injectIntoPageIndication( {
|
|
19
19
|
id: 'document-recently-edited',
|
|
20
|
-
|
|
20
|
+
component: RecentlyEdited,
|
|
21
21
|
} );
|
|
22
22
|
}
|
|
23
23
|
|