@wordpress/block-editor 10.5.0 → 11.1.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 +18 -0
- package/README.md +2 -1
- 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/alignment-control/ui.js +1 -7
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build/components/block-alignment-control/use-available-alignments.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-icon/index.js +4 -2
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +90 -37
- 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-list-appender/index.js +46 -34
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js +39 -34
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +30 -22
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +16 -8
- 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-styles/index.native.js +1 -3
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-styles/utils.js +7 -10
- package/build/components/block-styles/utils.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-toolbar/index.native.js +6 -8
- package/build/components/block-toolbar/index.native.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-tools/selected-block-popover.js +1 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-picker/index.js +2 -3
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/utils.js +2 -6
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +0 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +0 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/copy-handler/index.js +37 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +5 -2
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -4
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +11 -6
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -8
- package/build/components/gradients/use-gradient.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 +22 -101
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +93 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -0
- 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 +25 -7
- 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/hooks/use-insertion-point.js +4 -3
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +20 -6
- 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 +106 -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 +7 -3
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +15 -14
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +7 -3
- 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-select-button.js +1 -1
- package/build/components/list-view/block-select-button.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 +99 -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-select-button.js +3 -2
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +82 -38
- 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 +24 -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/off-canvas-editor/use-inserted-block.js +58 -0
- package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build/components/responsive-block-control/label.js.map +1 -1
- package/build/components/rich-text/format-edit.js +12 -10
- package/build/components/rich-text/format-edit.js.map +1 -1
- 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-paste-handler.js +21 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- 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/index.js +0 -1
- package/build/components/spacing-sizes-control/index.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/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.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/url-popover/image-url-input-ui.js +2 -2
- package/build/components/url-popover/image-url-input-ui.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/components/writing-flow/index.js +1 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/color-panel.js +0 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -2
- package/build/hooks/color.js.map +1 -1
- 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/font-family.js +4 -4
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +5 -3
- package/build/hooks/font-size.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/hooks/use-typography-props.js +11 -8
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/store/reducer.js +411 -274
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +58 -48
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js +6 -11
- package/build/utils/pasting.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/alignment-control/ui.js +1 -6
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build-module/components/block-alignment-control/use-available-alignments.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-icon/index.js +4 -2
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +87 -34
- 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-list-appender/index.js +46 -34
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js +39 -32
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +31 -24
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +16 -8
- 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-styles/index.native.js +1 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-styles/utils.js +7 -9
- package/build-module/components/block-styles/utils.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-toolbar/index.native.js +6 -8
- package/build-module/components/block-toolbar/index.native.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-tools/selected-block-popover.js +1 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +2 -3
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/utils.js +3 -7
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +0 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +0 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/copy-handler/index.js +38 -10
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +5 -2
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +11 -5
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +12 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -7
- package/build-module/components/gradients/use-gradient.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 +21 -101
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +85 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
- 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 +27 -9
- 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/hooks/use-insertion-point.js +4 -3
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +20 -6
- 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 +92 -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 +7 -3
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +15 -13
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +7 -4
- 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-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.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 +83 -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-select-button.js +3 -2
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +83 -41
- 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 +24 -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/off-canvas-editor/use-inserted-block.js +47 -0
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build-module/components/responsive-block-control/label.js +1 -2
- package/build-module/components/responsive-block-control/label.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +12 -9
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- 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-paste-handler.js +22 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- 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/index.js +0 -1
- package/build-module/components/spacing-sizes-control/index.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/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.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/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.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/components/writing-flow/index.js +1 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.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/color-panel.js +0 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -2
- package/build-module/hooks/color.js.map +1 -1
- 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/font-family.js +5 -5
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +5 -3
- package/build-module/hooks/font-size.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/hooks/use-typography-props.js +11 -8
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/store/reducer.js +409 -274
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +55 -48
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js +6 -10
- package/build-module/utils/pasting.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 +17 -3
- package/build-style/default-editor-styles.css +17 -3
- package/build-style/style-rtl.css +313 -665
- package/build-style/style.css +313 -665
- 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 +6 -1
- package/src/components/alignment-control/ui.js +1 -7
- package/src/components/block-alignment-control/test/index.js +6 -1
- package/src/components/block-alignment-control/use-available-alignments.js +4 -3
- 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-icon/index.js +4 -2
- package/src/components/block-icon/test/index.js +9 -5
- package/src/components/block-inspector/index.js +173 -85
- package/src/components/block-inspector/style.scss +16 -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-list-appender/index.js +65 -54
- package/src/components/block-list-appender/index.native.js +45 -34
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +42 -28
- package/src/components/block-mobile-toolbar/index.native.js +1 -1
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -2
- package/src/components/block-mover/test/index.native.js +157 -1
- package/src/components/block-pattern-setup/index.js +17 -7
- package/src/components/block-pattern-setup/style.scss +29 -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-styles/index.native.js +1 -2
- package/src/components/block-styles/utils.js +5 -7
- package/src/components/block-switcher/test/index.js +6 -1
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/index.native.js +8 -11
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/selected-block-popover.js +1 -3
- package/src/components/block-tools/style.scss +12 -5
- package/src/components/block-variation-picker/index.js +6 -5
- package/src/components/block-vertical-alignment-control/test/index.js +6 -1
- package/src/components/colors/test/with-colors.js +2 -0
- package/src/components/colors/utils.js +5 -3
- package/src/components/colors-gradients/control.js +0 -7
- package/src/components/colors-gradients/dropdown.js +0 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/src/components/copy-handler/index.js +53 -7
- package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/default-block-appender/test/index.js +2 -0
- package/src/components/font-sizes/fluid-utils.js +7 -1
- package/src/components/font-sizes/utils.js +5 -3
- package/src/components/font-sizes/with-font-sizes.js +4 -4
- package/src/components/gradients/use-gradient.js +2 -7
- 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 +33 -121
- package/src/components/iframe/use-compatibility-styles.js +95 -0
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/image-size-control/test/index.js +147 -79
- 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 +26 -7
- 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/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/index.js +24 -3
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +89 -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 +4 -0
- package/src/components/inserter/search-items.js +1 -2
- package/src/components/inserter/search-results.js +5 -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 +204 -403
- package/src/components/link-control/use-internal-input-value.js +3 -3
- package/src/components/list-view/block-select-button.js +1 -1
- 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 +21 -16
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +39 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/appender.js +98 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block-select-button.js +6 -2
- package/src/components/off-canvas-editor/block.js +160 -77
- package/src/components/off-canvas-editor/branch.js +3 -5
- package/src/components/off-canvas-editor/index.js +68 -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 +19 -386
- package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/off-canvas-editor/use-inserted-block.js +47 -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/responsive-block-control/label.js +2 -3
- package/src/components/responsive-block-control/test/index.js +4 -2
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-edit.js +6 -10
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +3 -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-paste-handler.js +33 -14
- 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/index.js +0 -1
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/typewriter/index.js +3 -1
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-input/test/button.js +2 -0
- package/src/components/url-popover/image-url-input-ui.js +5 -4
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +37 -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/components/warning/test/index.js +2 -0
- package/src/components/writing-flow/index.js +1 -1
- package/src/content.scss +10 -0
- package/src/hooks/border.js +0 -1
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/color-panel.js +0 -1
- package/src/hooks/color.js +0 -2
- package/src/hooks/content-lock-ui.js +1 -1
- package/src/hooks/dimensions.js +45 -7
- package/src/hooks/font-family.js +3 -5
- package/src/hooks/font-size.js +13 -4
- package/src/hooks/layout.js +60 -0
- package/src/hooks/min-height.js +2 -19
- package/src/hooks/test/use-typography-props.js +26 -0
- package/src/hooks/use-typography-props.js +15 -7
- package/src/store/reducer.js +471 -428
- package/src/store/selectors.js +57 -59
- 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/pasting.js +3 -9
- 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/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build/components/rich-text/file-paste-handler.js +0 -21
- package/build/components/rich-text/file-paste-handler.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/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build-module/components/rich-text/file-paste-handler.js +0 -13
- package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/src/components/rich-text/file-paste-handler.js +0 -13
|
@@ -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,34 +365,37 @@ 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
|
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
)
|
|
419
|
-
);
|
|
376
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
377
|
+
name: /Search results for.*/,
|
|
378
|
+
} );
|
|
420
379
|
|
|
421
|
-
const
|
|
422
|
-
(
|
|
423
|
-
|
|
380
|
+
const searchResultTextHighlightElements = within( searchResults )
|
|
381
|
+
.getAllByRole( 'option' )
|
|
382
|
+
// TODO: Change to `getByRole( 'mark' )` when officially supported by
|
|
383
|
+
// WAI-ARIA 1.3 - see https://w3c.github.io/aria/#mark
|
|
384
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
385
|
+
.map( ( searchResult ) => searchResult.querySelector( 'mark' ) )
|
|
386
|
+
.flat()
|
|
387
|
+
.filter( Boolean );
|
|
424
388
|
|
|
425
389
|
// Given we're mocking out the results we should always have 4 mark elements.
|
|
426
390
|
expect( searchResultTextHighlightElements ).toHaveLength( 4 );
|
|
427
391
|
|
|
428
392
|
// Make sure there are no `mark` elements which contain anything other
|
|
429
393
|
// than the trimmed search term (ie: no whitespace).
|
|
430
|
-
expect(
|
|
394
|
+
expect(
|
|
395
|
+
searchResultTextHighlightElements.every(
|
|
396
|
+
( mark ) => mark.innerHTML === 'Hello'
|
|
397
|
+
)
|
|
398
|
+
).toBe( true );
|
|
431
399
|
|
|
432
400
|
// Implementation detail test to ensure that the fetch handler is called
|
|
433
401
|
// with the trimmed search value. We do this because we are mocking out
|
|
@@ -447,14 +415,10 @@ describe( 'Searching for a link', () => {
|
|
|
447
415
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
448
416
|
|
|
449
417
|
// Simulate searching for a term.
|
|
450
|
-
|
|
451
|
-
await user.keyboard( 'anything' );
|
|
418
|
+
await user.type( searchInput, 'anything' );
|
|
452
419
|
|
|
453
420
|
const searchResultsField = screen.queryByRole( 'listbox' );
|
|
454
421
|
|
|
455
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
456
|
-
await eventLoopTick();
|
|
457
|
-
|
|
458
422
|
expect( searchResultsField ).not.toBeInTheDocument();
|
|
459
423
|
expect( mockFetchSearchSuggestions ).not.toHaveBeenCalled();
|
|
460
424
|
} );
|
|
@@ -472,14 +436,10 @@ describe( 'Searching for a link', () => {
|
|
|
472
436
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
473
437
|
|
|
474
438
|
// Simulate searching for a term.
|
|
475
|
-
|
|
476
|
-
await user.keyboard( searchTerm );
|
|
477
|
-
|
|
478
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
479
|
-
await eventLoopTick();
|
|
439
|
+
await user.type( searchInput, searchTerm );
|
|
480
440
|
|
|
481
441
|
const searchResultElements = within(
|
|
482
|
-
screen.
|
|
442
|
+
await screen.findByRole( 'listbox', {
|
|
483
443
|
name: /Search results for.*/,
|
|
484
444
|
} )
|
|
485
445
|
).getAllByRole( 'option' );
|
|
@@ -510,14 +470,10 @@ describe( 'Searching for a link', () => {
|
|
|
510
470
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
511
471
|
|
|
512
472
|
// Simulate searching for a term.
|
|
513
|
-
|
|
514
|
-
await user.keyboard( 'couldbeurlorentitysearchterm' );
|
|
515
|
-
|
|
516
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
517
|
-
await eventLoopTick();
|
|
473
|
+
await user.type( searchInput, 'couldbeurlorentitysearchterm' );
|
|
518
474
|
|
|
519
475
|
const searchResultElements = within(
|
|
520
|
-
screen.
|
|
476
|
+
await screen.findByRole( 'listbox', {
|
|
521
477
|
name: /Search results for.*/,
|
|
522
478
|
} )
|
|
523
479
|
).getAllByRole( 'option' );
|
|
@@ -544,14 +500,10 @@ describe( 'Manual link entry', () => {
|
|
|
544
500
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
545
501
|
|
|
546
502
|
// Simulate searching for a term.
|
|
547
|
-
|
|
548
|
-
await user.keyboard( searchTerm );
|
|
549
|
-
|
|
550
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
551
|
-
await eventLoopTick();
|
|
503
|
+
await user.type( searchInput, searchTerm );
|
|
552
504
|
|
|
553
505
|
const searchResultElements = within(
|
|
554
|
-
screen.
|
|
506
|
+
await screen.findByRole( 'listbox', {
|
|
555
507
|
name: /Search results for.*/,
|
|
556
508
|
} )
|
|
557
509
|
).getByRole( 'option' );
|
|
@@ -584,29 +536,25 @@ describe( 'Manual link entry', () => {
|
|
|
584
536
|
name: 'URL',
|
|
585
537
|
} );
|
|
586
538
|
|
|
587
|
-
let submitButton = screen.
|
|
539
|
+
let submitButton = screen.getByRole( 'button', {
|
|
588
540
|
name: 'Submit',
|
|
589
541
|
} );
|
|
590
542
|
|
|
591
543
|
expect( submitButton ).toBeDisabled();
|
|
592
544
|
expect( submitButton ).toBeVisible();
|
|
593
545
|
|
|
594
|
-
searchInput.focus();
|
|
595
546
|
if ( searchString.length ) {
|
|
596
547
|
// Simulate searching for a term.
|
|
597
|
-
await user.
|
|
548
|
+
await user.type( searchInput, searchString );
|
|
598
549
|
} else {
|
|
599
550
|
// Simulate clearing the search term.
|
|
600
|
-
await
|
|
551
|
+
await user.clear( searchInput );
|
|
601
552
|
}
|
|
602
553
|
|
|
603
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
604
|
-
await eventLoopTick();
|
|
605
|
-
|
|
606
554
|
// Attempt to submit the empty search value in the input.
|
|
607
555
|
await user.keyboard( '[Enter]' );
|
|
608
556
|
|
|
609
|
-
submitButton = screen.
|
|
557
|
+
submitButton = screen.getByRole( 'button', {
|
|
610
558
|
name: 'Submit',
|
|
611
559
|
} );
|
|
612
560
|
|
|
@@ -637,18 +585,14 @@ describe( 'Manual link entry', () => {
|
|
|
637
585
|
expect( submitButton ).toBeVisible();
|
|
638
586
|
|
|
639
587
|
// Simulate searching for a term.
|
|
640
|
-
searchInput.focus();
|
|
641
588
|
if ( searchString.length ) {
|
|
642
589
|
// Simulate searching for a term.
|
|
643
|
-
await user.
|
|
590
|
+
await user.type( searchInput, searchString );
|
|
644
591
|
} else {
|
|
645
592
|
// Simulate clearing the search term.
|
|
646
|
-
await
|
|
593
|
+
await user.clear( searchInput );
|
|
647
594
|
}
|
|
648
595
|
|
|
649
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
650
|
-
await eventLoopTick();
|
|
651
|
-
|
|
652
596
|
// Attempt to submit the empty search value in the input.
|
|
653
597
|
await user.click( submitButton );
|
|
654
598
|
|
|
@@ -681,14 +625,10 @@ describe( 'Manual link entry', () => {
|
|
|
681
625
|
} );
|
|
682
626
|
|
|
683
627
|
// Simulate searching for a term.
|
|
684
|
-
|
|
685
|
-
await user.keyboard( searchTerm );
|
|
686
|
-
|
|
687
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
688
|
-
await eventLoopTick();
|
|
628
|
+
await user.type( searchInput, searchTerm );
|
|
689
629
|
|
|
690
630
|
const searchResultElements = within(
|
|
691
|
-
screen.
|
|
631
|
+
await screen.findByRole( 'listbox', {
|
|
692
632
|
name: /Search results for.*/,
|
|
693
633
|
} )
|
|
694
634
|
).getByRole( 'option' );
|
|
@@ -706,14 +646,10 @@ describe( 'Manual link entry', () => {
|
|
|
706
646
|
|
|
707
647
|
describe( 'Default search suggestions', () => {
|
|
708
648
|
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
649
|
render( <LinkControl showInitialSuggestions /> );
|
|
712
650
|
|
|
713
|
-
await eventLoopTick();
|
|
714
|
-
|
|
715
651
|
expect(
|
|
716
|
-
screen.
|
|
652
|
+
await screen.findByRole( 'listbox', {
|
|
717
653
|
name: 'Recently updated',
|
|
718
654
|
} )
|
|
719
655
|
).toBeVisible();
|
|
@@ -731,24 +667,16 @@ describe( 'Default search suggestions', () => {
|
|
|
731
667
|
expect( mockFetchSearchSuggestions ).toHaveBeenCalledTimes( 1 );
|
|
732
668
|
|
|
733
669
|
// Verify the search results already display the initial suggestions.
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
);
|
|
670
|
+
// `LinkControl` internally always limits the number of initial suggestions to 3.
|
|
671
|
+
expect( screen.queryAllByRole( 'option' ) ).toHaveLength( 3 );
|
|
737
672
|
} );
|
|
738
673
|
|
|
739
674
|
it( 'should not display initial suggestions when input value is present', async () => {
|
|
740
675
|
const user = userEvent.setup();
|
|
741
676
|
|
|
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();
|
|
677
|
+
// Render with an initial value an ensure that no initial suggestions are shown.
|
|
678
|
+
const initialValue = fauxEntitySuggestions[ 0 ];
|
|
679
|
+
render( <LinkControl showInitialSuggestions value={ initialValue } /> );
|
|
752
680
|
|
|
753
681
|
expect( mockFetchSearchSuggestions ).not.toHaveBeenCalled();
|
|
754
682
|
|
|
@@ -758,23 +686,21 @@ describe( 'Default search suggestions', () => {
|
|
|
758
686
|
const currentLinkBtn = within( currentLinkUI ).getByRole( 'button', {
|
|
759
687
|
name: 'Edit',
|
|
760
688
|
} );
|
|
761
|
-
|
|
762
689
|
await user.click( currentLinkBtn );
|
|
763
690
|
|
|
764
691
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
765
|
-
|
|
692
|
+
// Search input is set to the URL value.
|
|
693
|
+
expect( searchInput ).toHaveValue( initialValue.url );
|
|
766
694
|
|
|
767
|
-
|
|
695
|
+
// Focus the search input to display suggestions
|
|
696
|
+
await user.click( searchInput );
|
|
768
697
|
|
|
769
698
|
const searchResultElements = within(
|
|
770
|
-
screen.
|
|
699
|
+
await screen.findByRole( 'listbox', {
|
|
771
700
|
name: /Search results for.*/,
|
|
772
701
|
} )
|
|
773
702
|
).getAllByRole( 'option' );
|
|
774
703
|
|
|
775
|
-
// Search input is set to the URL value.
|
|
776
|
-
expect( searchInput ).toHaveValue( fauxEntitySuggestions[ 0 ].url );
|
|
777
|
-
|
|
778
704
|
// It should match any url that's like ?p= and also include a URL option.
|
|
779
705
|
expect( searchResultElements ).toHaveLength( 5 );
|
|
780
706
|
|
|
@@ -789,63 +715,45 @@ describe( 'Default search suggestions', () => {
|
|
|
789
715
|
|
|
790
716
|
render( <LinkControl showInitialSuggestions /> );
|
|
791
717
|
|
|
792
|
-
let searchResultElements;
|
|
793
|
-
let searchInput;
|
|
794
|
-
|
|
795
718
|
// Search Input UI.
|
|
796
|
-
searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
719
|
+
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
797
720
|
|
|
798
721
|
// Simulate searching for a term.
|
|
799
|
-
|
|
800
|
-
await user.keyboard( searchTerm );
|
|
801
|
-
|
|
802
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
803
|
-
await eventLoopTick();
|
|
722
|
+
await user.type( searchInput, searchTerm );
|
|
804
723
|
|
|
805
724
|
expect( searchInput ).toHaveValue( searchTerm );
|
|
806
725
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
} )
|
|
811
|
-
).getAllByRole( 'option' );
|
|
812
|
-
|
|
813
|
-
// Delete the text.
|
|
814
|
-
await userEvent.clear( searchInput );
|
|
726
|
+
const searchResultsList = await screen.findByRole( 'listbox', {
|
|
727
|
+
name: /Search results for.*/,
|
|
728
|
+
} );
|
|
815
729
|
|
|
816
|
-
|
|
730
|
+
expect( searchResultsList ).toBeVisible();
|
|
817
731
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
} )
|
|
822
|
-
).getAllByRole( 'option' );
|
|
732
|
+
expect(
|
|
733
|
+
within( searchResultsList ).getAllByRole( 'option' )
|
|
734
|
+
).toHaveLength( 4 );
|
|
823
735
|
|
|
824
|
-
|
|
736
|
+
// Delete the text.
|
|
737
|
+
await userEvent.clear( searchInput );
|
|
825
738
|
|
|
826
739
|
// Check the input is empty now.
|
|
827
740
|
expect( searchInput ).toHaveValue( '' );
|
|
828
741
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
} )
|
|
833
|
-
).toBeVisible();
|
|
742
|
+
const initialResultsList = await screen.findByRole( 'listbox', {
|
|
743
|
+
name: 'Recently updated',
|
|
744
|
+
} );
|
|
834
745
|
|
|
835
|
-
expect(
|
|
746
|
+
expect(
|
|
747
|
+
within( initialResultsList ).getAllByRole( 'option' )
|
|
748
|
+
).toHaveLength( 3 );
|
|
836
749
|
} );
|
|
837
750
|
|
|
838
751
|
it( 'should not display initial suggestions when there are no recently updated pages/posts', async () => {
|
|
839
|
-
const noResults = [];
|
|
840
752
|
// Force API returning empty results for recently updated Pages.
|
|
841
|
-
mockFetchSearchSuggestions.mockImplementation( () =>
|
|
842
|
-
Promise.resolve( noResults )
|
|
843
|
-
);
|
|
753
|
+
mockFetchSearchSuggestions.mockImplementation( async () => [] );
|
|
844
754
|
|
|
845
755
|
render( <LinkControl showInitialSuggestions /> );
|
|
846
756
|
|
|
847
|
-
await eventLoopTick();
|
|
848
|
-
|
|
849
757
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
850
758
|
|
|
851
759
|
const searchResultsField = screen.queryByRole( 'listbox', {
|
|
@@ -876,19 +784,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
876
784
|
async ( entityNameText ) => {
|
|
877
785
|
const user = userEvent.setup();
|
|
878
786
|
let resolver;
|
|
879
|
-
let resolvedEntity;
|
|
880
|
-
|
|
881
787
|
const createSuggestion = ( title ) =>
|
|
882
788
|
new Promise( ( resolve ) => {
|
|
883
|
-
resolver = (
|
|
884
|
-
resolve(
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
type: 'page',
|
|
891
|
-
};
|
|
789
|
+
resolver = () =>
|
|
790
|
+
resolve( {
|
|
791
|
+
title,
|
|
792
|
+
id: 123,
|
|
793
|
+
url: '/?p=123',
|
|
794
|
+
type: 'page',
|
|
795
|
+
} );
|
|
892
796
|
} );
|
|
893
797
|
|
|
894
798
|
const LinkControlConsumer = () => {
|
|
@@ -911,16 +815,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
911
815
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
912
816
|
|
|
913
817
|
// Simulate searching for a term.
|
|
914
|
-
|
|
915
|
-
await user.keyboard( entityNameText );
|
|
916
|
-
|
|
917
|
-
await eventLoopTick();
|
|
818
|
+
await user.type( searchInput, entityNameText );
|
|
918
819
|
|
|
919
|
-
const
|
|
820
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
821
|
+
name: /Search results for.*/,
|
|
822
|
+
} );
|
|
920
823
|
|
|
921
|
-
const createButton =
|
|
922
|
-
|
|
923
|
-
)
|
|
824
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
825
|
+
name: /^Create:/,
|
|
826
|
+
} );
|
|
924
827
|
|
|
925
828
|
expect( createButton ).toBeVisible();
|
|
926
829
|
expect( createButton ).toHaveTextContent( entityNameText );
|
|
@@ -929,8 +832,6 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
929
832
|
// resolution manually via the `resolver` reference.
|
|
930
833
|
await user.click( createButton );
|
|
931
834
|
|
|
932
|
-
await eventLoopTick();
|
|
933
|
-
|
|
934
835
|
// Check for loading indicator.
|
|
935
836
|
const loadingIndicator = screen.getByText( 'Creating…' );
|
|
936
837
|
const currentLinkLabel =
|
|
@@ -943,13 +844,11 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
943
844
|
);
|
|
944
845
|
|
|
945
846
|
// Resolve the `createSuggestion` promise.
|
|
946
|
-
|
|
947
|
-
resolver( resolvedEntity );
|
|
948
|
-
} );
|
|
949
|
-
|
|
950
|
-
await eventLoopTick();
|
|
847
|
+
resolver();
|
|
951
848
|
|
|
952
|
-
const currentLink = screen.
|
|
849
|
+
const currentLink = await screen.findByLabelText(
|
|
850
|
+
'Currently selected'
|
|
851
|
+
);
|
|
953
852
|
|
|
954
853
|
expect( currentLink ).toHaveTextContent( entityNameText );
|
|
955
854
|
expect( currentLink ).toHaveTextContent( '/?p=123' );
|
|
@@ -983,25 +882,18 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
983
882
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
984
883
|
|
|
985
884
|
// Simulate searching for a term.
|
|
986
|
-
|
|
987
|
-
await user.keyboard( 'Some new page to create' );
|
|
988
|
-
|
|
989
|
-
await eventLoopTick();
|
|
885
|
+
await user.type( searchInput, 'Some new page to create' );
|
|
990
886
|
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
} )
|
|
995
|
-
).getAllByRole( 'option' );
|
|
887
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
888
|
+
name: /Search results for.*/,
|
|
889
|
+
} );
|
|
996
890
|
|
|
997
|
-
const createButton =
|
|
998
|
-
|
|
999
|
-
)
|
|
891
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
892
|
+
name: /^Create:/,
|
|
893
|
+
} );
|
|
1000
894
|
|
|
1001
895
|
await user.click( createButton );
|
|
1002
896
|
|
|
1003
|
-
await eventLoopTick();
|
|
1004
|
-
|
|
1005
897
|
const currentLink = screen.getByLabelText( 'Currently selected' );
|
|
1006
898
|
|
|
1007
899
|
expect( currentLink ).toHaveTextContent( 'Some new page to create' );
|
|
@@ -1039,33 +931,27 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1039
931
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1040
932
|
|
|
1041
933
|
// Simulate searching for a term.
|
|
1042
|
-
|
|
1043
|
-
await user.keyboard( entityNameText );
|
|
934
|
+
await user.type( searchInput, entityNameText );
|
|
1044
935
|
|
|
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 ];
|
|
936
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
937
|
+
name: /Search results for.*/,
|
|
938
|
+
} );
|
|
1055
939
|
|
|
1056
|
-
// Step down into the search results,
|
|
940
|
+
// Step down into the search results, selecting the first result item.
|
|
1057
941
|
triggerArrowDown( searchInput );
|
|
1058
942
|
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
943
|
+
// Check that the create button is in the results and that it's selected
|
|
944
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
945
|
+
name: /^Create:/,
|
|
946
|
+
selected: true,
|
|
947
|
+
} );
|
|
948
|
+
expect( createButton ).toBeVisible();
|
|
1064
949
|
|
|
1065
|
-
|
|
950
|
+
expect( searchInput ).toHaveFocus();
|
|
951
|
+
triggerEnter( searchInput );
|
|
1066
952
|
|
|
1067
953
|
expect(
|
|
1068
|
-
screen.
|
|
954
|
+
await screen.findByLabelText( 'Currently selected' )
|
|
1069
955
|
).toHaveTextContent( entityNameText );
|
|
1070
956
|
} );
|
|
1071
957
|
|
|
@@ -1088,20 +974,15 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1088
974
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1089
975
|
|
|
1090
976
|
// Simulate searching for a term.
|
|
1091
|
-
|
|
1092
|
-
await user.keyboard( entityNameText );
|
|
977
|
+
await user.type( searchInput, entityNameText );
|
|
1093
978
|
|
|
1094
|
-
await
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
screen.getByRole( 'listbox', {
|
|
1098
|
-
name: /Search results for.*/,
|
|
1099
|
-
} )
|
|
1100
|
-
).getAllByRole( 'option' );
|
|
979
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
980
|
+
name: /Search results for.*/,
|
|
981
|
+
} );
|
|
1101
982
|
|
|
1102
|
-
const createButton =
|
|
1103
|
-
|
|
1104
|
-
)
|
|
983
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
984
|
+
name: /Custom suggestion text/,
|
|
985
|
+
} );
|
|
1105
986
|
|
|
1106
987
|
expect( createButton ).toBeVisible();
|
|
1107
988
|
} );
|
|
@@ -1112,9 +993,6 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1112
993
|
async ( handler ) => {
|
|
1113
994
|
render( <LinkControl createSuggestion={ handler } /> );
|
|
1114
995
|
|
|
1115
|
-
// Await the initial suggestions to be fetched.
|
|
1116
|
-
await eventLoopTick();
|
|
1117
|
-
|
|
1118
996
|
// Search Input UI.
|
|
1119
997
|
const searchInput = screen.getByRole( 'combobox', {
|
|
1120
998
|
name: 'URL',
|
|
@@ -1128,17 +1006,14 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1128
1006
|
}
|
|
1129
1007
|
);
|
|
1130
1008
|
|
|
1131
|
-
it( 'should not show
|
|
1009
|
+
it( 'should not show an option to create an entity when input is empty', async () => {
|
|
1132
1010
|
render(
|
|
1133
1011
|
<LinkControl
|
|
1134
|
-
showInitialSuggestions
|
|
1012
|
+
showInitialSuggestions // Should show even if we're not showing initial suggestions.
|
|
1135
1013
|
createSuggestion={ jest.fn() }
|
|
1136
1014
|
/>
|
|
1137
1015
|
);
|
|
1138
1016
|
|
|
1139
|
-
// Await the initial suggestions to be fetched.
|
|
1140
|
-
await eventLoopTick();
|
|
1141
|
-
|
|
1142
1017
|
// Search Input UI.
|
|
1143
1018
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1144
1019
|
|
|
@@ -1167,22 +1042,17 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1167
1042
|
} );
|
|
1168
1043
|
|
|
1169
1044
|
// 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' );
|
|
1045
|
+
await user.type( searchInput, inputText );
|
|
1180
1046
|
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1183
|
-
)
|
|
1047
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
1048
|
+
name: /Search results for.*/,
|
|
1049
|
+
} );
|
|
1184
1050
|
|
|
1185
|
-
|
|
1051
|
+
const createButton = within( searchResults ).queryByRole(
|
|
1052
|
+
'option',
|
|
1053
|
+
{ name: /New page/ }
|
|
1054
|
+
);
|
|
1055
|
+
expect( createButton ).not.toBeInTheDocument(); // Shouldn't exist!
|
|
1186
1056
|
}
|
|
1187
1057
|
);
|
|
1188
1058
|
} );
|
|
@@ -1205,24 +1075,18 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1205
1075
|
searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1206
1076
|
|
|
1207
1077
|
// Simulate searching for a term.
|
|
1208
|
-
|
|
1209
|
-
await user.keyboard( searchText );
|
|
1078
|
+
await user.type( searchInput, searchText );
|
|
1210
1079
|
|
|
1211
|
-
await
|
|
1080
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
1081
|
+
name: /Search results for.*/,
|
|
1082
|
+
} );
|
|
1212
1083
|
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
} )
|
|
1217
|
-
).getAllByRole( 'option' );
|
|
1218
|
-
const createButton = Array.from( searchResultElements ).filter(
|
|
1219
|
-
( result ) => result.innerHTML.includes( 'Create:' )
|
|
1220
|
-
)[ 0 ];
|
|
1084
|
+
const createButton = within( searchResults ).getByRole( 'option', {
|
|
1085
|
+
name: /^Create:/,
|
|
1086
|
+
} );
|
|
1221
1087
|
|
|
1222
1088
|
await user.click( createButton );
|
|
1223
1089
|
|
|
1224
|
-
await eventLoopTick();
|
|
1225
|
-
|
|
1226
1090
|
searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1227
1091
|
|
|
1228
1092
|
const errorNotice = screen.getAllByText(
|
|
@@ -1234,6 +1098,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
|
|
|
1234
1098
|
|
|
1235
1099
|
// Check human readable error notice is perceivable.
|
|
1236
1100
|
expect( errorNotice ).toBeVisible();
|
|
1101
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
1237
1102
|
expect( errorNotice.parentElement ).toHaveClass(
|
|
1238
1103
|
'block-editor-link-control__search-error'
|
|
1239
1104
|
);
|
|
@@ -1340,14 +1205,10 @@ describe( 'Selecting links', () => {
|
|
|
1340
1205
|
} );
|
|
1341
1206
|
|
|
1342
1207
|
// Simulate searching for a term.
|
|
1343
|
-
|
|
1344
|
-
await user.keyboard( searchTerm );
|
|
1345
|
-
|
|
1346
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
1347
|
-
await eventLoopTick();
|
|
1208
|
+
await user.type( searchInput, searchTerm );
|
|
1348
1209
|
|
|
1349
1210
|
const searchResultElements = within(
|
|
1350
|
-
screen.
|
|
1211
|
+
await screen.findByRole( 'listbox', {
|
|
1351
1212
|
name: /Search results for.*/,
|
|
1352
1213
|
} )
|
|
1353
1214
|
).getAllByRole( 'option' );
|
|
@@ -1406,20 +1267,17 @@ describe( 'Selecting links', () => {
|
|
|
1406
1267
|
} );
|
|
1407
1268
|
|
|
1408
1269
|
// Simulate searching for a term.
|
|
1409
|
-
|
|
1410
|
-
await user.keyboard( searchTerm );
|
|
1270
|
+
await user.type( searchInput, searchTerm );
|
|
1411
1271
|
|
|
1412
|
-
|
|
1413
|
-
|
|
1272
|
+
const searchResults = await screen.findByRole( 'listbox', {
|
|
1273
|
+
name: /Search results for.*/,
|
|
1274
|
+
} );
|
|
1414
1275
|
|
|
1415
1276
|
// Step down into the search results, highlighting the first result item.
|
|
1416
1277
|
triggerArrowDown( searchInput );
|
|
1417
1278
|
|
|
1418
|
-
const searchResultElements =
|
|
1419
|
-
|
|
1420
|
-
name: /Search results for.*/,
|
|
1421
|
-
} )
|
|
1422
|
-
).getAllByRole( 'option' );
|
|
1279
|
+
const searchResultElements =
|
|
1280
|
+
within( searchResults ).getAllByRole( 'option' );
|
|
1423
1281
|
|
|
1424
1282
|
const firstSearchSuggestion = searchResultElements[ 0 ];
|
|
1425
1283
|
const secondSearchSuggestion = searchResultElements[ 1 ];
|
|
@@ -1429,7 +1287,7 @@ describe( 'Selecting links', () => {
|
|
|
1429
1287
|
} );
|
|
1430
1288
|
|
|
1431
1289
|
// We should have highlighted the first item using the keyboard.
|
|
1432
|
-
expect( selectedSearchResultElement ).
|
|
1290
|
+
expect( selectedSearchResultElement ).toBe(
|
|
1433
1291
|
firstSearchSuggestion
|
|
1434
1292
|
);
|
|
1435
1293
|
|
|
@@ -1444,7 +1302,7 @@ describe( 'Selecting links', () => {
|
|
|
1444
1302
|
|
|
1445
1303
|
// We should have highlighted the first item using the keyboard
|
|
1446
1304
|
// eslint-disable-next-line jest/no-conditional-expect
|
|
1447
|
-
expect( selectedSearchResultElement ).
|
|
1305
|
+
expect( selectedSearchResultElement ).toBe(
|
|
1448
1306
|
secondSearchSuggestion
|
|
1449
1307
|
);
|
|
1450
1308
|
|
|
@@ -1457,7 +1315,7 @@ describe( 'Selecting links', () => {
|
|
|
1457
1315
|
|
|
1458
1316
|
// We should be back to highlighting the first search result again
|
|
1459
1317
|
// eslint-disable-next-line jest/no-conditional-expect
|
|
1460
|
-
expect( selectedSearchResultElement ).
|
|
1318
|
+
expect( selectedSearchResultElement ).toBe(
|
|
1461
1319
|
firstSearchSuggestion
|
|
1462
1320
|
);
|
|
1463
1321
|
}
|
|
@@ -1473,7 +1331,8 @@ describe( 'Selecting links', () => {
|
|
|
1473
1331
|
} );
|
|
1474
1332
|
|
|
1475
1333
|
// Make sure focus is retained after submission.
|
|
1476
|
-
|
|
1334
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
1335
|
+
expect( container.firstChild ).toHaveFocus();
|
|
1477
1336
|
|
|
1478
1337
|
expect( currentLink ).toBeVisible();
|
|
1479
1338
|
expect(
|
|
@@ -1486,10 +1345,8 @@ describe( 'Selecting links', () => {
|
|
|
1486
1345
|
it( 'should allow selection of initial search results via the keyboard', async () => {
|
|
1487
1346
|
render( <LinkControl showInitialSuggestions /> );
|
|
1488
1347
|
|
|
1489
|
-
await eventLoopTick();
|
|
1490
|
-
|
|
1491
1348
|
expect(
|
|
1492
|
-
screen.
|
|
1349
|
+
await screen.findByRole( 'listbox', {
|
|
1493
1350
|
name: 'Recently updated',
|
|
1494
1351
|
} )
|
|
1495
1352
|
).toBeVisible();
|
|
@@ -1500,8 +1357,6 @@ describe( 'Selecting links', () => {
|
|
|
1500
1357
|
// Step down into the search results, highlighting the first result item.
|
|
1501
1358
|
triggerArrowDown( searchInput );
|
|
1502
1359
|
|
|
1503
|
-
await eventLoopTick();
|
|
1504
|
-
|
|
1505
1360
|
const searchResultElements = within(
|
|
1506
1361
|
screen.getByRole( 'listbox', {
|
|
1507
1362
|
name: 'Recently updated',
|
|
@@ -1626,14 +1481,10 @@ describe( 'Post types', () => {
|
|
|
1626
1481
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1627
1482
|
|
|
1628
1483
|
// Simulate searching for a term.
|
|
1629
|
-
|
|
1630
|
-
await user.keyboard( searchTerm );
|
|
1631
|
-
|
|
1632
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
1633
|
-
await eventLoopTick();
|
|
1484
|
+
await user.type( searchInput, searchTerm );
|
|
1634
1485
|
|
|
1635
1486
|
const searchResultElements = within(
|
|
1636
|
-
screen.
|
|
1487
|
+
await screen.findByRole( 'listbox', {
|
|
1637
1488
|
name: /Search results for.*/,
|
|
1638
1489
|
} )
|
|
1639
1490
|
).getAllByRole( 'option' );
|
|
@@ -1657,14 +1508,10 @@ describe( 'Post types', () => {
|
|
|
1657
1508
|
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
|
|
1658
1509
|
|
|
1659
1510
|
// Simulate searching for a term.
|
|
1660
|
-
|
|
1661
|
-
await user.keyboard( searchTerm );
|
|
1662
|
-
|
|
1663
|
-
// fetchFauxEntitySuggestions resolves on next "tick" of event loop.
|
|
1664
|
-
await eventLoopTick();
|
|
1511
|
+
await user.type( searchInput, searchTerm );
|
|
1665
1512
|
|
|
1666
1513
|
const searchResultElements = within(
|
|
1667
|
-
screen.
|
|
1514
|
+
await screen.findByRole( 'listbox', {
|
|
1668
1515
|
name: /Search results for.*/,
|
|
1669
1516
|
} )
|
|
1670
1517
|
).getAllByRole( 'option' );
|
|
@@ -1712,11 +1559,6 @@ describe( 'Rich link previews', () => {
|
|
|
1712
1559
|
|
|
1713
1560
|
render( <LinkControl value={ selectedLink } /> );
|
|
1714
1561
|
|
|
1715
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1716
|
-
await act( async () => {
|
|
1717
|
-
await eventLoopTick();
|
|
1718
|
-
} );
|
|
1719
|
-
|
|
1720
1562
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1721
1563
|
|
|
1722
1564
|
const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
|
|
@@ -1738,16 +1580,9 @@ describe( 'Rich link previews', () => {
|
|
|
1738
1580
|
|
|
1739
1581
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1740
1582
|
|
|
1741
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1742
|
-
await act( async () => {
|
|
1743
|
-
await eventLoopTick();
|
|
1744
|
-
} );
|
|
1745
|
-
|
|
1746
1583
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1747
1584
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
expect( isRichLinkPreview ).toBe( true );
|
|
1585
|
+
await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
|
|
1751
1586
|
} );
|
|
1752
1587
|
|
|
1753
1588
|
it( 'should not display placeholders for the image and description if neither is available in the data', async () => {
|
|
@@ -1762,19 +1597,18 @@ describe( 'Rich link previews', () => {
|
|
|
1762
1597
|
|
|
1763
1598
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1764
1599
|
|
|
1765
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1766
|
-
await act( async () => {
|
|
1767
|
-
await eventLoopTick();
|
|
1768
|
-
} );
|
|
1769
|
-
|
|
1770
1600
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1771
1601
|
|
|
1602
|
+
await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
|
|
1603
|
+
|
|
1772
1604
|
// Todo: refactor to use user-facing queries.
|
|
1605
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
1773
1606
|
const hasRichImagePreview = linkPreview.querySelector(
|
|
1774
1607
|
'.block-editor-link-control__search-item-image'
|
|
1775
1608
|
);
|
|
1776
1609
|
|
|
1777
1610
|
// Todo: refactor to use user-facing queries.
|
|
1611
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
1778
1612
|
const hasRichDescriptionPreview = linkPreview.querySelector(
|
|
1779
1613
|
'.block-editor-link-control__search-item-description'
|
|
1780
1614
|
);
|
|
@@ -1795,15 +1629,9 @@ describe( 'Rich link previews', () => {
|
|
|
1795
1629
|
|
|
1796
1630
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1797
1631
|
|
|
1798
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1799
|
-
await act( async () => {
|
|
1800
|
-
await eventLoopTick();
|
|
1801
|
-
} );
|
|
1802
|
-
|
|
1803
1632
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1804
1633
|
|
|
1805
|
-
|
|
1806
|
-
expect( isRichLinkPreview ).toBe( true );
|
|
1634
|
+
await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
|
|
1807
1635
|
|
|
1808
1636
|
const titlePreview = screen.getByText( selectedLink.title );
|
|
1809
1637
|
|
|
@@ -1824,21 +1652,18 @@ describe( 'Rich link previews', () => {
|
|
|
1824
1652
|
|
|
1825
1653
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1826
1654
|
|
|
1827
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1828
|
-
await act( async () => {
|
|
1829
|
-
await eventLoopTick();
|
|
1830
|
-
} );
|
|
1831
|
-
|
|
1832
1655
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1833
1656
|
|
|
1834
|
-
|
|
1835
|
-
expect( isRichLinkPreview ).toBe( true );
|
|
1657
|
+
await waitFor( () => expect( linkPreview ).toHaveClass( 'is-rich' ) );
|
|
1836
1658
|
|
|
1659
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
1837
1660
|
const iconPreview = linkPreview.querySelector(
|
|
1838
1661
|
`.block-editor-link-control__search-item-icon`
|
|
1839
1662
|
);
|
|
1840
1663
|
|
|
1664
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
1841
1665
|
const fallBackIcon = iconPreview.querySelector( 'svg' );
|
|
1666
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
1842
1667
|
const richIcon = iconPreview.querySelector( 'img' );
|
|
1843
1668
|
|
|
1844
1669
|
expect( fallBackIcon ).toBeVisible();
|
|
@@ -1862,17 +1687,13 @@ describe( 'Rich link previews', () => {
|
|
|
1862
1687
|
|
|
1863
1688
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1864
1689
|
|
|
1865
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1866
|
-
await act( async () => {
|
|
1867
|
-
await eventLoopTick();
|
|
1868
|
-
} );
|
|
1869
|
-
|
|
1870
1690
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1871
1691
|
|
|
1872
|
-
|
|
1873
|
-
linkPreview.
|
|
1874
|
-
|
|
1692
|
+
await waitFor( () =>
|
|
1693
|
+
expect( linkPreview ).toHaveClass( 'is-rich' )
|
|
1694
|
+
);
|
|
1875
1695
|
|
|
1696
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
1876
1697
|
const missingDataItem = linkPreview.querySelector(
|
|
1877
1698
|
`.block-editor-link-control__search-item-${ dataItem }`
|
|
1878
1699
|
);
|
|
@@ -1887,23 +1708,19 @@ describe( 'Rich link previews', () => {
|
|
|
1887
1708
|
] )(
|
|
1888
1709
|
'should not display a rich preview when data is %s',
|
|
1889
1710
|
async ( _descriptor, data ) => {
|
|
1890
|
-
mockFetchRichUrlData.mockImplementation( () =>
|
|
1891
|
-
Promise.resolve( data )
|
|
1892
|
-
);
|
|
1711
|
+
mockFetchRichUrlData.mockImplementation( async () => data );
|
|
1893
1712
|
|
|
1894
1713
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1895
1714
|
|
|
1896
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1897
|
-
await act( async () => {
|
|
1898
|
-
await eventLoopTick();
|
|
1899
|
-
} );
|
|
1900
|
-
|
|
1901
1715
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1902
1716
|
|
|
1903
|
-
|
|
1904
|
-
linkPreview.classList.contains( 'is-rich' );
|
|
1717
|
+
expect( linkPreview ).toHaveClass( 'is-fetching' );
|
|
1905
1718
|
|
|
1906
|
-
|
|
1719
|
+
await waitFor( () =>
|
|
1720
|
+
expect( linkPreview ).not.toHaveClass( 'is-fetching' )
|
|
1721
|
+
);
|
|
1722
|
+
|
|
1723
|
+
expect( linkPreview ).not.toHaveClass( 'is-rich' );
|
|
1907
1724
|
}
|
|
1908
1725
|
);
|
|
1909
1726
|
|
|
@@ -1914,19 +1731,10 @@ describe( 'Rich link previews', () => {
|
|
|
1914
1731
|
|
|
1915
1732
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1916
1733
|
|
|
1917
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1918
|
-
await act( async () => {
|
|
1919
|
-
await eventLoopTick();
|
|
1920
|
-
} );
|
|
1921
|
-
|
|
1922
1734
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1923
1735
|
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
const isRichLinkPreview = linkPreview.classList.contains( 'is-rich' );
|
|
1927
|
-
|
|
1928
|
-
expect( isFetchingRichPreview ).toBe( true );
|
|
1929
|
-
expect( isRichLinkPreview ).toBe( false );
|
|
1736
|
+
expect( linkPreview ).toHaveClass( 'is-fetching' );
|
|
1737
|
+
expect( linkPreview ).not.toHaveClass( 'is-rich' );
|
|
1930
1738
|
} );
|
|
1931
1739
|
|
|
1932
1740
|
it( 'should remove fetching UI indicators and fallback to standard preview if request for rich preview results in an error', async () => {
|
|
@@ -1936,20 +1744,15 @@ describe( 'Rich link previews', () => {
|
|
|
1936
1744
|
|
|
1937
1745
|
render( <LinkControl value={ selectedLink } hasRichPreviews /> );
|
|
1938
1746
|
|
|
1939
|
-
// mockFetchRichUrlData resolves on next "tick" of event loop.
|
|
1940
|
-
await act( async () => {
|
|
1941
|
-
await eventLoopTick();
|
|
1942
|
-
} );
|
|
1943
|
-
|
|
1944
1747
|
const linkPreview = screen.getByLabelText( 'Currently selected' );
|
|
1945
1748
|
|
|
1946
|
-
|
|
1947
|
-
linkPreview.classList.contains( 'is-fetching' );
|
|
1749
|
+
expect( linkPreview ).toHaveClass( 'is-fetching' );
|
|
1948
1750
|
|
|
1949
|
-
|
|
1751
|
+
await waitFor( () =>
|
|
1752
|
+
expect( linkPreview ).not.toHaveClass( 'is-fetching' )
|
|
1753
|
+
);
|
|
1950
1754
|
|
|
1951
|
-
expect(
|
|
1952
|
-
expect( isRichLinkPreview ).toBe( false );
|
|
1755
|
+
expect( linkPreview ).not.toHaveClass( 'is-rich' );
|
|
1953
1756
|
} );
|
|
1954
1757
|
|
|
1955
1758
|
afterAll( () => {
|
|
@@ -2050,8 +1853,7 @@ describe( 'Controlling link title text', () => {
|
|
|
2050
1853
|
|
|
2051
1854
|
const textInput = screen.queryByRole( 'textbox', { name: 'Text' } );
|
|
2052
1855
|
|
|
2053
|
-
|
|
2054
|
-
await userEvent.clear( textInput );
|
|
1856
|
+
await user.clear( textInput );
|
|
2055
1857
|
await user.keyboard( textValue );
|
|
2056
1858
|
|
|
2057
1859
|
expect( textInput ).toHaveValue( textValue );
|
|
@@ -2087,8 +1889,7 @@ describe( 'Controlling link title text', () => {
|
|
|
2087
1889
|
|
|
2088
1890
|
expect( textInput ).toBeVisible();
|
|
2089
1891
|
|
|
2090
|
-
|
|
2091
|
-
await userEvent.clear( textInput );
|
|
1892
|
+
await user.clear( textInput );
|
|
2092
1893
|
await user.keyboard( textValue );
|
|
2093
1894
|
|
|
2094
1895
|
// Attempt to submit the empty search value in the input.
|