@wordpress/block-library 7.0.2 → 7.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 +2 -0
- package/build/audio/edit.js +4 -4
- package/build/audio/edit.js.map +1 -1
- package/build/audio/edit.native.js +4 -4
- package/build/audio/edit.native.js.map +1 -1
- package/build/audio/transforms.js +1 -1
- package/build/audio/transforms.js.map +1 -1
- package/build/block/edit.js +3 -9
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +3 -2
- package/build/button/edit.js.map +1 -1
- package/build/button/edit.native.js +2 -2
- package/build/button/edit.native.js.map +1 -1
- package/build/buttons/transforms.js +8 -8
- package/build/buttons/transforms.js.map +1 -1
- package/build/categories/edit.js +15 -26
- package/build/categories/edit.js.map +1 -1
- package/build/code/index.js +0 -1
- package/build/code/index.js.map +1 -1
- package/build/columns/columnCalculations.native.js +1 -1
- package/build/columns/columnCalculations.native.js.map +1 -1
- package/build/columns/edit.js +1 -1
- package/build/columns/edit.js.map +1 -1
- package/build/columns/edit.native.js +3 -3
- package/build/columns/edit.native.js.map +1 -1
- package/build/cover/controls.native.js +5 -5
- package/build/cover/controls.native.js.map +1 -1
- package/build/cover/deprecated.js +188 -17
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit.js +8 -11
- package/build/cover/edit.js.map +1 -1
- package/build/cover/edit.native.js +8 -8
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/overlay-color-settings.native.js +3 -3
- package/build/cover/overlay-color-settings.native.js.map +1 -1
- package/build/cover/save.js +1 -1
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +2 -2
- package/build/cover/shared.js.map +1 -1
- package/build/embed/edit.js +1 -1
- package/build/embed/edit.js.map +1 -1
- package/build/embed/edit.native.js +1 -1
- package/build/embed/edit.native.js.map +1 -1
- package/build/embed/util.js +2 -2
- package/build/embed/util.js.map +1 -1
- package/build/embed/variations.js +1 -1
- package/build/embed/variations.js.map +1 -1
- package/build/file/edit.js +20 -17
- package/build/file/edit.js.map +1 -1
- package/build/file/edit.native.js +1 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/save.js +7 -3
- package/build/file/save.js.map +1 -1
- package/build/freeform/edit.js +2 -2
- package/build/freeform/edit.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.native.js +1 -1
- package/build/gallery/gallery.native.js.map +1 -1
- package/build/gallery/v1/edit.js +3 -3
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery-image.native.js +3 -3
- package/build/gallery/v1/gallery-image.native.js.map +1 -1
- package/build/gallery/v1/gallery.native.js +2 -2
- package/build/gallery/v1/gallery.native.js.map +1 -1
- package/build/group/index.js +3 -37
- package/build/group/index.js.map +1 -1
- package/build/group/transforms.js +45 -0
- package/build/group/transforms.js.map +1 -0
- package/build/home-link/edit.js +1 -1
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +7 -6
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +25 -10
- package/build/image/edit.native.js.map +1 -1
- package/build/image/transforms.js +1 -1
- package/build/image/transforms.js.map +1 -1
- package/build/index.js +3 -4
- package/build/index.js.map +1 -1
- package/build/index.native.js +2 -2
- package/build/index.native.js.map +1 -1
- package/build/media-text/edit.js +21 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/edit.native.js +2 -2
- package/build/media-text/edit.native.js.map +1 -1
- package/build/media-text/media-container.native.js +1 -1
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/missing/edit.native.js +1 -1
- package/build/missing/edit.native.js.map +1 -1
- package/build/more/transforms.js +2 -2
- package/build/more/transforms.js.map +1 -1
- package/build/navigation/edit/index.js +134 -60
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +8 -3
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +66 -53
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +31 -46
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/placeholder/placeholder-preview.js +3 -12
- package/build/navigation/edit/placeholder/placeholder-preview.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +3 -1
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +120 -0
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -0
- package/build/navigation/edit/use-create-navigation-menu.js +53 -4
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/edit/use-navigation-notice.js +3 -3
- package/build/navigation/edit/use-navigation-notice.js.map +1 -1
- package/build/navigation/menu-items-to-blocks.js +1 -1
- package/build/navigation/menu-items-to-blocks.js.map +1 -1
- package/build/navigation/use-navigation-entities.js +25 -49
- package/build/navigation/use-navigation-entities.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +2 -0
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-link/fallback-variations.js +1 -1
- package/build/navigation-link/fallback-variations.js.map +1 -1
- package/build/navigation-link/hooks.js +2 -2
- package/build/navigation-link/hooks.js.map +1 -1
- package/build/navigation-submenu/edit.js +2 -2
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +13 -23
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +8 -22
- package/build/page-list/edit.js.map +1 -1
- package/build/post-author-name/edit.js +2 -1
- package/build/post-author-name/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +3 -1
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +7 -4
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-terms/edit.js +3 -1
- package/build/post-terms/edit.js.map +1 -1
- package/build/query-title/edit.js +0 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/search/edit.js +4 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/edit.native.js +1 -1
- package/build/search/edit.native.js.map +1 -1
- package/build/separator/save.js +4 -4
- package/build/separator/save.js.map +1 -1
- package/build/separator/separator-settings.native.js +1 -1
- package/build/separator/separator-settings.native.js.map +1 -1
- package/build/site-logo/edit.js +1 -1
- package/build/site-logo/edit.js.map +1 -1
- package/build/social-link/edit.native.js +11 -3
- package/build/social-link/edit.native.js.map +1 -1
- package/build/spacer/controls.js +5 -5
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +5 -5
- package/build/spacer/controls.native.js.map +1 -1
- package/build/table/edit.js +2 -2
- package/build/table/edit.js.map +1 -1
- package/build/video/edit.js +4 -4
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +3 -3
- package/build/video/edit.native.js.map +1 -1
- package/build-module/audio/edit.js +4 -4
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/edit.native.js +4 -4
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/audio/transforms.js +1 -1
- package/build-module/audio/transforms.js.map +1 -1
- package/build-module/block/edit.js +5 -11
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +3 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/edit.native.js +2 -2
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/buttons/transforms.js +8 -8
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/categories/edit.js +15 -25
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/code/index.js +0 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/columns/columnCalculations.native.js +1 -1
- package/build-module/columns/columnCalculations.native.js.map +1 -1
- package/build-module/columns/edit.js +1 -1
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +3 -3
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/cover/controls.native.js +5 -5
- package/build-module/cover/controls.native.js.map +1 -1
- package/build-module/cover/deprecated.js +190 -17
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit.js +8 -11
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/edit.native.js +8 -8
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/overlay-color-settings.native.js +3 -3
- package/build-module/cover/overlay-color-settings.native.js.map +1 -1
- package/build-module/cover/save.js +1 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +2 -2
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/embed/edit.js +1 -1
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/edit.native.js +1 -1
- package/build-module/embed/edit.native.js.map +1 -1
- package/build-module/embed/util.js +2 -2
- package/build-module/embed/util.js.map +1 -1
- package/build-module/embed/variations.js +1 -1
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/file/edit.js +21 -18
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/edit.native.js +1 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/save.js +7 -3
- package/build-module/file/save.js.map +1 -1
- package/build-module/freeform/edit.js +2 -2
- package/build-module/freeform/edit.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.native.js +1 -1
- package/build-module/gallery/gallery.native.js.map +1 -1
- package/build-module/gallery/v1/edit.js +3 -3
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery-image.native.js +3 -3
- package/build-module/gallery/v1/gallery-image.native.js.map +1 -1
- package/build-module/gallery/v1/gallery.native.js +2 -2
- package/build-module/gallery/v1/gallery.native.js.map +1 -1
- package/build-module/group/index.js +2 -36
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/transforms.js +36 -0
- package/build-module/group/transforms.js.map +1 -0
- package/build-module/home-link/edit.js +1 -1
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +7 -6
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +25 -10
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/transforms.js +1 -1
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/index.js +4 -5
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +2 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/media-text/edit.js +20 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/edit.native.js +2 -2
- package/build-module/media-text/edit.native.js.map +1 -1
- package/build-module/media-text/media-container.native.js +1 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/missing/edit.native.js +1 -1
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/more/transforms.js +2 -2
- package/build-module/more/transforms.js.map +1 -1
- package/build-module/navigation/edit/index.js +128 -60
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +8 -3
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +66 -50
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +32 -45
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/placeholder/placeholder-preview.js +3 -9
- package/build-module/navigation/edit/placeholder/placeholder-preview.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +3 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +100 -0
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -0
- package/build-module/navigation/edit/use-create-navigation-menu.js +48 -5
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/edit/use-navigation-notice.js +3 -3
- package/build-module/navigation/edit/use-navigation-notice.js.map +1 -1
- package/build-module/navigation/menu-items-to-blocks.js +1 -1
- package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
- package/build-module/navigation/use-navigation-entities.js +26 -50
- package/build-module/navigation/use-navigation-entities.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +2 -0
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-link/fallback-variations.js +1 -1
- package/build-module/navigation-link/fallback-variations.js.map +1 -1
- package/build-module/navigation-link/hooks.js +2 -2
- package/build-module/navigation-link/hooks.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +2 -2
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +15 -25
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +9 -23
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-author-name/edit.js +2 -1
- package/build-module/post-author-name/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +4 -2
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +9 -6
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +2 -1
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/query-title/edit.js +0 -1
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/search/edit.js +3 -1
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/edit.native.js +1 -1
- package/build-module/search/edit.native.js.map +1 -1
- package/build-module/separator/save.js +4 -4
- package/build-module/separator/save.js.map +1 -1
- package/build-module/separator/separator-settings.native.js +1 -1
- package/build-module/separator/separator-settings.native.js.map +1 -1
- package/build-module/site-logo/edit.js +1 -1
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/social-link/edit.native.js +11 -3
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/spacer/controls.js +5 -5
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +5 -5
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/table/edit.js +2 -2
- package/build-module/table/edit.js.map +1 -1
- package/build-module/video/edit.js +4 -4
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +3 -3
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/button/editor-rtl.css +0 -3
- package/build-style/button/editor.css +0 -3
- package/build-style/code/style-rtl.css +2 -1
- package/build-style/code/style.css +2 -1
- package/build-style/code/theme-rtl.css +0 -3
- package/build-style/code/theme.css +0 -3
- package/build-style/common-rtl.css +1 -1
- package/build-style/common.css +1 -1
- package/build-style/cover/style-rtl.css +1 -5
- package/build-style/cover/style.css +1 -5
- package/build-style/editor-rtl.css +16 -3
- package/build-style/editor.css +16 -3
- package/build-style/image/style-rtl.css +2 -1
- package/build-style/image/style.css +2 -1
- package/build-style/navigation/editor-rtl.css +16 -0
- package/build-style/navigation/editor.css +16 -0
- package/build-style/style-rtl.css +12 -10
- package/build-style/style.css +12 -10
- package/build-style/tag-cloud/style-rtl.css +6 -2
- package/build-style/tag-cloud/style.css +6 -2
- package/build-style/theme-rtl.css +0 -3
- package/build-style/theme.css +0 -3
- package/package.json +32 -28
- package/src/audio/edit.js +4 -4
- package/src/audio/edit.native.js +4 -4
- package/src/audio/transforms.js +1 -1
- package/src/block/edit.js +7 -22
- package/src/block/test/edit.native.js +9 -9
- package/src/button/edit.js +2 -1
- package/src/button/edit.native.js +2 -2
- package/src/button/editor.scss +0 -5
- package/src/buttons/test/edit.native.js +3 -3
- package/src/buttons/transforms.js +8 -8
- package/src/categories/edit.js +12 -22
- package/src/code/block.json +0 -1
- package/src/code/style.scss +4 -2
- package/src/code/theme.scss +0 -3
- package/src/columns/columnCalculations.native.js +1 -1
- package/src/columns/edit.js +1 -1
- package/src/columns/edit.native.js +3 -3
- package/src/comments-pagination-numbers/index.php +1 -1
- package/src/common.scss +1 -1
- package/src/cover/controls.native.js +1 -1
- package/src/cover/deprecated.js +214 -1
- package/src/cover/edit.js +6 -8
- package/src/cover/edit.native.js +8 -8
- package/src/cover/overlay-color-settings.native.js +3 -3
- package/src/cover/save.js +4 -3
- package/src/cover/shared.js +2 -2
- package/src/cover/style.scss +1 -3
- package/src/cover/test/edit.native.js +39 -39
- package/src/embed/edit.js +1 -1
- package/src/embed/edit.native.js +1 -1
- package/src/embed/test/index.native.js +105 -105
- package/src/embed/util.js +2 -2
- package/src/embed/variations.js +1 -1
- package/src/file/edit.js +19 -17
- package/src/file/edit.native.js +1 -1
- package/src/file/save.js +9 -3
- package/src/file/style.native.scss +1 -0
- package/src/freeform/edit.js +2 -2
- package/src/gallery/edit.js +1 -1
- package/src/gallery/gallery.native.js +1 -1
- package/src/gallery/test/__snapshots__/index.native.js.snap +164 -0
- package/src/gallery/test/helpers.native.js +293 -0
- package/src/gallery/test/index.native.js +583 -65
- package/src/gallery/v1/edit.js +3 -4
- package/src/gallery/v1/gallery-image.native.js +3 -3
- package/src/gallery/v1/gallery.native.js +2 -2
- package/src/group/index.js +2 -54
- package/src/group/transforms.js +52 -0
- package/src/home-link/edit.js +1 -1
- package/src/image/edit.js +7 -6
- package/src/image/edit.native.js +25 -8
- package/src/image/style.scss +2 -1
- package/src/image/test/edit.native.js +1 -1
- package/src/image/transforms.js +1 -1
- package/src/index.js +2 -3
- package/src/index.native.js +2 -2
- package/src/media-text/edit.js +20 -2
- package/src/media-text/edit.native.js +2 -2
- package/src/media-text/media-container.native.js +1 -1
- package/src/media-text/style.native.scss +1 -0
- package/src/missing/edit.native.js +1 -1
- package/src/missing/test/edit-integration.native.js +4 -4
- package/src/missing/test/edit.native.js +2 -2
- package/src/more/transforms.js +2 -2
- package/src/navigation/edit/index.js +194 -69
- package/src/navigation/edit/inner-blocks.js +11 -4
- package/src/navigation/edit/navigation-menu-selector.js +97 -79
- package/src/navigation/edit/placeholder/index.js +61 -84
- package/src/navigation/edit/placeholder/placeholder-preview.js +3 -10
- package/src/navigation/edit/unsaved-inner-blocks.js +3 -1
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +137 -0
- package/src/navigation/edit/use-create-navigation-menu.js +59 -8
- package/src/navigation/edit/use-navigation-notice.js +3 -3
- package/src/navigation/editor.scss +23 -1
- package/src/navigation/menu-items-to-blocks.js +1 -1
- package/src/navigation/test/menu-items-to-blocks.js +1 -1
- package/src/navigation/use-navigation-entities.js +26 -60
- package/src/navigation/use-navigation-menu.js +5 -0
- package/src/navigation-link/fallback-variations.js +1 -1
- package/src/navigation-link/hooks.js +2 -2
- package/src/navigation-link/test/edit.js +5 -5
- package/src/navigation-submenu/edit.js +2 -2
- package/src/page-list/convert-to-links-modal.js +17 -31
- package/src/page-list/edit.js +14 -23
- package/src/post-author-name/edit.js +1 -0
- package/src/post-author-name/index.php +1 -1
- package/src/post-comments-form/edit.js +7 -3
- package/src/post-excerpt/edit.js +9 -12
- package/src/post-terms/edit.js +2 -1
- package/src/query-title/edit.js +0 -1
- package/src/search/edit.js +6 -0
- package/src/search/edit.native.js +1 -1
- package/src/search/index.php +3 -2
- package/src/search/test/edit.native.js +0 -1
- package/src/separator/save.js +4 -4
- package/src/separator/separator-settings.native.js +1 -1
- package/src/site-logo/edit.js +1 -1
- package/src/social-link/edit.native.js +17 -8
- package/src/social-link/test/index.native.js +138 -0
- package/src/spacer/controls.js +1 -1
- package/src/spacer/controls.native.js +1 -1
- package/src/table/edit.js +2 -2
- package/src/tag-cloud/style.scss +12 -7
- package/src/video/edit.js +4 -4
- package/src/video/edit.native.js +3 -3
- package/src/video/style.native.scss +1 -0
- package/build/navigation/use-convert-classic-menu.js +0 -59
- package/build/navigation/use-convert-classic-menu.js.map +0 -1
- package/build-module/navigation/use-convert-classic-menu.js +0 -47
- package/build-module/navigation/use-convert-classic-menu.js.map +0 -1
- package/src/navigation/use-convert-classic-menu.js +0 -58
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
+
act,
|
|
5
6
|
getEditorHtml,
|
|
6
7
|
initializeEditor,
|
|
7
8
|
fireEvent,
|
|
8
|
-
waitFor,
|
|
9
9
|
within,
|
|
10
10
|
} from 'test/helpers';
|
|
11
11
|
|
|
@@ -14,6 +14,48 @@ import {
|
|
|
14
14
|
*/
|
|
15
15
|
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
16
16
|
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
17
|
+
import { Platform } from '@wordpress/element';
|
|
18
|
+
import {
|
|
19
|
+
getOtherMediaOptions,
|
|
20
|
+
requestImageFailedRetryDialog,
|
|
21
|
+
requestImageUploadCancelDialog,
|
|
22
|
+
} from '@wordpress/react-native-bridge';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
import {
|
|
28
|
+
addGalleryBlock,
|
|
29
|
+
initializeWithGalleryBlock,
|
|
30
|
+
getGalleryItem,
|
|
31
|
+
setupMediaUpload,
|
|
32
|
+
generateGalleryBlock,
|
|
33
|
+
setCaption,
|
|
34
|
+
setupMediaPicker,
|
|
35
|
+
triggerGalleryLayout,
|
|
36
|
+
openBlockSettings,
|
|
37
|
+
} from './helpers';
|
|
38
|
+
|
|
39
|
+
const media = [
|
|
40
|
+
{
|
|
41
|
+
localId: 1,
|
|
42
|
+
localUrl: 'file:///local-image-1.jpeg',
|
|
43
|
+
serverId: 2000,
|
|
44
|
+
serverUrl: 'https://test-site.files.wordpress.com/local-image-1.jpeg',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
localId: 2,
|
|
48
|
+
localUrl: 'file:///local-image-2.jpeg',
|
|
49
|
+
serverId: 2001,
|
|
50
|
+
serverUrl: 'https://test-site.files.wordpress.com/local-image-2.jpeg',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
localId: 3,
|
|
54
|
+
localUrl: 'file:///local-image-3.jpeg',
|
|
55
|
+
serverId: 2002,
|
|
56
|
+
serverUrl: 'https://test-site.files.wordpress.com/local-image-3.jpeg',
|
|
57
|
+
},
|
|
58
|
+
];
|
|
17
59
|
|
|
18
60
|
beforeAll( () => {
|
|
19
61
|
// Register all core blocks
|
|
@@ -27,102 +69,578 @@ afterAll( () => {
|
|
|
27
69
|
} );
|
|
28
70
|
} );
|
|
29
71
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<!-- /wp:image --></figure>
|
|
34
|
-
<!-- /wp:gallery -->`;
|
|
72
|
+
describe( 'Gallery block', () => {
|
|
73
|
+
it( 'inserts block', async () => {
|
|
74
|
+
const { getByA11yLabel } = await addGalleryBlock();
|
|
35
75
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
76
|
+
expect( getByA11yLabel( /Gallery Block\. Row 1/ ) ).toBeVisible();
|
|
77
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
78
|
+
} );
|
|
39
79
|
|
|
40
|
-
|
|
80
|
+
it( 'selects a gallery item', async () => {
|
|
81
|
+
const { galleryBlock } = await initializeWithGalleryBlock( {
|
|
82
|
+
numberOfItems: 1,
|
|
83
|
+
media,
|
|
84
|
+
selected: false,
|
|
85
|
+
} );
|
|
86
|
+
|
|
87
|
+
const galleryItem = getGalleryItem( galleryBlock, 1 );
|
|
88
|
+
fireEvent.press( galleryItem );
|
|
41
89
|
|
|
42
|
-
|
|
43
|
-
// onScroll event used to force the FlatList to render all items
|
|
44
|
-
fireEvent.scroll( blockList, {
|
|
45
|
-
nativeEvent: {
|
|
46
|
-
contentOffset: { y: 0, x: 0 },
|
|
47
|
-
contentSize: { width: 100, height: 100 },
|
|
48
|
-
layoutMeasurement: { width: 100, height: 100 },
|
|
49
|
-
},
|
|
90
|
+
expect( galleryItem ).toBeVisible();
|
|
50
91
|
} );
|
|
51
92
|
|
|
52
|
-
|
|
93
|
+
it( 'shows appender button when gallery has images', async () => {
|
|
94
|
+
const { galleryBlock, getByText } = await initializeWithGalleryBlock( {
|
|
95
|
+
numberOfItems: 1,
|
|
96
|
+
media,
|
|
97
|
+
} );
|
|
53
98
|
|
|
54
|
-
|
|
55
|
-
|
|
99
|
+
const appenderButton = within( galleryBlock ).getByTestId(
|
|
100
|
+
'media-placeholder-appender-icon'
|
|
101
|
+
);
|
|
102
|
+
fireEvent.press( appenderButton );
|
|
56
103
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
104
|
+
expect( getByText( 'Choose from device' ) ).toBeVisible();
|
|
105
|
+
expect( getByText( 'Take a Photo' ) ).toBeVisible();
|
|
106
|
+
expect( getByText( 'WordPress Media Library' ) ).toBeVisible();
|
|
107
|
+
} );
|
|
108
|
+
|
|
109
|
+
// This case is disabled until the issue (https://github.com/WordPress/gutenberg/issues/38444)
|
|
110
|
+
// is addressed.
|
|
111
|
+
it.skip( 'displays media options picker when selecting the block', async () => {
|
|
112
|
+
// Initialize with an empty gallery
|
|
113
|
+
const {
|
|
114
|
+
getByA11yLabel,
|
|
115
|
+
getByText,
|
|
116
|
+
getByTestId,
|
|
117
|
+
} = await initializeEditor( {
|
|
118
|
+
initialHtml: generateGalleryBlock( 0 ),
|
|
119
|
+
} );
|
|
120
|
+
|
|
121
|
+
// Tap on Gallery block
|
|
122
|
+
fireEvent.press( getByText( 'ADD MEDIA' ) );
|
|
123
|
+
|
|
124
|
+
// Observe that media options picker is displayed
|
|
125
|
+
expect( getByText( 'Choose images' ) ).toBeVisible();
|
|
126
|
+
expect( getByText( 'WordPress Media Library' ) ).toBeVisible();
|
|
127
|
+
|
|
128
|
+
// Dimiss the picker
|
|
129
|
+
if ( Platform.isIOS ) {
|
|
130
|
+
fireEvent.press( getByText( 'Cancel' ) );
|
|
131
|
+
} else {
|
|
132
|
+
fireEvent( getByTestId( 'media-options-picker' ), 'backdropPress' );
|
|
133
|
+
}
|
|
60
134
|
|
|
61
|
-
|
|
62
|
-
|
|
135
|
+
// Observe that the block is selected, this is done by checking if the block settings
|
|
136
|
+
// button is visible
|
|
137
|
+
const blockActionsButton = getByA11yLabel( /Open Block Actions Menu/ );
|
|
138
|
+
expect( blockActionsButton ).toBeVisible();
|
|
139
|
+
} );
|
|
140
|
+
|
|
141
|
+
// Test case related to TC001 - Close/Re-open post with an ongoing image upload
|
|
142
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc001
|
|
143
|
+
it( 'finishes pending uploads upon opening the editor', async () => {
|
|
144
|
+
const { notifyUploadingState, notifySucceedState } = setupMediaUpload();
|
|
145
|
+
|
|
146
|
+
// Initialize with a gallery that contains two items that are being uploaded
|
|
147
|
+
const { galleryBlock } = await initializeWithGalleryBlock( {
|
|
148
|
+
numberOfItems: 2,
|
|
149
|
+
media,
|
|
150
|
+
useLocalUrl: true,
|
|
151
|
+
} );
|
|
152
|
+
|
|
153
|
+
// Notify that the media items are uploading
|
|
154
|
+
await notifyUploadingState( media[ 0 ] );
|
|
155
|
+
await notifyUploadingState( media[ 1 ] );
|
|
156
|
+
|
|
157
|
+
// Check that images are showing a loading state
|
|
158
|
+
expect(
|
|
159
|
+
within( getGalleryItem( galleryBlock, 1 ) ).getByTestId( 'spinner' )
|
|
160
|
+
).toBeVisible();
|
|
161
|
+
expect(
|
|
162
|
+
within( getGalleryItem( galleryBlock, 2 ) ).getByTestId( 'spinner' )
|
|
163
|
+
).toBeVisible();
|
|
164
|
+
|
|
165
|
+
// Notify that the media items upload succeeded
|
|
166
|
+
await notifySucceedState( media[ 0 ] );
|
|
167
|
+
await notifySucceedState( media[ 1 ] );
|
|
168
|
+
|
|
169
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
170
|
+
} );
|
|
171
|
+
|
|
172
|
+
// Test case related to TC003 - Add caption to gallery
|
|
173
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc003
|
|
174
|
+
it( 'sets caption to gallery', async () => {
|
|
175
|
+
// Initialize with a gallery that contains one item
|
|
176
|
+
const { getByA11yLabel } = await initializeWithGalleryBlock( {
|
|
177
|
+
numberOfItems: 1,
|
|
178
|
+
media,
|
|
179
|
+
} );
|
|
180
|
+
|
|
181
|
+
// Check gallery item caption is not visible
|
|
182
|
+
const galleryItemCaption = getByA11yLabel( /Image caption. Empty/ );
|
|
183
|
+
expect( galleryItemCaption ).not.toBeVisible();
|
|
184
|
+
|
|
185
|
+
// Set gallery caption
|
|
186
|
+
const captionField = within(
|
|
187
|
+
getByA11yLabel( /Gallery caption. Empty/ )
|
|
188
|
+
).getByPlaceholderText( 'Add caption' );
|
|
189
|
+
setCaption(
|
|
190
|
+
captionField,
|
|
191
|
+
'<strong>Bold</strong> <em>italic</em> <s>strikethrough</s> gallery caption'
|
|
63
192
|
);
|
|
64
193
|
|
|
65
|
-
expect( galleryBlock ).toHaveProperty( 'type', 'View' );
|
|
66
194
|
expect( getEditorHtml() ).toMatchSnapshot();
|
|
67
195
|
} );
|
|
68
196
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
197
|
+
// Test case related to TC004 - Add caption to gallery images
|
|
198
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc004
|
|
199
|
+
it( 'sets caption to gallery items', async () => {
|
|
200
|
+
// Initialize with a gallery that contains one item
|
|
201
|
+
const { galleryBlock } = await initializeWithGalleryBlock( {
|
|
202
|
+
numberOfItems: 1,
|
|
203
|
+
media,
|
|
72
204
|
} );
|
|
73
205
|
|
|
74
|
-
|
|
75
|
-
|
|
206
|
+
// Select gallery item
|
|
207
|
+
const galleryItem = getGalleryItem( galleryBlock, 1 );
|
|
208
|
+
fireEvent.press( galleryItem );
|
|
209
|
+
|
|
210
|
+
// Set gallery item caption
|
|
211
|
+
const captionField = within( galleryItem ).getByPlaceholderText(
|
|
212
|
+
'Add caption'
|
|
213
|
+
);
|
|
214
|
+
setCaption(
|
|
215
|
+
captionField,
|
|
216
|
+
'<strong>Bold</strong> <em>italic</em> <s>strikethrough</s> image caption'
|
|
76
217
|
);
|
|
77
|
-
fireEvent.press( galleryBlock );
|
|
78
218
|
|
|
79
|
-
|
|
80
|
-
|
|
219
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
220
|
+
} );
|
|
221
|
+
|
|
222
|
+
// Test case related to TC005 - Choose from device (stay in editor) - Successful upload
|
|
223
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc005
|
|
224
|
+
it( 'successfully uploads items', async () => {
|
|
225
|
+
const { notifyUploadingState, notifySucceedState } = setupMediaUpload();
|
|
226
|
+
const {
|
|
227
|
+
expectMediaPickerCall,
|
|
228
|
+
mediaPickerCallback,
|
|
229
|
+
} = setupMediaPicker();
|
|
230
|
+
|
|
231
|
+
// Initialize with an empty gallery
|
|
232
|
+
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
233
|
+
|
|
234
|
+
// Upload images from device
|
|
235
|
+
fireEvent.press( getByText( 'ADD MEDIA' ) );
|
|
236
|
+
fireEvent.press( getByText( 'Choose from device' ) );
|
|
237
|
+
expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
|
|
238
|
+
|
|
239
|
+
// Return media items picked
|
|
240
|
+
await mediaPickerCallback( media[ 0 ], media[ 1 ] );
|
|
241
|
+
|
|
242
|
+
// Check that gallery items are visible
|
|
243
|
+
await triggerGalleryLayout( galleryBlock );
|
|
244
|
+
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
245
|
+
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
246
|
+
expect( galleryItem1 ).toBeVisible();
|
|
247
|
+
expect( galleryItem2 ).toBeVisible();
|
|
248
|
+
|
|
249
|
+
// Check that images are showing a loading state
|
|
250
|
+
await notifyUploadingState( media[ 0 ] );
|
|
251
|
+
await notifyUploadingState( media[ 1 ] );
|
|
252
|
+
expect( within( galleryItem1 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
253
|
+
expect( within( galleryItem2 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
254
|
+
|
|
255
|
+
// Notify that the media items upload succeeded
|
|
256
|
+
await notifySucceedState( media[ 0 ] );
|
|
257
|
+
await notifySucceedState( media[ 1 ] );
|
|
258
|
+
|
|
259
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
260
|
+
} );
|
|
261
|
+
|
|
262
|
+
// Test case related to TC006 - Choose from device (stay in editor) - Failed upload
|
|
263
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc006
|
|
264
|
+
it( 'handles failed uploads', async () => {
|
|
265
|
+
const { notifyUploadingState, notifyFailedState } = setupMediaUpload();
|
|
266
|
+
const {
|
|
267
|
+
expectMediaPickerCall,
|
|
268
|
+
mediaPickerCallback,
|
|
269
|
+
} = setupMediaPicker();
|
|
270
|
+
|
|
271
|
+
// Initialize with an empty gallery
|
|
272
|
+
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
273
|
+
|
|
274
|
+
// Upload images from device
|
|
275
|
+
fireEvent.press( getByText( 'ADD MEDIA' ) );
|
|
276
|
+
fireEvent.press( getByText( 'Choose from device' ) );
|
|
277
|
+
expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
|
|
278
|
+
|
|
279
|
+
// Return media items picked
|
|
280
|
+
await mediaPickerCallback( media[ 0 ], media[ 1 ] );
|
|
281
|
+
|
|
282
|
+
// Check that gallery items are visible
|
|
283
|
+
await triggerGalleryLayout( galleryBlock );
|
|
284
|
+
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
285
|
+
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
286
|
+
expect( galleryItem1 ).toBeVisible();
|
|
287
|
+
expect( galleryItem2 ).toBeVisible();
|
|
288
|
+
|
|
289
|
+
// Check that images are showing a loading state
|
|
290
|
+
await notifyUploadingState( media[ 0 ] );
|
|
291
|
+
await notifyUploadingState( media[ 1 ] );
|
|
292
|
+
expect( within( galleryItem1 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
293
|
+
expect( within( galleryItem2 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
294
|
+
|
|
295
|
+
// Notify that the media items uploads failed
|
|
296
|
+
await notifyFailedState( media[ 0 ] );
|
|
297
|
+
await notifyFailedState( media[ 1 ] );
|
|
298
|
+
|
|
299
|
+
// Check that failed images provide the option to retry the upload
|
|
300
|
+
fireEvent.press( galleryItem1 );
|
|
301
|
+
fireEvent.press(
|
|
302
|
+
within( galleryItem1 ).getByText( /Failed to insert media/ )
|
|
81
303
|
);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
304
|
+
expect( requestImageFailedRetryDialog ).toHaveBeenCalledWith(
|
|
305
|
+
media[ 0 ].localId
|
|
306
|
+
);
|
|
307
|
+
fireEvent.press( galleryItem2 );
|
|
308
|
+
fireEvent.press(
|
|
309
|
+
within( galleryItem2 ).getByText( /Failed to insert media/ )
|
|
310
|
+
);
|
|
311
|
+
expect( requestImageFailedRetryDialog ).toHaveBeenCalledWith(
|
|
312
|
+
media[ 1 ].localId
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
316
|
+
} );
|
|
317
|
+
|
|
318
|
+
// Test case related to TC007 - Take a photo
|
|
319
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc007
|
|
320
|
+
it( 'takes a photo', async () => {
|
|
321
|
+
const { notifyUploadingState, notifySucceedState } = setupMediaUpload();
|
|
322
|
+
const {
|
|
323
|
+
expectMediaPickerCall,
|
|
324
|
+
mediaPickerCallback,
|
|
325
|
+
} = setupMediaPicker();
|
|
326
|
+
|
|
327
|
+
// Initialize with an empty gallery
|
|
328
|
+
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
329
|
+
|
|
330
|
+
// Take a photo
|
|
331
|
+
fireEvent.press( getByText( 'ADD MEDIA' ) );
|
|
332
|
+
fireEvent.press( getByText( 'Take a Photo' ) );
|
|
333
|
+
expectMediaPickerCall( 'DEVICE_CAMERA', [ 'image' ], true );
|
|
334
|
+
|
|
335
|
+
// Return media item from photo taken
|
|
336
|
+
await mediaPickerCallback( media[ 0 ] );
|
|
337
|
+
|
|
338
|
+
// Check gallery item is visible
|
|
339
|
+
await triggerGalleryLayout( galleryBlock );
|
|
340
|
+
const galleryItem = getGalleryItem( galleryBlock, 1 );
|
|
341
|
+
expect( galleryItem ).toBeVisible();
|
|
342
|
+
|
|
343
|
+
// Check image is showing a loading state
|
|
344
|
+
await notifyUploadingState( media[ 0 ] );
|
|
345
|
+
expect( within( galleryItem ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
346
|
+
|
|
347
|
+
// Notify that the media item upload succeeded
|
|
348
|
+
await notifySucceedState( media[ 0 ] );
|
|
349
|
+
|
|
350
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
351
|
+
} );
|
|
352
|
+
|
|
353
|
+
// Test case related to TC008 - Choose from the free photo library
|
|
354
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc008
|
|
355
|
+
it( 'uploads from free photo library', async () => {
|
|
356
|
+
const freePhotoMedia = [ ...media ].map( ( item, index ) => ( {
|
|
357
|
+
...item,
|
|
358
|
+
localUrl: `https://images.pexels.com/photos/110854/pexels-photo-${
|
|
359
|
+
index + 1
|
|
360
|
+
}.jpeg`,
|
|
361
|
+
} ) );
|
|
362
|
+
const { notifyUploadingState, notifySucceedState } = setupMediaUpload();
|
|
363
|
+
const {
|
|
364
|
+
expectMediaPickerCall,
|
|
365
|
+
mediaPickerCallback,
|
|
366
|
+
} = setupMediaPicker();
|
|
367
|
+
|
|
368
|
+
let otherMediaOptionsCallback;
|
|
369
|
+
getOtherMediaOptions.mockImplementation( ( filter, callback ) => {
|
|
370
|
+
otherMediaOptionsCallback = callback;
|
|
88
371
|
} );
|
|
89
372
|
|
|
90
|
-
|
|
91
|
-
|
|
373
|
+
// Initialize with an empty gallery
|
|
374
|
+
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
375
|
+
|
|
376
|
+
// Notify other media options
|
|
377
|
+
act( () =>
|
|
378
|
+
otherMediaOptionsCallback( [
|
|
379
|
+
{
|
|
380
|
+
label: 'Free Photo Library',
|
|
381
|
+
value: 'stock-photo-library',
|
|
382
|
+
},
|
|
383
|
+
] )
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
// Upload images from free photo library
|
|
387
|
+
fireEvent.press( getByText( 'ADD MEDIA' ) );
|
|
388
|
+
fireEvent.press( getByText( 'Free Photo Library' ) );
|
|
389
|
+
expectMediaPickerCall( 'stock-photo-library', [ 'image' ], true );
|
|
390
|
+
|
|
391
|
+
// Return media items picked
|
|
392
|
+
await act( async () =>
|
|
393
|
+
mediaPickerCallback( freePhotoMedia[ 0 ], freePhotoMedia[ 1 ] )
|
|
92
394
|
);
|
|
93
|
-
fireEvent.press( galleryItem );
|
|
94
395
|
|
|
95
|
-
|
|
396
|
+
// Check that gallery items are visible
|
|
397
|
+
await triggerGalleryLayout( galleryBlock );
|
|
398
|
+
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
399
|
+
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
400
|
+
expect( galleryItem1 ).toBeVisible();
|
|
401
|
+
expect( galleryItem2 ).toBeVisible();
|
|
402
|
+
|
|
403
|
+
// Check that images are showing a loading state
|
|
404
|
+
await notifyUploadingState( freePhotoMedia[ 0 ] );
|
|
405
|
+
await notifyUploadingState( freePhotoMedia[ 1 ] );
|
|
406
|
+
expect( within( galleryItem1 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
407
|
+
expect( within( galleryItem2 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
408
|
+
|
|
409
|
+
// Notify that the media items upload succeeded
|
|
410
|
+
await notifySucceedState( freePhotoMedia[ 0 ] );
|
|
411
|
+
await notifySucceedState( freePhotoMedia[ 1 ] );
|
|
412
|
+
|
|
413
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
96
414
|
} );
|
|
97
415
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
416
|
+
// Test case related to TC009 - Choose from device (stay in editor) - Cancel upload
|
|
417
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc009
|
|
418
|
+
it( 'cancels uploads', async () => {
|
|
419
|
+
const { notifyUploadingState, notifyResetState } = setupMediaUpload();
|
|
420
|
+
const {
|
|
421
|
+
expectMediaPickerCall,
|
|
422
|
+
mediaPickerCallback,
|
|
423
|
+
} = setupMediaPicker();
|
|
424
|
+
|
|
425
|
+
// Initialize with an empty gallery
|
|
426
|
+
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
427
|
+
|
|
428
|
+
// Upload images from device
|
|
429
|
+
fireEvent.press( getByText( 'ADD MEDIA' ) );
|
|
430
|
+
fireEvent.press( getByText( 'Choose from device' ) );
|
|
431
|
+
expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
|
|
432
|
+
|
|
433
|
+
// Return media items picked
|
|
434
|
+
await mediaPickerCallback( media[ 0 ], media[ 1 ] );
|
|
435
|
+
|
|
436
|
+
// Check that gallery items are visible
|
|
437
|
+
await triggerGalleryLayout( galleryBlock );
|
|
438
|
+
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
439
|
+
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
440
|
+
expect( galleryItem1 ).toBeVisible();
|
|
441
|
+
expect( galleryItem2 ).toBeVisible();
|
|
442
|
+
|
|
443
|
+
// Check that images are showing a loading state
|
|
444
|
+
await notifyUploadingState( media[ 0 ] );
|
|
445
|
+
await notifyUploadingState( media[ 1 ] );
|
|
446
|
+
expect( within( galleryItem1 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
447
|
+
expect( within( galleryItem2 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
448
|
+
|
|
449
|
+
// Cancel uploads
|
|
450
|
+
fireEvent.press( galleryItem1 );
|
|
451
|
+
fireEvent.press( within( galleryItem1 ).getByTestId( 'spinner' ) );
|
|
452
|
+
expect( requestImageUploadCancelDialog ).toHaveBeenCalledWith(
|
|
453
|
+
media[ 0 ].localId
|
|
454
|
+
);
|
|
455
|
+
await notifyResetState( media[ 0 ] );
|
|
456
|
+
|
|
457
|
+
fireEvent.press( galleryItem2 );
|
|
458
|
+
fireEvent.press( within( galleryItem2 ).getByTestId( 'spinner' ) );
|
|
459
|
+
expect( requestImageUploadCancelDialog ).toHaveBeenCalledWith(
|
|
460
|
+
media[ 1 ].localId
|
|
461
|
+
);
|
|
462
|
+
await notifyResetState( media[ 1 ] );
|
|
463
|
+
|
|
464
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
465
|
+
} );
|
|
466
|
+
|
|
467
|
+
// Test case related to TC010 - Rearrange images in Gallery
|
|
468
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc010
|
|
469
|
+
it( 'rearranges gallery items', async () => {
|
|
470
|
+
// Initialize with a gallery that contains three items
|
|
471
|
+
const { galleryBlock } = await initializeWithGalleryBlock( {
|
|
472
|
+
numberOfItems: 3,
|
|
473
|
+
media,
|
|
101
474
|
} );
|
|
102
475
|
|
|
103
|
-
|
|
104
|
-
|
|
476
|
+
// Rearrange items (final disposition will be: Image 3 - Image 1 - Image 2)
|
|
477
|
+
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
478
|
+
const galleryItem3 = getGalleryItem( galleryBlock, 3 );
|
|
479
|
+
|
|
480
|
+
fireEvent.press( galleryItem3 );
|
|
481
|
+
await act( () =>
|
|
482
|
+
fireEvent.press(
|
|
483
|
+
within( galleryItem3 ).getByA11yLabel(
|
|
484
|
+
/Move block left from position 3 to position 2/
|
|
485
|
+
)
|
|
486
|
+
)
|
|
105
487
|
);
|
|
106
|
-
fireEvent.press( galleryBlock );
|
|
107
488
|
|
|
108
|
-
|
|
109
|
-
|
|
489
|
+
fireEvent.press( galleryItem1 );
|
|
490
|
+
await act( () =>
|
|
491
|
+
fireEvent.press(
|
|
492
|
+
within( galleryItem1 ).getByA11yLabel(
|
|
493
|
+
/Move block right from position 1 to position 2/
|
|
494
|
+
)
|
|
495
|
+
)
|
|
110
496
|
);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
497
|
+
|
|
498
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
499
|
+
} );
|
|
500
|
+
|
|
501
|
+
// Test case related to TC011 - Choose from Other Apps (iOS Files App)
|
|
502
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc011
|
|
503
|
+
it( 'uploads from other apps', async () => {
|
|
504
|
+
const otherAppsMedia = [ ...media ].map( ( item, index ) => ( {
|
|
505
|
+
...item,
|
|
506
|
+
localUrl: `file:///IMG_${ index + 1 }.JPG`,
|
|
507
|
+
} ) );
|
|
508
|
+
const { notifyUploadingState, notifySucceedState } = setupMediaUpload();
|
|
509
|
+
const {
|
|
510
|
+
expectMediaPickerCall,
|
|
511
|
+
mediaPickerCallback,
|
|
512
|
+
} = setupMediaPicker();
|
|
513
|
+
|
|
514
|
+
let otherMediaOptionsCallback;
|
|
515
|
+
getOtherMediaOptions.mockImplementation( ( filter, callback ) => {
|
|
516
|
+
otherMediaOptionsCallback = callback;
|
|
117
517
|
} );
|
|
118
518
|
|
|
119
|
-
|
|
120
|
-
|
|
519
|
+
// Initialize with an empty gallery
|
|
520
|
+
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
521
|
+
|
|
522
|
+
// Notify other media options
|
|
523
|
+
act( () =>
|
|
524
|
+
otherMediaOptionsCallback( [
|
|
525
|
+
{ label: 'Other Apps', value: 'other-files' },
|
|
526
|
+
] )
|
|
121
527
|
);
|
|
122
|
-
fireEvent.press( appenderButton );
|
|
123
528
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
529
|
+
// Upload images from other apps
|
|
530
|
+
fireEvent.press( getByText( 'ADD MEDIA' ) );
|
|
531
|
+
fireEvent.press( getByText( 'Other Apps' ) );
|
|
532
|
+
expectMediaPickerCall( 'other-files', [ 'image' ], true );
|
|
533
|
+
|
|
534
|
+
// Return media items picked
|
|
535
|
+
await mediaPickerCallback( otherAppsMedia[ 0 ], otherAppsMedia[ 1 ] );
|
|
536
|
+
|
|
537
|
+
// Check that gallery items are visible
|
|
538
|
+
await triggerGalleryLayout( galleryBlock );
|
|
539
|
+
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
540
|
+
const galleryItem2 = getGalleryItem( galleryBlock, 2 );
|
|
541
|
+
expect( galleryItem1 ).toBeVisible();
|
|
542
|
+
expect( galleryItem2 ).toBeVisible();
|
|
543
|
+
|
|
544
|
+
// Check that images are showing a loading state
|
|
545
|
+
await notifyUploadingState( otherAppsMedia[ 0 ] );
|
|
546
|
+
await notifyUploadingState( otherAppsMedia[ 1 ] );
|
|
547
|
+
expect( within( galleryItem1 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
548
|
+
expect( within( galleryItem2 ).getByTestId( 'spinner' ) ).toBeVisible();
|
|
549
|
+
|
|
550
|
+
// Notify that the media items upload succeeded
|
|
551
|
+
await notifySucceedState( otherAppsMedia[ 0 ] );
|
|
552
|
+
await notifySucceedState( otherAppsMedia[ 1 ] );
|
|
553
|
+
|
|
554
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
555
|
+
} );
|
|
556
|
+
|
|
557
|
+
// Test case related to TC012 - Settings - Link to
|
|
558
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc012
|
|
559
|
+
it( 'overrides "Link to" setting of gallery items', async () => {
|
|
560
|
+
// Initialize with a gallery that contains two items, the latter includes "linkDestination" attribute
|
|
561
|
+
const screen = await initializeWithGalleryBlock( {
|
|
562
|
+
html: `<!-- wp:gallery {"linkTo":"none"} -->
|
|
563
|
+
<figure class="wp-block-gallery has-nested-images columns-default is-cropped"><!-- wp:image {"id":${ media[ 0 ].localId }} -->
|
|
564
|
+
<figure class="wp-block-image"><img src="${ media[ 0 ].localUrl }" alt="" class="wp-image-${ media[ 0 ].localId }"/></figure>
|
|
565
|
+
<!-- /wp:image -->
|
|
566
|
+
|
|
567
|
+
<!-- wp:image {"id":${ media[ 1 ].localId },"linkDestination":"attachment"} -->
|
|
568
|
+
<figure class="wp-block-image"><img src="${ media[ 1 ].localUrl }" alt="" class="wp-image-${ media[ 1 ].localId }"/></figure>
|
|
569
|
+
<!-- /wp:image --></figure>
|
|
570
|
+
<!-- /wp:gallery -->`,
|
|
571
|
+
numberOfItems: 2,
|
|
572
|
+
} );
|
|
573
|
+
const { getByText } = screen;
|
|
574
|
+
|
|
575
|
+
// Set "Link to" setting via Gallery block settings
|
|
576
|
+
await openBlockSettings( screen );
|
|
577
|
+
fireEvent.press( getByText( 'Link to' ) );
|
|
578
|
+
fireEvent.press( getByText( 'Media File' ) );
|
|
579
|
+
|
|
580
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
581
|
+
} );
|
|
582
|
+
|
|
583
|
+
// Test cases related to TC013 - Settings - Columns
|
|
584
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc013
|
|
585
|
+
describe( 'Columns setting', () => {
|
|
586
|
+
it( 'does not increment due to maximum value', async () => {
|
|
587
|
+
// Initialize with a gallery that contains three items
|
|
588
|
+
const screen = await initializeWithGalleryBlock( {
|
|
589
|
+
numberOfItems: 3,
|
|
590
|
+
media,
|
|
591
|
+
} );
|
|
592
|
+
const { getByA11yLabel } = screen;
|
|
593
|
+
|
|
594
|
+
await openBlockSettings( screen );
|
|
595
|
+
|
|
596
|
+
// Can't increment due to maximum value
|
|
597
|
+
// NOTE: Default columns value is 3
|
|
598
|
+
fireEvent(
|
|
599
|
+
getByA11yLabel( /Columns\. Value is 3/ ),
|
|
600
|
+
'accessibilityAction',
|
|
601
|
+
{
|
|
602
|
+
nativeEvent: { actionName: 'increment' },
|
|
603
|
+
}
|
|
604
|
+
);
|
|
605
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
606
|
+
} );
|
|
607
|
+
|
|
608
|
+
it( 'decrements columns', async () => {
|
|
609
|
+
// Initialize with a gallery that contains three items
|
|
610
|
+
const screen = await initializeWithGalleryBlock( {
|
|
611
|
+
numberOfItems: 3,
|
|
612
|
+
media,
|
|
613
|
+
} );
|
|
614
|
+
const { getByA11yLabel } = screen;
|
|
615
|
+
|
|
616
|
+
await openBlockSettings( screen );
|
|
617
|
+
|
|
618
|
+
// Decrement columns
|
|
619
|
+
fireEvent(
|
|
620
|
+
getByA11yLabel( /Columns\. Value is 3/ ),
|
|
621
|
+
'accessibilityAction',
|
|
622
|
+
{
|
|
623
|
+
nativeEvent: { actionName: 'decrement' },
|
|
624
|
+
}
|
|
625
|
+
);
|
|
626
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
627
|
+
} );
|
|
628
|
+
} );
|
|
629
|
+
|
|
630
|
+
// Test case related to TC014 - Settings - Crop images
|
|
631
|
+
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc014
|
|
632
|
+
it( 'disables crop images setting', async () => {
|
|
633
|
+
// Initialize with a gallery that contains one item
|
|
634
|
+
const screen = await initializeWithGalleryBlock( {
|
|
635
|
+
numberOfItems: 1,
|
|
636
|
+
media,
|
|
637
|
+
} );
|
|
638
|
+
const { getByText } = screen;
|
|
639
|
+
|
|
640
|
+
await openBlockSettings( screen );
|
|
641
|
+
|
|
642
|
+
// Disable crop images setting
|
|
643
|
+
fireEvent.press( getByText( 'Crop images' ) );
|
|
644
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
127
645
|
} );
|
|
128
646
|
} );
|