@wordpress/block-editor 10.5.0 → 11.0.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 +10 -0
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-card/index.js +51 -3
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +46 -39
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -3
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +4 -7
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-inspector/index.js +35 -33
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-context.native.js +5 -8
- package/build/components/block-list/block-list-context.native.js.map +1 -1
- package/build/components/block-list/block.js +55 -24
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +61 -28
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +3 -2
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +33 -11
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +5 -9
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +8 -49
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/height-control/index.js +115 -0
- package/build/components/height-control/index.js.map +1 -0
- package/build/components/iframe/index.js +11 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +1 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +20 -6
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +25 -46
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +27 -0
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build/components/inserter/index.js +8 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -4
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +103 -0
- package/build/components/inserter/media-tab/hooks.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +32 -0
- package/build/components/inserter/media-tab/index.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +100 -0
- package/build/components/inserter/media-tab/media-list.js.map +1 -0
- package/build/components/inserter/media-tab/media-panel.js +96 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build/components/inserter/media-tab/media-tab.js +120 -0
- package/build/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build/components/inserter/media-tab/utils.js +54 -0
- package/build/components/inserter/media-tab/utils.js.map +1 -0
- package/build/components/inserter/menu.js +35 -12
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +70 -0
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build/components/inserter/quick-inserter.js +1 -0
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +16 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +71 -0
- package/build/components/inspector-controls-tabs/index.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build/components/inspector-controls-tabs/utils.js +37 -0
- package/build/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build/components/link-control/index.js +1 -0
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +3 -3
- package/build/components/link-control/use-internal-input-value.js.map +1 -1
- package/build/components/list-view/block.js +5 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +13 -12
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-upload/index.native.js +2 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +104 -0
- package/build/components/off-canvas-editor/appender.js.map +1 -0
- package/build/components/off-canvas-editor/block-edit-button.js +50 -0
- package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +36 -4
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +3 -5
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +20 -11
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf.js +1 -1
- package/build/components/off-canvas-editor/leaf.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +185 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build/components/off-canvas-editor/update-attributes.js +108 -0
- package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +8 -4
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +3 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-insert-replacement-text.js +43 -0
- package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -19
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +4 -2
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +46 -43
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +8 -4
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +9 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/content-lock-ui.js +1 -1
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +25 -7
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +57 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/min-height.js +4 -10
- package/build/hooks/min-height.js.map +1 -1
- package/build/store/reducer.js +393 -270
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +57 -47
- package/build/store/selectors.js.map +1 -1
- package/build/utils/sorting.js +63 -0
- package/build/utils/sorting.js.map +1 -0
- package/build-module/autocompleters/block.js +2 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -0
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +40 -31
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +4 -6
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +32 -30
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-context.native.js +5 -8
- package/build-module/components/block-list/block-list-context.native.js.map +1 -1
- package/build-module/components/block-list/block.js +55 -25
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +61 -28
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +3 -2
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +35 -13
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +5 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +8 -49
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/height-control/index.js +103 -0
- package/build-module/components/height-control/index.js.map +1 -0
- package/build-module/components/iframe/index.js +11 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +22 -8
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +27 -49
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -2
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build-module/components/inserter/index.js +8 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +3 -5
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +89 -0
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +4 -0
- package/build-module/components/inserter/media-tab/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +86 -0
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js +77 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-tab.js +100 -0
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build-module/components/inserter/media-tab/utils.js +45 -0
- package/build-module/components/inserter/media-tab/utils.js.map +1 -0
- package/build-module/components/inserter/menu.js +33 -12
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build-module/components/inserter/quick-inserter.js +1 -0
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +15 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -2
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +56 -0
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/utils.js +26 -0
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build-module/components/link-control/index.js +1 -0
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +3 -3
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
- package/build-module/components/list-view/block.js +5 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +12 -11
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +2 -4
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +89 -0
- package/build-module/components/off-canvas-editor/appender.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +36 -6
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +3 -4
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +20 -12
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf.js +1 -1
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +165 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
- package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +6 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -16
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -2
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +46 -43
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +9 -5
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +8 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/child-layout.js +189 -0
- package/build-module/hooks/child-layout.js.map +1 -0
- package/build-module/hooks/content-lock-ui.js +1 -1
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +25 -8
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +55 -0
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/min-height.js +3 -9
- package/build-module/hooks/min-height.js.map +1 -1
- package/build-module/store/reducer.js +391 -271
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +54 -47
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/sorting.js +56 -0
- package/build-module/utils/sorting.js.map +1 -0
- package/build-style/content-rtl.css +701 -0
- package/build-style/content.css +701 -0
- package/build-style/default-editor-styles-rtl.css +14 -0
- package/build-style/default-editor-styles.css +14 -0
- package/build-style/style-rtl.css +286 -662
- package/build-style/style.css +286 -662
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.js +4 -1
- package/src/components/block-card/index.js +46 -2
- package/src/components/block-card/style.scss +4 -0
- package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
- package/src/components/block-draggable/content.scss +20 -0
- package/src/components/block-draggable/index.native.js +54 -40
- package/src/components/block-draggable/style.scss +0 -21
- package/src/components/block-draggable/test/helpers.native.js +7 -9
- package/src/components/block-draggable/test/index.native.js +35 -45
- package/src/components/block-edit/edit.js +5 -2
- package/src/components/block-edit/edit.native.js +5 -6
- package/src/components/block-inspector/index.js +96 -81
- package/src/components/block-inspector/style.scss +9 -1
- package/src/components/block-list/block-list-context.native.js +5 -8
- package/src/components/block-list/block.js +74 -23
- package/src/components/block-list/block.native.js +78 -23
- package/src/components/block-list/{style.scss → content.scss} +1 -15
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
- package/src/components/block-pattern-setup/index.js +2 -1
- package/src/components/block-patterns-list/index.js +47 -24
- package/src/components/block-preview/README.md +15 -10
- package/src/components/block-preview/auto.js +7 -1
- package/src/components/block-preview/content.scss +4 -0
- package/src/components/block-preview/index.js +7 -12
- package/src/components/block-preview/style.scss +0 -7
- package/src/components/block-preview/test/index.js +18 -35
- package/src/components/block-selection-clearer/test/index.js +12 -12
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
- package/src/components/block-switcher/test/index.js +4 -0
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/style.scss +12 -5
- package/src/components/block-variation-picker/index.js +1 -4
- package/src/components/block-vertical-alignment-control/test/index.js +4 -1
- package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/height-control/index.js +123 -0
- package/src/components/height-control/stories/index.js +21 -0
- package/src/components/height-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -18
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +23 -6
- package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
- package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +28 -71
- package/src/components/inserter/block-types-tab.js +3 -2
- package/src/components/inserter/hooks/use-debounced-input.js +17 -0
- package/src/components/inserter/index.js +10 -2
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +88 -0
- package/src/components/inserter/media-tab/index.js +3 -0
- package/src/components/inserter/media-tab/media-list.js +93 -0
- package/src/components/inserter/media-tab/media-panel.js +83 -0
- package/src/components/inserter/media-tab/media-tab.js +135 -0
- package/src/components/inserter/media-tab/utils.js +37 -0
- package/src/components/inserter/menu.js +55 -13
- package/src/components/inserter/mobile-tab-navigation.js +85 -0
- package/src/components/inserter/quick-inserter.js +1 -0
- package/src/components/inserter/search-results.js +3 -2
- package/src/components/inserter/stories/index.js +1 -1
- package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
- package/src/components/inserter/style.scss +176 -11
- package/src/components/inserter/tabs.js +12 -1
- package/src/components/inserter-list-item/index.js +11 -1
- package/src/components/inserter-list-item/style.scss +26 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/index.js +62 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
- package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
- package/src/components/inspector-controls-tabs/utils.js +28 -0
- package/src/components/line-height-control/test/index.js +5 -5
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/search-input.js +0 -1
- package/src/components/link-control/test/index.js +188 -401
- package/src/components/link-control/use-internal-input-value.js +3 -3
- package/src/components/list-view/block.js +3 -0
- package/src/components/list-view/branch.js +10 -8
- package/src/components/list-view/style.scss +20 -9
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +37 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/appender.js +93 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block.js +88 -22
- package/src/components/off-canvas-editor/branch.js +3 -5
- package/src/components/off-canvas-editor/index.js +59 -33
- package/src/components/off-canvas-editor/leaf.js +5 -1
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +17 -388
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/plain-text/{style.scss → content.scss} +0 -0
- package/src/components/recursion-provider/test/index.js +27 -29
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +2 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +0 -43
- package/src/components/rich-text/use-insert-replacement-text.js +31 -0
- package/src/components/rich-text/use-undo-automatic-change.js +7 -1
- package/src/components/rich-text/utils.js +2 -21
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +21 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +13 -1
- package/src/components/use-setting/test/index.js +99 -0
- package/src/content.scss +10 -0
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/content-lock-ui.js +1 -1
- package/src/hooks/dimensions.js +45 -7
- package/src/hooks/layout.js +60 -0
- package/src/hooks/min-height.js +2 -19
- package/src/store/reducer.js +459 -423
- package/src/store/selectors.js +56 -57
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +623 -491
- package/src/store/test/selectors.js +1820 -1306
- package/src/style.scss +4 -7
- package/src/utils/sorting.js +54 -0
- package/src/utils/test/sorting.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-preview/live.js +0 -30
- package/build/components/block-preview/live.js.map +0 -1
- package/build-module/components/block-preview/live.js +0 -20
- package/build-module/components/block-preview/live.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
fireEvent,
|
|
6
|
+
render,
|
|
7
|
+
screen,
|
|
8
|
+
waitFor,
|
|
9
|
+
within,
|
|
10
|
+
} from '@testing-library/react';
|
|
5
11
|
import userEvent from '@testing-library/user-event';
|
|
6
12
|
|
|
7
13
|
/**
|
|
8
14
|
* WordPress dependencies
|
|
9
15
|
*/
|
|
10
16
|
import { useState } from '@wordpress/element';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
17
|
import { useSelect } from '@wordpress/data';
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Internal dependencies
|
|
18
21
|
*/
|
|
@@ -23,14 +26,6 @@ import {
|
|
|
23
26
|
uniqueId,
|
|
24
27
|
} from './fixtures';
|
|
25
28
|
|
|
26
|
-
// Mock debounce() so that it runs instantly.
|
|
27
|
-
jest.mock( '@wordpress/compose/src/utils/debounce', () => ( {
|
|
28
|
-
debounce: ( fn ) => {
|
|
29
|
-
fn.cancel = jest.fn();
|
|
30
|
-
return fn;
|
|
31
|
-
},
|
|
32
|
-
} ) );
|
|
33
|
-
|
|
34
29
|
const mockFetchSearchSuggestions = jest.fn();
|
|
35
30
|
|
|
36
31
|
/**
|
|
@@ -58,18 +53,6 @@ jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( {
|
|
|
58
53
|
|
|
59
54
|
jest.useRealTimers();
|
|
60
55
|
|
|
61
|
-
/**
|
|
62
|
-
* Wait for next tick of event loop. This is required
|
|
63
|
-
* because the `fetchSearchSuggestions` Promise will
|
|
64
|
-
* resolve on the next tick of the event loop (this is
|
|
65
|
-
* inline with the Promise spec). As a result we need to
|
|
66
|
-
* wait on this loop to "tick" before we can expect the UI
|
|
67
|
-
* to have updated.
|
|
68
|
-
*/
|
|
69
|
-
function eventLoopTick() {
|
|
70
|
-
return new Promise( ( resolve ) => setImmediate( resolve ) );
|
|
71
|
-
}
|
|
72
|
-
|
|
73
56
|
beforeEach( () => {
|
|
74
57
|
// Setup a DOM element as a render target.
|
|
75
58
|
mockFetchSearchSuggestions.mockImplementation( fetchFauxEntitySuggestions );
|
|
@@ -186,8 +169,7 @@ describe( 'Basic rendering', () => {
|
|
|
186
169
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
187
170
|
|
|
188
171
|
// Simulate searching for a term.
|
|
189
|
-
|
|
190
|
-
await user.keyboard( searchTerm );
|
|
172
|
+
await user.type( searchInput, searchTerm );
|
|
191
173
|
|
|
192
174
|
expect( screen.queryByText( '://' ) ).not.toBeInTheDocument();
|
|
193
175
|
} );
|
|
@@ -289,6 +271,7 @@ describe( 'Basic rendering', () => {
|
|
|
289
271
|
it( 'should show "Unlink" button if a onRemove handler is provided', async () => {
|
|
290
272
|
const user = userEvent.setup();
|
|
291
273
|
const mockOnRemove = jest.fn();
|
|
274
|
+
|
|
292
275
|
render(
|
|
293
276
|
<LinkControl
|
|
294
277
|
value={ { url: 'https://example.com' } }
|
|
@@ -314,13 +297,12 @@ describe( 'Searching for a link', () => {
|
|
|
314
297
|
const searchTerm = 'Hello';
|
|
315
298
|
|
|
316
299
|
let resolver;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
mockFetchSearchSuggestions.mockImplementation( fauxRequest );
|
|
300
|
+
mockFetchSearchSuggestions.mockImplementation(
|
|
301
|
+
() =>
|
|
302
|
+
new Promise( ( resolve ) => {
|
|
303
|
+
resolver = resolve;
|
|
304
|
+
} )
|
|
305
|
+
);
|
|
324
306
|
|
|
325
307
|
render( <LinkControl /> );
|
|
326
308
|
|
|
@@ -328,35 +310,22 @@ describe( 'Searching for a link', () => {
|
|
|
328
310
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
329
311
|
|
|
330
312
|
// Simulate searching for a term.
|
|
331
|
-
|
|
332
|
-
await user.keyboard( searchTerm );
|
|
313
|
+
await user.type( searchInput, searchTerm );
|
|
333
314
|
|
|
334
|
-
|
|
335
|
-
|
|
315
|
+
expect( await screen.findByRole( 'presentation' ) ).toBeVisible();
|
|
316
|
+
expect( screen.queryByRole( 'listbox' ) ).not.toBeInTheDocument();
|
|
336
317
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
let loadingUI = screen.queryByRole( 'presentation' );
|
|
340
|
-
|
|
341
|
-
expect( searchResultsField ).not.toBeInTheDocument();
|
|
342
|
-
|
|
343
|
-
expect( loadingUI ).toBeVisible();
|
|
318
|
+
// make the search suggestions fetch return a response
|
|
319
|
+
resolver( fauxEntitySuggestions );
|
|
344
320
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
} );
|
|
348
|
-
|
|
349
|
-
await eventLoopTick();
|
|
350
|
-
|
|
351
|
-
loadingUI = screen.queryByRole( 'presentation' );
|
|
352
|
-
|
|
353
|
-
expect( loadingUI ).not.toBeInTheDocument();
|
|
321
|
+
expect( await screen.findByRole( 'listbox' ) ).toBeVisible();
|
|
322
|
+
expect( screen.queryByRole( 'presentation' ) ).not.toBeInTheDocument();
|
|
354
323
|
} );
|
|
355
324
|
|
|
356
325
|
it( 'should display only search suggestions when current input value is not URL-like', async () => {
|
|
357
326
|
const user = userEvent.setup();
|
|
358
327
|
const searchTerm = 'Hello world';
|
|
359
|
-
const
|
|
328
|
+
const firstSuggestion = fauxEntitySuggestions[ 0 ];
|
|
360
329
|
|
|
361
330
|
render( <LinkControl /> );
|
|
362
331
|
|
|
@@ -364,14 +333,10 @@ describe( 'Searching for a link', () => {
|
|
|
364
333
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
365
334
|
|
|
366
335
|
// Simulate searching for a term.
|
|
367
|
-
|
|
368
|
-
await user.keyboard( searchTerm );
|
|
369
|
-
|
|
370
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
371
|
-
await eventLoopTick();
|
|
336
|
+
await user.type( searchInput, searchTerm );
|
|
372
337
|
|
|
373
338
|
const searchResultElements = within(
|
|
374
|
-
screen.
|
|
339
|
+
await screen.findByRole( 'listbox', {
|
|
375
340
|
name: /Search results for.*/,
|
|
376
341
|
} )
|
|
377
342
|
).getAllByRole( 'option' );
|
|
@@ -382,12 +347,12 @@ describe( 'Searching for a link', () => {
|
|
|
382
347
|
|
|
383
348
|
expect( searchInput ).toHaveAttribute( 'aria-expanded', 'true' );
|
|
384
349
|
|
|
385
|
-
//
|
|
350
|
+
// Check that a search suggestion shows up corresponding to the data.
|
|
386
351
|
expect( searchResultElements[ 0 ] ).toHaveTextContent(
|
|
387
|
-
|
|
352
|
+
firstSuggestion.title
|
|
388
353
|
);
|
|
389
354
|
expect( searchResultElements[ 0 ] ).toHaveTextContent(
|
|
390
|
-
|
|
355
|
+
firstSuggestion.type
|
|
391
356
|
);
|
|
392
357
|
|
|
393
358
|
// The fallback URL suggestion should not be shown when input is not URL-like.
|
|
@@ -400,26 +365,19 @@ describe( 'Searching for a link', () => {
|
|
|
400
365
|
const user = userEvent.setup();
|
|
401
366
|
const searchTerm = ' Hello ';
|
|
402
367
|
|
|
403
|
-
|
|
368
|
+
render( <LinkControl /> );
|
|
404
369
|
|
|
405
370
|
// Search Input UI.
|
|
406
371
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
407
372
|
|
|
408
373
|
// Simulate searching for a term.
|
|
409
|
-
|
|
410
|
-
await user.keyboard( searchTerm );
|
|
411
|
-
|
|
412
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
413
|
-
await eventLoopTick();
|
|
374
|
+
await user.type( searchInput, searchTerm );
|
|
414
375
|
|
|
376
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
377
|
+
name: /Search results for.*/,
|
|
378
|
+
} );
|
|
415
379
|
const searchResultTextHighlightElements = Array.from(
|
|
416
|
-
|
|
417
|
-
'[role="listbox"] button[role="option"] mark'
|
|
418
|
-
)
|
|
419
|
-
);
|
|
420
|
-
|
|
421
|
-
const invalidResults = searchResultTextHighlightElements.find(
|
|
422
|
-
( mark ) => mark.innerHTML !== 'Hello'
|
|
380
|
+
searchResults.querySelectorAll( 'button[role="option"] mark' )
|
|
423
381
|
);
|
|
424
382
|
|
|
425
383
|
// Given we're mocking out the results we should always have 4 mark elements.
|
|
@@ -427,7 +385,11 @@ describe( 'Searching for a link', () => {
|
|
|
427
385
|
|
|
428
386
|
// Make sure there are no `mark` elements which contain anything other
|
|
429
387
|
// than the trimmed search term (ie: no whitespace).
|
|
430
|
-
expect(
|
|
388
|
+
expect(
|
|
389
|
+
searchResultTextHighlightElements.every(
|
|
390
|
+
( mark ) => mark.innerHTML === 'Hello'
|
|
391
|
+
)
|
|
392
|
+
).toBe( true );
|
|
431
393
|
|
|
432
394
|
// Implementation detail test to ensure that the fetch handler is called
|
|
433
395
|
// with the trimmed search value. We do this because we are mocking out
|
|
@@ -447,14 +409,10 @@ describe( 'Searching for a link', () => {
|
|
|
447
409
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
448
410
|
|
|
449
411
|
// Simulate searching for a term.
|
|
450
|
-
|
|
451
|
-
await user.keyboard( 'anything' );
|
|
412
|
+
await user.type( searchInput, 'anything' );
|
|
452
413
|
|
|
453
414
|
const searchResultsField = screen.queryByRole( 'listbox' );
|
|
454
415
|
|
|
455
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
456
|
-
await eventLoopTick();
|
|
457
|
-
|
|
458
416
|
expect( searchResultsField ).not.toBeInTheDocument();
|
|
459
417
|
expect( mockFetchSearchSuggestions ).not.toHaveBeenCalled();
|
|
460
418
|
} );
|
|
@@ -472,14 +430,10 @@ describe( 'Searching for a link', () => {
|
|
|
472
430
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
473
431
|
|
|
474
432
|
// Simulate searching for a term.
|
|
475
|
-
|
|
476
|
-
await user.keyboard( searchTerm );
|
|
477
|
-
|
|
478
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
479
|
-
await eventLoopTick();
|
|
433
|
+
await user.type( searchInput, searchTerm );
|
|
480
434
|
|
|
481
435
|
const searchResultElements = within(
|
|
482
|
-
screen.
|
|
436
|
+
await screen.findByRole( 'listbox', {
|
|
483
437
|
name: /Search results for.*/,
|
|
484
438
|
} )
|
|
485
439
|
).getAllByRole( 'option' );
|
|
@@ -510,14 +464,10 @@ describe( 'Searching for a link', () => {
|
|
|
510
464
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
511
465
|
|
|
512
466
|
// Simulate searching for a term.
|
|
513
|
-
|
|
514
|
-
await user.keyboard( 'couldbeurlorentitysearchterm' );
|
|
515
|
-
|
|
516
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
517
|
-
await eventLoopTick();
|
|
467
|
+
await user.type( searchInput, 'couldbeurlorentitysearchterm' );
|
|
518
468
|
|
|
519
469
|
const searchResultElements = within(
|
|
520
|
-
screen.
|
|
470
|
+
await screen.findByRole( 'listbox', {
|
|
521
471
|
name: /Search results for.*/,
|
|
522
472
|
} )
|
|
523
473
|
).getAllByRole( 'option' );
|
|
@@ -544,14 +494,10 @@ describe( 'Manual link entry', () => {
|
|
|
544
494
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
545
495
|
|
|
546
496
|
// Simulate searching for a term.
|
|
547
|
-
|
|
548
|
-
await user.keyboard( searchTerm );
|
|
549
|
-
|
|
550
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
551
|
-
await eventLoopTick();
|
|
497
|
+
await user.type( searchInput, searchTerm );
|
|
552
498
|
|
|
553
499
|
const searchResultElements = within(
|
|
554
|
-
screen.
|
|
500
|
+
await screen.findByRole( 'listbox', {
|
|
555
501
|
name: /Search results for.*/,
|
|
556
502
|
} )
|
|
557
503
|
).getByRole( 'option' );
|
|
@@ -584,29 +530,25 @@ describe( 'Manual link entry', () => {
|
|
|
584
530
|
name: 'URL',
|
|
585
531
|
} );
|
|
586
532
|
|
|
587
|
-
let submitButton = screen.
|
|
533
|
+
let submitButton = screen.getByRole( 'button', {
|
|
588
534
|
name: 'Submit',
|
|
589
535
|
} );
|
|
590
536
|
|
|
591
537
|
expect( submitButton ).toBeDisabled();
|
|
592
538
|
expect( submitButton ).toBeVisible();
|
|
593
539
|
|
|
594
|
-
searchInput.focus();
|
|
595
540
|
if ( searchString.length ) {
|
|
596
541
|
// Simulate searching for a term.
|
|
597
|
-
await user.
|
|
542
|
+
await user.type( searchInput, searchString );
|
|
598
543
|
} else {
|
|
599
544
|
// Simulate clearing the search term.
|
|
600
|
-
await
|
|
545
|
+
await user.clear( searchInput );
|
|
601
546
|
}
|
|
602
547
|
|
|
603
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
604
|
-
await eventLoopTick();
|
|
605
|
-
|
|
606
548
|
// Attempt to submit the empty search value in the input.
|
|
607
549
|
await user.keyboard( '[Enter]' );
|
|
608
550
|
|
|
609
|
-
submitButton = screen.
|
|
551
|
+
submitButton = screen.getByRole( 'button', {
|
|
610
552
|
name: 'Submit',
|
|
611
553
|
} );
|
|
612
554
|
|
|
@@ -637,18 +579,14 @@ describe( 'Manual link entry', () => {
|
|
|
637
579
|
expect( submitButton ).toBeVisible();
|
|
638
580
|
|
|
639
581
|
// Simulate searching for a term.
|
|
640
|
-
searchInput.focus();
|
|
641
582
|
if ( searchString.length ) {
|
|
642
583
|
// Simulate searching for a term.
|
|
643
|
-
await user.
|
|
584
|
+
await user.type( searchInput, searchString );
|
|
644
585
|
} else {
|
|
645
586
|
// Simulate clearing the search term.
|
|
646
|
-
await
|
|
587
|
+
await user.clear( searchInput );
|
|
647
588
|
}
|
|
648
589
|
|
|
649
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
650
|
-
await eventLoopTick();
|
|
651
|
-
|
|
652
590
|
// Attempt to submit the empty search value in the input.
|
|
653
591
|
await user.click( submitButton );
|
|
654
592
|
|
|
@@ -681,14 +619,10 @@ describe( 'Manual link entry', () => {
|
|
|
681
619
|
} );
|
|
682
620
|
|
|
683
621
|
// Simulate searching for a term.
|
|
684
|
-
|
|
685
|
-
await user.keyboard( searchTerm );
|
|
686
|
-
|
|
687
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
688
|
-
await eventLoopTick();
|
|
622
|
+
await user.type( searchInput, searchTerm );
|
|
689
623
|
|
|
690
624
|
const searchResultElements = within(
|
|
691
|
-
screen.
|
|
625
|
+
await screen.findByRole( 'listbox', {
|
|
692
626
|
name: /Search results for.*/,
|
|
693
627
|
} )
|
|
694
628
|
).getByRole( 'option' );
|
|
@@ -706,14 +640,10 @@ describe( 'Manual link entry', () => {
|
|
|
706
640
|
|
|
707
641
|
describe( 'Default search suggestions', () => {
|
|
708
642
|
it( 'should display a list of initial search suggestions when there is no search value or suggestions', async () => {
|
|
709
|
-
const expectedResultsLength = 3; // Set within `LinkControl`.
|
|
710
|
-
|
|
711
643
|
render( <LinkControl showInitialSuggestions /> );
|
|
712
644
|
|
|
713
|
-
await eventLoopTick();
|
|
714
|
-
|
|
715
645
|
expect(
|
|
716
|
-
screen.
|
|
646
|
+
await screen.findByRole( 'listbox', {
|
|
717
647
|
name: 'Recently updated',
|
|
718
648
|
} )
|
|
719
649
|
).toBeVisible();
|
|
@@ -731,24 +661,16 @@ describe( 'Default search suggestions', () => {
|
|
|
731
661
|
expect( mockFetchSearchSuggestions ).toHaveBeenCalledTimes( 1 );
|
|
732
662
|
|
|
733
663
|
// Verify the search results already display the initial suggestions.
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
);
|
|
664
|
+
// `LinkControl` internally always limits the number of initial suggestions to 3.
|
|
665
|
+
expect( screen.queryAllByRole( 'option' ) ).toHaveLength( 3 );
|
|
737
666
|
} );
|
|
738
667
|
|
|
739
668
|
it( 'should not display initial suggestions when input value is present', async () => {
|
|
740
669
|
const user = userEvent.setup();
|
|
741
670
|
|
|
742
|
-
// Render with an initial value an ensure that no initial suggestions
|
|
743
|
-
|
|
744
|
-
render(
|
|
745
|
-
<LinkControl
|
|
746
|
-
showInitialSuggestions
|
|
747
|
-
value={ fauxEntitySuggestions[ 0 ] }
|
|
748
|
-
/>
|
|
749
|
-
);
|
|
750
|
-
|
|
751
|
-
await eventLoopTick();
|
|
671
|
+
// Render with an initial value an ensure that no initial suggestions are shown.
|
|
672
|
+
const initialValue = fauxEntitySuggestions[ 0 ];
|
|
673
|
+
render( <LinkControl showInitialSuggestions value={ initialValue } /> );
|
|
752
674
|
|
|
753
675
|
expect( mockFetchSearchSuggestions ).not.toHaveBeenCalled();
|
|
754
676
|
|
|
@@ -758,23 +680,21 @@ describe( 'Default search suggestions', () => {
|
|
|
758
680
|
const currentLinkBtn = within( currentLinkUI ).getByRole( 'button', {
|
|
759
681
|
name: 'Edit',
|
|
760
682
|
} );
|
|
761
|
-
|
|
762
683
|
await user.click( currentLinkBtn );
|
|
763
684
|
|
|
764
685
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
765
|
-
|
|
686
|
+
// Search input is set to the URL value.
|
|
687
|
+
expect( searchInput ).toHaveValue( initialValue.url );
|
|
766
688
|
|
|
767
|
-
|
|
689
|
+
// Focus the search input to display suggestions
|
|
690
|
+
await user.click( searchInput );
|
|
768
691
|
|
|
769
692
|
const searchResultElements = within(
|
|
770
|
-
screen.
|
|
693
|
+
await screen.findByRole( 'listbox', {
|
|
771
694
|
name: /Search results for.*/,
|
|
772
695
|
} )
|
|
773
696
|
).getAllByRole( 'option' );
|
|
774
697
|
|
|
775
|
-
// Search input is set to the URL value.
|
|
776
|
-
expect( searchInput ).toHaveValue( fauxEntitySuggestions[ 0 ].url );
|
|
777
|
-
|
|
778
698
|
// It should match any url that's like ?p= and also include a URL option.
|
|
779
699
|
expect( searchResultElements ).toHaveLength( 5 );
|
|
780
700
|
|
|
@@ -789,63 +709,45 @@ describe( 'Default search suggestions', () => {
|
|
|
789
709
|
|
|
790
710
|
render( <LinkControl showInitialSuggestions /> );
|
|
791
711
|
|
|
792
|
-
let searchResultElements;
|
|
793
|
-
let searchInput;
|
|
794
|
-
|
|
795
712
|
// Search Input UI.
|
|
796
|
-
searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
713
|
+
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
797
714
|
|
|
798
715
|
// Simulate searching for a term.
|
|
799
|
-
|
|
800
|
-
await user.keyboard( searchTerm );
|
|
801
|
-
|
|
802
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
803
|
-
await eventLoopTick();
|
|
716
|
+
await user.type( searchInput, searchTerm );
|
|
804
717
|
|
|
805
718
|
expect( searchInput ).toHaveValue( searchTerm );
|
|
806
719
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
} )
|
|
811
|
-
).getAllByRole( 'option' );
|
|
812
|
-
|
|
813
|
-
// Delete the text.
|
|
814
|
-
await userEvent.clear( searchInput );
|
|
720
|
+
const searchResultsList = await screen.findByRole( 'listbox', {
|
|
721
|
+
name: /Search results for.*/,
|
|
722
|
+
} );
|
|
815
723
|
|
|
816
|
-
|
|
724
|
+
expect( searchResultsList ).toBeVisible();
|
|
817
725
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
} )
|
|
822
|
-
).getAllByRole( 'option' );
|
|
726
|
+
expect(
|
|
727
|
+
within( searchResultsList ).getAllByRole( 'option' )
|
|
728
|
+
).toHaveLength( 4 );
|
|
823
729
|
|
|
824
|
-
|
|
730
|
+
// Delete the text.
|
|
731
|
+
await userEvent.clear( searchInput );
|
|
825
732
|
|
|
826
733
|
// Check the input is empty now.
|
|
827
734
|
expect( searchInput ).toHaveValue( '' );
|
|
828
735
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
} )
|
|
833
|
-
).toBeVisible();
|
|
736
|
+
const initialResultsList = await screen.findByRole( 'listbox', {
|
|
737
|
+
name: 'Recently updated',
|
|
738
|
+
} );
|
|
834
739
|
|
|
835
|
-
expect(
|
|
740
|
+
expect(
|
|
741
|
+
within( initialResultsList ).getAllByRole( 'option' )
|
|
742
|
+
).toHaveLength( 3 );
|
|
836
743
|
} );
|
|
837
744
|
|
|
838
745
|
it( 'should not display initial suggestions when there are no recently updated pages/posts', async () => {
|
|
839
|
-
const noResults = [];
|
|
840
746
|
// Force API returning empty results for recently updated Pages.
|
|
841
|
-
mockFetchSearchSuggestions.mockImplementation( () =>
|
|
842
|
-
Promise.resolve( noResults )
|
|
843
|
-
);
|
|
747
|
+
mockFetchSearchSuggestions.mockImplementation( async () => [] );
|
|
844
748
|
|
|
845
749
|
render( <LinkControl showInitialSuggestions /> );
|
|
846
750
|
|
|
847
|
-
await eventLoopTick();
|
|
848
|
-
|
|
849
751
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
850
752
|
|
|
851
753
|
const searchResultsField = screen.queryByRole( 'listbox', {
|
|
@@ -876,19 +778,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
876
778
|
async ( entityNameText ) => {
|
|
877
779
|
const user = userEvent.setup();
|
|
878
780
|
let resolver;
|
|
879
|
-
let resolvedEntity;
|
|
880
|
-
|
|
881
781
|
const createSuggestion = ( title ) =>
|
|
882
782
|
new Promise( ( resolve ) => {
|
|
883
|
-
resolver = (
|
|
884
|
-
resolve(
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
type: 'page',
|
|
891
|
-
};
|
|
783
|
+
resolver = () =>
|
|
784
|
+
resolve( {
|
|
785
|
+
title,
|
|
786
|
+
id: 123,
|
|
787
|
+
url: '/?p=123',
|
|
788
|
+
type: 'page',
|
|
789
|
+
} );
|
|
892
790
|
} );
|
|
893
791
|
|
|
894
792
|
const LinkControlConsumer = () => {
|
|
@@ -911,16 +809,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
911
809
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
912
810
|
|
|
913
811
|
// Simulate searching for a term.
|
|
914
|
-
|
|
915
|
-
await user.keyboard( entityNameText );
|
|
916
|
-
|
|
917
|
-
await eventLoopTick();
|
|
812
|
+
await user.type( searchInput, entityNameText );
|
|
918
813
|
|
|
919
|
-
const
|
|
814
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
815
|
+
name: /Search results for.*/,
|
|
816
|
+
} );
|
|
920
817
|
|
|
921
|
-
const createButton =
|
|
922
|
-
|
|
923
|
-
)
|
|
818
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
819
|
+
name: /^Create:/,
|
|
820
|
+
} );
|
|
924
821
|
|
|
925
822
|
expect( createButton ).toBeVisible();
|
|
926
823
|
expect( createButton ).toHaveTextContent( entityNameText );
|
|
@@ -929,8 +826,6 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
929
826
|
// resolution manually via the `resolver` reference.
|
|
930
827
|
await user.click( createButton );
|
|
931
828
|
|
|
932
|
-
await eventLoopTick();
|
|
933
|
-
|
|
934
829
|
// Check for loading indicator.
|
|
935
830
|
const loadingIndicator = screen.getByText( 'Creating…' );
|
|
936
831
|
const currentLinkLabel =
|
|
@@ -943,13 +838,11 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
943
838
|
);
|
|
944
839
|
|
|
945
840
|
// Resolve the `createSuggestion` promise.
|
|
946
|
-
|
|
947
|
-
resolver( resolvedEntity );
|
|
948
|
-
} );
|
|
949
|
-
|
|
950
|
-
await eventLoopTick();
|
|
841
|
+
resolver();
|
|
951
842
|
|
|
952
|
-
const currentLink = screen.
|
|
843
|
+
const currentLink = await screen.findByLabelText(
|
|
844
|
+
'Currently selected'
|
|
845
|
+
);
|
|
953
846
|
|
|
954
847
|
expect( currentLink ).toHaveTextContent( entityNameText );
|
|
955
848
|
expect( currentLink ).toHaveTextContent( '/?p=123' );
|
|
@@ -983,25 +876,18 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
983
876
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
984
877
|
|
|
985
878
|
// Simulate searching for a term.
|
|
986
|
-
|
|
987
|
-
await user.keyboard( 'Some new page to create' );
|
|
988
|
-
|
|
989
|
-
await eventLoopTick();
|
|
879
|
+
await user.type( searchInput, 'Some new page to create' );
|
|
990
880
|
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
} )
|
|
995
|
-
).getAllByRole( 'option' );
|
|
881
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
882
|
+
name: /Search results for.*/,
|
|
883
|
+
} );
|
|
996
884
|
|
|
997
|
-
const createButton =
|
|
998
|
-
|
|
999
|
-
)
|
|
885
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
886
|
+
name: /^Create:/,
|
|
887
|
+
} );
|
|
1000
888
|
|
|
1001
889
|
await user.click( createButton );
|
|
1002
890
|
|
|
1003
|
-
await eventLoopTick();
|
|
1004
|
-
|
|
1005
891
|
const currentLink = screen.getByLabelText( 'Currently selected' );
|
|
1006
892
|
|
|
1007
893
|
expect( currentLink ).toHaveTextContent( 'Some new page to create' );
|
|
@@ -1039,33 +925,27 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1039
925
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1040
926
|
|
|
1041
927
|
// Simulate searching for a term.
|
|
1042
|
-
|
|
1043
|
-
await user.keyboard( entityNameText );
|
|
928
|
+
await user.type( searchInput, entityNameText );
|
|
1044
929
|
|
|
1045
|
-
await
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
screen.getByRole( 'listbox', {
|
|
1049
|
-
name: /Search results for.*/,
|
|
1050
|
-
} )
|
|
1051
|
-
).getAllByRole( 'option' );
|
|
1052
|
-
const createButton = Array.from( searchResultElements ).filter(
|
|
1053
|
-
( result ) => result.innerHTML.includes( 'Create:' )
|
|
1054
|
-
)[ 0 ];
|
|
930
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
931
|
+
name: /Search results for.*/,
|
|
932
|
+
} );
|
|
1055
933
|
|
|
1056
|
-
// Step down into the search results,
|
|
934
|
+
// Step down into the search results, selecting the first result item.
|
|
1057
935
|
triggerArrowDown( searchInput );
|
|
1058
936
|
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
937
|
+
// Check that the create button is in the results and that it's selected
|
|
938
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
939
|
+
name: /^Create:/,
|
|
940
|
+
selected: true,
|
|
941
|
+
} );
|
|
942
|
+
expect( createButton ).toBeVisible();
|
|
1064
943
|
|
|
1065
|
-
|
|
944
|
+
expect( searchInput ).toHaveFocus();
|
|
945
|
+
triggerEnter( searchInput );
|
|
1066
946
|
|
|
1067
947
|
expect(
|
|
1068
|
-
screen.
|
|
948
|
+
await screen.findByLabelText( 'Currently selected' )
|
|
1069
949
|
).toHaveTextContent( entityNameText );
|
|
1070
950
|
} );
|
|
1071
951
|
|
|
@@ -1088,20 +968,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1088
968
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1089
969
|
|
|
1090
970
|
// Simulate searching for a term.
|
|
1091
|
-
|
|
1092
|
-
await user.keyboard( entityNameText );
|
|
971
|
+
await user.type( searchInput, entityNameText );
|
|
1093
972
|
|
|
1094
|
-
await
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
screen.getByRole( 'listbox', {
|
|
1098
|
-
name: /Search results for.*/,
|
|
1099
|
-
} )
|
|
1100
|
-
).getAllByRole( 'option' );
|
|
973
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
974
|
+
name: /Search results for.*/,
|
|
975
|
+
} );
|
|
1101
976
|
|
|
1102
|
-
const createButton =
|
|
1103
|
-
|
|
1104
|
-
)
|
|
977
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
978
|
+
name: /Custom suggestion text/,
|
|
979
|
+
} );
|
|
1105
980
|
|
|
1106
981
|
expect( createButton ).toBeVisible();
|
|
1107
982
|
} );
|
|
@@ -1112,9 +987,6 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1112
987
|
async ( handler ) => {
|
|
1113
988
|
render( <LinkControl createSuggestion={ handler } /> );
|
|
1114
989
|
|
|
1115
|
-
// Await the initial suggestions to be fetched.
|
|
1116
|
-
await eventLoopTick();
|
|
1117
|
-
|
|
1118
990
|
// Search Input UI.
|
|
1119
991
|
const searchInput = screen.getByRole( 'combobox', {
|
|
1120
992
|
name: 'URL',
|
|
@@ -1128,17 +1000,14 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1128
1000
|
}
|
|
1129
1001
|
);
|
|
1130
1002
|
|
|
1131
|
-
it( 'should not show
|
|
1003
|
+
it( 'should not show an option to create an entity when input is empty', async () => {
|
|
1132
1004
|
render(
|
|
1133
1005
|
<LinkControl
|
|
1134
|
-
showInitialSuggestions
|
|
1006
|
+
showInitialSuggestions // Should show even if we're not showing initial suggestions.
|
|
1135
1007
|
createSuggestion={ jest.fn() }
|
|
1136
1008
|
/>
|
|
1137
1009
|
);
|
|
1138
1010
|
|
|
1139
|
-
// Await the initial suggestions to be fetched.
|
|
1140
|
-
await eventLoopTick();
|
|
1141
|
-
|
|
1142
1011
|
// Search Input UI.
|
|
1143
1012
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1144
1013
|
|
|
@@ -1167,22 +1036,17 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1167
1036
|
} );
|
|
1168
1037
|
|
|
1169
1038
|
// Simulate searching for a term.
|
|
1170
|
-
|
|
1171
|
-
await user.keyboard( inputText );
|
|
1172
|
-
|
|
1173
|
-
await eventLoopTick();
|
|
1174
|
-
|
|
1175
|
-
const searchResultElements = within(
|
|
1176
|
-
screen.getByRole( 'listbox', {
|
|
1177
|
-
name: /Search results for.*/,
|
|
1178
|
-
} )
|
|
1179
|
-
).getAllByRole( 'option' );
|
|
1039
|
+
await user.type( searchInput, inputText );
|
|
1180
1040
|
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1183
|
-
)
|
|
1041
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
1042
|
+
name: /Search results for.*/,
|
|
1043
|
+
} );
|
|
1184
1044
|
|
|
1185
|
-
|
|
1045
|
+
const createButton = within( searchResults ).queryByRole(
|
|
1046
|
+
'option',
|
|
1047
|
+
{ name: /New page/ }
|
|
1048
|
+
);
|
|
1049
|
+
expect( createButton ).not.toBeInTheDocument(); // Shouldn't exist!
|
|
1186
1050
|
}
|
|
1187
1051
|
);
|
|
1188
1052
|
} );
|
|
@@ -1205,24 +1069,18 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1205
1069
|
searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1206
1070
|
|
|
1207
1071
|
// Simulate searching for a term.
|
|
1208
|
-
|
|
1209
|
-
await user.keyboard( searchText );
|
|
1072
|
+
await user.type( searchInput, searchText );
|
|
1210
1073
|
|
|
1211
|
-
await
|
|
1074
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
1075
|
+
name: /Search results for.*/,
|
|
1076
|
+
} );
|
|
1212
1077
|
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
} )
|
|
1217
|
-
).getAllByRole( 'option' );
|
|
1218
|
-
const createButton = Array.from( searchResultElements ).filter(
|
|
1219
|
-
( result ) => result.innerHTML.includes( 'Create:' )
|
|
1220
|
-
)[ 0 ];
|
|
1078
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
1079
|
+
name: /^Create:/,
|
|
1080
|
+
} );
|
|
1221
1081
|
|
|
1222
1082
|
await user.click( createButton );
|
|
1223
1083
|
|
|
1224
|
-
await eventLoopTick();
|
|
1225
|
-
|
|
1226
1084
|
searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1227
1085
|
|
|
1228
1086
|
const errorNotice = screen.getAllByText(
|
|
@@ -1340,14 +1198,10 @@ describe( 'Selecting links', () => {
|
|
|
1340
1198
|
} );
|
|
1341
1199
|
|
|
1342
1200
|
// Simulate searching for a term.
|
|
1343
|
-
|
|
1344
|
-
await user.keyboard( searchTerm );
|
|
1345
|
-
|
|
1346
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
1347
|
-
await eventLoopTick();
|
|
1201
|
+
await user.type( searchInput, searchTerm );
|
|
1348
1202
|
|
|
1349
1203
|
const searchResultElements = within(
|
|
1350
|
-
screen.
|
|
1204
|
+
await screen.findByRole( 'listbox', {
|
|
1351
1205
|
name: /Search results for.*/,
|
|
1352
1206
|
} )
|
|
1353
1207
|
).getAllByRole( 'option' );
|
|
@@ -1406,20 +1260,17 @@ describe( 'Selecting links', () => {
|
|
|
1406
1260
|
} );
|
|
1407
1261
|
|
|
1408
1262
|
// Simulate searching for a term.
|
|
1409
|
-
|
|
1410
|
-
await user.keyboard( searchTerm );
|
|
1263
|
+
await user.type( searchInput, searchTerm );
|
|
1411
1264
|
|
|
1412
|
-
|
|
1413
|
-
|
|
1265
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
1266
|
+
name: /Search results for.*/,
|
|
1267
|
+
} );
|
|
1414
1268
|
|
|
1415
1269
|
// Step down into the search results, highlighting the first result item.
|
|
1416
1270
|
triggerArrowDown( searchInput );
|
|
1417
1271
|
|
|
1418
|
-
const searchResultElements =
|
|
1419
|
-
|
|
1420
|
-
name: /Search results for.*/,
|
|
1421
|
-
} )
|
|
1422
|
-
).getAllByRole( 'option' );
|
|
1272
|
+
const searchResultElements =
|
|
1273
|
+
within( searchResults ).getAllByRole( 'option' );
|
|
1423
1274
|
|
|
1424
1275
|
const firstSearchSuggestion = searchResultElements[ 0 ];
|
|
1425
1276
|
const secondSearchSuggestion = searchResultElements[ 1 ];
|
|
@@ -1429,7 +1280,7 @@ describe( 'Selecting links', () => {
|
|
|
1429
1280
|
} );
|
|
1430
1281
|
|
|
1431
1282
|
// We should have highlighted the first item using the keyboard.
|
|
1432
|
-
expect( selectedSearchResultElement ).
|
|
1283
|
+
expect( selectedSearchResultElement ).toBe(
|
|
1433
1284
|
firstSearchSuggestion
|
|
1434
1285
|
);
|
|
1435
1286
|
|
|
@@ -1444,7 +1295,7 @@ describe( 'Selecting links', () => {
|
|
|
1444
1295
|
|
|
1445
1296
|
// We should have highlighted the first item using the keyboard
|
|
1446
1297
|
// eslint-disable-next-line jest/no-conditional-expect
|
|
1447
|
-
expect( selectedSearchResultElement ).
|
|
1298
|
+
expect( selectedSearchResultElement ).toBe(
|
|
1448
1299
|
secondSearchSuggestion
|
|
1449
1300
|
);
|
|
1450
1301
|
|
|
@@ -1457,7 +1308,7 @@ describe( 'Selecting links', () => {
|
|
|
1457
1308
|
|
|
1458
1309
|
// We should be back to highlighting the first search result again
|
|
1459
1310
|
// eslint-disable-next-line jest/no-conditional-expect
|
|
1460
|
-
expect( selectedSearchResultElement ).
|
|
1311
|
+
expect( selectedSearchResultElement ).toBe(
|
|
1461
1312
|
firstSearchSuggestion
|
|
1462
1313
|
);
|
|
1463
1314
|
}
|
|
@@ -1486,10 +1337,8 @@ describe( 'Selecting links', () => {
|
|
|
1486
1337
|
it( 'should allow selection of initial search results via the keyboard', async () => {
|
|
1487
1338
|
render( <LinkControl showInitialSuggestions /> );
|
|
1488
1339
|
|
|
1489
|
-
await eventLoopTick();
|
|
1490
|
-
|
|
1491
1340
|
expect(
|
|
1492
|
-
screen.
|
|
1341
|
+
await screen.findByRole( 'listbox', {
|
|
1493
1342
|
name: 'Recently updated',
|
|
1494
1343
|
} )
|
|
1495
1344
|
).toBeVisible();
|
|
@@ -1500,8 +1349,6 @@ describe( 'Selecting links', () => {
|
|
|
1500
1349
|
// Step down into the search results, highlighting the first result item.
|
|
1501
1350
|
triggerArrowDown( searchInput );
|
|
1502
1351
|
|
|
1503
|
-
await eventLoopTick();
|
|
1504
|
-
|
|
1505
1352
|
const searchResultElements = within(
|
|
1506
1353
|
screen.getByRole( 'listbox', {
|
|
1507
1354
|
name: 'Recently updated',
|
|
@@ -1626,14 +1473,10 @@ describe( 'Post types', () => {
|
|
|
1626
1473
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1627
1474
|
|
|
1628
1475
|
// Simulate searching for a term.
|
|
1629
|
-
|
|
1630
|
-
await user.keyboard( searchTerm );
|
|
1631
|
-
|
|
1632
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
1633
|
-
await eventLoopTick();
|
|
1476
|
+
await user.type( searchInput, searchTerm );
|
|
1634
1477
|
|
|
1635
1478
|
const searchResultElements = within(
|
|
1636
|
-
screen.
|
|
1479
|
+
await screen.findByRole( 'listbox', {
|
|
1637
1480
|
name: /Search results for.*/,
|
|
1638
1481
|
} )
|
|
1639
1482
|
).getAllByRole( 'option' );
|
|
@@ -1657,14 +1500,10 @@ describe( 'Post types', () => {
|
|
|
1657
1500
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1658
1501
|
|
|
1659
1502
|
// Simulate searching for a term.
|
|
1660
|
-
|
|
1661
|
-
await user.keyboard( searchTerm );
|
|
1662
|
-
|
|
1663
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
1664
|
-
await eventLoopTick();
|
|
1503
|
+
await user.type( searchInput, searchTerm );
|
|
1665
1504
|
|
|
1666
1505
|
const searchResultElements = within(
|
|
1667
|
-
screen.
|
|
1506
|
+
await screen.findByRole( 'listbox', {
|
|
1668
1507
|
name: /Search results for.*/,
|
|
1669
1508
|
} )
|
|
1670
1509
|
).getAllByRole( 'option' );
|
|
@@ -1712,11 +1551,6 @@ describe( 'Rich link previews', () => {
|
|
|
1712
1551
|
|
|
1713
1552
|
render( <LinkControl value={ selectedLink } /> );
|
|
1714
1553
|
|
|
1715
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1716
|
-
await act( async () => {
|
|
1717
|
-
await eventLoopTick();
|
|
1718
|
-
} );
|
|
1719
|
-
|
|
1720
1554
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1721
1555
|
|
|
1722
1556
|
const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
|
|
@@ -1738,16 +1572,9 @@ describe( 'Rich link previews', () => {
|
|
|
1738
1572
|
|
|
1739
1573
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1740
1574
|
|
|
1741
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1742
|
-
await act( async () => {
|
|
1743
|
-
await eventLoopTick();
|
|
1744
|
-
} );
|
|
1745
|
-
|
|
1746
1575
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1747
1576
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
expect( isRichLinkPreview ).toBe( true );
|
|
1577
|
+
await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
|
|
1751
1578
|
} );
|
|
1752
1579
|
|
|
1753
1580
|
it( 'should not display placeholders for the image and description if neither is available in the data', async () => {
|
|
@@ -1762,13 +1589,10 @@ describe( 'Rich link previews', () => {
|
|
|
1762
1589
|
|
|
1763
1590
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1764
1591
|
|
|
1765
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1766
|
-
await act( async () => {
|
|
1767
|
-
await eventLoopTick();
|
|
1768
|
-
} );
|
|
1769
|
-
|
|
1770
1592
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1771
1593
|
|
|
1594
|
+
await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
|
|
1595
|
+
|
|
1772
1596
|
// Todo: refactor to use user-facing queries.
|
|
1773
1597
|
const hasRichImagePreview = linkPreview.querySelector(
|
|
1774
1598
|
'.block-editor-link-control__search-item-image'
|
|
@@ -1795,15 +1619,9 @@ describe( 'Rich link previews', () => {
|
|
|
1795
1619
|
|
|
1796
1620
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1797
1621
|
|
|
1798
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1799
|
-
await act( async () => {
|
|
1800
|
-
await eventLoopTick();
|
|
1801
|
-
} );
|
|
1802
|
-
|
|
1803
1622
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1804
1623
|
|
|
1805
|
-
|
|
1806
|
-
expect( isRichLinkPreview ).toBe( true );
|
|
1624
|
+
await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
|
|
1807
1625
|
|
|
1808
1626
|
const titlePreview = screen.getByText( selectedLink.title );
|
|
1809
1627
|
|
|
@@ -1824,15 +1642,9 @@ describe( 'Rich link previews', () => {
|
|
|
1824
1642
|
|
|
1825
1643
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1826
1644
|
|
|
1827
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1828
|
-
await act( async () => {
|
|
1829
|
-
await eventLoopTick();
|
|
1830
|
-
} );
|
|
1831
|
-
|
|
1832
1645
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1833
1646
|
|
|
1834
|
-
|
|
1835
|
-
expect( isRichLinkPreview ).toBe( true );
|
|
1647
|
+
await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
|
|
1836
1648
|
|
|
1837
1649
|
const iconPreview = linkPreview.querySelector(
|
|
1838
1650
|
`.block-editor-link-control__search-item-icon`
|
|
@@ -1862,16 +1674,11 @@ describe( 'Rich link previews', () => {
|
|
|
1862
1674
|
|
|
1863
1675
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1864
1676
|
|
|
1865
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1866
|
-
await act( async () => {
|
|
1867
|
-
await eventLoopTick();
|
|
1868
|
-
} );
|
|
1869
|
-
|
|
1870
1677
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1871
1678
|
|
|
1872
|
-
|
|
1873
|
-
linkPreview.
|
|
1874
|
-
|
|
1679
|
+
await waitFor( () =>
|
|
1680
|
+
expect( linkPreview ).toHaveClass( 'is-rich' )
|
|
1681
|
+
);
|
|
1875
1682
|
|
|
1876
1683
|
const missingDataItem = linkPreview.querySelector(
|
|
1877
1684
|
`.block-editor-link-control__search-item-${ dataItem }`
|
|
@@ -1887,23 +1694,19 @@ describe( 'Rich link previews', () => {
|
|
|
1887
1694
|
] )(
|
|
1888
1695
|
'should not display a rich preview when data is %s',
|
|
1889
1696
|
async ( _descriptor, data ) => {
|
|
1890
|
-
mockFetchRichUrlData.mockImplementation( () =>
|
|
1891
|
-
Promise.resolve( data )
|
|
1892
|
-
);
|
|
1697
|
+
mockFetchRichUrlData.mockImplementation( async () => data );
|
|
1893
1698
|
|
|
1894
1699
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1895
1700
|
|
|
1896
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1897
|
-
await act( async () => {
|
|
1898
|
-
await eventLoopTick();
|
|
1899
|
-
} );
|
|
1900
|
-
|
|
1901
1701
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1902
1702
|
|
|
1903
|
-
|
|
1904
|
-
linkPreview.classList.contains( 'is-rich' );
|
|
1703
|
+
expect( linkPreview ).toHaveClass( 'is-fetching' );
|
|
1905
1704
|
|
|
1906
|
-
|
|
1705
|
+
await waitFor( () =>
|
|
1706
|
+
expect( linkPreview ).not.toHaveClass( 'is-fetching' )
|
|
1707
|
+
);
|
|
1708
|
+
|
|
1709
|
+
expect( linkPreview ).not.toHaveClass( 'is-rich' );
|
|
1907
1710
|
}
|
|
1908
1711
|
);
|
|
1909
1712
|
|
|
@@ -1914,19 +1717,10 @@ describe( 'Rich link previews', () => {
|
|
|
1914
1717
|
|
|
1915
1718
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1916
1719
|
|
|
1917
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1918
|
-
await act( async () => {
|
|
1919
|
-
await eventLoopTick();
|
|
1920
|
-
} );
|
|
1921
|
-
|
|
1922
1720
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1923
1721
|
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
|
|
1927
|
-
|
|
1928
|
-
expect( isFetchingRichPreview ).toBe( true );
|
|
1929
|
-
expect( isRichLinkPreview ).toBe( false );
|
|
1722
|
+
expect( linkPreview ).toHaveClass( 'is-fetching' );
|
|
1723
|
+
expect( linkPreview ).not.toHaveClass( 'is-rich' );
|
|
1930
1724
|
} );
|
|
1931
1725
|
|
|
1932
1726
|
it( 'should remove fetching UI indicators and fallback to standard preview if request for rich preview results in an error', async () => {
|
|
@@ -1936,20 +1730,15 @@ describe( 'Rich link previews', () => {
|
|
|
1936
1730
|
|
|
1937
1731
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1938
1732
|
|
|
1939
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1940
|
-
await act( async () => {
|
|
1941
|
-
await eventLoopTick();
|
|
1942
|
-
} );
|
|
1943
|
-
|
|
1944
1733
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1945
1734
|
|
|
1946
|
-
|
|
1947
|
-
linkPreview.classList.contains( 'is-fetching' );
|
|
1735
|
+
expect( linkPreview ).toHaveClass( 'is-fetching' );
|
|
1948
1736
|
|
|
1949
|
-
|
|
1737
|
+
await waitFor( () =>
|
|
1738
|
+
expect( linkPreview ).not.toHaveClass( 'is-fetching' )
|
|
1739
|
+
);
|
|
1950
1740
|
|
|
1951
|
-
expect(
|
|
1952
|
-
expect( isRichLinkPreview ).toBe( false );
|
|
1741
|
+
expect( linkPreview ).not.toHaveClass( 'is-rich' );
|
|
1953
1742
|
} );
|
|
1954
1743
|
|
|
1955
1744
|
afterAll( () => {
|
|
@@ -2050,8 +1839,7 @@ describe( 'Controlling link title text', () => {
|
|
|
2050
1839
|
|
|
2051
1840
|
const textInput = screen.queryByRole( 'textbox', { name: 'Text' } );
|
|
2052
1841
|
|
|
2053
|
-
|
|
2054
|
-
await userEvent.clear( textInput );
|
|
1842
|
+
await user.clear( textInput );
|
|
2055
1843
|
await user.keyboard( textValue );
|
|
2056
1844
|
|
|
2057
1845
|
expect( textInput ).toHaveValue( textValue );
|
|
@@ -2087,8 +1875,7 @@ describe( 'Controlling link title text', () => {
|
|
|
2087
1875
|
|
|
2088
1876
|
expect( textInput ).toBeVisible();
|
|
2089
1877
|
|
|
2090
|
-
|
|
2091
|
-
await userEvent.clear( textInput );
|
|
1878
|
+
await user.clear( textInput );
|
|
2092
1879
|
await user.keyboard( textValue );
|
|
2093
1880
|
|
|
2094
1881
|
// Attempt to submit the empty search value in the input.
|