@wordpress/editor 12.14.1-next.d6164808d3.0 → 12.16.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 +8 -0
- package/build/components/post-featured-image/index.js +6 -4
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-publish-panel/index.js +6 -1
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-schedule/index.js +1 -1
- package/build/components/post-schedule/index.js.map +1 -1
- package/build/components/post-schedule/label.js +2 -2
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +6 -15
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-trash/index.js +5 -1
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/post-url/label.js +1 -1
- package/build/components/post-url/label.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +13 -5
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/actions.js +7 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +26 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +14 -0
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/post-featured-image/index.js +7 -5
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +7 -2
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-schedule/index.js +2 -4
- package/build-module/components/post-schedule/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js +3 -4
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +7 -15
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-trash/index.js +5 -1
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/post-url/label.js +1 -1
- package/build-module/components/post-url/label.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +14 -6
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/actions.js +7 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +24 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +11 -0
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +28 -28
- package/src/components/document-outline/test/__snapshots__/index.js.snap +92 -48
- package/src/components/document-outline/test/index.js +27 -44
- package/src/components/page-attributes/test/order.js +57 -64
- package/src/components/post-featured-image/index.js +3 -3
- package/src/components/post-publish-button/test/index.js +88 -71
- package/src/components/post-publish-panel/index.js +7 -6
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +670 -130
- package/src/components/post-publish-panel/test/index.js +30 -13
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +33 -24
- package/src/components/post-saved-state/test/index.js +31 -14
- package/src/components/post-schedule/index.js +2 -2
- package/src/components/post-schedule/label.js +3 -3
- package/src/components/post-schedule/test/label.js +7 -7
- package/src/components/post-slug/test/index.js +12 -25
- package/src/components/post-taxonomies/flat-term-selector.js +7 -18
- package/src/components/post-taxonomies/test/index.js +112 -44
- package/src/components/post-trash/index.js +5 -2
- package/src/components/post-url/label.js +1 -1
- package/src/components/provider/use-block-editor-settings.js +28 -8
- package/src/components/theme-support-check/test/index.js +13 -15
- package/src/store/actions.js +2 -0
- package/src/store/reducer.js +21 -0
- package/src/store/selectors.js +11 -0
- package/src/store/test/actions.js +42 -0
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Button } from '@wordpress/components';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* Internal dependencies
|
|
@@ -16,27 +12,25 @@ import { PostPublishButton } from '../';
|
|
|
16
12
|
describe( 'PostPublishButton', () => {
|
|
17
13
|
describe( 'aria-disabled', () => {
|
|
18
14
|
it( 'should be true if post is currently saving', () => {
|
|
19
|
-
|
|
20
|
-
<PostPublishButton isPublishable isSaveable isSaving />
|
|
21
|
-
);
|
|
15
|
+
render( <PostPublishButton isPublishable isSaveable isSaving /> );
|
|
22
16
|
|
|
23
|
-
expect(
|
|
24
|
-
|
|
25
|
-
);
|
|
17
|
+
expect(
|
|
18
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
19
|
+
).toHaveAttribute( 'aria-disabled', 'true' );
|
|
26
20
|
} );
|
|
27
21
|
|
|
28
22
|
it( 'should be true if forceIsSaving is true', () => {
|
|
29
|
-
|
|
23
|
+
render(
|
|
30
24
|
<PostPublishButton isPublishable isSaveable forceIsSaving />
|
|
31
25
|
);
|
|
32
26
|
|
|
33
|
-
expect(
|
|
34
|
-
|
|
35
|
-
);
|
|
27
|
+
expect(
|
|
28
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
29
|
+
).toHaveAttribute( 'aria-disabled', 'true' );
|
|
36
30
|
} );
|
|
37
31
|
|
|
38
32
|
it( 'should be true if post is not publishable and not forceIsDirty', () => {
|
|
39
|
-
|
|
33
|
+
render(
|
|
40
34
|
<PostPublishButton
|
|
41
35
|
isSaveable
|
|
42
36
|
isPublishable={ false }
|
|
@@ -44,23 +38,21 @@ describe( 'PostPublishButton', () => {
|
|
|
44
38
|
/>
|
|
45
39
|
);
|
|
46
40
|
|
|
47
|
-
expect(
|
|
48
|
-
|
|
49
|
-
);
|
|
41
|
+
expect(
|
|
42
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
43
|
+
).toHaveAttribute( 'aria-disabled', 'true' );
|
|
50
44
|
} );
|
|
51
45
|
|
|
52
46
|
it( 'should be true if post is not saveable', () => {
|
|
53
|
-
|
|
54
|
-
<PostPublishButton isPublishable isSaveable={ false } />
|
|
55
|
-
);
|
|
47
|
+
render( <PostPublishButton isPublishable isSaveable={ false } /> );
|
|
56
48
|
|
|
57
|
-
expect(
|
|
58
|
-
|
|
59
|
-
);
|
|
49
|
+
expect(
|
|
50
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
51
|
+
).toHaveAttribute( 'aria-disabled', 'true' );
|
|
60
52
|
} );
|
|
61
53
|
|
|
62
54
|
it( 'should be true if post saving is locked', () => {
|
|
63
|
-
|
|
55
|
+
render(
|
|
64
56
|
<PostPublishButton
|
|
65
57
|
isPublishable
|
|
66
58
|
isSaveable
|
|
@@ -68,13 +60,13 @@ describe( 'PostPublishButton', () => {
|
|
|
68
60
|
/>
|
|
69
61
|
);
|
|
70
62
|
|
|
71
|
-
expect(
|
|
72
|
-
|
|
73
|
-
);
|
|
63
|
+
expect(
|
|
64
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
65
|
+
).toHaveAttribute( 'aria-disabled', 'true' );
|
|
74
66
|
} );
|
|
75
67
|
|
|
76
68
|
it( 'should be false if post is saveable but not publishable and forceIsDirty is true', () => {
|
|
77
|
-
|
|
69
|
+
render(
|
|
78
70
|
<PostPublishButton
|
|
79
71
|
isSaveable
|
|
80
72
|
isPublishable={ false }
|
|
@@ -82,113 +74,136 @@ describe( 'PostPublishButton', () => {
|
|
|
82
74
|
/>
|
|
83
75
|
);
|
|
84
76
|
|
|
85
|
-
expect(
|
|
86
|
-
|
|
87
|
-
);
|
|
77
|
+
expect(
|
|
78
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
79
|
+
).toHaveAttribute( 'aria-disabled', 'false' );
|
|
88
80
|
} );
|
|
89
81
|
|
|
90
82
|
it( 'should be false if post is publishave and saveable', () => {
|
|
91
|
-
|
|
92
|
-
<PostPublishButton isPublishable isSaveable />
|
|
93
|
-
);
|
|
83
|
+
render( <PostPublishButton isPublishable isSaveable /> );
|
|
94
84
|
|
|
95
|
-
expect(
|
|
96
|
-
|
|
97
|
-
);
|
|
85
|
+
expect(
|
|
86
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
87
|
+
).toHaveAttribute( 'aria-disabled', 'false' );
|
|
98
88
|
} );
|
|
99
89
|
} );
|
|
100
90
|
|
|
101
91
|
describe( 'publish status', () => {
|
|
102
|
-
it( 'should be pending for contributor', () => {
|
|
92
|
+
it( 'should be pending for contributor', async () => {
|
|
93
|
+
const user = userEvent.setup( {
|
|
94
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
95
|
+
} );
|
|
103
96
|
const onStatusChange = jest.fn();
|
|
104
97
|
const onSave = jest.fn();
|
|
105
|
-
|
|
98
|
+
render(
|
|
106
99
|
<PostPublishButton
|
|
107
100
|
hasPublishAction={ false }
|
|
108
101
|
onStatusChange={ onStatusChange }
|
|
109
102
|
onSave={ onSave }
|
|
110
|
-
isSaveable
|
|
111
|
-
isPublishable
|
|
103
|
+
isSaveable
|
|
104
|
+
isPublishable
|
|
112
105
|
/>
|
|
113
106
|
);
|
|
114
107
|
|
|
115
|
-
|
|
108
|
+
await user.click(
|
|
109
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
110
|
+
);
|
|
116
111
|
|
|
117
112
|
expect( onStatusChange ).toHaveBeenCalledWith( 'pending' );
|
|
118
113
|
} );
|
|
119
114
|
|
|
120
|
-
it( 'should be future for scheduled post', () => {
|
|
115
|
+
it( 'should be future for scheduled post', async () => {
|
|
116
|
+
const user = userEvent.setup( {
|
|
117
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
118
|
+
} );
|
|
121
119
|
const onStatusChange = jest.fn();
|
|
122
120
|
const onSave = jest.fn();
|
|
123
|
-
|
|
121
|
+
render(
|
|
124
122
|
<PostPublishButton
|
|
125
|
-
hasPublishAction
|
|
123
|
+
hasPublishAction
|
|
126
124
|
onStatusChange={ onStatusChange }
|
|
127
125
|
onSave={ onSave }
|
|
128
126
|
isBeingScheduled
|
|
129
|
-
isSaveable
|
|
130
|
-
isPublishable
|
|
127
|
+
isSaveable
|
|
128
|
+
isPublishable
|
|
131
129
|
/>
|
|
132
130
|
);
|
|
133
131
|
|
|
134
|
-
|
|
132
|
+
await user.click(
|
|
133
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
134
|
+
);
|
|
135
135
|
|
|
136
136
|
expect( onStatusChange ).toHaveBeenCalledWith( 'future' );
|
|
137
137
|
} );
|
|
138
138
|
|
|
139
|
-
it( 'should be private for private visibility', () => {
|
|
139
|
+
it( 'should be private for private visibility', async () => {
|
|
140
|
+
const user = userEvent.setup( {
|
|
141
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
142
|
+
} );
|
|
140
143
|
const onStatusChange = jest.fn();
|
|
141
144
|
const onSave = jest.fn();
|
|
142
|
-
|
|
145
|
+
render(
|
|
143
146
|
<PostPublishButton
|
|
144
|
-
hasPublishAction
|
|
147
|
+
hasPublishAction
|
|
145
148
|
onStatusChange={ onStatusChange }
|
|
146
149
|
onSave={ onSave }
|
|
147
150
|
visibility="private"
|
|
148
|
-
isSaveable
|
|
149
|
-
isPublishable
|
|
151
|
+
isSaveable
|
|
152
|
+
isPublishable
|
|
150
153
|
/>
|
|
151
154
|
);
|
|
152
155
|
|
|
153
|
-
|
|
156
|
+
await user.click(
|
|
157
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
158
|
+
);
|
|
154
159
|
|
|
155
160
|
expect( onStatusChange ).toHaveBeenCalledWith( 'private' );
|
|
156
161
|
} );
|
|
157
162
|
|
|
158
|
-
it( 'should be publish otherwise', () => {
|
|
163
|
+
it( 'should be publish otherwise', async () => {
|
|
164
|
+
const user = userEvent.setup( {
|
|
165
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
166
|
+
} );
|
|
159
167
|
const onStatusChange = jest.fn();
|
|
160
168
|
const onSave = jest.fn();
|
|
161
|
-
|
|
169
|
+
render(
|
|
162
170
|
<PostPublishButton
|
|
163
|
-
hasPublishAction
|
|
171
|
+
hasPublishAction
|
|
164
172
|
onStatusChange={ onStatusChange }
|
|
165
173
|
onSave={ onSave }
|
|
166
|
-
isSaveable
|
|
167
|
-
isPublishable
|
|
174
|
+
isSaveable
|
|
175
|
+
isPublishable
|
|
168
176
|
/>
|
|
169
177
|
);
|
|
170
178
|
|
|
171
|
-
|
|
179
|
+
await user.click(
|
|
180
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
181
|
+
);
|
|
172
182
|
|
|
173
183
|
expect( onStatusChange ).toHaveBeenCalledWith( 'publish' );
|
|
174
184
|
} );
|
|
175
185
|
} );
|
|
176
186
|
|
|
177
187
|
describe( 'click', () => {
|
|
178
|
-
it( 'should save with status', () => {
|
|
188
|
+
it( 'should save with status', async () => {
|
|
189
|
+
const user = userEvent.setup( {
|
|
190
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
191
|
+
} );
|
|
179
192
|
const onStatusChange = jest.fn();
|
|
180
193
|
const onSave = jest.fn();
|
|
181
|
-
|
|
194
|
+
render(
|
|
182
195
|
<PostPublishButton
|
|
183
|
-
hasPublishAction
|
|
196
|
+
hasPublishAction
|
|
184
197
|
onStatusChange={ onStatusChange }
|
|
185
198
|
onSave={ onSave }
|
|
186
|
-
isSaveable
|
|
187
|
-
isPublishable
|
|
199
|
+
isSaveable
|
|
200
|
+
isPublishable
|
|
188
201
|
/>
|
|
189
202
|
);
|
|
190
203
|
|
|
191
|
-
|
|
204
|
+
await user.click(
|
|
205
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
206
|
+
);
|
|
192
207
|
|
|
193
208
|
expect( onStatusChange ).toHaveBeenCalledWith( 'publish' );
|
|
194
209
|
expect( onSave ).toHaveBeenCalled();
|
|
@@ -196,8 +211,10 @@ describe( 'PostPublishButton', () => {
|
|
|
196
211
|
} );
|
|
197
212
|
|
|
198
213
|
it( 'should have save modifier class', () => {
|
|
199
|
-
|
|
214
|
+
render( <PostPublishButton isSaving isPublished /> );
|
|
200
215
|
|
|
201
|
-
expect(
|
|
216
|
+
expect(
|
|
217
|
+
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
218
|
+
).toHaveClass( 'is-busy' );
|
|
202
219
|
} );
|
|
203
220
|
} );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get
|
|
4
|
+
import { get } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -69,11 +69,12 @@ export class PostPublishPanel extends Component {
|
|
|
69
69
|
PrePublishExtension,
|
|
70
70
|
...additionalProps
|
|
71
71
|
} = this.props;
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
const {
|
|
73
|
+
hasPublishAction,
|
|
74
|
+
isDirty,
|
|
75
|
+
isPostTypeViewable,
|
|
76
|
+
...propsForPanel
|
|
77
|
+
} = additionalProps;
|
|
77
78
|
const isPublishedOrScheduled =
|
|
78
79
|
isPublished || ( isScheduled && isBeingScheduled );
|
|
79
80
|
const isPrePublish = ! isPublishedOrScheduled && ! isSaving;
|