@wordpress/editor 12.17.1-next.4d3b314fd5.0 → 12.18.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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 12.18.0 (2022-10-05)
6
+
5
7
  ## 12.17.0 (2022-09-21)
6
8
 
7
9
  ## 12.16.0 (2022-09-13)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "12.17.1-next.4d3b314fd5.0",
3
+ "version": "12.18.0",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,32 +31,32 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.18.1-next.4d3b314fd5.0",
35
- "@wordpress/api-fetch": "^6.15.1-next.4d3b314fd5.0",
36
- "@wordpress/blob": "^3.18.1-next.4d3b314fd5.0",
37
- "@wordpress/block-editor": "^10.1.1-next.4d3b314fd5.0",
38
- "@wordpress/blocks": "^11.18.1-next.4d3b314fd5.0",
39
- "@wordpress/components": "^21.1.2-next.4d3b314fd5.0",
40
- "@wordpress/compose": "^5.16.1-next.4d3b314fd5.0",
41
- "@wordpress/core-data": "^5.1.1-next.4d3b314fd5.0",
42
- "@wordpress/data": "^7.2.1-next.4d3b314fd5.0",
43
- "@wordpress/date": "^4.18.1-next.4d3b314fd5.0",
44
- "@wordpress/deprecated": "^3.18.1-next.4d3b314fd5.0",
45
- "@wordpress/element": "^4.16.1-next.4d3b314fd5.0",
46
- "@wordpress/hooks": "^3.18.1-next.4d3b314fd5.0",
47
- "@wordpress/html-entities": "^3.18.1-next.4d3b314fd5.0",
48
- "@wordpress/i18n": "^4.18.1-next.4d3b314fd5.0",
49
- "@wordpress/icons": "^9.9.1-next.4d3b314fd5.0",
50
- "@wordpress/keyboard-shortcuts": "^3.16.1-next.4d3b314fd5.0",
51
- "@wordpress/keycodes": "^3.18.1-next.4d3b314fd5.0",
52
- "@wordpress/media-utils": "^4.9.1-next.4d3b314fd5.0",
53
- "@wordpress/notices": "^3.18.1-next.4d3b314fd5.0",
54
- "@wordpress/preferences": "^2.10.1-next.4d3b314fd5.0",
55
- "@wordpress/reusable-blocks": "^3.16.1-next.4d3b314fd5.0",
56
- "@wordpress/rich-text": "^5.16.1-next.4d3b314fd5.0",
57
- "@wordpress/server-side-render": "^3.16.1-next.4d3b314fd5.0",
58
- "@wordpress/url": "^3.19.1-next.4d3b314fd5.0",
59
- "@wordpress/wordcount": "^3.18.1-next.4d3b314fd5.0",
34
+ "@wordpress/a11y": "^3.19.0",
35
+ "@wordpress/api-fetch": "^6.16.0",
36
+ "@wordpress/blob": "^3.19.0",
37
+ "@wordpress/block-editor": "^10.2.0",
38
+ "@wordpress/blocks": "^11.18.0",
39
+ "@wordpress/components": "^21.2.0",
40
+ "@wordpress/compose": "^5.17.0",
41
+ "@wordpress/core-data": "^5.2.0",
42
+ "@wordpress/data": "^7.3.0",
43
+ "@wordpress/date": "^4.19.0",
44
+ "@wordpress/deprecated": "^3.19.0",
45
+ "@wordpress/element": "^4.17.0",
46
+ "@wordpress/hooks": "^3.19.0",
47
+ "@wordpress/html-entities": "^3.19.0",
48
+ "@wordpress/i18n": "^4.19.0",
49
+ "@wordpress/icons": "^9.10.0",
50
+ "@wordpress/keyboard-shortcuts": "^3.17.0",
51
+ "@wordpress/keycodes": "^3.19.0",
52
+ "@wordpress/media-utils": "^4.10.0",
53
+ "@wordpress/notices": "^3.19.0",
54
+ "@wordpress/preferences": "^2.11.0",
55
+ "@wordpress/reusable-blocks": "^3.17.0",
56
+ "@wordpress/rich-text": "^5.17.0",
57
+ "@wordpress/server-side-render": "^3.17.0",
58
+ "@wordpress/url": "^3.20.0",
59
+ "@wordpress/wordcount": "^3.19.0",
60
60
  "classnames": "^2.3.1",
61
61
  "lodash": "^4.17.21",
62
62
  "memize": "^1.1.0",
@@ -71,5 +71,5 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "25054766423cb49d959eb656c2533530073ff5c2"
74
+ "gitHead": "8d42d2febb7d0ba8372a33e560a62f5a5f6a9112"
75
75
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { shallow } from 'enzyme';
4
+ import { render } from '@testing-library/react';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -9,7 +9,6 @@ import { shallow } from 'enzyme';
9
9
  import { AutosaveMonitor } from '../';
10
10
 
11
11
  describe( 'AutosaveMonitor', () => {
12
- let wrapper;
13
12
  let setAutosaveTimerSpy;
14
13
  beforeEach( () => {
15
14
  jest.useFakeTimers( 'legacy' );
@@ -17,9 +16,6 @@ describe( 'AutosaveMonitor', () => {
17
16
  AutosaveMonitor.prototype,
18
17
  'setAutosaveTimer'
19
18
  );
20
- wrapper = shallow( <AutosaveMonitor isDirty />, {
21
- lifecycleExperimental: true,
22
- } );
23
19
  } );
24
20
 
25
21
  afterEach( () => {
@@ -29,128 +25,167 @@ describe( 'AutosaveMonitor', () => {
29
25
  setAutosaveTimerSpy.mockClear();
30
26
  } );
31
27
 
28
+ it( 'should render nothing', () => {
29
+ const { container } = render( <AutosaveMonitor isDirty /> );
30
+
31
+ expect( container ).toBeEmptyDOMElement();
32
+ } );
33
+
32
34
  it( 'should start autosave timer after being mounted', () => {
35
+ render( <AutosaveMonitor isDirty /> );
36
+
33
37
  expect( setAutosaveTimerSpy ).toHaveBeenCalled();
34
38
  } );
35
39
 
36
40
  it( 'should clear the autosave timer after being unmounted', () => {
37
- wrapper.unmount();
41
+ const { rerender } = render( <AutosaveMonitor isDirty /> );
42
+
43
+ rerender( <div /> );
44
+
45
+ expect( clearTimeout ).toHaveBeenCalled();
46
+ } );
47
+
48
+ it( 'should clear and restart autosave timer when the interval changes', () => {
49
+ const { rerender } = render( <AutosaveMonitor isDirty /> );
50
+
51
+ rerender( <AutosaveMonitor isDirty interval={ 999 } /> );
52
+
38
53
  expect( clearTimeout ).toHaveBeenCalled();
54
+ expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 2 );
39
55
  } );
40
56
 
41
- describe( '#componentDidUpdate()', () => {
42
- it( 'should clear and restart autosave timer when the interval changes', () => {
43
- wrapper.setProps( { interval: 999 } );
44
- expect( clearTimeout ).toHaveBeenCalled();
45
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 2 );
46
- } );
47
-
48
- it( 'should set needsAutosave=true when editReference changes', () => {
49
- expect( wrapper.instance().needsAutosave ).toBe( false );
50
- wrapper.setProps( {
51
- editsReference: [],
52
- } );
53
- expect( wrapper.instance().needsAutosave ).toBe( true );
54
- } );
55
-
56
- it( 'should set needsAutosave=true when editReference changes and the post becomes dirty', () => {
57
- expect( wrapper.instance().needsAutosave ).toBe( false );
58
- wrapper.setProps( {
59
- isDirty: true,
60
- editsReference: [],
61
- } );
62
- expect( wrapper.instance().needsAutosave ).toBe( true );
63
- } );
64
-
65
- it( 'should not set needsAutosave=true when editReference changes and the post is not dirty anymore', () => {
66
- expect( wrapper.instance().needsAutosave ).toBe( false );
67
- wrapper.setProps( {
68
- isDirty: true,
69
- editsReference: [],
70
- } );
71
- wrapper.setProps( {
72
- isDirty: false,
73
- editsReference: [],
74
- } );
75
- expect( wrapper.instance().needsAutosave ).toBe( false );
76
- } );
77
-
78
- it( 'should set needsAutosave=true when editReference changes and the post is not autosaving', () => {
79
- expect( wrapper.instance().needsAutosave ).toBe( false );
80
- wrapper.setProps( {
81
- isAutosaving: false,
82
- editsReference: [],
83
- } );
84
- expect( wrapper.instance().needsAutosave ).toBe( true );
85
- } );
86
-
87
- it( 'should not set needsAutosave=true when editReference changes and the post started autosaving', () => {
88
- expect( wrapper.instance().needsAutosave ).toBe( false );
89
- wrapper.setProps( {
90
- isAutosaving: false,
91
- editsReference: [],
92
- } );
93
- wrapper.setProps( {
94
- isAutosaving: true,
95
- editsReference: [],
96
- } );
97
- expect( wrapper.instance().needsAutosave ).toBe( false );
98
- } );
57
+ it( 'should autosave when `editReference` changes', () => {
58
+ const autosave = jest.fn();
59
+ const { rerender } = render(
60
+ <AutosaveMonitor isDirty isAutosaveable autosave={ autosave } />
61
+ );
62
+
63
+ expect( autosave ).not.toHaveBeenCalled();
64
+
65
+ rerender(
66
+ <AutosaveMonitor
67
+ isDirty
68
+ isAutosaveable
69
+ autosave={ autosave }
70
+ editsReference={ [] }
71
+ />
72
+ );
73
+
74
+ jest.runOnlyPendingTimers();
75
+
76
+ expect( autosave ).toHaveBeenCalledTimes( 1 );
99
77
  } );
100
78
 
101
- describe( '#autosaveTimerHandler()', () => {
102
- it( 'should schedule itself in another {interval} ms', () => {
103
- wrapper.setProps( {
104
- isAutosaveable: true,
105
- interval: 5,
106
- } );
107
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 2 );
108
- wrapper.instance().autosaveTimerHandler();
109
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 3 );
110
- expect( setTimeout ).lastCalledWith( expect.any( Function ), 5000 );
111
- } );
112
-
113
- it( 'should schedule itself in 1000 ms if the post is not autosaveable at a time', () => {
114
- wrapper.setProps( {
115
- isAutosaveable: false,
116
- interval: 5,
117
- } );
118
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 2 );
119
- wrapper.instance().autosaveTimerHandler();
120
- expect( setAutosaveTimerSpy ).toHaveBeenCalledTimes( 3 );
121
- expect( setTimeout ).lastCalledWith( expect.any( Function ), 1000 );
122
- } );
123
-
124
- it( 'should call autosave if needsAutosave=true', () => {
125
- const autosave = jest.fn();
126
- wrapper.setProps( {
127
- isAutosaveable: true,
128
- interval: 5,
129
- autosave,
130
- } );
131
- wrapper.instance().needsAutosave = true;
132
- expect( autosave ).toHaveBeenCalledTimes( 0 );
133
- wrapper.instance().autosaveTimerHandler();
134
- expect( autosave ).toHaveBeenCalledTimes( 1 );
135
- } );
136
-
137
- it( 'should not call autosave if needsAutosave is not true', () => {
138
- const autosave = jest.fn();
139
- wrapper.setProps( {
140
- isAutosaveable: true,
141
- interval: 5,
142
- autosave,
143
- } );
144
- wrapper.instance().needsAutosave = false;
145
- expect( autosave ).toHaveBeenCalledTimes( 0 );
146
- wrapper.instance().autosaveTimerHandler();
147
- expect( autosave ).toHaveBeenCalledTimes( 0 );
148
- } );
79
+ it( 'should autosave when `editReference` changes and the post becomes dirty', () => {
80
+ const autosave = jest.fn();
81
+ const { rerender } = render(
82
+ <AutosaveMonitor isAutosaveable autosave={ autosave } />
83
+ );
84
+
85
+ expect( autosave ).not.toHaveBeenCalled();
86
+
87
+ rerender(
88
+ <AutosaveMonitor
89
+ isDirty
90
+ isAutosaveable
91
+ autosave={ autosave }
92
+ editsReference={ [] }
93
+ />
94
+ );
95
+
96
+ jest.runOnlyPendingTimers();
97
+
98
+ expect( autosave ).toHaveBeenCalledTimes( 1 );
149
99
  } );
150
100
 
151
- describe( '#render()', () => {
152
- it( 'should render nothing', () => {
153
- expect( wrapper.type() ).toBe( null );
154
- } );
101
+ it( 'should not autosave when `editReference` changes and the post is not dirty anymore', () => {
102
+ const autosave = jest.fn();
103
+ const { rerender } = render(
104
+ <AutosaveMonitor isDirty isAutosaveable autosave={ autosave } />
105
+ );
106
+
107
+ expect( autosave ).not.toHaveBeenCalled();
108
+
109
+ rerender(
110
+ <AutosaveMonitor
111
+ isAutosaveable
112
+ autosave={ autosave }
113
+ editsReference={ [] }
114
+ />
115
+ );
116
+
117
+ jest.runOnlyPendingTimers();
118
+
119
+ expect( autosave ).not.toHaveBeenCalled();
120
+ } );
121
+
122
+ it( 'should not autosave when `editReference` changes and the post is not autosaving', () => {
123
+ const autosave = jest.fn();
124
+ const { rerender } = render(
125
+ <AutosaveMonitor isAutosaveable autosave={ autosave } />
126
+ );
127
+
128
+ expect( autosave ).not.toHaveBeenCalled();
129
+
130
+ rerender(
131
+ <AutosaveMonitor
132
+ isAutosaveable
133
+ autosave={ autosave }
134
+ isAutosaving={ false }
135
+ editsReference={ [] }
136
+ />
137
+ );
138
+
139
+ jest.runOnlyPendingTimers();
140
+
141
+ expect( autosave ).not.toHaveBeenCalled();
142
+ } );
143
+
144
+ it( 'should not autosave when `editReference` changes and the post started autosaving', () => {
145
+ const autosave = jest.fn();
146
+ const { rerender } = render(
147
+ <AutosaveMonitor
148
+ isAutosaveable
149
+ autosave={ autosave }
150
+ isAutosaving={ false }
151
+ />
152
+ );
153
+
154
+ expect( autosave ).not.toHaveBeenCalled();
155
+
156
+ rerender(
157
+ <AutosaveMonitor
158
+ isAutosaveable
159
+ autosave={ autosave }
160
+ isAutosaving
161
+ editsReference={ [] }
162
+ />
163
+ );
164
+
165
+ jest.runOnlyPendingTimers();
166
+
167
+ expect( autosave ).not.toHaveBeenCalled();
168
+ } );
169
+
170
+ it( 'should schedule itself in another {interval} ms', () => {
171
+ const { rerender } = render( <AutosaveMonitor isDirty /> );
172
+
173
+ rerender( <AutosaveMonitor isDirty isAutosaveable interval={ 5 } /> );
174
+
175
+ jest.runOnlyPendingTimers();
176
+
177
+ expect( setTimeout ).lastCalledWith( expect.any( Function ), 5000 );
178
+ } );
179
+
180
+ it( 'should schedule itself in 1000 ms if the post is not autosaveable at a time', () => {
181
+ const { rerender } = render( <AutosaveMonitor isDirty /> );
182
+
183
+ rerender(
184
+ <AutosaveMonitor isDirty isAutosaveable={ false } interval={ 5 } />
185
+ );
186
+
187
+ jest.runOnlyPendingTimers();
188
+
189
+ expect( setTimeout ).lastCalledWith( expect.any( Function ), 1000 );
155
190
  } );
156
191
  } );