@wordpress/edit-post 6.1.0 → 6.3.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/header/plugin-more-menu-item/index.js +5 -0
  3. package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
  4. package/build/components/header/template-title/delete-template.js +3 -1
  5. package/build/components/header/template-title/delete-template.js.map +1 -1
  6. package/build/components/sidebar/post-link/index.js +1 -1
  7. package/build/components/sidebar/post-link/index.js.map +1 -1
  8. package/build/components/visual-editor/index.js +3 -3
  9. package/build/components/visual-editor/index.js.map +1 -1
  10. package/build/editor.js +4 -6
  11. package/build/editor.js.map +1 -1
  12. package/build/index.js +5 -0
  13. package/build/index.js.map +1 -1
  14. package/build/index.native.js +15 -0
  15. package/build/index.native.js.map +1 -1
  16. package/build/store/actions.js +99 -74
  17. package/build/store/actions.js.map +1 -1
  18. package/build/store/index.js +7 -10
  19. package/build/store/index.js.map +1 -1
  20. package/build/store/reducer.js +0 -118
  21. package/build/store/reducer.js.map +1 -1
  22. package/build/store/selectors.js +95 -34
  23. package/build/store/selectors.js.map +1 -1
  24. package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
  25. package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
  26. package/build-module/components/header/template-title/delete-template.js +3 -1
  27. package/build-module/components/header/template-title/delete-template.js.map +1 -1
  28. package/build-module/components/sidebar/post-link/index.js +1 -1
  29. package/build-module/components/sidebar/post-link/index.js.map +1 -1
  30. package/build-module/components/visual-editor/index.js +3 -3
  31. package/build-module/components/visual-editor/index.js.map +1 -1
  32. package/build-module/editor.js +3 -6
  33. package/build-module/editor.js.map +1 -1
  34. package/build-module/index.js +5 -0
  35. package/build-module/index.js.map +1 -1
  36. package/build-module/index.native.js +13 -0
  37. package/build-module/index.native.js.map +1 -1
  38. package/build-module/store/actions.js +92 -68
  39. package/build-module/store/actions.js.map +1 -1
  40. package/build-module/store/index.js +7 -10
  41. package/build-module/store/index.js.map +1 -1
  42. package/build-module/store/reducer.js +1 -115
  43. package/build-module/store/reducer.js.map +1 -1
  44. package/build-module/store/selectors.js +89 -28
  45. package/build-module/store/selectors.js.map +1 -1
  46. package/build-style/style-rtl.css +1 -4
  47. package/build-style/style.css +1 -4
  48. package/package.json +27 -26
  49. package/src/components/header/plugin-more-menu-item/index.js +2 -0
  50. package/src/components/header/template-title/delete-template.js +3 -1
  51. package/src/components/sidebar/post-link/index.js +1 -1
  52. package/src/components/visual-editor/index.js +5 -3
  53. package/src/editor.js +3 -8
  54. package/src/index.js +5 -0
  55. package/src/index.native.js +14 -0
  56. package/src/store/actions.js +87 -42
  57. package/src/store/index.js +7 -11
  58. package/src/store/reducer.js +1 -106
  59. package/src/store/selectors.js +124 -50
  60. package/src/store/test/actions.js +89 -46
  61. package/src/store/test/reducer.js +0 -135
  62. package/src/store/test/selectors.js +0 -174
  63. package/src/style.scss +0 -4
  64. package/build/store/defaults.js +0 -19
  65. package/build/store/defaults.js.map +0 -1
  66. package/build-module/store/defaults.js +0 -12
  67. package/build-module/store/defaults.js.map +0 -1
  68. package/src/store/defaults.js +0 -11
@@ -1,117 +1,13 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { flow, get, includes, omit } from 'lodash';
4
+ import { includes } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { combineReducers } from '@wordpress/data';
10
10
 
11
- /**
12
- * Internal dependencies
13
- */
14
- import { PREFERENCES_DEFAULTS } from './defaults';
15
-
16
- /**
17
- * Higher-order reducer creator which provides the given initial state for the
18
- * original reducer.
19
- *
20
- * @param {*} initialState Initial state to provide to reducer.
21
- *
22
- * @return {Function} Higher-order reducer.
23
- */
24
- const createWithInitialState = ( initialState ) => ( reducer ) => {
25
- return ( state = initialState, action ) => reducer( state, action );
26
- };
27
-
28
- /**
29
- * Reducer returning the user preferences.
30
- *
31
- * @param {Object} state Current state.
32
- * @param {string} state.mode Current editor mode, either
33
- * "visual" or "text".
34
- * @param {boolean} state.isGeneralSidebarDismissed Whether general sidebar is
35
- * dismissed. False by default
36
- * or when closing general
37
- * sidebar, true when opening
38
- * sidebar.
39
- * @param {boolean} state.isSidebarOpened Whether the sidebar is
40
- * opened or closed.
41
- * @param {Object} state.panels The state of the different
42
- * sidebar panels.
43
- * @param {Object} action Dispatched action.
44
- *
45
- * @return {Object} Updated state.
46
- */
47
- export const preferences = flow( [
48
- combineReducers,
49
- createWithInitialState( PREFERENCES_DEFAULTS ),
50
- ] )( {
51
- panels( state, action ) {
52
- switch ( action.type ) {
53
- case 'TOGGLE_PANEL_ENABLED': {
54
- const { panelName } = action;
55
- return {
56
- ...state,
57
- [ panelName ]: {
58
- ...state[ panelName ],
59
- enabled: ! get( state, [ panelName, 'enabled' ], true ),
60
- },
61
- };
62
- }
63
-
64
- case 'TOGGLE_PANEL_OPENED': {
65
- const { panelName } = action;
66
- const isOpen =
67
- state[ panelName ] === true ||
68
- get( state, [ panelName, 'opened' ], false );
69
- return {
70
- ...state,
71
- [ panelName ]: {
72
- ...state[ panelName ],
73
- opened: ! isOpen,
74
- },
75
- };
76
- }
77
- }
78
-
79
- return state;
80
- },
81
- editorMode( state, action ) {
82
- if ( action.type === 'SWITCH_MODE' ) {
83
- return action.mode;
84
- }
85
-
86
- return state;
87
- },
88
- preferredStyleVariations( state, action ) {
89
- switch ( action.type ) {
90
- case 'UPDATE_PREFERRED_STYLE_VARIATIONS': {
91
- if ( ! action.blockName ) {
92
- return state;
93
- }
94
- if ( ! action.blockStyle ) {
95
- return omit( state, [ action.blockName ] );
96
- }
97
- return {
98
- ...state,
99
- [ action.blockName ]: action.blockStyle,
100
- };
101
- }
102
- }
103
- return state;
104
- },
105
- localAutosaveInterval( state, action ) {
106
- switch ( action.type ) {
107
- case 'UPDATE_LOCAL_AUTOSAVE_INTERVAL':
108
- return action.interval;
109
- }
110
-
111
- return state;
112
- },
113
- } );
114
-
115
11
  /**
116
12
  * Reducer storing the list of all programmatically removed panels.
117
13
  *
@@ -295,7 +191,6 @@ const metaBoxes = combineReducers( {
295
191
  export default combineReducers( {
296
192
  activeModal,
297
193
  metaBoxes,
298
- preferences,
299
194
  publishSidebarActive,
300
195
  removedPanels,
301
196
  deviceType,
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
- import { get, includes, some, flatten, values } from 'lodash';
5
+ import { includes, some, flatten, values } from 'lodash';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -12,8 +12,10 @@ import { store as interfaceStore } from '@wordpress/interface';
12
12
  import { store as preferencesStore } from '@wordpress/preferences';
13
13
  import { store as coreStore } from '@wordpress/core-data';
14
14
  import { store as editorStore } from '@wordpress/editor';
15
+ import deprecated from '@wordpress/deprecated';
15
16
 
16
17
  const EMPTY_ARRAY = [];
18
+ const EMPTY_OBJECT = {};
17
19
 
18
20
  /**
19
21
  * Returns the current editing mode.
@@ -22,9 +24,9 @@ const EMPTY_ARRAY = [];
22
24
  *
23
25
  * @return {string} Editing mode.
24
26
  */
25
- export function getEditorMode( state ) {
26
- return getPreference( state, 'editorMode', 'visual' );
27
- }
27
+ export const getEditorMode = createRegistrySelector( ( select ) => () =>
28
+ select( preferencesStore ).get( 'core/edit-post', 'editorMode' ) ?? 'visual'
29
+ );
28
30
 
29
31
  /**
30
32
  * Returns true if the editor sidebar is opened.
@@ -89,9 +91,57 @@ export const getActiveGeneralSidebarName = createRegistrySelector(
89
91
  }
90
92
  );
91
93
 
92
- // The current list of preference keys that have been migrated to the
93
- // preferences package.
94
- const MIGRATED_KEYS = [ 'hiddenBlockTypes' ];
94
+ /**
95
+ * Converts panels from the new preferences store format to the old format
96
+ * that the post editor previously used.
97
+ *
98
+ * The resultant converted data should look like this:
99
+ * {
100
+ * panelName: {
101
+ * enabled: false,
102
+ * opened: true,
103
+ * },
104
+ * anotherPanelName: {
105
+ * opened: true
106
+ * },
107
+ * }
108
+ *
109
+ * @param {string[] | undefined} inactivePanels An array of inactive panel names.
110
+ * @param {string[] | undefined} openPanels An array of open panel names.
111
+ *
112
+ * @return {Object} The converted panel data.
113
+ */
114
+ function convertPanelsToOldFormat( inactivePanels, openPanels ) {
115
+ // First reduce the inactive panels.
116
+ const panelsWithEnabledState = inactivePanels?.reduce(
117
+ ( accumulatedPanels, panelName ) => ( {
118
+ ...accumulatedPanels,
119
+ [ panelName ]: {
120
+ enabled: false,
121
+ },
122
+ } ),
123
+ {}
124
+ );
125
+
126
+ // Then reduce the open panels, passing in the result of the previous
127
+ // reduction as the initial value so that both open and inactive
128
+ // panel state is combined.
129
+ const panels = openPanels?.reduce( ( accumulatedPanels, panelName ) => {
130
+ const currentPanelState = accumulatedPanels?.[ panelName ];
131
+ return {
132
+ ...accumulatedPanels,
133
+ [ panelName ]: {
134
+ ...currentPanelState,
135
+ opened: true,
136
+ },
137
+ };
138
+ }, panelsWithEnabledState ?? {} );
139
+
140
+ // The panels variable will only be set if openPanels wasn't `undefined`.
141
+ // If it isn't set just return `panelsWithEnabledState`, and if that isn't
142
+ // set return an empty object.
143
+ return panels ?? panelsWithEnabledState ?? EMPTY_OBJECT;
144
+ }
95
145
 
96
146
  /**
97
147
  * Returns the preferences (these preferences are persisted locally).
@@ -100,34 +150,50 @@ const MIGRATED_KEYS = [ 'hiddenBlockTypes' ];
100
150
  *
101
151
  * @return {Object} Preferences Object.
102
152
  */
103
- export const getPreferences = createRegistrySelector(
104
- ( select ) => ( state ) => {
105
- const editPostPreferences = state.preferences;
106
-
107
- // Some preferences now exist in the preferences store.
108
- // Fetch them so that they can be merged into the post
109
- // editor preferences.
110
- const preferenceStorePreferences = MIGRATED_KEYS.reduce(
111
- ( accumulatedPrefs, preferenceKey ) => {
112
- const value = select( preferencesStore ).get(
113
- 'core/edit-post',
114
- preferenceKey
115
- );
116
-
117
- return {
118
- ...accumulatedPrefs,
119
- [ preferenceKey ]: value,
120
- };
121
- },
122
- {}
153
+ export const getPreferences = createRegistrySelector( ( select ) => () => {
154
+ deprecated( `wp.data.select( 'core/edit-post' ).getPreferences`, {
155
+ since: '6.0',
156
+ alternative: `wp.data.select( 'core/preferences' ).get`,
157
+ } );
158
+
159
+ // These preferences now exist in the preferences store.
160
+ // Fetch them so that they can be merged into the post
161
+ // editor preferences.
162
+ const preferences = [
163
+ 'hiddenBlockTypes',
164
+ 'editorMode',
165
+ 'preferredStyleVariations',
166
+ ].reduce( ( accumulatedPrefs, preferenceKey ) => {
167
+ const value = select( preferencesStore ).get(
168
+ 'core/edit-post',
169
+ preferenceKey
123
170
  );
124
171
 
125
172
  return {
126
- ...editPostPreferences,
127
- ...preferenceStorePreferences,
173
+ ...accumulatedPrefs,
174
+ [ preferenceKey ]: value,
128
175
  };
129
- }
130
- );
176
+ }, {} );
177
+
178
+ // Panels were a preference, but the data structure changed when the state
179
+ // was migrated to the preferences store. They need to be converted from
180
+ // the new preferences store format to old format to ensure no breaking
181
+ // changes for plugins.
182
+ const inactivePanels = select( preferencesStore ).get(
183
+ 'core/edit-post',
184
+ 'inactivePanels'
185
+ );
186
+ const openPanels = select( preferencesStore ).get(
187
+ 'core/edit-post',
188
+ 'openPanels'
189
+ );
190
+ const panels = convertPanelsToOldFormat( inactivePanels, openPanels );
191
+
192
+ return {
193
+ ...preferences,
194
+ panels,
195
+ };
196
+ } );
131
197
 
132
198
  /**
133
199
  *
@@ -138,11 +204,13 @@ export const getPreferences = createRegistrySelector(
138
204
  * @return {*} Preference Value.
139
205
  */
140
206
  export function getPreference( state, preferenceKey, defaultValue ) {
207
+ deprecated( `wp.data.select( 'core/edit-post' ).getPreference`, {
208
+ since: '6.0',
209
+ alternative: `wp.data.select( 'core/preferences' ).get`,
210
+ } );
211
+
141
212
  // Avoid using the `getPreferences` registry selector where possible.
142
- const isMigratedKey = MIGRATED_KEYS.includes( preferenceKey );
143
- const preferences = isMigratedKey
144
- ? getPreferences( state )
145
- : state.preferences;
213
+ const preferences = getPreferences( state );
146
214
  const value = preferences[ preferenceKey ];
147
215
  return value === undefined ? defaultValue : value;
148
216
  }
@@ -194,14 +262,18 @@ export function isEditorPanelRemoved( state, panelName ) {
194
262
  *
195
263
  * @return {boolean} Whether or not the panel is enabled.
196
264
  */
197
- export function isEditorPanelEnabled( state, panelName ) {
198
- const panels = getPreference( state, 'panels' );
199
-
200
- return (
201
- ! isEditorPanelRemoved( state, panelName ) &&
202
- get( panels, [ panelName, 'enabled' ], true )
203
- );
204
- }
265
+ export const isEditorPanelEnabled = createRegistrySelector(
266
+ ( select ) => ( state, panelName ) => {
267
+ const inactivePanels = select( preferencesStore ).get(
268
+ 'core/edit-post',
269
+ 'inactivePanels'
270
+ );
271
+ return (
272
+ ! isEditorPanelRemoved( state, panelName ) &&
273
+ ! inactivePanels?.includes( panelName )
274
+ );
275
+ }
276
+ );
205
277
 
206
278
  /**
207
279
  * Returns true if the given panel is open, or false otherwise. Panels are
@@ -212,13 +284,15 @@ export function isEditorPanelEnabled( state, panelName ) {
212
284
  *
213
285
  * @return {boolean} Whether or not the panel is open.
214
286
  */
215
- export function isEditorPanelOpened( state, panelName ) {
216
- const panels = getPreference( state, 'panels' );
217
- return (
218
- get( panels, [ panelName ] ) === true ||
219
- get( panels, [ panelName, 'opened' ] ) === true
220
- );
221
- }
287
+ export const isEditorPanelOpened = createRegistrySelector(
288
+ ( select ) => ( state, panelName ) => {
289
+ const openPanels = select( preferencesStore ).get(
290
+ 'core/edit-post',
291
+ 'openPanels'
292
+ );
293
+ return !! openPanels?.includes( panelName );
294
+ }
295
+ );
222
296
 
223
297
  /**
224
298
  * Returns true if a modal is active, or false otherwise.
@@ -71,6 +71,11 @@ describe( 'actions', () => {
71
71
 
72
72
  describe( 'switchEditorMode', () => {
73
73
  it( 'to visual', () => {
74
+ // Switch to text first, since the default is visual.
75
+ registry.dispatch( editPostStore ).switchEditorMode( 'text' );
76
+ expect( registry.select( editPostStore ).getEditorMode() ).toEqual(
77
+ 'text'
78
+ );
74
79
  registry.dispatch( editPostStore ).switchEditorMode( 'visual' );
75
80
  expect( registry.select( editPostStore ).getEditorMode() ).toEqual(
76
81
  'visual'
@@ -78,6 +83,10 @@ describe( 'actions', () => {
78
83
  } );
79
84
 
80
85
  it( 'to text', () => {
86
+ // It defaults to visual.
87
+ expect( registry.select( editPostStore ).getEditorMode() ).toEqual(
88
+ 'visual'
89
+ );
81
90
  // Add a selected client id and make sure it's there.
82
91
  const clientId = 'clientId_1';
83
92
  registry.dispatch( blockEditorStore ).selectionChange( clientId );
@@ -89,6 +98,9 @@ describe( 'actions', () => {
89
98
  expect(
90
99
  registry.select( blockEditorStore ).getSelectedBlockClientId()
91
100
  ).toBeNull();
101
+ expect( registry.select( editPostStore ).getEditorMode() ).toEqual(
102
+ 'text'
103
+ );
92
104
  } );
93
105
  } );
94
106
 
@@ -145,7 +157,6 @@ describe( 'actions', () => {
145
157
 
146
158
  const expected = [ 'core/quote', 'core/table' ];
147
159
 
148
- // TODO - remove once `getPreference` is deprecated.
149
160
  expect(
150
161
  registry
151
162
  .select( editPostStore )
@@ -155,6 +166,9 @@ describe( 'actions', () => {
155
166
  expect(
156
167
  registry.select( editPostStore ).getHiddenBlockTypes()
157
168
  ).toEqual( expected );
169
+
170
+ // Expect a deprecation message for `getPreference`.
171
+ expect( console ).toHaveWarned();
158
172
  } );
159
173
  } );
160
174
 
@@ -166,7 +180,6 @@ describe( 'actions', () => {
166
180
 
167
181
  const expectedA = [ 'core/quote', 'core/table' ];
168
182
 
169
- // TODO - remove once `getPreference` is deprecated.
170
183
  expect(
171
184
  registry
172
185
  .select( editPostStore )
@@ -183,7 +196,6 @@ describe( 'actions', () => {
183
196
 
184
197
  const expectedB = [ 'core/quote' ];
185
198
 
186
- // TODO - remove once `getPreference` is deprecated.
187
199
  expect(
188
200
  registry
189
201
  .select( editPostStore )
@@ -196,39 +208,23 @@ describe( 'actions', () => {
196
208
  } );
197
209
  } );
198
210
 
199
- describe( '__experimentalUpdateLocalAutosaveInterval', () => {
200
- it( 'sets the local autosave interval', () => {
201
- registry
202
- .dispatch( editPostStore )
203
- .__experimentalUpdateLocalAutosaveInterval( 42 );
204
-
205
- // TODO - remove once `getPreference` is deprecated.
206
- expect(
207
- registry
208
- .select( editPostStore )
209
- .getPreference( 'localAutosaveInterval' )
210
- ).toBe( 42 );
211
- } );
212
- } );
213
-
214
211
  describe( 'toggleEditorPanelEnabled', () => {
215
212
  it( 'toggles panels to be enabled and not enabled', () => {
216
- const defaultState = {
217
- 'post-status': {
218
- opened: true,
219
- },
220
- };
221
-
222
213
  // This will switch it off, since the default is on.
223
214
  registry
224
215
  .dispatch( editPostStore )
225
216
  .toggleEditorPanelEnabled( 'control-panel' );
226
217
 
227
- // TODO - remove once `getPreference` is deprecated.
218
+ expect(
219
+ registry
220
+ .select( editPostStore )
221
+ .isEditorPanelEnabled( 'control-panel' )
222
+ ).toBe( false );
223
+
224
+ // Also check that the `getPreference` selector includes panels.
228
225
  expect(
229
226
  registry.select( editPostStore ).getPreference( 'panels' )
230
227
  ).toEqual( {
231
- ...defaultState,
232
228
  'control-panel': {
233
229
  enabled: false,
234
230
  },
@@ -239,36 +235,34 @@ describe( 'actions', () => {
239
235
  .dispatch( editPostStore )
240
236
  .toggleEditorPanelEnabled( 'control-panel' );
241
237
 
242
- // TODO - remove once `getPreference` is deprecated.
238
+ expect(
239
+ registry
240
+ .select( editPostStore )
241
+ .isEditorPanelEnabled( 'control-panel' )
242
+ ).toBe( true );
243
+
243
244
  expect(
244
245
  registry.select( editPostStore ).getPreference( 'panels' )
245
- ).toEqual( {
246
- ...defaultState,
247
- 'control-panel': {
248
- enabled: true,
249
- },
250
- } );
246
+ ).toEqual( {} );
251
247
  } );
252
248
  } );
253
249
 
254
250
  describe( 'toggleEditorPanelOpened', () => {
255
251
  it( 'toggles panels open and closed', () => {
256
- const defaultState = {
257
- 'post-status': {
258
- opened: true,
259
- },
260
- };
261
-
262
252
  // This will open it, since the default is closed.
263
253
  registry
264
254
  .dispatch( editPostStore )
265
255
  .toggleEditorPanelOpened( 'control-panel' );
266
256
 
267
- // TODO - remove once `getPreference` is deprecated.
257
+ expect(
258
+ registry
259
+ .select( editPostStore )
260
+ .isEditorPanelOpened( 'control-panel' )
261
+ ).toBe( true );
262
+
268
263
  expect(
269
264
  registry.select( editPostStore ).getPreference( 'panels' )
270
265
  ).toEqual( {
271
- ...defaultState,
272
266
  'control-panel': {
273
267
  opened: true,
274
268
  },
@@ -279,14 +273,63 @@ describe( 'actions', () => {
279
273
  .dispatch( editPostStore )
280
274
  .toggleEditorPanelOpened( 'control-panel' );
281
275
 
282
- // TODO - remove once `getPreference` is deprecated.
276
+ expect(
277
+ registry
278
+ .select( editPostStore )
279
+ .isEditorPanelOpened( 'control-panel' )
280
+ ).toBe( false );
281
+
283
282
  expect(
284
283
  registry.select( editPostStore ).getPreference( 'panels' )
284
+ ).toEqual( {} );
285
+ } );
286
+ } );
287
+
288
+ describe( 'updatePreferredStyleVariations', () => {
289
+ it( 'sets a preferred style variation for a block when a style name is passed', () => {
290
+ registry
291
+ .dispatch( 'core/edit-post' )
292
+ .updatePreferredStyleVariations( 'core/paragraph', 'fancy' );
293
+ registry
294
+ .dispatch( 'core/edit-post' )
295
+ .updatePreferredStyleVariations( 'core/quote', 'posh' );
296
+
297
+ expect(
298
+ registry
299
+ .select( editPostStore )
300
+ .getPreference( 'preferredStyleVariations' )
285
301
  ).toEqual( {
286
- ...defaultState,
287
- 'control-panel': {
288
- opened: false,
289
- },
302
+ 'core/paragraph': 'fancy',
303
+ 'core/quote': 'posh',
304
+ } );
305
+ } );
306
+
307
+ it( 'removes a preferred style variation for a block when a style name is omitted', () => {
308
+ registry
309
+ .dispatch( 'core/edit-post' )
310
+ .updatePreferredStyleVariations( 'core/paragraph', 'fancy' );
311
+ registry
312
+ .dispatch( 'core/edit-post' )
313
+ .updatePreferredStyleVariations( 'core/quote', 'posh' );
314
+ expect(
315
+ registry
316
+ .select( editPostStore )
317
+ .getPreference( 'preferredStyleVariations' )
318
+ ).toEqual( {
319
+ 'core/paragraph': 'fancy',
320
+ 'core/quote': 'posh',
321
+ } );
322
+
323
+ registry
324
+ .dispatch( 'core/edit-post' )
325
+ .updatePreferredStyleVariations( 'core/paragraph' );
326
+
327
+ expect(
328
+ registry
329
+ .select( editPostStore )
330
+ .getPreference( 'preferredStyleVariations' )
331
+ ).toEqual( {
332
+ 'core/quote': 'posh',
290
333
  } );
291
334
  } );
292
335
  } );