@wordpress/edit-post 6.0.1 → 6.0.2

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 (41) hide show
  1. package/build/components/header/fullscreen-mode-close/index.js +11 -4
  2. package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
  3. package/build/components/header/index.js +3 -1
  4. package/build/components/header/index.js.map +1 -1
  5. package/build/components/header/template-title/delete-template.js +29 -20
  6. package/build/components/header/template-title/delete-template.js.map +1 -1
  7. package/build/components/preferences-modal/index.js +4 -41
  8. package/build/components/preferences-modal/index.js.map +1 -1
  9. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
  10. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  11. package/build/store/actions.js +135 -87
  12. package/build/store/actions.js.map +1 -1
  13. package/build/store/index.js +0 -3
  14. package/build/store/index.js.map +1 -1
  15. package/build-module/components/header/fullscreen-mode-close/index.js +8 -4
  16. package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
  17. package/build-module/components/header/index.js +3 -1
  18. package/build-module/components/header/index.js.map +1 -1
  19. package/build-module/components/header/template-title/delete-template.js +32 -22
  20. package/build-module/components/header/template-title/delete-template.js.map +1 -1
  21. package/build-module/components/preferences-modal/index.js +5 -42
  22. package/build-module/components/preferences-modal/index.js.map +1 -1
  23. package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
  24. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  25. package/build-module/store/actions.js +107 -75
  26. package/build-module/store/actions.js.map +1 -1
  27. package/build-module/store/index.js +0 -2
  28. package/build-module/store/index.js.map +1 -1
  29. package/build-style/style-rtl.css +14 -9
  30. package/build-style/style.css +14 -9
  31. package/package.json +17 -17
  32. package/src/components/header/fullscreen-mode-close/index.js +9 -4
  33. package/src/components/header/fullscreen-mode-close/style.scss +5 -1
  34. package/src/components/header/index.js +1 -1
  35. package/src/components/header/template-title/delete-template.js +57 -46
  36. package/src/components/preferences-modal/index.js +5 -33
  37. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +9 -9
  38. package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
  39. package/src/store/actions.js +85 -121
  40. package/src/store/index.js +0 -2
  41. package/src/store/test/actions.js +107 -97
@@ -7,10 +7,9 @@ import { castArray, reduce } from 'lodash';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { __ } from '@wordpress/i18n';
10
- import { apiFetch } from '@wordpress/data-controls';
11
- import { store as interfaceStore } from '@wordpress/interface';
12
- import { controls, select, subscribe, dispatch } from '@wordpress/data';
10
+ import apiFetch from '@wordpress/api-fetch';
13
11
  import { speak } from '@wordpress/a11y';
12
+ import { store as interfaceStore } from '@wordpress/interface';
14
13
  import { store as noticesStore } from '@wordpress/notices';
15
14
  import { store as coreStore } from '@wordpress/core-data';
16
15
  import { store as blockEditorStore } from '@wordpress/block-editor';
@@ -21,34 +20,24 @@ import { store as editorStore } from '@wordpress/editor';
21
20
  */
22
21
  import { getMetaBoxContainer } from '../utils/meta-boxes';
23
22
  import { store as editPostStore } from '.';
23
+
24
24
  /**
25
25
  * Returns an action object used in signalling that the user opened an editor sidebar.
26
26
  *
27
27
  * @param {?string} name Sidebar name to be opened.
28
- *
29
- * @yield {Object} Action object.
30
28
  */
31
- export function* openGeneralSidebar( name ) {
32
- yield controls.dispatch(
33
- interfaceStore,
34
- 'enableComplementaryArea',
35
- editPostStore.name,
36
- name
37
- );
38
- }
29
+ export const openGeneralSidebar = ( name ) => ( { registry } ) =>
30
+ registry
31
+ .dispatch( interfaceStore )
32
+ .enableComplementaryArea( editPostStore.name, name );
39
33
 
40
34
  /**
41
35
  * Returns an action object signalling that the user closed the sidebar.
42
- *
43
- * @yield {Object} Action object.
44
36
  */
45
- export function* closeGeneralSidebar() {
46
- yield controls.dispatch(
47
- interfaceStore,
48
- 'disableComplementaryArea',
49
- editPostStore.name
50
- );
51
- }
37
+ export const closeGeneralSidebar = () => ( { registry } ) =>
38
+ registry
39
+ .dispatch( interfaceStore )
40
+ .disableComplementaryArea( editPostStore.name );
52
41
 
53
42
  /**
54
43
  * Returns an action object used in signalling that the user opened a modal.
@@ -157,24 +146,20 @@ export function removeEditorPanel( panelName ) {
157
146
  *
158
147
  * @param {string} feature Feature name.
159
148
  */
160
- export function* toggleFeature( feature ) {
161
- yield controls.dispatch(
162
- interfaceStore.name,
163
- 'toggleFeature',
164
- 'core/edit-post',
165
- feature
166
- );
167
- }
149
+ export const toggleFeature = ( feature ) => ( { registry } ) =>
150
+ registry
151
+ .dispatch( interfaceStore )
152
+ .toggleFeature( 'core/edit-post', feature );
168
153
 
169
- export function* switchEditorMode( mode ) {
170
- yield {
154
+ export const switchEditorMode = ( mode ) => ( { dispatch, registry } ) => {
155
+ dispatch( {
171
156
  type: 'SWITCH_MODE',
172
157
  mode,
173
- };
158
+ } );
174
159
 
175
160
  // Unselect blocks when we switch to the code editor.
176
161
  if ( mode !== 'visual' ) {
177
- yield controls.dispatch( blockEditorStore, 'clearSelectedBlock' );
162
+ registry.dispatch( blockEditorStore ).clearSelectedBlock();
178
163
  }
179
164
 
180
165
  const message =
@@ -182,28 +167,22 @@ export function* switchEditorMode( mode ) {
182
167
  ? __( 'Visual editor selected' )
183
168
  : __( 'Code editor selected' );
184
169
  speak( message, 'assertive' );
185
- }
170
+ };
186
171
 
187
172
  /**
188
173
  * Triggers an action object used to toggle a plugin name flag.
189
174
  *
190
175
  * @param {string} pluginName Plugin name.
191
176
  */
192
- export function* togglePinnedPluginItem( pluginName ) {
193
- const isPinned = yield controls.select(
194
- interfaceStore,
195
- 'isItemPinned',
196
- 'core/edit-post',
197
- pluginName
198
- );
177
+ export const togglePinnedPluginItem = ( pluginName ) => ( { registry } ) => {
178
+ const isPinned = registry
179
+ .select( interfaceStore )
180
+ .isItemPinned( 'core/edit-post', pluginName );
199
181
 
200
- yield controls.dispatch(
201
- interfaceStore,
202
- isPinned ? 'unpinItem' : 'pinItem',
203
- 'core/edit-post',
204
- pluginName
205
- );
206
- }
182
+ registry
183
+ .dispatch( interfaceStore )
184
+ [ isPinned ? 'unpinItem' : 'pinItem' ]( 'core/edit-post', pluginName );
185
+ };
207
186
 
208
187
  /**
209
188
  * Returns an action object used in signalling that block types by the given
@@ -270,25 +249,26 @@ export function showBlockTypes( blockNames ) {
270
249
  * what Meta boxes are available in which location.
271
250
  *
272
251
  * @param {Object} metaBoxesPerLocation Meta boxes per location.
273
- *
274
- * @yield {Object} Action object.
275
252
  */
276
- export function* setAvailableMetaBoxesPerLocation( metaBoxesPerLocation ) {
277
- yield {
253
+ export const setAvailableMetaBoxesPerLocation = ( metaBoxesPerLocation ) => ( {
254
+ dispatch,
255
+ } ) =>
256
+ dispatch( {
278
257
  type: 'SET_META_BOXES_PER_LOCATIONS',
279
258
  metaBoxesPerLocation,
280
- };
281
- }
259
+ } );
282
260
 
283
261
  /**
284
- * Returns an action object used to request meta box update.
285
- *
286
- * @yield {Object} Action object.
262
+ * Update a metabox.
287
263
  */
288
- export function* requestMetaBoxUpdates() {
289
- yield {
264
+ export const requestMetaBoxUpdates = () => async ( {
265
+ registry,
266
+ select,
267
+ dispatch,
268
+ } ) => {
269
+ dispatch( {
290
270
  type: 'REQUEST_META_BOX_UPDATES',
291
- };
271
+ } );
292
272
 
293
273
  // Saves the wp_editor fields
294
274
  if ( window.tinyMCE ) {
@@ -297,7 +277,7 @@ export function* requestMetaBoxUpdates() {
297
277
 
298
278
  // Additional data needed for backward compatibility.
299
279
  // If we do not provide this data, the post will be overridden with the default values.
300
- const post = yield controls.select( editorStore, 'getCurrentPost' );
280
+ const post = registry.select( editorStore ).getCurrentPost();
301
281
  const additionalData = [
302
282
  post.comment_status ? [ 'comment_status', post.comment_status ] : false,
303
283
  post.ping_status ? [ 'ping_status', post.ping_status ] : false,
@@ -309,10 +289,7 @@ export function* requestMetaBoxUpdates() {
309
289
  const baseFormData = new window.FormData(
310
290
  document.querySelector( '.metabox-base-form' )
311
291
  );
312
- const activeMetaBoxLocations = yield controls.select(
313
- editPostStore,
314
- 'getActiveMetaBoxLocations'
315
- );
292
+ const activeMetaBoxLocations = select.getActiveMetaBoxLocations();
316
293
  const formDataToMerge = [
317
294
  baseFormData,
318
295
  ...activeMetaBoxLocations.map(
@@ -338,17 +315,17 @@ export function* requestMetaBoxUpdates() {
338
315
 
339
316
  try {
340
317
  // Save the metaboxes
341
- yield apiFetch( {
318
+ await apiFetch( {
342
319
  url: window._wpMetaBoxUrl,
343
320
  method: 'POST',
344
321
  body: formData,
345
322
  parse: false,
346
323
  } );
347
- yield controls.dispatch( editPostStore, 'metaBoxUpdatesSuccess' );
324
+ dispatch.metaBoxUpdatesSuccess();
348
325
  } catch {
349
- yield controls.dispatch( editPostStore, 'metaBoxUpdatesFailure' );
326
+ dispatch.metaBoxUpdatesFailure();
350
327
  }
351
- }
328
+ };
352
329
 
353
330
  /**
354
331
  * Returns an action object used to signal a successful meta box update.
@@ -436,93 +413,80 @@ export function setIsEditingTemplate( value ) {
436
413
  *
437
414
  * @param {boolean} newTemplate Is new template.
438
415
  */
439
- export function* __unstableSwitchToTemplateMode( newTemplate = false ) {
440
- yield setIsEditingTemplate( true );
441
-
442
- const isWelcomeGuideActive = yield controls.select(
443
- editPostStore,
444
- 'isFeatureActive',
416
+ export const __unstableSwitchToTemplateMode = ( newTemplate = false ) => ( {
417
+ registry,
418
+ select,
419
+ dispatch,
420
+ } ) => {
421
+ dispatch( setIsEditingTemplate( true ) );
422
+ const isWelcomeGuideActive = select.isFeatureActive(
445
423
  'welcomeGuideTemplate'
446
424
  );
447
-
448
425
  if ( ! isWelcomeGuideActive ) {
449
426
  const message = newTemplate
450
427
  ? __( "Custom template created. You're in template mode now." )
451
428
  : __(
452
429
  'Editing template. Changes made here affect all posts and pages that use the template.'
453
430
  );
454
- yield controls.dispatch( noticesStore, 'createSuccessNotice', message, {
431
+ registry.dispatch( noticesStore ).createSuccessNotice( message, {
455
432
  type: 'snackbar',
456
433
  } );
457
434
  }
458
- }
435
+ };
459
436
 
460
437
  /**
461
438
  * Create a block based template.
462
439
  *
463
440
  * @param {Object?} template Template to create and assign.
464
441
  */
465
- export function* __unstableCreateTemplate( template ) {
466
- const savedTemplate = yield controls.dispatch(
467
- coreStore,
468
- 'saveEntityRecord',
469
- 'postType',
470
- 'wp_template',
471
- template
472
- );
473
- const post = yield controls.select( editorStore, 'getCurrentPost' );
474
-
475
- yield controls.dispatch(
476
- coreStore,
477
- 'editEntityRecord',
478
- 'postType',
479
- post.type,
480
- post.id,
481
- {
442
+ export const __unstableCreateTemplate = ( template ) => async ( {
443
+ registry,
444
+ } ) => {
445
+ const savedTemplate = await registry
446
+ .dispatch( coreStore )
447
+ .saveEntityRecord( 'postType', 'wp_template', template );
448
+ const post = registry.select( editorStore ).getCurrentPost();
449
+ registry
450
+ .dispatch( coreStore )
451
+ .editEntityRecord( 'postType', post.type, post.id, {
482
452
  template: savedTemplate.slug,
483
- }
484
- );
485
- }
453
+ } );
454
+ };
486
455
 
487
456
  let metaBoxesInitialized = false;
488
457
 
489
458
  /**
490
459
  * Initializes WordPress `postboxes` script and the logic for saving meta boxes.
491
460
  */
492
- export function* initializeMetaBoxes() {
493
- const isEditorReady = yield controls.select(
494
- editorStore,
495
- '__unstableIsEditorReady'
496
- );
461
+ export const initializeMetaBoxes = () => ( { registry, select, dispatch } ) => {
462
+ const isEditorReady = registry
463
+ .select( editorStore )
464
+ .__unstableIsEditorReady();
497
465
 
498
466
  if ( ! isEditorReady ) {
499
467
  return;
500
468
  }
501
-
502
- const postType = yield controls.select( editorStore, 'getCurrentPostType' );
503
-
504
469
  // Only initialize once.
505
470
  if ( metaBoxesInitialized ) {
506
471
  return;
507
472
  }
508
-
473
+ const postType = registry.select( editorStore ).getCurrentPostType();
509
474
  if ( window.postboxes.page !== postType ) {
510
475
  window.postboxes.add_postbox_toggles( postType );
511
476
  }
512
477
 
513
478
  metaBoxesInitialized = true;
514
479
 
515
- let wasSavingPost = yield controls.select( editorStore, 'isSavingPost' );
516
- let wasAutosavingPost = yield controls.select(
517
- editorStore,
518
- 'isAutosavingPost'
519
- );
520
- const hasMetaBoxes = yield controls.select( editPostStore, 'hasMetaBoxes' );
480
+ let wasSavingPost = registry.select( editorStore ).isSavingPost();
481
+ let wasAutosavingPost = registry.select( editorStore ).isAutosavingPost();
482
+ const hasMetaBoxes = select.hasMetaBoxes();
521
483
 
522
484
  // Save metaboxes when performing a full save on the post.
523
- subscribe( () => {
524
- const isSavingPost = select( editorStore ).isSavingPost();
525
- const isAutosavingPost = select( editorStore ).isAutosavingPost();
485
+ registry.subscribe( async () => {
486
+ const isSavingPost = registry.select( editorStore ).isSavingPost();
487
+ const isAutosavingPost = registry
488
+ .select( editorStore )
489
+ .isAutosavingPost();
526
490
 
527
491
  // Save metaboxes on save completion, except for autosaves that are not a post preview.
528
492
  //
@@ -541,11 +505,11 @@ export function* initializeMetaBoxes() {
541
505
  wasAutosavingPost = isAutosavingPost;
542
506
 
543
507
  if ( shouldTriggerMetaboxesSave ) {
544
- dispatch( editPostStore ).requestMetaBoxUpdates();
508
+ await dispatch.requestMetaBoxUpdates();
545
509
  }
546
510
  } );
547
511
 
548
- return {
512
+ dispatch( {
549
513
  type: 'META_BOXES_INITIALIZED',
550
- };
551
- }
514
+ } );
515
+ };
@@ -2,7 +2,6 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createReduxStore, registerStore } from '@wordpress/data';
5
- import { controls } from '@wordpress/data-controls';
6
5
 
7
6
  /**
8
7
  * Internal dependencies
@@ -16,7 +15,6 @@ const storeConfig = {
16
15
  reducer,
17
16
  actions,
18
17
  selectors,
19
- controls,
20
18
  persist: [ 'preferences' ],
21
19
  };
22
20
 
@@ -1,120 +1,130 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { controls } from '@wordpress/data';
4
+ import { createRegistry } from '@wordpress/data';
5
+ import { store as interfaceStore } from '@wordpress/interface';
6
+ import { store as noticesStore } from '@wordpress/notices';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+ import { store as blockEditorStore } from '@wordpress/block-editor';
9
+ import { store as editorStore } from '@wordpress/editor';
5
10
 
6
11
  /**
7
12
  * Internal dependencies
8
13
  */
9
- import {
10
- toggleEditorPanelEnabled,
11
- toggleEditorPanelOpened,
12
- removeEditorPanel,
13
- openPublishSidebar,
14
- closePublishSidebar,
15
- togglePublishSidebar,
16
- openModal,
17
- closeModal,
18
- requestMetaBoxUpdates,
19
- setIsListViewOpened,
20
- } from '../actions';
14
+ import { store as editPostStore } from '..';
15
+
16
+ function createRegistryWithStores() {
17
+ // Create a registry and register used stores.
18
+ const registry = createRegistry();
19
+ [
20
+ editPostStore,
21
+ noticesStore,
22
+ blockEditorStore,
23
+ coreStore,
24
+ interfaceStore,
25
+ editorStore,
26
+ ].forEach( registry.register );
27
+ return registry;
28
+ }
21
29
 
22
30
  describe( 'actions', () => {
23
- describe( 'openPublishSidebar', () => {
24
- it( 'should return an OPEN_PUBLISH_SIDEBAR action', () => {
25
- expect( openPublishSidebar() ).toEqual( {
26
- type: 'OPEN_PUBLISH_SIDEBAR',
27
- } );
28
- } );
31
+ let registry;
32
+ beforeEach( () => {
33
+ registry = createRegistryWithStores();
29
34
  } );
35
+ it( 'openGeneralSidebar/closeGeneralSidebar', () => {
36
+ registry.dispatch( editPostStore ).openGeneralSidebar( 'test/sidebar' );
37
+ expect(
38
+ registry
39
+ .select( interfaceStore )
40
+ .getActiveComplementaryArea( 'core/edit-post' )
41
+ ).toBe( 'test/sidebar' );
30
42
 
31
- describe( 'closePublishSidebar', () => {
32
- it( 'should return an CLOSE_PUBLISH_SIDEBAR action', () => {
33
- expect( closePublishSidebar() ).toEqual( {
34
- type: 'CLOSE_PUBLISH_SIDEBAR',
35
- } );
36
- } );
43
+ registry
44
+ .dispatch( editPostStore )
45
+ .closeGeneralSidebar( 'test/sidebar' );
46
+ expect(
47
+ registry
48
+ .select( interfaceStore )
49
+ .getActiveComplementaryArea( 'core/edit-post' )
50
+ ).toBeNull();
37
51
  } );
52
+ it( 'toggleFeature', () => {
53
+ registry.dispatch( editPostStore ).toggleFeature( 'welcomeGuide' );
54
+ expect(
55
+ registry
56
+ .select( interfaceStore )
57
+ .isFeatureActive( editPostStore.name, 'welcomeGuide' )
58
+ ).toBe( true );
38
59
 
39
- describe( 'togglePublishSidebar', () => {
40
- it( 'should return an TOGGLE_PUBLISH_SIDEBAR action', () => {
41
- expect( togglePublishSidebar() ).toEqual( {
42
- type: 'TOGGLE_PUBLISH_SIDEBAR',
43
- } );
44
- } );
60
+ registry.dispatch( editPostStore ).toggleFeature( 'welcomeGuide' );
61
+ expect(
62
+ registry
63
+ .select( interfaceStore )
64
+ .isFeatureActive( editPostStore.name, 'welcomeGuide' )
65
+ ).toBe( false );
45
66
  } );
46
-
47
- describe( 'removeEditorPanel', () => {
48
- it( 'should return a REMOVE_PANEL action', () => {
49
- expect( removeEditorPanel( 'post-status' ) ).toEqual( {
50
- type: 'REMOVE_PANEL',
51
- panelName: 'post-status',
52
- } );
67
+ describe( 'switchEditorMode', () => {
68
+ it( 'to visual', () => {
69
+ registry.dispatch( editPostStore ).switchEditorMode( 'visual' );
70
+ expect( registry.select( editPostStore ).getEditorMode() ).toEqual(
71
+ 'visual'
72
+ );
53
73
  } );
54
- } );
74
+ it( 'to text', () => {
75
+ // Add a selected client id and make sure it's there.
76
+ const clientId = 'clientId_1';
77
+ registry.dispatch( blockEditorStore ).selectionChange( clientId );
78
+ expect(
79
+ registry.select( blockEditorStore ).getSelectedBlockClientId()
80
+ ).toEqual( clientId );
55
81
 
56
- describe( 'toggleEditorPanelEnabled', () => {
57
- it( 'should return a TOGGLE_PANEL_ENABLED action', () => {
58
- expect( toggleEditorPanelEnabled( 'post-status' ) ).toEqual( {
59
- type: 'TOGGLE_PANEL_ENABLED',
60
- panelName: 'post-status',
61
- } );
82
+ registry.dispatch( editPostStore ).switchEditorMode( 'text' );
83
+ expect(
84
+ registry.select( blockEditorStore ).getSelectedBlockClientId()
85
+ ).toBeNull();
62
86
  } );
63
87
  } );
64
-
65
- describe( 'toggleEditorPanelOpened', () => {
66
- it( 'should return a TOGGLE_PANEL_OPENED action', () => {
67
- expect( toggleEditorPanelOpened( 'post-status' ) ).toEqual( {
68
- type: 'TOGGLE_PANEL_OPENED',
69
- panelName: 'post-status',
70
- } );
71
- } );
88
+ it( 'togglePinnedPluginItem', () => {
89
+ registry.dispatch( editPostStore ).togglePinnedPluginItem( 'rigatoni' );
90
+ // Sidebars are pinned by default.
91
+ // @See https://github.com/WordPress/gutenberg/pull/21645
92
+ expect(
93
+ registry
94
+ .select( interfaceStore )
95
+ .isItemPinned( editPostStore.name, 'rigatoni' )
96
+ ).toBe( false );
97
+ registry.dispatch( editPostStore ).togglePinnedPluginItem( 'rigatoni' );
98
+ expect(
99
+ registry
100
+ .select( interfaceStore )
101
+ .isItemPinned( editPostStore.name, 'rigatoni' )
102
+ ).toBe( true );
72
103
  } );
73
-
74
- describe( 'openModal', () => {
75
- it( 'should return OPEN_MODAL action', () => {
76
- const name = 'plugin/my-name';
77
- expect( openModal( name ) ).toEqual( {
78
- type: 'OPEN_MODAL',
79
- name,
80
- } );
104
+ describe( '__unstableSwitchToTemplateMode', () => {
105
+ it( 'welcome guide is active', () => {
106
+ // Activate `welcomeGuideTemplate` feature.
107
+ registry
108
+ .dispatch( editPostStore )
109
+ .toggleFeature( 'welcomeGuideTemplate' );
110
+ registry.dispatch( editPostStore ).__unstableSwitchToTemplateMode();
111
+ expect(
112
+ registry.select( editPostStore ).isEditingTemplate()
113
+ ).toBeTruthy();
114
+ const notices = registry.select( noticesStore ).getNotices();
115
+ expect( notices ).toHaveLength( 0 );
81
116
  } );
82
- } );
83
-
84
- describe( 'closeModal', () => {
85
- it( 'should return CLOSE_MODAL action', () => {
86
- expect( closeModal() ).toEqual( {
87
- type: 'CLOSE_MODAL',
88
- } );
89
- } );
90
- } );
91
-
92
- describe( 'requestMetaBoxUpdates', () => {
93
- it( 'should yield the REQUEST_META_BOX_UPDATES action', () => {
94
- const fulfillment = requestMetaBoxUpdates();
95
- expect( fulfillment.next() ).toEqual( {
96
- done: false,
97
- value: {
98
- type: 'REQUEST_META_BOX_UPDATES',
99
- },
100
- } );
101
- expect( fulfillment.next() ).toEqual( {
102
- done: false,
103
- value: controls.select( 'core/editor', 'getCurrentPost' ),
104
- } );
105
- } );
106
- } );
107
-
108
- describe( 'setIsListViewOpened', () => {
109
- it( 'should return the SET_IS_LIST_VIEW_OPENED action', () => {
110
- expect( setIsListViewOpened( true ) ).toEqual( {
111
- type: 'SET_IS_LIST_VIEW_OPENED',
112
- isOpen: true,
113
- } );
114
- expect( setIsListViewOpened( false ) ).toEqual( {
115
- type: 'SET_IS_LIST_VIEW_OPENED',
116
- isOpen: false,
117
- } );
117
+ it( 'welcome guide is inactive', () => {
118
+ expect(
119
+ registry.select( editPostStore ).isEditingTemplate()
120
+ ).toBeFalsy();
121
+ registry.dispatch( editPostStore ).__unstableSwitchToTemplateMode();
122
+ expect(
123
+ registry.select( editPostStore ).isEditingTemplate()
124
+ ).toBeTruthy();
125
+ const notices = registry.select( noticesStore ).getNotices();
126
+ expect( notices ).toHaveLength( 1 );
127
+ expect( notices[ 0 ].content ).toMatch( 'template' );
118
128
  } );
119
129
  } );
120
130
  } );